xref: /openbmc/qemu/configure (revision b7612f45)
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=""
4982b2325ffSGerd Hoffmannlibusb=""
49969354a83SHans de Goedeusb_redir=""
500da076ffeSGerd Hoffmannopengl=""
501014cb152SGerd Hoffmannopengl_dmabuf="no"
5025dd89908SRichard Hendersoncpuid_h="no"
50386583a07SLiam Merwickavx2_opt=""
5041ece9905SAlon Levyzlib="yes"
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=""
571a5665051SPaolo Bonziniskip_meson=no
572e8f3bd71SMarc-André Lureaugettext=""
573377529c0SPaolo Bonzini
574fb59dabdSPeter Maydellbogus_os="no"
5755a22ab71SYang Zhongmalloc_trim=""
576898be3e0SPeter Maydell
577ac0df51dSaliguori# parse CC options first
578ac0df51dSaliguorifor opt do
57989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
580ac0df51dSaliguori  case "$opt" in
581ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
582ac0df51dSaliguori  ;;
5833d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
584ac0df51dSaliguori  ;;
58583f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
58683f73fceSTomoki Sekiyama  ;;
5872ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5882ff6b91eSJuan Quintela  ;;
589de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
590db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
591e2a2ed06SJuan Quintela  ;;
59211cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
59311cde1c8SBruno Dominguez  ;;
594db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
595f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
596e2a2ed06SJuan Quintela  ;;
5975bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5985bc62e01SGerd Hoffmann  ;;
5995bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
6005bc62e01SGerd Hoffmann  ;;
601d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
602d75402b5SAlex Bennée  ;;
603d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
604d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
6052038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
606d422b2bcSAlex Bennée  ;;
607d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
6082038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
609d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
6102038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
611d75402b5SAlex Bennée  ;;
612ac0df51dSaliguori  esac
613ac0df51dSaliguoridone
614ac0df51dSaliguori# OS specific
615ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
61693148aa5SStefan Weil# we can eliminate its usage altogether.
617ac0df51dSaliguori
618e49d021eSPeter Maydell# Preferred compiler:
619e49d021eSPeter Maydell#  ${CC} (if set)
620e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
621e49d021eSPeter Maydell#  system compiler
622e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
623e49d021eSPeter Maydell  cc="$host_cc"
624e49d021eSPeter Maydellelse
625b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
626e49d021eSPeter Maydellfi
627e49d021eSPeter Maydell
62883f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
62983f73fceSTomoki Sekiyama  cxx="c++"
63083f73fceSTomoki Sekiyamaelse
63183f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
63283f73fceSTomoki Sekiyamafi
63383f73fceSTomoki Sekiyama
634b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
635cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
6365f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
6373dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
638b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
639b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
6409f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
6414852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
642b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
643b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
64417884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
64517884d7bSSergei Trofimovichquery_pkg_config() {
64617884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
64717884d7bSSergei Trofimovich}
64817884d7bSSergei Trofimovichpkg_config=query_pkg_config
64947c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
650ac0df51dSaliguori
65145d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
65245d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
65345d285abSPeter Maydell
654be17dc90SMichael S. Tsirkin# default flags for all hosts
6552d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
6562d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
6572d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
6582d31515bSPeter Maydell# provides these semantics.)
659086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
660086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
661c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
662be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
66325211446SPaolo BonziniQEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
66425211446SPaolo BonziniQEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
665086d5f75SPaolo BonziniCFLAGS="-std=gnu99 -Wall"
666086d5f75SPaolo Bonzini
667be17dc90SMichael S. Tsirkin
668cab00a5aSMichael S. Tsirkin# running configure in the source tree?
669cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
670cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
671cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
672cab00a5aSMichael S. Tsirkinelse
673cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
674cab00a5aSMichael S. Tsirkinfi
675cab00a5aSMichael S. Tsirkin
676ac0df51dSaliguoricheck_define() {
677ac0df51dSaliguoricat > $TMPC <<EOF
678ac0df51dSaliguori#if !defined($1)
679fd786e1aSPeter Maydell#error $1 not defined
680ac0df51dSaliguori#endif
681ac0df51dSaliguoriint main(void) { return 0; }
682ac0df51dSaliguoriEOF
68352166aa0SJuan Quintela  compile_object
684ac0df51dSaliguori}
685ac0df51dSaliguori
686307119e7SGerd Hoffmanncheck_include() {
687307119e7SGerd Hoffmanncat > $TMPC <<EOF
688307119e7SGerd Hoffmann#include <$1>
689307119e7SGerd Hoffmannint main(void) { return 0; }
690307119e7SGerd HoffmannEOF
691307119e7SGerd Hoffmann  compile_object
692307119e7SGerd Hoffmann}
693307119e7SGerd Hoffmann
69493b25869SJohn Snowwrite_c_skeleton() {
69593b25869SJohn Snow    cat > $TMPC <<EOF
69693b25869SJohn Snowint main(void) { return 0; }
69793b25869SJohn SnowEOF
69893b25869SJohn Snow}
69993b25869SJohn Snow
700adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
701adc28027SAlexander Bulekov    cat > $TMPC <<EOF
702adc28027SAlexander Bulekov#include <stdint.h>
703adc28027SAlexander Bulekov#include <sys/types.h>
704adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
705adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
706adc28027SAlexander BulekovEOF
707adc28027SAlexander Bulekov}
708adc28027SAlexander Bulekov
709bbea4050SPeter Maydellif check_define __linux__ ; then
710bbea4050SPeter Maydell  targetos="Linux"
711bbea4050SPeter Maydellelif check_define _WIN32 ; then
712bbea4050SPeter Maydell  targetos='MINGW32'
713bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
714bbea4050SPeter Maydell  targetos='OpenBSD'
715bbea4050SPeter Maydellelif check_define __sun__ ; then
716bbea4050SPeter Maydell  targetos='SunOS'
717bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
718bbea4050SPeter Maydell  targetos='Haiku'
719951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
720951fedfcSPeter Maydell  targetos='FreeBSD'
721951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
722951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
723951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
724951fedfcSPeter Maydell  targetos='DragonFly'
725951fedfcSPeter Maydellelif check_define __NetBSD__; then
726951fedfcSPeter Maydell  targetos='NetBSD'
727951fedfcSPeter Maydellelif check_define __APPLE__; then
728951fedfcSPeter Maydell  targetos='Darwin'
729bbea4050SPeter Maydellelse
730951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
731951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
732951fedfcSPeter Maydell  # be the result of a missing compiler.
733951fedfcSPeter Maydell  targetos='bogus'
734951fedfcSPeter Maydell  bogus_os='yes'
735bbea4050SPeter Maydellfi
736bbea4050SPeter Maydell
737bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
738bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
739bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
740bbea4050SPeter Maydell# the correct CPU with the --cpu option.
741bbea4050SPeter Maydellcase $targetos in
742bbea4050SPeter MaydellDarwin)
743bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
744bbea4050SPeter Maydell  # run 64-bit userspace code.
745bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
746bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
747bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
748bbea4050SPeter Maydell    cpu="x86_64"
749bbea4050SPeter Maydell  fi
750bbea4050SPeter Maydell  ;;
751bbea4050SPeter MaydellSunOS)
75289138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
753bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
754bbea4050SPeter Maydell    cpu="x86_64"
755bbea4050SPeter Maydell  fi
756bbea4050SPeter Maydellesac
757bbea4050SPeter Maydell
7582ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
7592ff6b91eSJuan Quintela  # command line argument
7602ff6b91eSJuan Quintela  :
7612ff6b91eSJuan Quintelaelif check_define __i386__ ; then
762ac0df51dSaliguori  cpu="i386"
763ac0df51dSaliguorielif check_define __x86_64__ ; then
764c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
765c72b26ecSRichard Henderson    cpu="x32"
766c72b26ecSRichard Henderson  else
767ac0df51dSaliguori    cpu="x86_64"
768c72b26ecSRichard Henderson  fi
7693aa9bd6cSblueswir1elif check_define __sparc__ ; then
7703aa9bd6cSblueswir1  if check_define __arch64__ ; then
7713aa9bd6cSblueswir1    cpu="sparc64"
7723aa9bd6cSblueswir1  else
7733aa9bd6cSblueswir1    cpu="sparc"
7743aa9bd6cSblueswir1  fi
775fdf7ed96Smalcelif check_define _ARCH_PPC ; then
776fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
777f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
778f8378accSRichard Henderson      cpu="ppc64le"
779f8378accSRichard Henderson    else
780fdf7ed96Smalc      cpu="ppc64"
781f8378accSRichard Henderson    fi
782ac0df51dSaliguori  else
783fdf7ed96Smalc    cpu="ppc"
784fdf7ed96Smalc  fi
785afa05235SAurelien Jarnoelif check_define __mips__ ; then
786afa05235SAurelien Jarno  cpu="mips"
787d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
788d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
789d66ed0eaSAurelien Jarno    cpu="s390x"
790d66ed0eaSAurelien Jarno  else
791d66ed0eaSAurelien Jarno    cpu="s390"
792d66ed0eaSAurelien Jarno  fi
793c4f80543SAlistair Franciselif check_define __riscv ; then
794c4f80543SAlistair Francis  if check_define _LP64 ; then
795c4f80543SAlistair Francis    cpu="riscv64"
796c4f80543SAlistair Francis  else
797c4f80543SAlistair Francis    cpu="riscv32"
798c4f80543SAlistair Francis  fi
79921d89f84SPeter Maydellelif check_define __arm__ ; then
80021d89f84SPeter Maydell  cpu="arm"
8011f080313SClaudio Fontanaelif check_define __aarch64__ ; then
8021f080313SClaudio Fontana  cpu="aarch64"
803fdf7ed96Smalcelse
80489138857SStefan Weil  cpu=$(uname -m)
805ac0df51dSaliguorifi
806ac0df51dSaliguori
807359bc95dSPeter MaydellARCH=
808359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
809359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
8107d13299dSbellardcase "$cpu" in
811ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
812898be3e0SPeter Maydell  ;;
813f8378accSRichard Henderson  ppc64le)
814f8378accSRichard Henderson    ARCH="ppc64"
815f8378accSRichard Henderson  ;;
8167d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
81797a847bcSbellard    cpu="i386"
8187d13299dSbellard  ;;
819aaa5fa14Saurel32  x86_64|amd64)
820aaa5fa14Saurel32    cpu="x86_64"
821aaa5fa14Saurel32  ;;
82221d89f84SPeter Maydell  armv*b|armv*l|arm)
82321d89f84SPeter Maydell    cpu="arm"
8247d13299dSbellard  ;;
8251f080313SClaudio Fontana  aarch64)
8261f080313SClaudio Fontana    cpu="aarch64"
8271f080313SClaudio Fontana  ;;
828afa05235SAurelien Jarno  mips*)
829afa05235SAurelien Jarno    cpu="mips"
830afa05235SAurelien Jarno  ;;
8313142255cSblueswir1  sparc|sun4[cdmuv])
832ae228531Sbellard    cpu="sparc"
833ae228531Sbellard  ;;
8347d13299dSbellard  *)
835359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
836359bc95dSPeter Maydell    ARCH=unknown
8377d13299dSbellard  ;;
8387d13299dSbellardesac
839359bc95dSPeter Maydellif test -z "$ARCH"; then
840359bc95dSPeter Maydell  ARCH="$cpu"
841359bc95dSPeter Maydellfi
842e2d52ad3SJuan Quintela
8437d13299dSbellard# OS specific
8440dbfc675SJuan Quintela
845adfc3e91SStacey Son# host *BSD for user mode
846adfc3e91SStacey SonHOST_VARIANT_DIR=""
847adfc3e91SStacey Son
8487d13299dSbellardcase $targetos in
84967b915a5SbellardMINGW32*)
85067b915a5Sbellard  mingw32="yes"
851b0cb0a66SVincent Palatin  hax="yes"
852299e6f19SPaolo Bonzini  vhost_user="no"
8533cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
854307119e7SGerd Hoffmann  if check_include dsound.h; then
8553cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
856307119e7SGerd Hoffmann  else
857307119e7SGerd Hoffmann    audio_drv_list=""
858307119e7SGerd Hoffmann  fi
859898be3e0SPeter Maydell  supported_os="yes"
860fb648e9cSDaniel P. Berrangé  pie="no"
86167b915a5Sbellard;;
8625c40d2bdSthsGNU/kFreeBSD)
863a167ba50SAurelien Jarno  bsd="yes"
8646a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8650bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
8665c40d2bdSths;;
8677d3505c5SbellardFreeBSD)
8687d3505c5Sbellard  bsd="yes"
8690db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8706a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8710bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
872f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
873f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
87458952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
875adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
8767d3505c5Sbellard;;
877c5e97233Sblueswir1DragonFly)
878c5e97233Sblueswir1  bsd="yes"
8790db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8806a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8810bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
882adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
883c5e97233Sblueswir1;;
8847d3505c5SbellardNetBSD)
8857d3505c5Sbellard  bsd="yes"
886604a5b99SKamil Rytarowski  hax="yes"
8870db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8886a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8890bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8908ef92a88Sblueswir1  oss_lib="-lossaudio"
891adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8927d3505c5Sbellard;;
8937d3505c5SbellardOpenBSD)
8947d3505c5Sbellard  bsd="yes"
8950db4a067SPaolo Bonzini  make="${MAKE-gmake}"
896f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8970bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
898adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8997d3505c5Sbellard;;
90083fb7adfSbellardDarwin)
90183fb7adfSbellard  bsd="yes"
90283fb7adfSbellard  darwin="yes"
903b0cb0a66SVincent Palatin  hax="yes"
904c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
90517969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
9061b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
907a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
908db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
9091b0f9cc2Saliguori  fi
910fd677642Sths  cocoa="yes"
9116a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
91214382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
913db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
914a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
915a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
916a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
917adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
91883fb7adfSbellard;;
919ec530c81SbellardSunOS)
920ec530c81Sbellard  solaris="yes"
9210db4a067SPaolo Bonzini  make="${MAKE-gmake}"
9220db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
923e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
9246b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
9256a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
9266b4d2ba1Sths  fi
927c2de5c91Smalc  audio_possible_drivers="oss sdl"
928d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
929d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
930d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
931d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
932560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
933560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
934ec530c81Sbellard;;
935179cf400SAndreas FärberHaiku)
936179cf400SAndreas Färber  haiku="yes"
937fc433430SDavid CARLIER  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
938fc433430SDavid CARLIER  LIBS="-lposix_error_mapper -lnetwork -lbsd $LIBS"
939179cf400SAndreas Färber;;
940898be3e0SPeter MaydellLinux)
9417183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
9420bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
9435327cf48Sbellard  linux="yes"
944831b7825Sths  linux_user="yes"
945af2be207SJan Kiszka  kvm="yes"
94625211446SPaolo Bonzini  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
9473efac6ebSTomáš Golembiovský  libudev="yes"
948898be3e0SPeter Maydell;;
9497d13299dSbellardesac
9507d13299dSbellard
9517d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
952b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
95384778508Sblueswir1    bsd_user="yes"
9547d3505c5Sbellard  fi
95508de3949SAndreas Färberfi
9567d3505c5Sbellard
9570db4a067SPaolo Bonzini: ${make=${MAKE-make}}
9580db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
959faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
960faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
961ddf90699SEduardo Habkost# we check that too
962faf44142SDaniel P. Berrangépython=
9630a01d76fSMarc-André Lureauexplicit_python=no
964ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
965faf44142SDaniel P. Berrangédo
966faf44142SDaniel P. Berrangé    if has "$binary"
967faf44142SDaniel P. Berrangé    then
96895c5f2deSPaolo Bonzini        python=$(command -v "$binary")
969faf44142SDaniel P. Berrangé        break
970faf44142SDaniel P. Berrangé    fi
971faf44142SDaniel P. Berrangédone
972903458c8SMarkus Armbruster
973903458c8SMarkus Armbrustersphinx_build=
974903458c8SMarkus Armbrusterfor binary in sphinx-build-3 sphinx-build
975903458c8SMarkus Armbrusterdo
976903458c8SMarkus Armbruster    if has "$binary"
977903458c8SMarkus Armbruster    then
978903458c8SMarkus Armbruster        sphinx_build=$(command -v "$binary")
979903458c8SMarkus Armbruster        break
980903458c8SMarkus Armbruster    fi
981903458c8SMarkus Armbrusterdone
982903458c8SMarkus Armbruster
98339d87c8cSAlex Bennée# Check for ancillary tools used in testing
98439d87c8cSAlex Bennéegenisoimage=
9853df437c7SAlex Bennéefor binary in genisoimage mkisofs
98639d87c8cSAlex Bennéedo
98739d87c8cSAlex Bennée    if has $binary
98839d87c8cSAlex Bennée    then
98939d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
99039d87c8cSAlex Bennée        break
99139d87c8cSAlex Bennée    fi
99239d87c8cSAlex Bennéedone
99339d87c8cSAlex Bennée
994e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9950db4a067SPaolo Bonzini
9963c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9973c4a4d0dSPeter Maydellif has clang; then
9983c4a4d0dSPeter Maydell  objcc=clang
9993c4a4d0dSPeter Maydellelse
10003c4a4d0dSPeter Maydell  objcc="$cc"
10013c4a4d0dSPeter Maydellfi
10023c4a4d0dSPeter Maydell
10033457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
10043457a3f8SJuan Quintela  EXESUF=".exe"
1005484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
100678e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
1007086d5f75SPaolo Bonzini  CFLAGS="-mthreads $CFLAGS"
1008b965e8c5SPaolo Bonzini  LIBS="-lwinmm -lws2_32 $LIBS"
100993b25869SJohn Snow  write_c_skeleton;
1010f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
1011f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
1012f7cf5d5bSStefan Weil  fi
1013c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
1014683035deSPaolo Bonzini  confsuffix=""
1015105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
10163457a3f8SJuan Quintelafi
10173457a3f8SJuan Quintela
1018487fefdbSAnthony Liguoriwerror=""
101985aa5189Sbellard
10207d13299dSbellardfor opt do
102189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
10227d13299dSbellard  case "$opt" in
10232efc3265Sbellard  --help|-h) show_help=yes
10242efc3265Sbellard  ;;
102599123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
102699123e13SMike Frysinger  ;;
1027b1a550a0Spbrook  --prefix=*) prefix="$optarg"
10287d13299dSbellard  ;;
1029b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
103032ce6337Sbellard  ;;
1031ac0df51dSaliguori  --cross-prefix=*)
10327d13299dSbellard  ;;
1033ac0df51dSaliguori  --cc=*)
10347d13299dSbellard  ;;
1035b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
103683469015Sbellard  ;;
103783f73fceSTomoki Sekiyama  --cxx=*)
103883f73fceSTomoki Sekiyama  ;;
1039e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
1040e007dbecSMichael S. Tsirkin  ;;
10413c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
10423c4a4d0dSPeter Maydell  ;;
1043b1a550a0Spbrook  --make=*) make="$optarg"
10447d13299dSbellard  ;;
10456a882643Spbrook  --install=*) install="$optarg"
10466a882643Spbrook  ;;
10470a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
1048c886edfbSBlue Swirl  ;;
10492eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
10502eb054c2SPeter Maydell  ;;
1051a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
1052a5665051SPaolo Bonzini  ;;
1053a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
1054a5665051SPaolo Bonzini  ;;
1055e2d8830eSBrad  --smbd=*) smbd="$optarg"
1056e2d8830eSBrad  ;;
1057e2a2ed06SJuan Quintela  --extra-cflags=*)
10587d13299dSbellard  ;;
105911cde1c8SBruno Dominguez  --extra-cxxflags=*)
106011cde1c8SBruno Dominguez  ;;
1061e2a2ed06SJuan Quintela  --extra-ldflags=*)
10627d13299dSbellard  ;;
10635bc62e01SGerd Hoffmann  --enable-debug-info)
10645bc62e01SGerd Hoffmann  ;;
10655bc62e01SGerd Hoffmann  --disable-debug-info)
10665bc62e01SGerd Hoffmann  ;;
1067d75402b5SAlex Bennée  --cross-cc-*)
1068d75402b5SAlex Bennée  ;;
106917969268SFam Zheng  --enable-modules)
107017969268SFam Zheng      modules="yes"
107117969268SFam Zheng  ;;
10723aa88b31SStefan Hajnoczi  --disable-modules)
10733aa88b31SStefan Hajnoczi      modules="no"
10743aa88b31SStefan Hajnoczi  ;;
1075bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
1076bd83c861SChristian Ehrhardt  ;;
1077bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
1078bd83c861SChristian Ehrhardt  ;;
10792ff6b91eSJuan Quintela  --cpu=*)
10807d13299dSbellard  ;;
1081b1a550a0Spbrook  --target-list=*) target_list="$optarg"
1082447e133fSAlex Bennée                   if test "$target_list_exclude"; then
1083447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
1084447e133fSAlex Bennée                   fi
1085447e133fSAlex Bennée  ;;
1086447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
1087447e133fSAlex Bennée                   if test "$target_list"; then
1088447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
1089447e133fSAlex Bennée                   fi
1090de83cd02Sbellard  ;;
10915b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
10925b808275SLluís Vilanova  ;;
10935b808275SLluís Vilanova  # XXX: backwards compatibility
10945b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
109594a420b1SStefan Hajnoczi  ;;
109674242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
10979410b56cSPrerna Saxena  ;;
1098f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1099f3494749SPaolo Bonzini  ;;
1100f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1101f3494749SPaolo Bonzini  ;;
11027d13299dSbellard  --enable-gprof) gprof="yes"
11037d13299dSbellard  ;;
11041d728c39SBlue Swirl  --enable-gcov) gcov="yes"
11051d728c39SBlue Swirl  ;;
110679427693SLoïc Minier  --static)
110779427693SLoïc Minier    static="yes"
110817884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
110943ce4dfeSbellard  ;;
11100b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
11110b24e75fSPaolo Bonzini  ;;
11120b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
11130b24e75fSPaolo Bonzini  ;;
11143aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
11153aa5d2beSAlon Levy  ;;
11168bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
11178bf188aaSMichael Tokarev  ;;
11180f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
11190f94d6daSAlon Levy  ;;
1120528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
11210b24e75fSPaolo Bonzini  ;;
1122023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1123023d3d67SEduardo Habkost  ;;
1124850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
11250b24e75fSPaolo Bonzini  ;;
1126ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
112707381cc1SAnthony Liguori  ;;
1128785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1129785c23aeSLuiz Capitulino  ;;
11303d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
11313d5eecabSGerd Hoffmann  ;;
1132181ce1d0SOlaf Hering  --host=*|--build=*|\
1133181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1134785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1135023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1136023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1137023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1138023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1139023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1140023ddd74SMax Filippov    # lots of directory switches by default.
1141023ddd74SMax Filippov  ;;
114235be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
114397a847bcSbellard  ;;
114435be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
1145c4198157SJuan Quintela  ;;
114635be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
1147a442fe2fSDaniel P. Berrangé  ;;
114835be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
1149a442fe2fSDaniel P. Berrangé  ;;
11503556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
11513556c233SPaolo Bonzini  ;;
11523556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
11533556c233SPaolo Bonzini  ;;
1154983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1155983eef5aSMeador Inge  ;;
1156983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1157983eef5aSMeador Inge  ;;
1158fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1159fe8fc5aeSPaolo Bonzini  ;;
1160fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1161fe8fc5aeSPaolo Bonzini  ;;
1162a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1163821601eaSJes Sorensen  ;;
1164a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1165821601eaSJes Sorensen  ;;
1166e8f3bd71SMarc-André Lureau  --disable-gettext) gettext="false"
1167e8f3bd71SMarc-André Lureau  ;;
1168e8f3bd71SMarc-André Lureau  --enable-gettext) gettext="true"
1169e8f3bd71SMarc-André Lureau  ;;
11702f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
11712f6a1ab0Sblueswir1  ;;
11720c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
11730c58ac1cSmalc  ;;
117489138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1175b64ec4e4SFam Zheng  ;;
117689138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1177eb852011SMarkus Armbruster  ;;
1178f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1179f8393946Saurel32  ;;
1180f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1181f8393946Saurel32  ;;
1182f3d08ee6SPaul Brook  --enable-debug)
1183f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1184f3d08ee6SPaul Brook      debug_tcg="yes"
11851fcc6d42SPeter Xu      debug_mutex="yes"
1186f3d08ee6SPaul Brook      debug="yes"
1187f3d08ee6SPaul Brook      strip_opt="no"
1188b553a042SJohn Snow      fortify_source="no"
1189f3d08ee6SPaul Brook  ;;
1190247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1191247724cbSMarc-André Lureau  ;;
1192247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1193247724cbSMarc-André Lureau  ;;
11940aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
11950aebab04SLingfeng Yang  ;;
11960aebab04SLingfeng Yang  --disable-tsan) tsan="no"
11970aebab04SLingfeng Yang  ;;
119803b4fe7dSaliguori  --enable-sparse) sparse="yes"
119903b4fe7dSaliguori  ;;
120003b4fe7dSaliguori  --disable-sparse) sparse="no"
120103b4fe7dSaliguori  ;;
12021625af87Saliguori  --disable-strip) strip_opt="no"
12031625af87Saliguori  ;;
1204a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
12052f9606b3Saliguori  ;;
1206a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1207ea784e3bSJuan Quintela  ;;
1208a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
12092f6f5c7aSCorentin Chary  ;;
1210a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
12112f6f5c7aSCorentin Chary  ;;
1212a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1213efe556adSCorentin Chary  ;;
1214a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1215efe556adSCorentin Chary  ;;
1216443f1376Sbellard  --disable-slirp) slirp="no"
1217c20709aaSbellard  ;;
12187c57bdd8SMarc-André Lureau  --enable-slirp=git) slirp="git"
12197c57bdd8SMarc-André Lureau  ;;
1220675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1221675b9b53SMarc-André Lureau  ;;
1222e0e6c8c0Saliguori  --disable-vde) vde="no"
12238a16d273Sths  ;;
1224dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1225dfb278bdSJuan Quintela  ;;
122658952137SVincenzo Maffione  --disable-netmap) netmap="no"
122758952137SVincenzo Maffione  ;;
122858952137SVincenzo Maffione  --enable-netmap) netmap="yes"
122958952137SVincenzo Maffione  ;;
1230e37630caSaliguori  --disable-xen) xen="no"
1231e37630caSaliguori  ;;
1232fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1233fc321b4bSJuan Quintela  ;;
1234eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1235eb6fda0fSAnthony PERARD  ;;
1236eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1237eb6fda0fSAnthony PERARD  ;;
12382e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
12392e4d9fb1Saurel32  ;;
12404ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
12414ffcedb6SJuan Quintela  ;;
12427ba1e619Saliguori  --disable-kvm) kvm="no"
12437ba1e619Saliguori  ;;
1244b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1245b31a0277SJuan Quintela  ;;
1246b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1247180fb750Szhanghailiang  ;;
1248b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1249180fb750Szhanghailiang  ;;
1250c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1251c97d6d2cSSergio Andres Gomez Del Real  ;;
1252c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1253c97d6d2cSSergio Andres Gomez Del Real  ;;
1254d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1255d661d9a4SJustin Terry (VM)  ;;
1256d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1257d661d9a4SJustin Terry (VM)  ;;
12589195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
12599195b2c2SStefan Weil  ;;
12609195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
12619195b2c2SStefan Weil  ;;
126247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
126347e98658SCorey Bryant  ;;
126447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
126547e98658SCorey Bryant  ;;
1266b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1267b3f6ea7eSPaolo Bonzini  ;;
1268b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1269b3f6ea7eSPaolo Bonzini  ;;
12705a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
12715a22ab71SYang Zhong  ;;
12725a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
12735a22ab71SYang Zhong  ;;
1274cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1275cd4ec0b4SGerd Hoffmann  ;;
1276cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1277cd4ec0b4SGerd Hoffmann  ;;
1278c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1279c589b249SRonnie Sahlberg  ;;
1280c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1281c589b249SRonnie Sahlberg  ;;
12826542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
12836542aa9cSPeter Lieven  ;;
12846542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
12856542aa9cSPeter Lieven  ;;
128605c2a3e7Sbellard  --enable-profiler) profiler="yes"
128705c2a3e7Sbellard  ;;
128814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
128914821030SPavel Borzenkov  ;;
1290c2de5c91Smalc  --enable-cocoa)
1291c2de5c91Smalc      cocoa="yes" ;
129289138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
12935b0753e0Sbellard  ;;
1294cad25d69Spbrook  --disable-system) softmmu="no"
12950a8e90f4Spbrook  ;;
1296cad25d69Spbrook  --enable-system) softmmu="yes"
12970a8e90f4Spbrook  ;;
12980953a80fSZachary Amsden  --disable-user)
12990953a80fSZachary Amsden      linux_user="no" ;
13000953a80fSZachary Amsden      bsd_user="no" ;
13010953a80fSZachary Amsden  ;;
13020953a80fSZachary Amsden  --enable-user) ;;
1303831b7825Sths  --disable-linux-user) linux_user="no"
13040a8e90f4Spbrook  ;;
1305831b7825Sths  --enable-linux-user) linux_user="yes"
1306831b7825Sths  ;;
130784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
130884778508Sblueswir1  ;;
130984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
131084778508Sblueswir1  ;;
131140d6444eSAvi Kivity  --enable-pie) pie="yes"
131234005a00SKirill A. Shutemov  ;;
131340d6444eSAvi Kivity  --disable-pie) pie="no"
131434005a00SKirill A. Shutemov  ;;
131585aa5189Sbellard  --enable-werror) werror="yes"
131685aa5189Sbellard  ;;
131785aa5189Sbellard  --disable-werror) werror="no"
131885aa5189Sbellard  ;;
131963678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
132063678e17SSteven Noonan  ;;
132163678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
132263678e17SSteven Noonan  ;;
13231e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
13241e4f6065SDaniele Buono  ;;
13251e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
13261e4f6065SDaniele Buono  ;;
13274d3b6f6eSbalrog  --disable-curses) curses="no"
13284d3b6f6eSbalrog  ;;
1329c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1330c584a6d0SJuan Quintela  ;;
1331e08bb301SSamuel Thibault  --disable-iconv) iconv="no"
1332e08bb301SSamuel Thibault  ;;
1333e08bb301SSamuel Thibault  --enable-iconv) iconv="yes"
1334e08bb301SSamuel Thibault  ;;
1335769ce76dSAlexander Graf  --disable-curl) curl="no"
1336769ce76dSAlexander Graf  ;;
1337788c8196SJuan Quintela  --enable-curl) curl="yes"
1338788c8196SJuan Quintela  ;;
13392df87df7SJuan Quintela  --disable-fdt) fdt="no"
13402df87df7SJuan Quintela  ;;
13412df87df7SJuan Quintela  --enable-fdt) fdt="yes"
13422df87df7SJuan Quintela  ;;
13435c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
13445c6c3a6cSChristoph Hellwig  ;;
13455c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
13465c6c3a6cSChristoph Hellwig  ;;
1347c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1348c10dd856SAarushi Mehta  ;;
1349c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1350c10dd856SAarushi Mehta  ;;
1351758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1352758e8e38SVenkateswararao Jujjuri (JV)  ;;
1353758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1354758e8e38SVenkateswararao Jujjuri (JV)  ;;
1355a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1356a40161cbSPaolo Bonzini  ;;
1357a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1358a40161cbSPaolo Bonzini  ;;
135977755340Sths  --disable-blobs) blobs="no"
136077755340Sths  ;;
13617e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
13624a19f1ecSpbrook  ;;
1363519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1364519175a2SAlex Barcelo  ;;
136570c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
136670c60c08SStefan Hajnoczi  ;;
136770c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
136870c60c08SStefan Hajnoczi  ;;
13697d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
13707d992e4dSPeter Lieven  ;;
1371f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1372f0d92b56SLongpeng(Mike)  ;;
1373f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1374f0d92b56SLongpeng(Mike)  ;;
1375a25dba17SJuan Quintela  --disable-docs) docs="no"
137670ec5dc0SAnthony Liguori  ;;
1377a25dba17SJuan Quintela  --enable-docs) docs="yes"
137883a3ab8bSJuan Quintela  ;;
1379d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1380d5970055SMichael S. Tsirkin  ;;
1381d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1382d5970055SMichael S. Tsirkin  ;;
1383042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1384042cea27SGonglei  ;;
1385299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1386042cea27SGonglei  ;;
13875e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
13885e9be92dSNicholas Bellinger  ;;
13895e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
13905e9be92dSNicholas Bellinger  ;;
1391fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1392fc0b9b0eSStefan Hajnoczi  ;;
1393fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1394fc0b9b0eSStefan Hajnoczi  ;;
139598fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
139698fc1adaSDr. David Alan Gilbert  ;;
139798fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
139898fc1adaSDr. David Alan Gilbert  ;;
1399da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
140020ff075bSMichael Walle  ;;
1401da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
140220ff075bSMichael Walle  ;;
1403f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1404f27aaf4bSChristian Brunner  ;;
1405f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1406f27aaf4bSChristian Brunner  ;;
14078c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
14088c84cf11SSergei Trofimovich  ;;
14098c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
14108c84cf11SSergei Trofimovich  ;;
14117b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1412111a38b0SRobert Relyea  ;;
14137b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1414111a38b0SRobert Relyea  ;;
14152b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
14162b2325ffSGerd Hoffmann  ;;
14172b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
14182b2325ffSGerd Hoffmann  ;;
141969354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
142069354a83SHans de Goede  ;;
142169354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
142269354a83SHans de Goede  ;;
14231ece9905SAlon Levy  --disable-zlib-test) zlib="no"
14241ece9905SAlon Levy  ;;
1425b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1426b25c9dffSStefan Weil  ;;
1427607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1428607dacd0Sqiaonuohan  ;;
1429b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1430b25c9dffSStefan Weil  ;;
1431607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1432607dacd0Sqiaonuohan  ;;
14336b383c08SPeter Wu  --disable-bzip2) bzip2="no"
14346b383c08SPeter Wu  ;;
14356b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
14366b383c08SPeter Wu  ;;
143783bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
143883bc1f97SJulio Faracco  ;;
143983bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
144083bc1f97SJulio Faracco  ;;
14413a678481SJuan Quintela  --disable-zstd) zstd="no"
14423a678481SJuan Quintela  ;;
14433a678481SJuan Quintela  --enable-zstd) zstd="yes"
14443a678481SJuan Quintela  ;;
1445d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1446d138cee9SMichael Roth  ;;
1447d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1448d138cee9SMichael Roth  ;;
14499dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
14509dacf32dSYossi Hindin  ;;
14519dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
14529dacf32dSYossi Hindin  ;;
1453d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1454d9840e25STomoki Sekiyama  ;;
1455d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1456d9840e25STomoki Sekiyama  ;;
1457d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1458d9840e25STomoki Sekiyama  ;;
1459d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1460d9840e25STomoki Sekiyama  ;;
1461d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1462d9840e25STomoki Sekiyama  ;;
1463d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1464d9840e25STomoki Sekiyama  ;;
14654b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
14664b1c11fdSDaniel P. Berrange  ;;
14674b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
14684b1c11fdSDaniel P. Berrange  ;;
1469f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1470f794573eSEduardo Otubo  ;;
1471f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1472f794573eSEduardo Otubo  ;;
1473eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1474eb100396SBharata B Rao  ;;
147586583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
147686583a07SLiam Merwick  ;;
147786583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
147886583a07SLiam Merwick  ;;
14796b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
14806b8cd447SRobert Hoo  ;;
14816b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
14826b8cd447SRobert Hoo  ;;
14836b8cd447SRobert Hoo
1484eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1485eb100396SBharata B Rao  ;;
148652b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
148752b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1488583f6e7bSStefan Hajnoczi  ;;
1489cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1490cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1491cb6414dfSFam Zheng  ;;
1492315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1493315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1494315d3184SFam Zheng  ;;
1495a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1496a4ccabcfSAnthony Liguori  ;;
1497a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1498a4ccabcfSAnthony Liguori  ;;
1499a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1500a1c5e949SDaniel P. Berrange  ;;
1501ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1502ddbb0d09SDaniel P. Berrange  ;;
1503ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1504ddbb0d09SDaniel P. Berrange  ;;
150591bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
150691bfcdb0SDaniel P. Berrange  ;;
150791bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
150891bfcdb0SDaniel P. Berrange  ;;
150991bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
151091bfcdb0SDaniel P. Berrange  ;;
151191bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
151291bfcdb0SDaniel P. Berrange  ;;
15138953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
15148953caf3SDaniel P. Berrange  ;;
15158953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
15168953caf3SDaniel P. Berrange  ;;
15172da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
15182da776dbSMichael R. Hines  ;;
15192da776dbSMichael R. Hines  --disable-rdma) rdma="no"
15202da776dbSMichael R. Hines  ;;
152121ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
152221ab34c9SMarcel Apfelbaum  ;;
152321ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
152421ab34c9SMarcel Apfelbaum  ;;
1525bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1526bbbf9bfbSStefan Weil  ;;
1527bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1528bbbf9bfbSStefan Weil  ;;
15299d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
15309d9e1521SGerd Hoffmann  ;;
15319d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
15329d9e1521SGerd Hoffmann  ;;
1533e91c793cSCole Robinson  --disable-tpm) tpm="no"
1534e91c793cSCole Robinson  ;;
1535ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1536ab214c29SStefan Berger  ;;
1537b10d49d7SPino Toscano  --disable-libssh) libssh="no"
15380a12ec87SRichard W.M. Jones  ;;
1539b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
15400a12ec87SRichard W.M. Jones  ;;
1541ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1542ed1701c6SDr. David Alan Gilbert  ;;
1543ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1544ed1701c6SDr. David Alan Gilbert  ;;
1545a99d57bbSWanlong Gao  --disable-numa) numa="no"
1546a99d57bbSWanlong Gao  ;;
1547a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1548a99d57bbSWanlong Gao  ;;
1549ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1550ed279a06SKlim Kireev  ;;
1551ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1552ed279a06SKlim Kireev  ;;
15532847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
15542847b469SFam Zheng  ;;
15552847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
15562847b469SFam Zheng  ;;
15577b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
15587b01cb97SAlexandre Derumier  ;;
15597b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
15607b01cb97SAlexandre Derumier  ;;
1561a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1562a6b1d4c0SChanglong Xie  ;;
1563a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1564a6b1d4c0SChanglong Xie  ;;
15652f740136SJeff Cody  --disable-bochs) bochs="no"
15662f740136SJeff Cody  ;;
15672f740136SJeff Cody  --enable-bochs) bochs="yes"
15682f740136SJeff Cody  ;;
15692f740136SJeff Cody  --disable-cloop) cloop="no"
15702f740136SJeff Cody  ;;
15712f740136SJeff Cody  --enable-cloop) cloop="yes"
15722f740136SJeff Cody  ;;
15732f740136SJeff Cody  --disable-dmg) dmg="no"
15742f740136SJeff Cody  ;;
15752f740136SJeff Cody  --enable-dmg) dmg="yes"
15762f740136SJeff Cody  ;;
15772f740136SJeff Cody  --disable-qcow1) qcow1="no"
15782f740136SJeff Cody  ;;
15792f740136SJeff Cody  --enable-qcow1) qcow1="yes"
15802f740136SJeff Cody  ;;
15812f740136SJeff Cody  --disable-vdi) vdi="no"
15822f740136SJeff Cody  ;;
15832f740136SJeff Cody  --enable-vdi) vdi="yes"
15842f740136SJeff Cody  ;;
15852f740136SJeff Cody  --disable-vvfat) vvfat="no"
15862f740136SJeff Cody  ;;
15872f740136SJeff Cody  --enable-vvfat) vvfat="yes"
15882f740136SJeff Cody  ;;
15892f740136SJeff Cody  --disable-qed) qed="no"
15902f740136SJeff Cody  ;;
15912f740136SJeff Cody  --enable-qed) qed="yes"
15922f740136SJeff Cody  ;;
15932f740136SJeff Cody  --disable-parallels) parallels="no"
15942f740136SJeff Cody  ;;
15952f740136SJeff Cody  --enable-parallels) parallels="yes"
15962f740136SJeff Cody  ;;
15972f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
15982f740136SJeff Cody  ;;
15992f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
16002f740136SJeff Cody  ;;
1601e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1602e6a74868SMarc-André Lureau  ;;
1603299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1604299e6f19SPaolo Bonzini  ;;
1605108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1606108a6481SCindy Lu  ;;
1607108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1608108a6481SCindy Lu  ;;
1609299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1610299e6f19SPaolo Bonzini  ;;
1611299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1612e6a74868SMarc-André Lureau  ;;
16138ca80760SRichard Henderson  --disable-capstone) capstone="no"
16148ca80760SRichard Henderson  ;;
16158ca80760SRichard Henderson  --enable-capstone) capstone="yes"
16168ca80760SRichard Henderson  ;;
1617e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1618e219c499SRichard Henderson  ;;
1619e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1620e219c499SRichard Henderson  ;;
1621cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1622cc84d63aSDaniel P. Berrange  ;;
1623f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1624f62bbee5SDaniel P. Berrange  ;;
1625f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1626f62bbee5SDaniel P. Berrange  ;;
1627ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1628ba59fb77SPaolo Bonzini  ;;
1629ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1630ba59fb77SPaolo Bonzini  ;;
163117824406SJunyan He  --enable-libpmem) libpmem=yes
163217824406SJunyan He  ;;
163317824406SJunyan He  --disable-libpmem) libpmem=no
163417824406SJunyan He  ;;
16354113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
163675411919SJames Le Cuirot  ;;
16374113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
163875411919SJames Le Cuirot  ;;
163940e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
164040e8c6f4SAlex Bennée  ;;
164140e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
164240e8c6f4SAlex Bennée  ;;
1643afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1644afc3a8f9SAlex Bennée  ;;
1645afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1646afc3a8f9SAlex Bennée  ;;
1647adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1648adc28027SAlexander Bulekov  ;;
1649adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1650adc28027SAlexander Bulekov  ;;
1651f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1652f48e590aSAlex Bennée  ;;
1653b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1654b767d257SMarek Marczykowski-Górecki  ;;
1655b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1656b767d257SMarek Marczykowski-Górecki  ;;
165754e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
165854e7aac0SAlexey Krasikov  ;;
165954e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
166054e7aac0SAlexey Krasikov  ;;
166121b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
166221b2eca6SJingqi Liu  ;;
166321b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
166421b2eca6SJingqi Liu  ;;
16652d2ad6d0SFam Zheng  *)
16662d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
16672d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
16682d2ad6d0SFam Zheng      exit 1
16697f1559c6Sbalrog  ;;
16707d13299dSbellard  esac
16717d13299dSbellarddone
16727d13299dSbellard
167322a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
167422a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
167522a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
167622a87800SMarc-André Lureau
167722a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
167822a87800SMarc-André Lureau    mandir="$prefix"
167922a87800SMarc-André Lureau    datadir="$prefix"
168022a87800SMarc-André Lureau    qemu_docdir="$prefix"
168122a87800SMarc-André Lureau    bindir="$prefix"
168222a87800SMarc-André Lureau    sysconfdir="$prefix"
168322a87800SMarc-André Lureau    local_statedir=
168422a87800SMarc-André Lureauelse
168522a87800SMarc-André Lureau    mandir="${mandir:-$prefix/share/man}"
168622a87800SMarc-André Lureau    datadir="${datadir:-$prefix/share}"
168722a87800SMarc-André Lureau    qemu_docdir="${qemu_docdir:-$prefix/share/doc/qemu}"
168822a87800SMarc-André Lureau    bindir="${bindir:-$prefix/bin}"
168922a87800SMarc-André Lureau    sysconfdir="${sysconfdir:-$prefix/etc}"
169022a87800SMarc-André Lureau    local_statedir="${local_statedir:-$prefix/var}"
169122a87800SMarc-André Lureaufi
169222a87800SMarc-André Lureau
169340293e58Sbellardcase "$cpu" in
1694e3608d66SRichard Henderson    ppc)
1695e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1696db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1697e3608d66SRichard Henderson           ;;
1698e3608d66SRichard Henderson    ppc64)
1699e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1700db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1701e3608d66SRichard Henderson           ;;
17029b9c37c3SRichard Henderson    sparc)
1703f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1704db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
17053142255cSblueswir1           ;;
1706ed968ff1SJuan Quintela    sparc64)
170779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1708db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
17093142255cSblueswir1           ;;
171076d83bdeSths    s390)
1711061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1712db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
171328d7cc49SRichard Henderson           ;;
171428d7cc49SRichard Henderson    s390x)
1715061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1716db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
171776d83bdeSths           ;;
171840293e58Sbellard    i386)
171979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1720db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
172140293e58Sbellard           ;;
172240293e58Sbellard    x86_64)
17237ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
17247ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
17257ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
17267ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1727db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1728379f6698SPaul Brook           ;;
1729c72b26ecSRichard Henderson    x32)
1730c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1731db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1732c72b26ecSRichard Henderson           ;;
173330163d89SPeter Maydell    # No special flags required for other host CPUs
17343142255cSblueswir1esac
17353142255cSblueswir1
17362038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
17372038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
173879f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
173979f3b12fSPeter Crosthwaite
1740affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1741affc88ccSPeter Maydell# support, even if we're using TCI.
1742affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1743affc88ccSPeter Maydell  bsd_user="no"
1744affc88ccSPeter Maydell  linux_user="no"
1745affc88ccSPeter Maydellfi
1746affc88ccSPeter Maydell
17471cf295beSPhilippe Mathieu-Daudéif [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
17481cf295beSPhilippe Mathieu-Daudé  tcg="no"
17491cf295beSPhilippe Mathieu-Daudéfi
17501cf295beSPhilippe Mathieu-Daudé
175160e0df25SPeter Maydelldefault_target_list=""
175260e0df25SPeter Maydell
17536e92f823SPeter Maydellmak_wilds=""
17546e92f823SPeter Maydell
175560e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
17566e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
175760e0df25SPeter Maydellfi
175860e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
17596e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
176060e0df25SPeter Maydellfi
176160e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
17626e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
176360e0df25SPeter Maydellfi
176460e0df25SPeter Maydell
1765447e133fSAlex Bennéeif test -z "$target_list_exclude"; then
17666e92f823SPeter Maydell    for config in $mak_wilds; do
17676e92f823SPeter Maydell        default_target_list="${default_target_list} $(basename "$config" .mak)"
17686e92f823SPeter Maydell    done
1769447e133fSAlex Bennéeelse
1770447e133fSAlex Bennée    exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1771447e133fSAlex Bennée    for config in $mak_wilds; do
1772447e133fSAlex Bennée        target="$(basename "$config" .mak)"
1773447e133fSAlex Bennée        exclude="no"
1774447e133fSAlex Bennée        for excl in $exclude_list; do
1775447e133fSAlex Bennée            if test "$excl" = "$target"; then
1776447e133fSAlex Bennée                exclude="yes"
1777447e133fSAlex Bennée                break;
1778447e133fSAlex Bennée            fi
1779447e133fSAlex Bennée        done
1780447e133fSAlex Bennée        if test "$exclude" = "no"; then
1781447e133fSAlex Bennée            default_target_list="${default_target_list} $target"
1782447e133fSAlex Bennée        fi
1783447e133fSAlex Bennée    done
1784447e133fSAlex Bennéefi
17856e92f823SPeter Maydell
1786c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
178764a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1788c53eeaf7SStefan Hajnoczi
1789af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1790af5db58eSpbrookcat << EOF
1791af5db58eSpbrook
1792af5db58eSpbrookUsage: configure [options]
1793af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1794af5db58eSpbrook
179508fb77edSStefan WeilStandard options:
179608fb77edSStefan Weil  --help                   print this message
179708fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
179808fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
179908fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
180008fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
180108fb77edSStefan Weil$(echo Available targets: $default_target_list | \
180208fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1803447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
180408fb77edSStefan Weil
180508fb77edSStefan WeilAdvanced options (experts only):
180608fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
180708fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
180808fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
180908fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
181008fb77edSStefan Weil                           build time
181108fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
181208fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
181308fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
181411cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
181508fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1816d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1817d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
181808fb77edSStefan Weil  --make=MAKE              use specified make [$make]
181908fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
182008fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
18212eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1822a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
182308fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1824db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
182508fb77edSStefan Weil  --static                 enable static build [$static]
182608fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
182708fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
182808fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
182908fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
183008fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1831db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
183208fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
183308fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
18343d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
183513336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1836e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1837db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
183808fb77edSStefan Weil  --enable-debug           enable common debug build options
1839247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
18400aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
184108fb77edSStefan Weil  --disable-strip          disable stripping binaries
184208fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
184363678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
184408fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
184508fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
184608fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
184708fb77edSStefan Weil  --block-drv-rw-whitelist=L
184808fb77edSStefan Weil                           set block driver read-write whitelist
184908fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
185008fb77edSStefan Weil  --block-drv-ro-whitelist=L
185108fb77edSStefan Weil                           set block driver read-only whitelist
185208fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
18535b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1854c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
185508fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
185608fb77edSStefan Weil                           Default:trace-<pid>
1857c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1858c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
18595a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1860c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1861c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
186208fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
186333c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
186408fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1865c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1866c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1867c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1868a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1869c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1870c12d66aaSLin Ma  --enable-profiler        profiler support
1871c12d66aaSLin Ma  --enable-debug-stack-usage
1872c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
187340e8c6f4SAlex Bennée  --enable-plugins
187440e8c6f4SAlex Bennée                           enable plugins via shared library loading
1875afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1876f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1877c23f23b9SMichael Tokarev
1878c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1879c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1880c23f23b9SMichael Tokarev
1881c23f23b9SMichael Tokarev  system          all system emulation targets
1882c23f23b9SMichael Tokarev  user            supported user emulation targets
1883c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1884c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1885c23f23b9SMichael Tokarev  docs            build documentation
1886c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1887c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1888c23f23b9SMichael Tokarev  pie             Position Independent Executables
188921e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1890bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1891c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1892c23f23b9SMichael Tokarev  debug-info      debugging information
1893c23f23b9SMichael Tokarev  sparse          sparse checker
18941e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18951e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1896c23f23b9SMichael Tokarev
1897ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
189891bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
189991bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
19008953caf3SDaniel P. Berrange  auth-pam        PAM access control
1901c23f23b9SMichael Tokarev  sdl             SDL UI
190204c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1903c23f23b9SMichael Tokarev  gtk             gtk UI
1904c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1905c23f23b9SMichael Tokarev  curses          curses UI
1906e08bb301SSamuel Thibault  iconv           font glyph conversion support
1907c23f23b9SMichael Tokarev  vnc             VNC UI support
1908c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1909c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1910c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1911c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1912c23f23b9SMichael Tokarev  virtfs          VirtFS
1913fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1914c23f23b9SMichael Tokarev  xen             xen backend driver support
191570c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1916c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1917c23f23b9SMichael Tokarev  curl            curl connectivity
1918a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1919c23f23b9SMichael Tokarev  fdt             fdt device tree
1920c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1921b0cb0a66SVincent Palatin  hax             HAX acceleration support
1922c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1923d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
192421ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
192521ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1926c23f23b9SMichael Tokarev  vde             support for vde network
1927c23f23b9SMichael Tokarev  netmap          support for netmap network
1928c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1929c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1930c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1931c23f23b9SMichael Tokarev  attr            attr and xattr support
1932299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1933299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1934299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1935299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1936299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1937299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1938108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1939c23f23b9SMichael Tokarev  spice           spice
1940c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1941c23f23b9SMichael Tokarev  libiscsi        iscsi support
1942c23f23b9SMichael Tokarev  libnfs          nfs support
19437b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1944c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1945ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1946c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1947c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1948c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1949c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1950c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
195183bc1f97SJulio Faracco  lzfse           support of lzfse compression library
195283bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19533a678481SJuan Quintela  zstd            support for zstd compression library
1954d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1955c23f23b9SMichael Tokarev  seccomp         seccomp support
1956c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1957c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1958c23f23b9SMichael Tokarev  tpm             TPM support
1959b10d49d7SPino Toscano  libssh          ssh block device support
1960c23f23b9SMichael Tokarev  numa            libnuma support
1961ed279a06SKlim Kireev  libxml2         for Parallels image format
1962c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19637b01cb97SAlexandre Derumier  jemalloc        jemalloc support
196486583a07SLiam Merwick  avx2            AVX2 optimization support
19656b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1966a6b1d4c0SChanglong Xie  replication     replication support
1967c12d66aaSLin Ma  opengl          opengl support
1968c12d66aaSLin Ma  virglrenderer   virgl rendering support
1969c12d66aaSLin Ma  xfsctl          xfsctl support
1970c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19718de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19722f740136SJeff Cody  bochs           bochs image format support
19732f740136SJeff Cody  cloop           cloop image format support
19742f740136SJeff Cody  dmg             dmg image format support
19752f740136SJeff Cody  qcow1           qcow v1 image format support
19762f740136SJeff Cody  vdi             vdi image format support
19772f740136SJeff Cody  vvfat           vvfat image format support
19782f740136SJeff Cody  qed             qed image format support
19792f740136SJeff Cody  parallels       parallels image format support
19802f740136SJeff Cody  sheepdog        sheepdog block driver support
1981f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19828ca80760SRichard Henderson  capstone        capstone disassembler support
1983ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
198417824406SJunyan He  libpmem         libpmem support
198575411919SJames Le Cuirot  xkbcommon       xkbcommon support
1986b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
198721b2eca6SJingqi Liu  libdaxctl       libdaxctl support
198808fb77edSStefan Weil
198908fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1990af5db58eSpbrookEOF
19912d2ad6d0SFam Zhengexit 0
1992af5db58eSpbrookfi
1993af5db58eSpbrook
19949c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1995bb768f71SThomas Huthrm -f */config-devices.mak.d
19969c790242SThomas Huth
1997faf44142SDaniel P. Berrangéif test -z "$python"
1998faf44142SDaniel P. Berrangéthen
1999c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
2000c53eeaf7SStefan Hajnoczifi
2001c53eeaf7SStefan Hajnoczi
2002c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
2003c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
2004ddf90699SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
2005ddf90699SEduardo Habkost  error_exit "Cannot use '$python', Python >= 3.5 is required." \
2006c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
2007c53eeaf7SStefan Hajnoczifi
2008c53eeaf7SStefan Hajnoczi
2009755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
2010406ab2f3SCleber 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)
2011755ee70fSCleber Rosa
2012c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
2013c53eeaf7SStefan Hajnoczipython="$python -B"
2014c53eeaf7SStefan Hajnoczi
20150a01d76fSMarc-André Lureauif test -z "$meson"; then
20160a01d76fSMarc-André Lureau    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.0; then
20170a01d76fSMarc-André Lureau        meson=meson
20180a01d76fSMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
20190a01d76fSMarc-André Lureau        meson=git
20200a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
20210a01d76fSMarc-André Lureau        meson=internal
20220a01d76fSMarc-André Lureau    else
20230a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
20240a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
20250a01d76fSMarc-André Lureau        else
2026a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
2027a5665051SPaolo Bonzini        fi
20280a01d76fSMarc-André Lureau    fi
20290a01d76fSMarc-André Lureauelse
20300a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
20310a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
20320a01d76fSMarc-André Lureau    #
20330a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
20340a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
20350a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
20360a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
20370a01d76fSMarc-André Lureau        case "$meson" in
20380a01d76fSMarc-André Lureau            git | internal) ;;
20390a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
20400a01d76fSMarc-André Lureau        esac
20410a01d76fSMarc-André Lureau    fi
20420a01d76fSMarc-André Lureaufi
2043a5665051SPaolo Bonzini
20440a01d76fSMarc-André Lureauif test "$meson" = git; then
20450a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20460a01d76fSMarc-André Lureaufi
20470a01d76fSMarc-André Lureauif test "$git_update" = yes; then
20480a01d76fSMarc-André Lureau    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
20490a01d76fSMarc-André Lureaufi
20500a01d76fSMarc-André Lureau
20510a01d76fSMarc-André Lureaucase "$meson" in
20520a01d76fSMarc-André Lureau    git | internal)
2053a5665051SPaolo Bonzini        if ! $python -c 'import pkg_resources' > /dev/null 2>&1; then
2054a5665051SPaolo Bonzini            error_exit "Python setuptools not found"
2055a5665051SPaolo Bonzini        fi
20560a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20570a01d76fSMarc-André Lureau        ;;
20580a01d76fSMarc-André Lureau    *) meson=$(command -v meson) ;;
20590a01d76fSMarc-André Lureauesac
20600a01d76fSMarc-André Lureau
2061a5665051SPaolo Bonzini
20629aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20639aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20649aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20659aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20669aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20679aae6e54SDaniel Henrique Barbozaif compile_object ; then
20689aae6e54SDaniel Henrique Barboza  : C compiler works ok
20699aae6e54SDaniel Henrique Barbozaelse
20709aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20719aae6e54SDaniel Henrique Barbozafi
20729aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20739aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20749aae6e54SDaniel Henrique Barbozafi
20759aae6e54SDaniel Henrique Barboza
2076359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
2077359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
2078359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
2079359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
2080359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
2081359bc95dSPeter Maydell    else
208276ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
2083359bc95dSPeter Maydell    fi
2084359bc95dSPeter Maydellfi
2085359bc95dSPeter Maydell
20869c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20879c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20889c83ffd8SPeter Maydellif test -z "$werror" ; then
2089fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
2090e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20919c83ffd8SPeter Maydell        werror="yes"
20929c83ffd8SPeter Maydell    else
20939c83ffd8SPeter Maydell        werror="no"
20949c83ffd8SPeter Maydell    fi
20959c83ffd8SPeter Maydellfi
20969c83ffd8SPeter Maydell
2097fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
2098fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2099fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2100fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2101fb59dabdSPeter Maydell    # host OS we should stop now.
2102951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2103fb59dabdSPeter Maydellfi
2104fb59dabdSPeter Maydell
2105efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2106efc6c070SThomas Huthcat > $TMPC << EOF
2107efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2108efc6c070SThomas Huth# ifdef __apple_build_version__
2109efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2110efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
2111efc6c070SThomas Huth#  endif
2112efc6c070SThomas Huth# else
2113efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2114efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
2115efc6c070SThomas Huth#  endif
2116efc6c070SThomas Huth# endif
2117efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2118efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2119efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
2120efc6c070SThomas Huth# endif
2121efc6c070SThomas Huth#else
2122efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2123efc6c070SThomas Huth#endif
2124efc6c070SThomas Huthint main (void) { return 0; }
2125efc6c070SThomas HuthEOF
2126efc6c070SThomas Huthif ! compile_prog "" "" ; then
2127efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2128efc6c070SThomas Huthfi
2129efc6c070SThomas Huth
213000849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
213100849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
213200849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
213300849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
213400849b92SRichard Henderson# just silently disable some features, so it's too error prone.
213500849b92SRichard Henderson
213600849b92SRichard Hendersonwarn_flags=
213700849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
213800849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
213900849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
214000849b92SRichard Hendersonadd_to warn_flags -Wformat-security
214100849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
214200849b92SRichard Hendersonadd_to warn_flags -Winit-self
214300849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
214400849b92SRichard Hendersonadd_to warn_flags -Wempty-body
214500849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
214600849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
214700849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
214800849b92SRichard Henderson
214900849b92SRichard Hendersonnowarn_flags=
215000849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
215100849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
215200849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
215300849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
215400849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2155aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2156bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
215700849b92SRichard Henderson
215800849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
215993b25869SJohn Snow
216093b25869SJohn Snowcc_has_warning_flag() {
216193b25869SJohn Snow    write_c_skeleton;
216293b25869SJohn Snow
2163a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2164a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2165a1d29d6cSPeter Maydell    # warning options).
216693b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
216793b25869SJohn Snow    compile_prog "-Werror $optflag" ""
216893b25869SJohn Snow}
216993b25869SJohn Snow
217093b25869SJohn Snowfor flag in $gcc_flags; do
217193b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21728d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21738d05095cSPaolo Bonzini    fi
21748d05095cSPaolo Bonzinidone
21758d05095cSPaolo Bonzini
217663678e17SSteven Noonanif test "$stack_protector" != "no"; then
2177fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2178fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2179fccd35a0SRodrigo Rebello{
2180fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2181fccd35a0SRodrigo Rebello    while (*c) {
2182fccd35a0SRodrigo Rebello        *p++ = *c++;
2183fccd35a0SRodrigo Rebello    }
2184fccd35a0SRodrigo Rebello    return 0;
2185fccd35a0SRodrigo Rebello}
2186fccd35a0SRodrigo RebelloEOF
218763678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21883b463a3fSMiroslav Rezanina  sp_on=0
218963678e17SSteven Noonan  for flag in $gcc_flags; do
2190590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2191590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2192086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2193590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
219463678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2195db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21963b463a3fSMiroslav Rezanina      sp_on=1
219763678e17SSteven Noonan      break
219863678e17SSteven Noonan    fi
219963678e17SSteven Noonan  done
22003b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
22013b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
22023b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
22033b463a3fSMiroslav Rezanina    fi
22043b463a3fSMiroslav Rezanina  fi
220537746c5eSMarc-André Lureaufi
220637746c5eSMarc-André Lureau
220720bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
220820bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
220920bc94a2SPaolo Bonzinicat > $TMPC << EOF
221020bc94a2SPaolo Bonzinistruct {
221120bc94a2SPaolo Bonzini  int a[2];
221220bc94a2SPaolo Bonzini} x = {0};
221320bc94a2SPaolo BonziniEOF
221420bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
221520bc94a2SPaolo Bonzini  :
221620bc94a2SPaolo Bonzinielse
221720bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
221820bc94a2SPaolo Bonzinifi
221920bc94a2SPaolo Bonzini
222021e709aaSMarc-André Lureau# Our module code doesn't support Windows
222121e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
222221e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
222321e709aaSMarc-André Lureaufi
222421e709aaSMarc-André Lureau
2225bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2226bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2227bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2228bd83c861SChristian Ehrhardtfi
2229bd83c861SChristian Ehrhardt
2230d376e9deSThomas Huth# Static linking is not possible with modules or PIE
223140d6444eSAvi Kivityif test "$static" = "yes" ; then
2232aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2233aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2234aa0d1f44SPaolo Bonzini  fi
223540d6444eSAvi Kivityfi
223640d6444eSAvi Kivity
2237768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2238768b7855SEmilio G. Cota  cat > $TMPC << EOF
2239768b7855SEmilio G. Cotastatic __thread int tls_var;
2240768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2241768b7855SEmilio G. CotaEOF
2242768b7855SEmilio G. Cota
2243768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2244768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2245768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2246768b7855SEmilio G. Cotafi
2247768b7855SEmilio G. Cota
224840d6444eSAvi Kivitycat > $TMPC << EOF
224921d4a791SAvi Kivity
225021d4a791SAvi Kivity#ifdef __linux__
225121d4a791SAvi Kivity#  define THREAD __thread
225221d4a791SAvi Kivity#else
225321d4a791SAvi Kivity#  define THREAD
225421d4a791SAvi Kivity#endif
225521d4a791SAvi Kivitystatic THREAD int tls_var;
225621d4a791SAvi Kivityint main(void) { return tls_var; }
225740d6444eSAvi KivityEOF
2258b2634124SRichard Henderson
2259b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2260412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2261412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2262b2634124SRichard Henderson  LDFLAGS_NOPIE="-no-pie"
2263412aeacdSAlex Bennéefi
2264412aeacdSAlex Bennée
226512781462SRichard Hendersonif test "$static" = "yes"; then
2266eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
2267086d5f75SPaolo Bonzini    CFLAGS="-fPIE -DPIE $CFLAGS"
226812781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
226912781462SRichard Henderson    pie="yes"
227012781462SRichard Henderson  elif test "$pie" = "yes"; then
227112781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
227212781462SRichard Henderson  else
227312781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
227412781462SRichard Henderson    pie="no"
227512781462SRichard Henderson  fi
227612781462SRichard Hendersonelif test "$pie" = "no"; then
2277086d5f75SPaolo Bonzini  CFLAGS="$CFLAGS_NOPIE $CFLAGS"
2278086d5f75SPaolo Bonzini  LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
2279eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
2280086d5f75SPaolo Bonzini  CFLAGS="-fPIE -DPIE $CFLAGS"
2281086d5f75SPaolo Bonzini  LDFLAGS="-pie $LDFLAGS"
228240d6444eSAvi Kivity  pie="yes"
22832c674109SRichard Hendersonelif test "$pie" = "yes"; then
228476ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
228540d6444eSAvi Kivityelse
228640d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
228740d6444eSAvi Kivity  pie="no"
228840d6444eSAvi Kivityfi
228940d6444eSAvi Kivity
2290e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2291e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2292e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2293e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2294e6cbd751SRichard Hendersonfi
2295e6cbd751SRichard Henderson
229609dada40SPaolo Bonzini##########################################
229709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
229809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
229909dada40SPaolo Bonzini# specification is necessary
230009dada40SPaolo Bonzini
230109dada40SPaolo Bonziniif test "$cpu" = "i386"; then
230209dada40SPaolo Bonzini  cat > $TMPC << EOF
230309dada40SPaolo Bonzinistatic int sfaa(int *ptr)
230409dada40SPaolo Bonzini{
230509dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
230609dada40SPaolo Bonzini}
230709dada40SPaolo Bonzini
230809dada40SPaolo Bonziniint main(void)
230909dada40SPaolo Bonzini{
231009dada40SPaolo Bonzini  int val = 42;
23111405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
231209dada40SPaolo Bonzini  sfaa(&val);
231309dada40SPaolo Bonzini  return val;
231409dada40SPaolo Bonzini}
231509dada40SPaolo BonziniEOF
231609dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
231709dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
231809dada40SPaolo Bonzini  fi
231909dada40SPaolo Bonzinifi
232009dada40SPaolo Bonzini
232109dada40SPaolo Bonzini#########################################
2322ec530c81Sbellard# Solaris specific configure tool chain decisions
232309dada40SPaolo Bonzini
2324ec530c81Sbellardif test "$solaris" = "yes" ; then
23256792aa11SLoïc Minier  if has $install; then
23266792aa11SLoïc Minier    :
23276792aa11SLoïc Minier  else
232876ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
232976ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
233076ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2331ec530c81Sbellard  fi
233289138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
233376ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
233476ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
233576ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2336ec530c81Sbellard  fi
23376792aa11SLoïc Minier  if has ar; then
23386792aa11SLoïc Minier    :
23396792aa11SLoïc Minier  else
2340ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
234176ad07a4SPeter Maydell      error_exit "No path includes ar" \
234276ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2343ec530c81Sbellard    fi
234476ad07a4SPeter Maydell    error_exit "No path includes ar"
2345ec530c81Sbellard  fi
2346ec530c81Sbellardfi
2347ec530c81Sbellard
2348afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2349d880a3baSPaolo Bonzini    for target in $default_target_list; do
2350d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2351d880a3baSPaolo Bonzini            target_list="$target_list $target"
2352d880a3baSPaolo Bonzini    done
2353d880a3baSPaolo Bonzini    target_list="${target_list# }"
2354121afa9eSAnthony Liguorielse
235589138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2356d880a3baSPaolo Bonzini    for target in $target_list; do
235725b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
235825b48338SPeter Maydell        # friendly error message than if we let it fall through.
235925b48338SPeter Maydell        case " $default_target_list " in
236025b48338SPeter Maydell            *" $target "*)
236125b48338SPeter Maydell                ;;
236225b48338SPeter Maydell            *)
236325b48338SPeter Maydell                error_exit "Unknown target name '$target'"
236425b48338SPeter Maydell                ;;
236525b48338SPeter Maydell        esac
2366d880a3baSPaolo Bonzini        supported_target $target || exit 1
236725b48338SPeter Maydell    done
2368d880a3baSPaolo Bonzinifi
236925b48338SPeter Maydell
2370f55fe278SPaolo Bonzini# see if system emulation was really requested
2371f55fe278SPaolo Bonzinicase " $target_list " in
2372f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2373f55fe278SPaolo Bonzini  ;;
2374f55fe278SPaolo Bonzini  *) softmmu=no
2375f55fe278SPaolo Bonzini  ;;
2376f55fe278SPaolo Bonziniesac
23775327cf48Sbellard
237805dfa22bSPhilippe Mathieu-Daudéfor target in $target_list; do
237905dfa22bSPhilippe Mathieu-Daudé  case "$target" in
238005dfa22bSPhilippe Mathieu-Daudé    arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
238105dfa22bSPhilippe Mathieu-Daudé      edk2_blobs="yes"
238205dfa22bSPhilippe Mathieu-Daudé      ;;
238305dfa22bSPhilippe Mathieu-Daudé  esac
238405dfa22bSPhilippe Mathieu-Daudédone
2385623ef637SPhilippe Mathieu-Daudé# The EDK2 binaries are compressed with bzip2
2386623ef637SPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" && ! has bzip2; then
2387623ef637SPhilippe Mathieu-Daudé  error_exit "The bzip2 program is required for building QEMU"
2388623ef637SPhilippe Mathieu-Daudéfi
238905dfa22bSPhilippe Mathieu-Daudé
2390249247c9SJuan Quintelafeature_not_found() {
2391249247c9SJuan Quintela  feature=$1
239221684af0SStewart Smith  remedy=$2
2393249247c9SJuan Quintela
239476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
239521684af0SStewart Smith      "configure was not able to find it." \
239621684af0SStewart Smith      "$remedy"
2397249247c9SJuan Quintela}
2398249247c9SJuan Quintela
23997d13299dSbellard# ---
24007d13299dSbellard# big/little endian test
24017d13299dSbellardcat > $TMPC << EOF
240261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
240361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
240461cc919fSMike Frysingerextern int foo(short *, short *);
240561cc919fSMike Frysingerint main(int argc, char *argv[]) {
240661cc919fSMike Frysinger    return foo(big_endian, little_endian);
24077d13299dSbellard}
24087d13299dSbellardEOF
24097d13299dSbellard
241061cc919fSMike Frysingerif compile_object ; then
241112f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
241261cc919fSMike Frysinger        bigendian="yes"
241312f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
241461cc919fSMike Frysinger        bigendian="no"
24157d13299dSbellard    else
24167d13299dSbellard        echo big/little test failed
24177d13299dSbellard    fi
24187d13299dSbellardelse
241961cc919fSMike Frysinger    echo big/little test failed
24207d13299dSbellardfi
24217d13299dSbellard
2422b0a47e79SJuan Quintela##########################################
2423e10ee3f5SPhilippe Mathieu-Daudé# system tools
2424e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2425e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2426e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2427e10ee3f5SPhilippe Mathieu-Daudé    else
2428e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2429e10ee3f5SPhilippe Mathieu-Daudé    fi
2430e10ee3f5SPhilippe Mathieu-Daudéfi
2431e10ee3f5SPhilippe Mathieu-Daudé
2432e10ee3f5SPhilippe Mathieu-Daudé##########################################
2433a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2434a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2435a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2436a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2437a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2438a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2439a30878e7SPeter Maydell    fi
2440a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2441a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2442a30878e7SPeter Maydell    fi
2443a30878e7SPeter Maydell    gtk=no
244435be72baSPaolo Bonzini    sdl=disabled
2445a30878e7SPeter Maydellfi
2446a30878e7SPeter Maydell
24476b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
24486b39b063SEric Blakecat > $TMPC << EOF
24496b39b063SEric Blake#include <stdint.h>
24506b39b063SEric Blake#include <stdio.h>
24516b39b063SEric Blakeint main(int argc, char *argv[]) {
24526b39b063SEric Blake    return printf("%zu", SIZE_MAX);
24536b39b063SEric Blake}
24546b39b063SEric BlakeEOF
24556b39b063SEric Blakehave_broken_size_max=no
24566b39b063SEric Blakeif ! compile_object -Werror ; then
24576b39b063SEric Blake    have_broken_size_max=yes
24586b39b063SEric Blakefi
24596b39b063SEric Blake
2460a30878e7SPeter Maydell##########################################
2461015a33bdSGonglei# L2TPV3 probe
2462015a33bdSGonglei
2463015a33bdSGongleicat > $TMPC <<EOF
2464015a33bdSGonglei#include <sys/socket.h>
2465bff6cb72SMichael Tokarev#include <linux/ip.h>
2466015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2467015a33bdSGongleiEOF
2468015a33bdSGongleiif compile_prog "" "" ; then
2469015a33bdSGonglei  l2tpv3=yes
2470015a33bdSGongleielse
2471015a33bdSGonglei  l2tpv3=no
2472015a33bdSGongleifi
2473015a33bdSGonglei
2474c9c8b88fSDavid CARLIERif check_include "pty.h" ; then
2475c9c8b88fSDavid CARLIER  pty_h=yes
2476c9c8b88fSDavid CARLIERelse
2477c9c8b88fSDavid CARLIER  pty_h=no
2478c9c8b88fSDavid CARLIERfi
2479c9c8b88fSDavid CARLIER
2480195588ccSDavid CARLIERcat > $TMPC <<EOF
2481195588ccSDavid CARLIER#include <sys/mman.h>
2482195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2483195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2484195588ccSDavid CARLIER}
2485195588ccSDavid CARLIEREOF
2486195588ccSDavid CARLIERif compile_prog "" "" ; then
2487195588ccSDavid CARLIER  have_mlockall=yes
2488195588ccSDavid CARLIERelse
2489195588ccSDavid CARLIER  have_mlockall=no
2490195588ccSDavid CARLIERfi
2491195588ccSDavid CARLIER
2492299e6f19SPaolo Bonzini#########################################
2493299e6f19SPaolo Bonzini# vhost interdependencies and host support
2494299e6f19SPaolo Bonzini
2495299e6f19SPaolo Bonzini# vhost backends
2496299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2497299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2498299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2499299e6f19SPaolo Bonzinifi
2500108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2501108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2502108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2503108a6481SCindy Lufi
2504299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2505299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2506299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2507299e6f19SPaolo Bonzinifi
2508299e6f19SPaolo Bonzini
2509299e6f19SPaolo Bonzini# vhost-kernel devices
2510299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2511299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2512299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2513299e6f19SPaolo Bonzinifi
2514299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2515299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2516299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2517299e6f19SPaolo Bonzinifi
2518299e6f19SPaolo Bonzini
2519299e6f19SPaolo Bonzini# vhost-user backends
2520299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2521299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2522299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2523299e6f19SPaolo Bonzinifi
2524299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2525299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2526299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2527299e6f19SPaolo Bonzinifi
252898fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
252998fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
253098fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
253198fc1adaSDr. David Alan Gilbertfi
2532108a6481SCindy Lu#vhost-vdpa backends
2533108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2534108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2535108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2536108a6481SCindy Lufi
2537299e6f19SPaolo Bonzini
2538299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2539299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2540299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2541299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2542299e6f19SPaolo Bonzinifi
2543299e6f19SPaolo Bonzini
2544015a33bdSGonglei##########################################
25454d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
25464d9310f4SDaniel P. Berrange
25474d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
25484d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
25494d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
25504d9310f4SDaniel P. Berrange    #
25514d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
25524d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
25534d9310f4SDaniel P. Berrange    #
25544d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
25554d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
25564d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
25574d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
25584d9310f4SDaniel P. Berrange    # that for you.
25594d9310f4SDaniel P. Berrange    #
25604d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
25614d9310f4SDaniel P. Berrange    # are not in fact redundant.
25624d9310f4SDaniel P. Berrangecat > $TMPC << EOF
25634d9310f4SDaniel P. Berrange#include <unistd.h>
25644d9310f4SDaniel P. Berrange#include <time.h>
25654d9310f4SDaniel P. Berrange#undef localtime_r
25664d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
25674d9310f4SDaniel P. BerrangeEOF
25684d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
25694d9310f4SDaniel P. Berrange        localtime_r="yes"
25704d9310f4SDaniel P. Berrange    else
25714d9310f4SDaniel P. Berrange        localtime_r="no"
25724d9310f4SDaniel P. Berrange    fi
25734d9310f4SDaniel P. Berrangefi
25744d9310f4SDaniel P. Berrange
25754d9310f4SDaniel P. Berrange##########################################
2576779ab5e3SStefan Weil# pkg-config probe
2577779ab5e3SStefan Weil
2578779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
257976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2580779ab5e3SStefan Weilfi
2581779ab5e3SStefan Weil
2582779ab5e3SStefan Weil##########################################
2583b0a47e79SJuan Quintela# NPTL probe
2584b0a47e79SJuan Quintela
258524cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2586bd0c5661Spbrook  cat > $TMPC <<EOF
2587bd0c5661Spbrook#include <sched.h>
258830813ceaSpbrook#include <linux/futex.h>
2589182eacc0SStefan Weilint main(void) {
2590bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2591bd0c5661Spbrook#error bork
2592bd0c5661Spbrook#endif
2593182eacc0SStefan Weil  return 0;
2594bd0c5661Spbrook}
2595bd0c5661SpbrookEOF
259624cb36a6SPeter Maydell  if ! compile_object ; then
259721684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2598b0a47e79SJuan Quintela  fi
2599bd0c5661Spbrookfi
2600bd0c5661Spbrook
2601ac62922eSbalrog##########################################
2602607dacd0Sqiaonuohan# lzo check
2603607dacd0Sqiaonuohan
2604607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2605607dacd0Sqiaonuohan    cat > $TMPC << EOF
2606607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2607607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2608607dacd0SqiaonuohanEOF
2609607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2610708eab42SMarc-André Lureau        lzo_libs="-llzo2"
2611b25c9dffSStefan Weil        lzo="yes"
2612b25c9dffSStefan Weil    else
2613b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2614b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2615b25c9dffSStefan Weil        fi
2616b25c9dffSStefan Weil        lzo="no"
2617b25c9dffSStefan Weil    fi
2618607dacd0Sqiaonuohanfi
2619607dacd0Sqiaonuohan
2620607dacd0Sqiaonuohan##########################################
2621607dacd0Sqiaonuohan# snappy check
2622607dacd0Sqiaonuohan
2623607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2624607dacd0Sqiaonuohan    cat > $TMPC << EOF
2625607dacd0Sqiaonuohan#include <snappy-c.h>
2626607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2627607dacd0SqiaonuohanEOF
2628607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2629708eab42SMarc-André Lureau        snappy_libs='-lsnappy'
2630b25c9dffSStefan Weil        snappy="yes"
2631b25c9dffSStefan Weil    else
2632b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2633b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2634b25c9dffSStefan Weil        fi
2635b25c9dffSStefan Weil        snappy="no"
2636b25c9dffSStefan Weil    fi
2637607dacd0Sqiaonuohanfi
2638607dacd0Sqiaonuohan
2639607dacd0Sqiaonuohan##########################################
26406b383c08SPeter Wu# bzip2 check
26416b383c08SPeter Wu
26426b383c08SPeter Wuif test "$bzip2" != "no" ; then
26436b383c08SPeter Wu    cat > $TMPC << EOF
26446b383c08SPeter Wu#include <bzlib.h>
26456b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
26466b383c08SPeter WuEOF
26476b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
26486b383c08SPeter Wu        bzip2="yes"
26496b383c08SPeter Wu    else
26506b383c08SPeter Wu        if test "$bzip2" = "yes"; then
26516b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
26526b383c08SPeter Wu        fi
26536b383c08SPeter Wu        bzip2="no"
26546b383c08SPeter Wu    fi
26556b383c08SPeter Wufi
26566b383c08SPeter Wu
26576b383c08SPeter Wu##########################################
265883bc1f97SJulio Faracco# lzfse check
265983bc1f97SJulio Faracco
266083bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
266183bc1f97SJulio Faracco    cat > $TMPC << EOF
266283bc1f97SJulio Faracco#include <lzfse.h>
266383bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
266483bc1f97SJulio FaraccoEOF
266583bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
266683bc1f97SJulio Faracco        lzfse="yes"
266783bc1f97SJulio Faracco    else
266883bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
266983bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
267083bc1f97SJulio Faracco        fi
267183bc1f97SJulio Faracco        lzfse="no"
267283bc1f97SJulio Faracco    fi
267383bc1f97SJulio Faraccofi
267483bc1f97SJulio Faracco
267583bc1f97SJulio Faracco##########################################
26763a678481SJuan Quintela# zstd check
26773a678481SJuan Quintela
26783a678481SJuan Quintelaif test "$zstd" != "no" ; then
2679297254c7SJuan Quintela    libzstd_minver="1.4.0"
2680297254c7SJuan Quintela    if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
26813a678481SJuan Quintela        zstd_cflags="$($pkg_config --cflags libzstd)"
26823a678481SJuan Quintela        zstd_libs="$($pkg_config --libs libzstd)"
26833a678481SJuan Quintela        zstd="yes"
26843a678481SJuan Quintela    else
26853a678481SJuan Quintela        if test "$zstd" = "yes" ; then
26863a678481SJuan Quintela            feature_not_found "libzstd" "Install libzstd devel"
26873a678481SJuan Quintela        fi
26883a678481SJuan Quintela        zstd="no"
26893a678481SJuan Quintela    fi
26903a678481SJuan Quintelafi
26913a678481SJuan Quintela
26923a678481SJuan Quintela##########################################
2693f794573eSEduardo Otubo# libseccomp check
2694f794573eSEduardo Otubo
2695f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
26963e684455SMichael Strosaker    libseccomp_minver="2.3.0"
269725ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2698c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2699c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2700f794573eSEduardo Otubo        seccomp="yes"
2701f794573eSEduardo Otubo    else
2702f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2703693e5910SAndrew Jones            feature_not_found "libseccomp" \
2704693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2705896848f0SEduardo Otubo        fi
2706e84d5956SYann E. MORIN        seccomp="no"
2707f794573eSEduardo Otubo    fi
2708f794573eSEduardo Otubofi
2709f794573eSEduardo Otubo##########################################
2710e37630caSaliguori# xen probe
2711e37630caSaliguori
2712fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2713c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2714c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2715c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2716c1cdd9d5SJuergen Gross
2717c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2718c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2719c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2720c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2721c1cdd9d5SJuergen Gross    xen=yes
2722c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2723c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
272458ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
272558ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
272658ea9a7aSAnthony PERARD    fi
2727c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2728582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2729582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2730c1cdd9d5SJuergen Gross  else
2731c1cdd9d5SJuergen Gross
2732b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2733d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2734d5b93ddfSAnthony PERARD
273550ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
273650ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
273750ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
273850ced5b3SStefan Weil
273950ced5b3SStefan Weil    # Xen (any)
274050ced5b3SStefan Weil    cat > $TMPC <<EOF
274150ced5b3SStefan Weil#include <xenctrl.h>
274250ced5b3SStefan Weilint main(void) {
274350ced5b3SStefan Weil  return 0;
274450ced5b3SStefan Weil}
274550ced5b3SStefan WeilEOF
274650ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
274750ced5b3SStefan Weil      # Xen not found
274850ced5b3SStefan Weil      if test "$xen" = "yes" ; then
274921684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
275050ced5b3SStefan Weil      fi
275150ced5b3SStefan Weil      xen=no
275250ced5b3SStefan Weil
2753d5b93ddfSAnthony PERARD    # Xen unstable
275469deef08SPeter Maydell    elif
275569deef08SPeter Maydell        cat > $TMPC <<EOF &&
27562cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
27572cbf8903SRoss Lagerwall#define __XEN_TOOLS__
27582cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2759d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
27602cbf8903SRoss Lagerwallint main(void) {
27612cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2762d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
27632cbf8903SRoss Lagerwall
27642cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
27652cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
27662cbf8903SRoss Lagerwall
2767d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2768d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2769d3c49ebbSPaul Durrant
27702cbf8903SRoss Lagerwall  return 0;
27712cbf8903SRoss Lagerwall}
27722cbf8903SRoss LagerwallEOF
27732cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
27742cbf8903SRoss Lagerwall      then
27752cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
27762cbf8903SRoss Lagerwall      xen_ctrl_version=41100
27772cbf8903SRoss Lagerwall      xen=yes
27782cbf8903SRoss Lagerwall    elif
27792cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
27805ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
27815ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
278258ea9a7aSAnthony PERARD#include <xentoolcore.h>
27835ba3d756SIgor Druzhininint main(void) {
27845ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
27855ba3d756SIgor Druzhinin
27865ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
27875ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
278858ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
27895ba3d756SIgor Druzhinin
27905ba3d756SIgor Druzhinin  return 0;
27915ba3d756SIgor Druzhinin}
27925ba3d756SIgor DruzhininEOF
279358ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
27945ba3d756SIgor Druzhinin      then
279558ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
27965ba3d756SIgor Druzhinin      xen_ctrl_version=41000
27975ba3d756SIgor Druzhinin      xen=yes
27985ba3d756SIgor Druzhinin    elif
27995ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2800da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2801da8090ccSPaul Durrant#define __XEN_TOOLS__
2802da8090ccSPaul Durrant#include <xendevicemodel.h>
2803da8090ccSPaul Durrantint main(void) {
2804da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2805da8090ccSPaul Durrant
2806da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2807da8090ccSPaul Durrant  xendevicemodel_close(xd);
2808da8090ccSPaul Durrant
2809da8090ccSPaul Durrant  return 0;
2810da8090ccSPaul Durrant}
2811da8090ccSPaul DurrantEOF
2812da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2813da8090ccSPaul Durrant      then
2814da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2815f1167ee6SJuergen Gross      xen_ctrl_version=40900
2816da8090ccSPaul Durrant      xen=yes
2817da8090ccSPaul Durrant    elif
2818da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
28195eeb39c2SIan Campbell/*
28205eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
28215eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2822b6eb9b45SPaulina Szubarczyk *
2823b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2824b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2825b6eb9b45SPaulina Szubarczyk */
2826b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2827b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2828b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2829b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2830b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2831b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2832b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2833b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2834b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2835b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2836b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2837b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2838b6eb9b45SPaulina Szubarczyk#endif
2839b6eb9b45SPaulina Szubarczykint main(void) {
2840b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2841b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2842b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2843b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2844b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2845b6eb9b45SPaulina Szubarczyk
2846b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2847b6eb9b45SPaulina Szubarczyk
2848b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2849b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2850b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2851b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2852b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2853b6eb9b45SPaulina Szubarczyk
2854b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2855b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2856b6eb9b45SPaulina Szubarczyk
2857b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2858b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2859b6eb9b45SPaulina Szubarczyk
2860b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2861b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2862b6eb9b45SPaulina Szubarczyk
2863b6eb9b45SPaulina Szubarczyk  return 0;
2864b6eb9b45SPaulina Szubarczyk}
2865b6eb9b45SPaulina SzubarczykEOF
2866b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2867b6eb9b45SPaulina Szubarczyk      then
2868f1167ee6SJuergen Gross      xen_ctrl_version=40800
2869b6eb9b45SPaulina Szubarczyk      xen=yes
2870b6eb9b45SPaulina Szubarczyk    elif
2871b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2872b6eb9b45SPaulina Szubarczyk/*
2873b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2874b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
28755eeb39c2SIan Campbell */
28765eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
28775eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
28785eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
28795eeb39c2SIan Campbell#include <xenctrl.h>
28805eeb39c2SIan Campbell#include <xenstore.h>
28815eeb39c2SIan Campbell#include <xenevtchn.h>
28825eeb39c2SIan Campbell#include <xengnttab.h>
28835eeb39c2SIan Campbell#include <xenforeignmemory.h>
28845eeb39c2SIan Campbell#include <stdint.h>
28855eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
28865eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
28875eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
28885eeb39c2SIan Campbell#endif
28895eeb39c2SIan Campbellint main(void) {
28905eeb39c2SIan Campbell  xc_interface *xc = NULL;
28915eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
28925eeb39c2SIan Campbell  xenevtchn_handle *xe;
28935eeb39c2SIan Campbell  xengnttab_handle *xg;
28945eeb39c2SIan Campbell
28955eeb39c2SIan Campbell  xs_daemon_open();
28965eeb39c2SIan Campbell
28975eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
28985eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
28995eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29005eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29015eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
29025eeb39c2SIan Campbell
29035eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
29045eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
29055eeb39c2SIan Campbell
29065eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
29075eeb39c2SIan Campbell  xenevtchn_fd(xe);
29085eeb39c2SIan Campbell
29095eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
29105eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
29115eeb39c2SIan Campbell
29125eeb39c2SIan Campbell  return 0;
29135eeb39c2SIan Campbell}
29145eeb39c2SIan CampbellEOF
29155eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
29165eeb39c2SIan Campbell      then
2917f1167ee6SJuergen Gross      xen_ctrl_version=40701
29185eeb39c2SIan Campbell      xen=yes
2919cdadde39SRoger Pau Monne
2920cdadde39SRoger Pau Monne    # Xen 4.6
2921cdadde39SRoger Pau Monne    elif
2922cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2923cdadde39SRoger Pau Monne#include <xenctrl.h>
2924e108a3c1SAnthony PERARD#include <xenstore.h>
2925d5b93ddfSAnthony PERARD#include <stdint.h>
2926d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2927d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2928d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2929d5b93ddfSAnthony PERARD#endif
2930d5b93ddfSAnthony PERARDint main(void) {
2931d5b93ddfSAnthony PERARD  xc_interface *xc;
2932d5b93ddfSAnthony PERARD  xs_daemon_open();
2933d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2934d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2935d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2936b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29378688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2938d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
293920a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2940d8b441a3SJan Beulich  return 0;
2941d8b441a3SJan Beulich}
2942d8b441a3SJan BeulichEOF
2943d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2944d8b441a3SJan Beulich      then
2945f1167ee6SJuergen Gross      xen_ctrl_version=40600
2946d8b441a3SJan Beulich      xen=yes
2947d8b441a3SJan Beulich
2948d8b441a3SJan Beulich    # Xen 4.5
2949d8b441a3SJan Beulich    elif
2950d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2951d8b441a3SJan Beulich#include <xenctrl.h>
2952d8b441a3SJan Beulich#include <xenstore.h>
2953d8b441a3SJan Beulich#include <stdint.h>
2954d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2955d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2956d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2957d8b441a3SJan Beulich#endif
2958d8b441a3SJan Beulichint main(void) {
2959d8b441a3SJan Beulich  xc_interface *xc;
2960d8b441a3SJan Beulich  xs_daemon_open();
2961d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2962d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2963d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2964d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2965d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29663996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
29673996e85cSPaul Durrant  return 0;
29683996e85cSPaul Durrant}
29693996e85cSPaul DurrantEOF
29703996e85cSPaul Durrant        compile_prog "" "$xen_libs"
29713996e85cSPaul Durrant      then
2972f1167ee6SJuergen Gross      xen_ctrl_version=40500
29733996e85cSPaul Durrant      xen=yes
29743996e85cSPaul Durrant
29753996e85cSPaul Durrant    elif
29763996e85cSPaul Durrant        cat > $TMPC <<EOF &&
29773996e85cSPaul Durrant#include <xenctrl.h>
29783996e85cSPaul Durrant#include <xenstore.h>
29793996e85cSPaul Durrant#include <stdint.h>
29803996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
29813996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
29823996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
29833996e85cSPaul Durrant#endif
29843996e85cSPaul Durrantint main(void) {
29853996e85cSPaul Durrant  xc_interface *xc;
29863996e85cSPaul Durrant  xs_daemon_open();
29873996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
29883996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
29893996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
29903996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29913996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29928688e065SStefano Stabellini  return 0;
29938688e065SStefano Stabellini}
29948688e065SStefano StabelliniEOF
29958688e065SStefano Stabellini        compile_prog "" "$xen_libs"
299669deef08SPeter Maydell      then
2997f1167ee6SJuergen Gross      xen_ctrl_version=40200
29988688e065SStefano Stabellini      xen=yes
29998688e065SStefano Stabellini
3000e37630caSaliguori    else
3001fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
3002edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
3003edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
3004fc321b4bSJuan Quintela      fi
3005fc321b4bSJuan Quintela      xen=no
3006e37630caSaliguori    fi
3007d5b93ddfSAnthony PERARD
3008d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
3009f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
3010582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
30115eeb39c2SIan Campbell      fi
3012d5b93ddfSAnthony PERARD    fi
3013e37630caSaliguori  fi
3014c1cdd9d5SJuergen Grossfi
3015e37630caSaliguori
3016eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
3017edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
3018eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
3019eb6fda0fSAnthony PERARD  else
3020eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
302176ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
302276ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
3023eb6fda0fSAnthony PERARD    fi
3024eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
3025eb6fda0fSAnthony PERARD  fi
3026eb6fda0fSAnthony PERARDfi
3027eb6fda0fSAnthony PERARD
3028e37630caSaliguori##########################################
3029d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
3030d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
3031327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
3032d661d9a4SJustin Terry (VM)        whpx="yes"
3033d661d9a4SJustin Terry (VM)    else
3034d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
303553537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
3036d661d9a4SJustin Terry (VM)        fi
3037d661d9a4SJustin Terry (VM)        whpx="no"
3038d661d9a4SJustin Terry (VM)    fi
3039d661d9a4SJustin Terry (VM)fi
3040d661d9a4SJustin Terry (VM)
3041d661d9a4SJustin Terry (VM)##########################################
3042e8f3bd71SMarc-André Lureau# gettext probe
3043e8f3bd71SMarc-André Lureauif test "$gettext" != "false" ; then
3044e8f3bd71SMarc-André Lureau  if has xgettext; then
3045e8f3bd71SMarc-André Lureau    gettext=true
3046e8f3bd71SMarc-André Lureau  else
3047e8f3bd71SMarc-André Lureau    if test "$gettext" = "true" ; then
3048e8f3bd71SMarc-André Lureau      feature_not_found "gettext" "Install xgettext binary"
3049e8f3bd71SMarc-André Lureau    fi
3050e8f3bd71SMarc-André Lureau    gettext=false
3051e8f3bd71SMarc-André Lureau  fi
3052e8f3bd71SMarc-André Lureaufi
3053e8f3bd71SMarc-André Lureau
3054e8f3bd71SMarc-André Lureau##########################################
3055dfffc653SJuan Quintela# Sparse probe
3056dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
3057968b4db3SPaolo Bonzini  if has sparse; then
3058dfffc653SJuan Quintela    sparse=yes
3059dfffc653SJuan Quintela  else
3060dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
306121684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
3062dfffc653SJuan Quintela    fi
3063dfffc653SJuan Quintela    sparse=no
3064dfffc653SJuan Quintela  fi
3065dfffc653SJuan Quintelafi
3066dfffc653SJuan Quintela
3067dfffc653SJuan Quintela##########################################
3068f676c67eSJeremy White# X11 probe
3069f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
30708781595bSGerd Hoffmann    have_x11=yes
307189138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
307289138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
3073f676c67eSJeremy Whitefi
3074f676c67eSJeremy White
3075f676c67eSJeremy White##########################################
3076a4ccabcfSAnthony Liguori# GTK probe
3077a4ccabcfSAnthony Liguori
30785a464e6cSPeter Xuif test "$gtk" != "no"; then
307989d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
308089d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
30817b23d121SVolker Rümelin    gtkversion="3.22.0"
3082bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
308389138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
308489138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
308589138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
30860a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
30878781595bSGerd Hoffmann            need_x11=yes
3088f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
3089f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
30900a337ed0SGerd Hoffmann        fi
3091bbbf9bfbSStefan Weil        gtk="yes"
3092bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
30935fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
3094bbbf9bfbSStefan Weil    else
3095bbbf9bfbSStefan Weil        gtk="no"
3096bbbf9bfbSStefan Weil    fi
3097bbbf9bfbSStefan Weilfi
3098bbbf9bfbSStefan Weil
3099ddbb0d09SDaniel P. Berrange
3100ddbb0d09SDaniel P. Berrange##########################################
3101ddbb0d09SDaniel P. Berrange# GNUTLS probe
3102ddbb0d09SDaniel P. Berrange
3103ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
3104a73e82efSRichard Henderson    pass="no"
3105a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
310689138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
310789138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
3108a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
3109a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
3110a73e82efSRichard Henderson        write_c_skeleton
3111a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
3112243dc2cfSRichard Henderson            LIBS="$gnutls_libs $LIBS"
3113ddbb0d09SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
3114a73e82efSRichard Henderson            pass="yes"
3115a73e82efSRichard Henderson        fi
3116a73e82efSRichard Henderson    fi
3117a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
3118a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
3119ddbb0d09SDaniel P. Berrange    else
3120a73e82efSRichard Henderson        gnutls="$pass"
3121ddbb0d09SDaniel P. Berrange    fi
3122ddbb0d09SDaniel P. Berrangefi
3123ddbb0d09SDaniel P. Berrange
312491bfcdb0SDaniel P. Berrange
312591bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
312691bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
3127a0722409SDaniel P. Berrangé# explicitly
312891bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
312991bfcdb0SDaniel P. Berrangethen
3130a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
313191bfcdb0SDaniel P. Berrange    then
313291bfcdb0SDaniel P. Berrange        gcrypt="no"
313391bfcdb0SDaniel P. Berrange    fi
313491bfcdb0SDaniel P. Berrangefi
313591bfcdb0SDaniel P. Berrange
313691bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
313791bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
3138a0722409SDaniel P. Berrangé# explicitly
313991bfcdb0SDaniel P. Berrangeif test -z "$nettle"
314091bfcdb0SDaniel P. Berrangethen
3141a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
314291bfcdb0SDaniel P. Berrange    then
314391bfcdb0SDaniel P. Berrange        nettle="no"
314491bfcdb0SDaniel P. Berrange    fi
314591bfcdb0SDaniel P. Berrangefi
314691bfcdb0SDaniel P. Berrange
3147dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
314891bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
314991bfcdb0SDaniel P. Berrange    then
315091bfcdb0SDaniel P. Berrange	return 1
315191bfcdb0SDaniel P. Berrange    fi
315291bfcdb0SDaniel P. Berrange
315391bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
315491bfcdb0SDaniel P. Berrange    then
315589138857SStefan Weil	host=$(libgcrypt-config --host)
315691bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
315791bfcdb0SDaniel P. Berrange	then
315891bfcdb0SDaniel P. Berrange	    return 1
315991bfcdb0SDaniel P. Berrange	fi
316091bfcdb0SDaniel P. Berrange    fi
316191bfcdb0SDaniel P. Berrange
3162dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
3163dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
3164dea7a64eSDaniel P. Berrangé
3165dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
3166dea7a64eSDaniel P. Berrangé    then
3167dea7a64eSDaniel P. Berrangé       return 1
3168dea7a64eSDaniel P. Berrangé    fi
3169dea7a64eSDaniel P. Berrangé
317091bfcdb0SDaniel P. Berrange    return 0
317191bfcdb0SDaniel P. Berrange}
317291bfcdb0SDaniel P. Berrange
3173a0722409SDaniel P. Berrangé
3174a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
3175a73e82efSRichard Henderson    pass="no"
317664dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
3177a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
3178a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
3179a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
3180a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3181a73e82efSRichard Henderson        write_c_skeleton
3182a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
3183243dc2cfSRichard Henderson            LIBS="$nettle_libs $LIBS"
3184a0722409SDaniel P. Berrangé            QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
3185a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
3186a0722409SDaniel P. Berrangé               gcrypt="no"
3187a0722409SDaniel P. Berrangé            fi
3188a73e82efSRichard Henderson            pass="yes"
3189a73e82efSRichard Henderson        fi
3190a73e82efSRichard Henderson    fi
3191dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
3192dc2207afSDaniel P. Berrangé    then
3193dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
3194dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
3195dc2207afSDaniel P. Berrangéint main(void) {
3196dc2207afSDaniel P. Berrangé  return 0;
3197dc2207afSDaniel P. Berrangé}
3198dc2207afSDaniel P. BerrangéEOF
3199dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
3200dc2207afSDaniel P. Berrangé            nettle_xts=yes
3201dc2207afSDaniel P. Berrangé            qemu_private_xts=no
3202dc2207afSDaniel P. Berrangé        fi
3203dc2207afSDaniel P. Berrangé    fi
3204a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
320564dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3206a0722409SDaniel P. Berrangé    else
3207a73e82efSRichard Henderson        nettle="$pass"
3208a0722409SDaniel P. Berrangé    fi
3209a0722409SDaniel P. Berrangéfi
3210a0722409SDaniel P. Berrangé
321191bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
3212a73e82efSRichard Henderson    pass="no"
3213dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
321489138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
321589138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
3216a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
321791bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
321891bfcdb0SDaniel P. Berrange        # turn breaks static builds...
321991bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
322091bfcdb0SDaniel P. Berrange        then
322191bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
322291bfcdb0SDaniel P. Berrange        fi
32231f923c70SLongpeng(Mike)
3224a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3225a73e82efSRichard Henderson        write_c_skeleton
3226a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
3227243dc2cfSRichard Henderson            LIBS="$gcrypt_libs $LIBS"
322837788f25SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
3229a73e82efSRichard Henderson            pass="yes"
3230a73e82efSRichard Henderson        fi
3231a73e82efSRichard Henderson    fi
3232a73e82efSRichard Henderson    if test "$pass" = "yes"; then
323337788f25SDaniel P. Berrange        gcrypt="yes"
32341f923c70SLongpeng(Mike)        cat > $TMPC << EOF
32351f923c70SLongpeng(Mike)#include <gcrypt.h>
32361f923c70SLongpeng(Mike)int main(void) {
32371f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
32381f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
32391f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
32401f923c70SLongpeng(Mike)  return 0;
32411f923c70SLongpeng(Mike)}
32421f923c70SLongpeng(Mike)EOF
32431f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
32441f923c70SLongpeng(Mike)            gcrypt_hmac=yes
32451f923c70SLongpeng(Mike)        fi
3246e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
3247e0576942SDaniel P. Berrangé#include <gcrypt.h>
3248e0576942SDaniel P. Berrangéint main(void) {
3249e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
3250e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3251e0576942SDaniel P. Berrangé  return 0;
3252e0576942SDaniel P. Berrangé}
3253e0576942SDaniel P. BerrangéEOF
3254e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3255e0576942SDaniel P. Berrangé            gcrypt_xts=yes
3256e0576942SDaniel P. Berrangé            qemu_private_xts=no
3257e0576942SDaniel P. Berrangé        fi
3258a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
3259dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
326091bfcdb0SDaniel P. Berrange    else
326191bfcdb0SDaniel P. Berrange        gcrypt="no"
326291bfcdb0SDaniel P. Berrange    fi
326362893b67SDaniel P. Berrangefi
326462893b67SDaniel P. Berrange
3265ddbb0d09SDaniel P. Berrange
326691bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
326791bfcdb0SDaniel P. Berrangethen
326891bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
326991bfcdb0SDaniel P. Berrangefi
3270ed754746SDaniel P. Berrange
32719a2fd434SDaniel P. Berrange##########################################
32729a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
32739a2fd434SDaniel P. Berrange
32749a2fd434SDaniel P. Berrangetasn1=yes
327590246037SDaniel P. Berrangetasn1_cflags=""
327690246037SDaniel P. Berrangetasn1_libs=""
32779a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
327889138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
327989138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
32809a2fd434SDaniel P. Berrangeelse
32819a2fd434SDaniel P. Berrange    tasn1=no
32829a2fd434SDaniel P. Berrangefi
32839a2fd434SDaniel P. Berrange
3284ed754746SDaniel P. Berrange
3285bbbf9bfbSStefan Weil##########################################
32868953caf3SDaniel P. Berrange# PAM probe
32878953caf3SDaniel P. Berrange
32888953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
32898953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
32908953caf3SDaniel P. Berrange#include <security/pam_appl.h>
32918953caf3SDaniel P. Berrange#include <stdio.h>
32928953caf3SDaniel P. Berrangeint main(void) {
32938953caf3SDaniel P. Berrange   const char *service_name = "qemu";
32948953caf3SDaniel P. Berrange   const char *user = "frank";
32959c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
32968953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
32979c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
32988953caf3SDaniel P. Berrange   return 0;
32998953caf3SDaniel P. Berrange}
33008953caf3SDaniel P. BerrangeEOF
33018953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
33028953caf3SDaniel P. Berrange        auth_pam=yes
33038953caf3SDaniel P. Berrange    else
33048953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
33058953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
33068953caf3SDaniel P. Berrange        else
33078953caf3SDaniel P. Berrange            auth_pam=no
33088953caf3SDaniel P. Berrange        fi
33098953caf3SDaniel P. Berrange    fi
33108953caf3SDaniel P. Berrangefi
33118953caf3SDaniel P. Berrange
33128953caf3SDaniel P. Berrange##########################################
3313559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
3314559607eaSDaniel P. Berrange
3315559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
3316559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
3317559607eaSDaniel P. Berrange  have_ifaddrs_h=no
3318559607eaSDaniel P. Berrangefi
3319559607eaSDaniel P. Berrange
3320e865b97fSChen Gang#########################################
3321e865b97fSChen Gang# libdrm check
3322e865b97fSChen Ganghave_drm_h=no
3323e865b97fSChen Gangif check_include "libdrm/drm.h" ; then
3324e865b97fSChen Gang    have_drm_h=yes
3325e865b97fSChen Gangfi
3326e865b97fSChen Gang
33272a4b472cSDavid CARLIER#########################################
33282a4b472cSDavid CARLIER# sys/signal.h check
33292a4b472cSDavid CARLIERhave_sys_signal_h=no
33302a4b472cSDavid CARLIERif check_include "sys/signal.h" ; then
33312a4b472cSDavid CARLIER  have_sys_signal_h=yes
33322a4b472cSDavid CARLIERfi
33332a4b472cSDavid CARLIER
3334559607eaSDaniel P. Berrange##########################################
3335bbbf9bfbSStefan Weil# VTE probe
3336bbbf9bfbSStefan Weil
3337bbbf9bfbSStefan Weilif test "$vte" != "no"; then
3338c6feff9eSCole Robinson    vteminversion="0.32.0"
3339c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3340c6feff9eSCole Robinson      vtepackage="vte-2.91"
3341c6feff9eSCole Robinson    else
3342528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3343c6feff9eSCole Robinson    fi
3344c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
334589138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
334689138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
334789138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3348bbbf9bfbSStefan Weil        vte="yes"
3349bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3350c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
33519e04c683SStefan Weil    else
3352bbbf9bfbSStefan Weil        vte="no"
3353a4ccabcfSAnthony Liguori    fi
3354a4ccabcfSAnthony Liguorifi
3355a4ccabcfSAnthony Liguori
3356a4ccabcfSAnthony Liguori##########################################
33572da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
33582da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
33592da776dbSMichael R. Hines  cat > $TMPC <<EOF
33602da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
33612da776dbSMichael R. Hinesint main(void) { return 0; }
33622da776dbSMichael R. HinesEOF
3363ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
33642da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
33652da776dbSMichael R. Hines    rdma="yes"
33662da776dbSMichael R. Hines  else
33672da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
33682da776dbSMichael R. Hines        error_exit \
3369ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
33702da776dbSMichael R. Hines            " Your options:" \
3371ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
33722da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
33732da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
33742da776dbSMichael R. Hines    fi
33752da776dbSMichael R. Hines    rdma="no"
33762da776dbSMichael R. Hines  fi
33772da776dbSMichael R. Hinesfi
33782da776dbSMichael R. Hines
337921ab34c9SMarcel Apfelbaum##########################################
338021ab34c9SMarcel Apfelbaum# PVRDMA detection
338121ab34c9SMarcel Apfelbaum
338221ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
338321ab34c9SMarcel Apfelbaum#include <sys/mman.h>
338421ab34c9SMarcel Apfelbaum
338521ab34c9SMarcel Apfelbaumint
338621ab34c9SMarcel Apfelbaummain(void)
338721ab34c9SMarcel Apfelbaum{
338821ab34c9SMarcel Apfelbaum    char buf = 0;
338921ab34c9SMarcel Apfelbaum    void *addr = &buf;
339021ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
339121ab34c9SMarcel Apfelbaum
339221ab34c9SMarcel Apfelbaum    return 0;
339321ab34c9SMarcel Apfelbaum}
339421ab34c9SMarcel ApfelbaumEOF
339521ab34c9SMarcel Apfelbaum
339621ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
339721ab34c9SMarcel Apfelbaum    case "$pvrdma" in
339821ab34c9SMarcel Apfelbaum    "")
339921ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
340021ab34c9SMarcel Apfelbaum            pvrdma="yes"
340121ab34c9SMarcel Apfelbaum        else
340221ab34c9SMarcel Apfelbaum            pvrdma="no"
340321ab34c9SMarcel Apfelbaum        fi
340421ab34c9SMarcel Apfelbaum        ;;
340521ab34c9SMarcel Apfelbaum    "yes")
340621ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
340721ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
340821ab34c9SMarcel Apfelbaum        fi
340921ab34c9SMarcel Apfelbaum        pvrdma="yes"
341021ab34c9SMarcel Apfelbaum        ;;
341121ab34c9SMarcel Apfelbaum    "no")
341221ab34c9SMarcel Apfelbaum        pvrdma="no"
341321ab34c9SMarcel Apfelbaum        ;;
341421ab34c9SMarcel Apfelbaum    esac
341521ab34c9SMarcel Apfelbaumelse
341621ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
341721ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
341821ab34c9SMarcel Apfelbaum    fi
341921ab34c9SMarcel Apfelbaum    pvrdma="no"
342021ab34c9SMarcel Apfelbaumfi
342195c6bff3SBenoît Canet
3422ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3423ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3424ee108585SYuval Shaia
3425ee108585SYuval Shaiacat > $TMPC <<EOF &&
3426ee108585SYuval Shaia#include <infiniband/verbs.h>
3427ee108585SYuval Shaia
3428ee108585SYuval Shaiaint
3429ee108585SYuval Shaiamain(void)
3430ee108585SYuval Shaia{
3431ee108585SYuval Shaia    struct ibv_mr *mr;
3432ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3433ee108585SYuval Shaia    size_t length = 10;
3434ee108585SYuval Shaia    uint64_t iova = 0;
3435ee108585SYuval Shaia    int access = 0;
3436ee108585SYuval Shaia    void *addr = NULL;
3437ee108585SYuval Shaia
3438ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3439ee108585SYuval Shaia
3440ee108585SYuval Shaia    ibv_dereg_mr(mr);
3441ee108585SYuval Shaia
3442ee108585SYuval Shaia    return 0;
3443ee108585SYuval Shaia}
3444ee108585SYuval ShaiaEOF
3445ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3446ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3447ee108585SYuval Shaia    fi
3448ee108585SYuval Shaiafi
3449ee108585SYuval Shaia
345095c6bff3SBenoît Canet##########################################
3451c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3452dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3453dce512deSChristoph Hellwig  cat > $TMPC << EOF
3454ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3455dce512deSChristoph Hellwig#include <xfs/xfs.h>
3456dce512deSChristoph Hellwigint main(void)
3457dce512deSChristoph Hellwig{
3458dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3459dce512deSChristoph Hellwig    return 0;
3460dce512deSChristoph Hellwig}
3461dce512deSChristoph HellwigEOF
3462dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3463dce512deSChristoph Hellwig    xfs="yes"
3464dce512deSChristoph Hellwig  else
3465dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
346621684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3467dce512deSChristoph Hellwig    fi
3468dce512deSChristoph Hellwig    xfs=no
3469dce512deSChristoph Hellwig  fi
3470dce512deSChristoph Hellwigfi
3471dce512deSChristoph Hellwig
3472dce512deSChristoph Hellwig##########################################
34738a16d273Sths# vde libraries probe
3474dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
34754baae0acSJuan Quintela  vde_libs="-lvdeplug"
34768a16d273Sths  cat > $TMPC << EOF
34778a16d273Sths#include <libvdeplug.h>
34784a7f0e06Spbrookint main(void)
34794a7f0e06Spbrook{
34804a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3481fea08e08SPeter Maydell    char s[] = "";
3482fea08e08SPeter Maydell    vde_open(s, s, &a);
34834a7f0e06Spbrook    return 0;
34844a7f0e06Spbrook}
34858a16d273SthsEOF
348652166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
34874baae0acSJuan Quintela    vde=yes
3488dfb278bdSJuan Quintela  else
3489dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
349021684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3491dfb278bdSJuan Quintela    fi
3492dfb278bdSJuan Quintela    vde=no
34938a16d273Sths  fi
34948a16d273Sthsfi
34958a16d273Sths
34968a16d273Sths##########################################
34970a985b37SVincenzo Maffione# netmap support probe
34980a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
34990a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
35000a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
35010a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
35020a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
350358952137SVincenzo Maffioneif test "$netmap" != "no" ; then
350458952137SVincenzo Maffione  cat > $TMPC << EOF
350558952137SVincenzo Maffione#include <inttypes.h>
350658952137SVincenzo Maffione#include <net/if.h>
350758952137SVincenzo Maffione#include <net/netmap.h>
350858952137SVincenzo Maffione#include <net/netmap_user.h>
35090a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
35100a985b37SVincenzo Maffione#error
35110a985b37SVincenzo Maffione#endif
351258952137SVincenzo Maffioneint main(void) { return 0; }
351358952137SVincenzo MaffioneEOF
351458952137SVincenzo Maffione  if compile_prog "" "" ; then
351558952137SVincenzo Maffione    netmap=yes
351658952137SVincenzo Maffione  else
351758952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
351858952137SVincenzo Maffione      feature_not_found "netmap"
351958952137SVincenzo Maffione    fi
352058952137SVincenzo Maffione    netmap=no
352158952137SVincenzo Maffione  fi
352258952137SVincenzo Maffionefi
352358952137SVincenzo Maffione
352458952137SVincenzo Maffione##########################################
352547e98658SCorey Bryant# libcap-ng library probe
352647e98658SCorey Bryantif test "$cap_ng" != "no" ; then
352747e98658SCorey Bryant  cap_libs="-lcap-ng"
352847e98658SCorey Bryant  cat > $TMPC << EOF
352947e98658SCorey Bryant#include <cap-ng.h>
353047e98658SCorey Bryantint main(void)
353147e98658SCorey Bryant{
353247e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
353347e98658SCorey Bryant    return 0;
353447e98658SCorey Bryant}
353547e98658SCorey BryantEOF
353647e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
353747e98658SCorey Bryant    cap_ng=yes
353847e98658SCorey Bryant  else
353947e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
354021684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
354147e98658SCorey Bryant    fi
354247e98658SCorey Bryant    cap_ng=no
354347e98658SCorey Bryant  fi
354447e98658SCorey Bryantfi
354547e98658SCorey Bryant
354647e98658SCorey Bryant##########################################
3547c2de5c91Smalc# Sound support libraries probe
35488f28f3fbSths
354989138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3550c2de5c91Smalcfor drv in $audio_drv_list; do
3551c2de5c91Smalc    case $drv in
3552e42975a1SGerd Hoffmann    alsa | try-alsa)
3553c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3554c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3555478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3556478e943fSPaolo Bonzini        alsa=yes
3557e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3558e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3559e42975a1SGerd Hoffmann        fi
3560e42975a1SGerd Hoffmann    else
3561e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3562e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3563c80a867fSGerd Hoffmann        else
3564c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3565c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3566c80a867fSGerd Hoffmann        fi
3567e42975a1SGerd Hoffmann    fi
3568c2de5c91Smalc    ;;
3569c2de5c91Smalc
3570e42975a1SGerd Hoffmann    pa | try-pa)
3571c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3572478e943fSPaolo Bonzini        libpulse=yes
3573c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3574478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3575e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3576e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3577e42975a1SGerd Hoffmann        fi
3578e42975a1SGerd Hoffmann    else
3579e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3580e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3581c80a867fSGerd Hoffmann        else
3582c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3583c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3584c80a867fSGerd Hoffmann        fi
3585e42975a1SGerd Hoffmann    fi
3586b8e59f18Smalc    ;;
3587b8e59f18Smalc
3588373967b2SGerd Hoffmann    sdl)
3589373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3590373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3591373967b2SGerd Hoffmann    fi
3592373967b2SGerd Hoffmann    ;;
3593373967b2SGerd Hoffmann
3594e42975a1SGerd Hoffmann    try-sdl)
3595e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3596e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3597e42975a1SGerd Hoffmann    else
3598e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3599e42975a1SGerd Hoffmann    fi
3600e42975a1SGerd Hoffmann    ;;
3601e42975a1SGerd Hoffmann
3602997e690aSJuan Quintela    coreaudio)
3603b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3604997e690aSJuan Quintela    ;;
3605997e690aSJuan Quintela
3606a4bf6780SJuan Quintela    dsound)
3607b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3608d5631638Smalc      audio_win_int="yes"
3609a4bf6780SJuan Quintela    ;;
3610a4bf6780SJuan Quintela
3611a4bf6780SJuan Quintela    oss)
3612b1149911SFam Zheng      oss_libs="$oss_lib"
3613a4bf6780SJuan Quintela    ;;
3614a4bf6780SJuan Quintela
36152e445703SGeoffrey McRae    jack | try-jack)
36162e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3617478e943fSPaolo Bonzini        libjack=yes
36182e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
36192e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
36202e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
36212e445703SGeoffrey McRae        fi
36222e445703SGeoffrey McRae    else
36232e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
36242e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
36252e445703SGeoffrey McRae        else
36262e445703SGeoffrey McRae            error_exit "$drv check failed" \
36272e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
36282e445703SGeoffrey McRae        fi
36292e445703SGeoffrey McRae    fi
36302e445703SGeoffrey McRae    ;;
36312e445703SGeoffrey McRae
3632e4c63a6aSmalc    *)
36331c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
363476ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
363576ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3636e4c63a6aSmalc    }
3637e4c63a6aSmalc    ;;
3638c2de5c91Smalc    esac
3639c2de5c91Smalcdone
36408f28f3fbSths
36414d3b6f6eSbalrog##########################################
36422e4d9fb1Saurel32# BrlAPI probe
36432e4d9fb1Saurel32
36444ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3645eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
36462e4d9fb1Saurel32  cat > $TMPC << EOF
36472e4d9fb1Saurel32#include <brlapi.h>
3648832ce9c2SScott Wood#include <stddef.h>
36492e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
36502e4d9fb1Saurel32EOF
365152166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
36522e4d9fb1Saurel32    brlapi=yes
36534ffcedb6SJuan Quintela  else
36544ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
365521684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
36564ffcedb6SJuan Quintela    fi
36574ffcedb6SJuan Quintela    brlapi=no
3658eb82284fSJuan Quintela  fi
3659eb82284fSJuan Quintelafi
36602e4d9fb1Saurel32
36612e4d9fb1Saurel32##########################################
3662e08bb301SSamuel Thibault# iconv probe
3663e08bb301SSamuel Thibaultif test "$iconv" != "no" ; then
3664e08bb301SSamuel Thibault  cat > $TMPC << EOF
3665e08bb301SSamuel Thibault#include <iconv.h>
3666e08bb301SSamuel Thibaultint main(void) {
3667e08bb301SSamuel Thibault  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3668e08bb301SSamuel Thibault  return conv != (iconv_t) -1;
3669e08bb301SSamuel Thibault}
3670e08bb301SSamuel ThibaultEOF
3671e08bb301SSamuel Thibault  iconv_prefix_list="/usr/local:/usr"
3672e08bb301SSamuel Thibault  iconv_lib_list=":-liconv"
3673e08bb301SSamuel Thibault  IFS=:
3674e08bb301SSamuel Thibault  for iconv_prefix in $iconv_prefix_list; do
3675e08bb301SSamuel Thibault    IFS=:
3676e08bb301SSamuel Thibault    iconv_cflags="-I$iconv_prefix/include"
3677e08bb301SSamuel Thibault    iconv_ldflags="-L$iconv_prefix/lib"
3678e08bb301SSamuel Thibault    for iconv_link in $iconv_lib_list; do
3679e08bb301SSamuel Thibault      unset IFS
3680e08bb301SSamuel Thibault      iconv_lib="$iconv_ldflags $iconv_link"
3681e08bb301SSamuel Thibault      echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3682e08bb301SSamuel Thibault      if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3683e08bb301SSamuel Thibault        iconv_found=yes
3684e08bb301SSamuel Thibault        break
3685e08bb301SSamuel Thibault      fi
3686e08bb301SSamuel Thibault    done
3687e08bb301SSamuel Thibault    if test "$iconv_found" = yes ; then
3688e08bb301SSamuel Thibault      break
3689e08bb301SSamuel Thibault    fi
3690e08bb301SSamuel Thibault  done
3691e08bb301SSamuel Thibault  if test "$iconv_found" = "yes" ; then
3692e08bb301SSamuel Thibault    iconv=yes
3693e08bb301SSamuel Thibault  else
3694e08bb301SSamuel Thibault    if test "$iconv" = "yes" ; then
3695e08bb301SSamuel Thibault      feature_not_found "iconv" "Install iconv devel"
3696e08bb301SSamuel Thibault    fi
3697e08bb301SSamuel Thibault    iconv=no
3698e08bb301SSamuel Thibault  fi
3699e08bb301SSamuel Thibaultfi
3700e08bb301SSamuel Thibault
3701e08bb301SSamuel Thibault##########################################
37024d3b6f6eSbalrog# curses probe
3703e08bb301SSamuel Thibaultif test "$iconv" = "no" ; then
3704e08bb301SSamuel Thibault  # curses will need iconv
3705e08bb301SSamuel Thibault  curses=no
3706e08bb301SSamuel Thibaultfi
3707a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3708e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
37098ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
37108ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3711e095e2f3SStefan Weil  else
37127c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
37138ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3714e095e2f3SStefan Weil  fi
3715c584a6d0SJuan Quintela  curses_found=no
37164d3b6f6eSbalrog  cat > $TMPC << EOF
37178ddc5bf9SSamuel Thibault#include <locale.h>
37184d3b6f6eSbalrog#include <curses.h>
37198ddc5bf9SSamuel Thibault#include <wchar.h>
37202f8b7cd5SSamuel Thibault#include <langinfo.h>
3721ef9a2524SStefan Weilint main(void) {
37222f8b7cd5SSamuel Thibault  const char *codeset;
37238ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
37248ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3725ef9a2524SStefan Weil  resize_term(0, 0);
37268ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
37278ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
37287c703002SSamuel Thibault  add_wch(WACS_DEGREE);
37292f8b7cd5SSamuel Thibault  codeset = nl_langinfo(CODESET);
37302f8b7cd5SSamuel Thibault  return codeset != 0;
3731ef9a2524SStefan Weil}
37324d3b6f6eSbalrogEOF
3733ecbe251fSVadim Evard  IFS=:
37348ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3735b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3736b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
37377c703002SSamuel Thibault    IFS=:
37388ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3739ecbe251fSVadim Evard      unset IFS
37408ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3741c584a6d0SJuan Quintela        curses_found=yes
37424f78ef9aSJuan Quintela        break
37434d3b6f6eSbalrog      fi
37444f78ef9aSJuan Quintela    done
37457c703002SSamuel Thibault    if test "$curses_found" = yes ; then
37467c703002SSamuel Thibault      break
37477c703002SSamuel Thibault    fi
37488ddc5bf9SSamuel Thibault  done
3749ecbe251fSVadim Evard  unset IFS
3750c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3751c584a6d0SJuan Quintela    curses=yes
3752c584a6d0SJuan Quintela  else
3753c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
375421684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3755c584a6d0SJuan Quintela    fi
3756c584a6d0SJuan Quintela    curses=no
3757c584a6d0SJuan Quintela  fi
37584f78ef9aSJuan Quintelafi
37594d3b6f6eSbalrog
3760414f0dabSblueswir1##########################################
3761769ce76dSAlexander Graf# curl probe
3762a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
376365d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3764a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
37654e2b0658SPaolo Bonzini  else
37664e2b0658SPaolo Bonzini    curlconfig=curl-config
37674e2b0658SPaolo Bonzini  fi
3768769ce76dSAlexander Graf  cat > $TMPC << EOF
3769769ce76dSAlexander Graf#include <curl/curl.h>
37700b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3771769ce76dSAlexander GrafEOF
377289138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
377389138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3774b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3775769ce76dSAlexander Graf    curl=yes
3776788c8196SJuan Quintela  else
3777788c8196SJuan Quintela    if test "$curl" = "yes" ; then
377821684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3779788c8196SJuan Quintela    fi
3780788c8196SJuan Quintela    curl=no
3781769ce76dSAlexander Graf  fi
3782769ce76dSAlexander Graffi # test "$curl"
3783769ce76dSAlexander Graf
3784769ce76dSAlexander Graf##########################################
3785e18df141SAnthony Liguori# glib support probe
3786a52d28afSPaolo Bonzini
378700f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3788aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3789aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3790a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3791aa0d1f44SPaolo Bonzinifi
379254cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
379354cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
379454cb65d8SEmilio G. Cotafi
3795e26110cfSFam Zheng
37964eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
37974eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
37984eaf7202SSameeh Jubran
3799e633a5c6SEric Blakeif test "$static" = yes && test "$mingw32" = yes; then
38004eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
38014eaf7202SSameeh Jubranfi
38024eaf7202SSameeh Jubran
3803aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3804e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
380589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
380689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
38074a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
380814015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3809e18df141SAnthony Liguori    else
3810e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3811e26110cfSFam Zheng    fi
3812e26110cfSFam Zhengdone
3813e26110cfSFam Zheng
3814f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3815f876b765SMarc-André Lureau    gio=yes
3816f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3817f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
381825a97a56SMarc-André Lureau    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
38190dba4897SMarc-André Lureau    if [ ! -x "$gdbus_codegen" ]; then
38200dba4897SMarc-André Lureau        gdbus_codegen=
38210dba4897SMarc-André Lureau    fi
3822f876b765SMarc-André Lureauelse
3823f876b765SMarc-André Lureau    gio=no
3824f876b765SMarc-André Lureaufi
3825f876b765SMarc-André Lureau
382625a97a56SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
382725a97a56SMarc-André Lureau    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
382825a97a56SMarc-André Lureau    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
382925a97a56SMarc-André Lureaufi
383025a97a56SMarc-André Lureau
3831977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3832977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3833977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3834977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3835977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3836977a82abSDaniel P. Berrange#include <glib.h>
3837977a82abSDaniel P. Berrange#include <unistd.h>
3838977a82abSDaniel P. Berrange
3839977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3840977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3841977a82abSDaniel P. Berrange
3842977a82abSDaniel P. Berrangeint main(void) {
3843977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3844977a82abSDaniel P. Berrange   return 0;
3845977a82abSDaniel P. Berrange}
3846977a82abSDaniel P. BerrangeEOF
3847977a82abSDaniel P. Berrange
38485919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3849977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3850977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3851977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3852977a82abSDaniel P. Berrange	       "build target"
3853977a82abSDaniel P. Berrangefi
3854977a82abSDaniel P. Berrange
3855bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3856bbbf2e04SJohn Snowcat > $TMPC << EOF
3857bbbf2e04SJohn Snow#include <glib.h>
3858bbbf2e04SJohn Snowint main(void) { return 0; }
3859bbbf2e04SJohn SnowEOF
3860bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3861bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3862bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3863086d5f75SPaolo Bonzini        QEMU_CFLAGS="-Wno-unknown-attributes $CFLAGS"
3864bbbf2e04SJohn Snow    fi
3865bbbf2e04SJohn Snowfi
3866bbbf2e04SJohn Snow
38679bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
38689bda600bSEric Blakecat > $TMPC << EOF
38699bda600bSEric Blake#include <glib.h>
38709bda600bSEric Blaketypedef struct Foo {
38719bda600bSEric Blake    int i;
38729bda600bSEric Blake} Foo;
38739bda600bSEric Blakestatic void foo_free(Foo *f)
38749bda600bSEric Blake{
38759bda600bSEric Blake    g_free(f);
38769bda600bSEric Blake}
38779bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
38789bda600bSEric Blakeint main(void) { return 0; }
38799bda600bSEric BlakeEOF
38809bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
38819bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
38829bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
38839bda600bSEric Blake        CFLAGS="$CFLAGS -Wno-unused-function"
38849bda600bSEric Blake    fi
38859bda600bSEric Blakefi
38869bda600bSEric Blake
38876a1f42bdSStefan Weil#########################################
38886a1f42bdSStefan Weil# zlib check
38896a1f42bdSStefan Weil
38906a1f42bdSStefan Weilif test "$zlib" != "no" ; then
38916a1f42bdSStefan Weil    if $pkg_config --exists zlib; then
38926a1f42bdSStefan Weil        zlib_cflags=$($pkg_config --cflags zlib)
38936a1f42bdSStefan Weil        zlib_libs=$($pkg_config --libs zlib)
38946a1f42bdSStefan Weil        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
38956a1f42bdSStefan Weil        LIBS="$zlib_libs $LIBS"
38966a1f42bdSStefan Weil    else
38976a1f42bdSStefan Weil        cat > $TMPC << EOF
38986a1f42bdSStefan Weil#include <zlib.h>
38996a1f42bdSStefan Weilint main(void) { zlibVersion(); return 0; }
39006a1f42bdSStefan WeilEOF
39016a1f42bdSStefan Weil        if compile_prog "" "-lz" ; then
39025e5733e5SMarc-André Lureau            zlib_libs=-lz
39035e5733e5SMarc-André Lureau            LIBS="$LIBS $zlib_libs"
39046a1f42bdSStefan Weil        else
39056a1f42bdSStefan Weil            error_exit "zlib check failed" \
39066a1f42bdSStefan Weil                "Make sure to have the zlib libs and headers installed."
39076a1f42bdSStefan Weil        fi
39086a1f42bdSStefan Weil    fi
39096a1f42bdSStefan Weilfi
39106a1f42bdSStefan Weil
3911e26110cfSFam Zheng##########################################
3912e26110cfSFam Zheng# SHA command probe for modules
3913e26110cfSFam Zhengif test "$modules" = yes; then
3914e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3915e26110cfSFam Zheng    for c in $shacmd_probe; do
39168ccefb91SFam Zheng        if has $c; then
3917e26110cfSFam Zheng            shacmd="$c"
3918e26110cfSFam Zheng            break
3919e26110cfSFam Zheng        fi
3920e26110cfSFam Zheng    done
3921e26110cfSFam Zheng    if test "$shacmd" = ""; then
3922e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3923e26110cfSFam Zheng    fi
3924e18df141SAnthony Liguorifi
3925e18df141SAnthony Liguori
3926e18df141SAnthony Liguori##########################################
3927fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3928fe8fc5aeSPaolo Bonzini
3929fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
39301b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3931fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3932fe8fc5aeSPaolo Bonzini#include <libudev.h>
3933fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3934fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3935fe8fc5aeSPaolo Bonziniint logsink;
3936b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3937b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3938b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3939b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3940b3f1c8c4SPaolo Bonzinistruct udev *udev;
3941b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3942b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3943b3f1c8c4SPaolo Bonzini
3944fe8fc5aeSPaolo Bonziniint main(void) {
3945b3f1c8c4SPaolo Bonzini    udev = udev_new();
3946b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3947fe8fc5aeSPaolo Bonzini    return 0;
3948fe8fc5aeSPaolo Bonzini}
3949fe8fc5aeSPaolo BonziniEOF
3950fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3951fe8fc5aeSPaolo Bonzini    mpathpersist=yes
39521b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
39531b0578f5SMurilo Opsfelder Araujo  else
39541b0578f5SMurilo Opsfelder Araujo    # probe for the old API
39551b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
39561b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
39571b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
39581b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
39591b0578f5SMurilo Opsfelder Araujoint logsink;
39601b0578f5SMurilo Opsfelder Araujoint main(void) {
39611b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
39621b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
39631b0578f5SMurilo Opsfelder Araujo    return 0;
39641b0578f5SMurilo Opsfelder Araujo}
39651b0578f5SMurilo Opsfelder AraujoEOF
39661b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
39671b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
39681b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3969fe8fc5aeSPaolo Bonzini    else
3970fe8fc5aeSPaolo Bonzini      mpathpersist=no
3971fe8fc5aeSPaolo Bonzini    fi
39721b0578f5SMurilo Opsfelder Araujo  fi
3973fe8fc5aeSPaolo Bonzinielse
3974fe8fc5aeSPaolo Bonzini  mpathpersist=no
3975fe8fc5aeSPaolo Bonzinifi
3976fe8fc5aeSPaolo Bonzini
3977fe8fc5aeSPaolo Bonzini##########################################
3978e5d355d1Saliguori# pthread probe
39794b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
39803c529d93Saliguori
3981e5d355d1Saliguoripthread=no
3982414f0dabSblueswir1cat > $TMPC << EOF
39833c529d93Saliguori#include <pthread.h>
39847a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
39857a42bbe4SStefan Weilint main(void) {
39867a42bbe4SStefan Weil  pthread_t thread;
39877a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
39887a42bbe4SStefan Weil  return 0;
39897a42bbe4SStefan Weil}
3990414f0dabSblueswir1EOF
3991bd00d539SAndreas Färberif compile_prog "" "" ; then
3992bd00d539SAndreas Färber  pthread=yes
3993bd00d539SAndreas Färberelse
3994de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
399552166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3996e5d355d1Saliguori      pthread=yes
3997e3c56761SPeter Portante      found=no
3998e3c56761SPeter Portante      for lib_entry in $LIBS; do
3999e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
4000e3c56761SPeter Portante          found=yes
4001e3c56761SPeter Portante          break
4002e3c56761SPeter Portante        fi
4003e3c56761SPeter Portante      done
4004e3c56761SPeter Portante      if test "$found" = "no"; then
40055572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
4006e3c56761SPeter Portante      fi
4007409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
4008de65fe0fSSebastian Herbszt      break
4009414f0dabSblueswir1    fi
4010de65fe0fSSebastian Herbszt  done
4011bd00d539SAndreas Färberfi
4012414f0dabSblueswir1
4013e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
401476ad07a4SPeter Maydell  error_exit "pthread check failed" \
401576ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
4016e5d355d1Saliguorifi
4017e5d355d1Saliguori
4018479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
4019479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
40205c312079SDr. David Alan Gilbertcat > $TMPC << EOF
40215c312079SDr. David Alan Gilbert#include <pthread.h>
40225c312079SDr. David Alan Gilbert
40235c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
40245c312079SDr. David Alan Gilbertint main(void)
40255c312079SDr. David Alan Gilbert{
40265c312079SDr. David Alan Gilbert    pthread_t thread;
40275c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
40285c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
40295c312079SDr. David Alan Gilbert    return 0;
40305c312079SDr. David Alan Gilbert}
40315c312079SDr. David Alan GilbertEOF
40325c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
4033479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
4034479a5747SRoman Bolshakovfi
4035479a5747SRoman Bolshakov
4036479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
4037479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
4038479a5747SRoman Bolshakovcat > $TMPC << EOF
4039479a5747SRoman Bolshakov#include <pthread.h>
4040479a5747SRoman Bolshakov
404112a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
4042479a5747SRoman Bolshakovint main(void)
4043479a5747SRoman Bolshakov{
4044479a5747SRoman Bolshakov    pthread_t thread;
4045479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
4046479a5747SRoman Bolshakov    return 0;
4047479a5747SRoman Bolshakov}
4048479a5747SRoman BolshakovEOF
4049479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
4050479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
40515c312079SDr. David Alan Gilbertfi
40525c312079SDr. David Alan Gilbert
4053bf9298b9Saliguori##########################################
4054f27aaf4bSChristian Brunner# rbd probe
4055f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
4056f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
4057f27aaf4bSChristian Brunner#include <stdio.h>
4058ad32e9c0SJosh Durgin#include <rbd/librbd.h>
4059f27aaf4bSChristian Brunnerint main(void) {
4060ad32e9c0SJosh Durgin    rados_t cluster;
4061ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
4062f27aaf4bSChristian Brunner    return 0;
4063f27aaf4bSChristian Brunner}
4064f27aaf4bSChristian BrunnerEOF
4065ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
4066f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
4067f27aaf4bSChristian Brunner    rbd=yes
4068f27aaf4bSChristian Brunner  else
4069f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
407021684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
4071f27aaf4bSChristian Brunner    fi
4072f27aaf4bSChristian Brunner    rbd=no
4073f27aaf4bSChristian Brunner  fi
4074f27aaf4bSChristian Brunnerfi
4075f27aaf4bSChristian Brunner
4076f27aaf4bSChristian Brunner##########################################
4077b10d49d7SPino Toscano# libssh probe
4078b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
4079b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
4080b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
4081b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
4082b10d49d7SPino Toscano    libssh=yes
40830a12ec87SRichard W.M. Jones  else
4084b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
4085b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
40860a12ec87SRichard W.M. Jones    fi
4087b10d49d7SPino Toscano    libssh=no
40880a12ec87SRichard W.M. Jones  fi
40890a12ec87SRichard W.M. Jonesfi
40900a12ec87SRichard W.M. Jones
40910a12ec87SRichard W.M. Jones##########################################
4092b10d49d7SPino Toscano# Check for libssh 0.8
4093b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
4094b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
4095b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
4096b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
40979a2d462eSRichard W.M. Jones
4098b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
40999a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
4100b10d49d7SPino Toscano#include <libssh/libssh.h>
4101b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
41029a2d462eSRichard W.M. JonesEOF
4103b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
4104b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
41059a2d462eSRichard W.M. Jones  fi
41069a2d462eSRichard W.M. Jonesfi
41079a2d462eSRichard W.M. Jones
41089a2d462eSRichard W.M. Jones##########################################
41095c6c3a6cSChristoph Hellwig# linux-aio probe
41105c6c3a6cSChristoph Hellwig
41115c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
41125c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
41135c6c3a6cSChristoph Hellwig#include <libaio.h>
41145c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
4115832ce9c2SScott Wood#include <stddef.h>
41165c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
41175c6c3a6cSChristoph HellwigEOF
41185c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
41195c6c3a6cSChristoph Hellwig    linux_aio=yes
41205c6c3a6cSChristoph Hellwig  else
41215c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
412221684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
41235c6c3a6cSChristoph Hellwig    fi
41243cfcae3cSLuiz Capitulino    linux_aio=no
41255c6c3a6cSChristoph Hellwig  fi
41265c6c3a6cSChristoph Hellwigfi
4127c10dd856SAarushi Mehta##########################################
4128c10dd856SAarushi Mehta# linux-io-uring probe
4129c10dd856SAarushi Mehta
4130c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
4131c10dd856SAarushi Mehta  if $pkg_config liburing; then
4132c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
4133c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
4134c10dd856SAarushi Mehta    linux_io_uring=yes
413573fd282eSStefan Hajnoczi
413673fd282eSStefan Hajnoczi    # io_uring is used in libqemuutil.a where per-file -libs variables are not
413773fd282eSStefan Hajnoczi    # seen by programs linking the archive.  It's not ideal, but just add the
413873fd282eSStefan Hajnoczi    # library dependency globally.
413973fd282eSStefan Hajnoczi    LIBS="$linux_io_uring_libs $LIBS"
4140c10dd856SAarushi Mehta  else
4141c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
4142c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
4143c10dd856SAarushi Mehta    fi
4144c10dd856SAarushi Mehta    linux_io_uring=no
4145c10dd856SAarushi Mehta  fi
4146c10dd856SAarushi Mehtafi
41475c6c3a6cSChristoph Hellwig
41485c6c3a6cSChristoph Hellwig##########################################
41497aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
41503b8acc11SPaolo Bonzini
41517aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
41527aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
41537aaa6a16SPaolo Bonzini    tpm=no
41543b8acc11SPaolo Bonzini  else
41557aaa6a16SPaolo Bonzini    tpm=yes
41567aaa6a16SPaolo Bonzini  fi
41577aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
41587aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
41597aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
41607aaa6a16SPaolo Bonzini  fi
41613b8acc11SPaolo Bonzinifi
41623b8acc11SPaolo Bonzini
41633b8acc11SPaolo Bonzini##########################################
4164758e8e38SVenkateswararao Jujjuri (JV)# attr probe
4165758e8e38SVenkateswararao Jujjuri (JV)
4166ec0d5893SMarc-André Lureaulibattr_libs=
4167758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
4168758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
4169758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
4170758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
4171f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
4172f2338fb4SPavel Borzenkov#include <attr/xattr.h>
4173f2338fb4SPavel Borzenkov#else
41744f26f2b6SAvi Kivity#include <sys/xattr.h>
4175f2338fb4SPavel Borzenkov#endif
4176758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4177758e8e38SVenkateswararao Jujjuri (JV)EOF
41784f26f2b6SAvi Kivity  if compile_prog "" "" ; then
41794f26f2b6SAvi Kivity    attr=yes
41804f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
4181f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4182758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
4183ec0d5893SMarc-André Lureau    libattr_libs="-lattr"
4184ec0d5893SMarc-André Lureau    LIBS="$libattr_libs $LIBS"
41854f26f2b6SAvi Kivity    libattr=yes
4186758e8e38SVenkateswararao Jujjuri (JV)  else
4187758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
418821684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
4189758e8e38SVenkateswararao Jujjuri (JV)    fi
4190758e8e38SVenkateswararao Jujjuri (JV)    attr=no
4191758e8e38SVenkateswararao Jujjuri (JV)  fi
4192758e8e38SVenkateswararao Jujjuri (JV)fi
4193758e8e38SVenkateswararao Jujjuri (JV)
4194758e8e38SVenkateswararao Jujjuri (JV)##########################################
4195bf9298b9Saliguori# iovec probe
4196bf9298b9Saliguoricat > $TMPC <<EOF
4197db34f0b3Sblueswir1#include <sys/types.h>
4198bf9298b9Saliguori#include <sys/uio.h>
4199db34f0b3Sblueswir1#include <unistd.h>
4200f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
4201bf9298b9SaliguoriEOF
4202bf9298b9Saliguoriiovec=no
420352166aa0SJuan Quintelaif compile_prog "" "" ; then
4204bf9298b9Saliguori  iovec=yes
4205bf9298b9Saliguorifi
4206bf9298b9Saliguori
4207f652e6afSaurel32##########################################
4208ceb42de8Saliguori# preadv probe
4209ceb42de8Saliguoricat > $TMPC <<EOF
4210ceb42de8Saliguori#include <sys/types.h>
4211ceb42de8Saliguori#include <sys/uio.h>
4212ceb42de8Saliguori#include <unistd.h>
4213c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
4214ceb42de8SaliguoriEOF
4215ceb42de8Saliguoripreadv=no
421652166aa0SJuan Quintelaif compile_prog "" "" ; then
4217ceb42de8Saliguori  preadv=yes
4218ceb42de8Saliguorifi
4219ceb42de8Saliguori
4220ceb42de8Saliguori##########################################
4221f652e6afSaurel32# fdt probe
4222e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
4223e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
4224e169e1e1SPeter Maydellfdt_required=no
4225e169e1e1SPeter Maydellfor target in $target_list; do
4226e169e1e1SPeter Maydell  case $target in
4227c8c35e5fSYoshinori Sato    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu)
4228e169e1e1SPeter Maydell      fdt_required=yes
4229e169e1e1SPeter Maydell    ;;
4230e169e1e1SPeter Maydell  esac
4231e169e1e1SPeter Maydelldone
4232e169e1e1SPeter Maydell
4233e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
4234e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
4235e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
4236e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
4237e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
4238e169e1e1SPeter Maydell  fi
4239e169e1e1SPeter Maydell  fdt=yes
42407ba4a4d3SPhilippe Mathieu-Daudéelif test "$fdt" != "yes" ; then
42417ba4a4d3SPhilippe Mathieu-Daudé  fdt=no
4242e169e1e1SPeter Maydellfi
4243e169e1e1SPeter Maydell
4244d599938aSLaurent Vivier# fdt is only required when building softmmu targets
4245d599938aSLaurent Vivierif test -z "$fdt" -a "$softmmu" != "yes" ; then
4246d599938aSLaurent Vivier    fdt="no"
4247d599938aSLaurent Vivierfi
4248d599938aSLaurent Vivier
42492df87df7SJuan Quintelaif test "$fdt" != "no" ; then
4250b41af4baSJuan Quintela  fdt_libs="-lfdt"
425196ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
42526e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
4253f652e6afSaurel32  cat > $TMPC << EOF
425431ce0adbSThomas Huth#include <libfdt.h>
425596ce6545SPeter Crosthwaite#include <libfdt_env.h>
4256fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
4257f652e6afSaurel32EOF
425852166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
4259a540f158SPeter Crosthwaite    # system DTC is good - use it
4260e3971d61SPhilippe Mathieu-Daudé    fdt=system
4261aef45d51SDaniel P. Berrange  else
4262aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
4263aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
4264aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
4265aef45d51SDaniel P. Berrange      fi
4266aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4267e3971d61SPhilippe Mathieu-Daudé          fdt=git
4268a540f158SPeter Crosthwaite          mkdir -p dtc
4269cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
4270a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
42712df87df7SJuan Quintela          fi
427225211446SPaolo Bonzini          fdt_cflags="-I${source_path}/dtc/libfdt"
427325211446SPaolo Bonzini          fdt_ldflags="-L$PWD/dtc/libfdt"
42748a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4275a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4276aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4277aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4278aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4279a540f158SPeter Crosthwaite      else
4280a540f158SPeter Crosthwaite          # don't have and don't want
4281de3a354aSMichael Walle          fdt_libs=
42822df87df7SJuan Quintela          fdt=no
4283f652e6afSaurel32      fi
4284f652e6afSaurel32  fi
4285aef45d51SDaniel P. Berrangefi
4286f652e6afSaurel32
428720ff075bSMichael Walle##########################################
4288fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4289b1546f32SGerd Hoffmann
4290d52c454aSMarc-André Lureaugbm="no"
4291d52c454aSMarc-André Lureauif $pkg_config gbm; then
4292d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
4293d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
4294d52c454aSMarc-André Lureau    gbm="yes"
4295d52c454aSMarc-André Lureaufi
4296d52c454aSMarc-André Lureau
4297da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
42984939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
42995f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
43005f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
43015f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4302da076ffeSGerd Hoffmann    opengl=yes
4303925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4304925a0400SGerd Hoffmann        gtk_gl="yes"
4305925a0400SGerd Hoffmann    fi
4306cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
430720ff075bSMichael Walle  else
4308da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4309dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
431020ff075bSMichael Walle    fi
4311f676c67eSJeremy White    opengl_cflags=""
4312da076ffeSGerd Hoffmann    opengl_libs=""
4313da076ffeSGerd Hoffmann    opengl=no
431420ff075bSMichael Walle  fi
431520ff075bSMichael Wallefi
431620ff075bSMichael Walle
4317014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4318014cb152SGerd Hoffmann  cat > $TMPC << EOF
4319014cb152SGerd Hoffmann#include <epoxy/egl.h>
4320014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4321014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4322014cb152SGerd Hoffmann#endif
4323014cb152SGerd Hoffmannint main(void) { return 0; }
4324014cb152SGerd HoffmannEOF
4325014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4326014cb152SGerd Hoffmann    opengl_dmabuf=yes
4327014cb152SGerd Hoffmann  fi
4328014cb152SGerd Hoffmannfi
4329c9a12e75SChrysostomos Nanakos
4330e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
433199e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
433299e1a93bSPhilippe Mathieu-Daudé    case $target in
433399e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
433499e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
433599e1a93bSPhilippe Mathieu-Daudé      ;;
433699e1a93bSPhilippe Mathieu-Daudé    esac
433799e1a93bSPhilippe Mathieu-Daudé  done
433899e1a93bSPhilippe Mathieu-Daudéfi
433999e1a93bSPhilippe Mathieu-Daudé
4340ed279a06SKlim Kireev##########################################
4341ed279a06SKlim Kireev# libxml2 probe
4342ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4343ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4344ed279a06SKlim Kireev        libxml2="yes"
4345ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4346ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4347ed279a06SKlim Kireev    else
4348ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4349ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4350ed279a06SKlim Kireev        fi
4351ed279a06SKlim Kireev        libxml2="no"
4352ed279a06SKlim Kireev    fi
4353ed279a06SKlim Kireevfi
4354c9a12e75SChrysostomos Nanakos
4355eb100396SBharata B Rao##########################################
4356eb100396SBharata B Rao# glusterfs probe
4357eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
435865d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4359e01bee08SBharata B Rao    glusterfs="yes"
436089138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
436189138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4362d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4363d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4364d85fa9ebSJeff Cody    fi
436565d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
43660c14fb47SBharata B Rao      glusterfs_discard="yes"
43670c14fb47SBharata B Rao    fi
43687c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4369df3a429aSNiels de Vos      glusterfs_fallocate="yes"
43707c815372SBharata B Rao      glusterfs_zerofill="yes"
43717c815372SBharata B Rao    fi
4372e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
4373e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
4374e014dbe7SPrasanna Kumar Kalever
4375e014dbe7SPrasanna Kumar Kaleverint
4376e014dbe7SPrasanna Kumar Kalevermain(void)
4377e014dbe7SPrasanna Kumar Kalever{
4378e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
4379e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
4380e014dbe7SPrasanna Kumar Kalever}
4381e014dbe7SPrasanna Kumar KaleverEOF
4382e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4383e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
4384e014dbe7SPrasanna Kumar Kalever    fi
43850e3b891fSNiels de Vos    cat > $TMPC << EOF
43860e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
43870e3b891fSNiels de Vos
43880e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
43890e3b891fSNiels de Vosstatic void
43900e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
43910e3b891fSNiels de Vos{}
43920e3b891fSNiels de Vos
43930e3b891fSNiels de Vosint
43940e3b891fSNiels de Vosmain(void)
43950e3b891fSNiels de Vos{
43960e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
43970e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
43980e3b891fSNiels de Vos	return 0;
43990e3b891fSNiels de Vos}
44000e3b891fSNiels de VosEOF
44010e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
44020e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
44030e3b891fSNiels de Vos    fi
4404eb100396SBharata B Rao  else
4405eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
44068efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
44078efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4408eb100396SBharata B Rao    fi
4409e01bee08SBharata B Rao    glusterfs="no"
4410eb100396SBharata B Rao  fi
4411eb100396SBharata B Raofi
4412eb100396SBharata B Rao
441339386ac7Saurel32# Check for inotify functions when we are building linux-user
44143b3f24adSaurel32# emulator.  This is done because older glibc versions don't
44153b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
44163b3f24adSaurel32# don't provide them even if kernel supports them.
44173b3f24adSaurel32#
44183b3f24adSaurel32inotify=no
44193b3f24adSaurel32cat > $TMPC << EOF
44203b3f24adSaurel32#include <sys/inotify.h>
44213b3f24adSaurel32
44223b3f24adSaurel32int
44233b3f24adSaurel32main(void)
44243b3f24adSaurel32{
44253b3f24adSaurel32	/* try to start inotify */
44268690e420Saurel32	return inotify_init();
44273b3f24adSaurel32}
44283b3f24adSaurel32EOF
442952166aa0SJuan Quintelaif compile_prog "" "" ; then
44303b3f24adSaurel32  inotify=yes
44313b3f24adSaurel32fi
44323b3f24adSaurel32
4433c05c7a73SRiku Voipioinotify1=no
4434c05c7a73SRiku Voipiocat > $TMPC << EOF
4435c05c7a73SRiku Voipio#include <sys/inotify.h>
4436c05c7a73SRiku Voipio
4437c05c7a73SRiku Voipioint
4438c05c7a73SRiku Voipiomain(void)
4439c05c7a73SRiku Voipio{
4440c05c7a73SRiku Voipio    /* try to start inotify */
4441c05c7a73SRiku Voipio    return inotify_init1(0);
4442c05c7a73SRiku Voipio}
4443c05c7a73SRiku VoipioEOF
4444c05c7a73SRiku Voipioif compile_prog "" "" ; then
4445c05c7a73SRiku Voipio  inotify1=yes
4446c05c7a73SRiku Voipiofi
4447c05c7a73SRiku Voipio
4448099d6b0fSRiku Voipio# check if pipe2 is there
4449099d6b0fSRiku Voipiopipe2=no
4450099d6b0fSRiku Voipiocat > $TMPC << EOF
4451099d6b0fSRiku Voipio#include <unistd.h>
4452099d6b0fSRiku Voipio#include <fcntl.h>
4453099d6b0fSRiku Voipio
4454099d6b0fSRiku Voipioint main(void)
4455099d6b0fSRiku Voipio{
4456099d6b0fSRiku Voipio    int pipefd[2];
44579bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4458099d6b0fSRiku Voipio}
4459099d6b0fSRiku VoipioEOF
446052166aa0SJuan Quintelaif compile_prog "" "" ; then
4461099d6b0fSRiku Voipio  pipe2=yes
4462099d6b0fSRiku Voipiofi
4463099d6b0fSRiku Voipio
446440ff6d7eSKevin Wolf# check if accept4 is there
446540ff6d7eSKevin Wolfaccept4=no
446640ff6d7eSKevin Wolfcat > $TMPC << EOF
446740ff6d7eSKevin Wolf#include <sys/socket.h>
446840ff6d7eSKevin Wolf#include <stddef.h>
446940ff6d7eSKevin Wolf
447040ff6d7eSKevin Wolfint main(void)
447140ff6d7eSKevin Wolf{
447240ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
447340ff6d7eSKevin Wolf    return 0;
447440ff6d7eSKevin Wolf}
447540ff6d7eSKevin WolfEOF
447640ff6d7eSKevin Wolfif compile_prog "" "" ; then
447740ff6d7eSKevin Wolf  accept4=yes
447840ff6d7eSKevin Wolffi
447940ff6d7eSKevin Wolf
44803ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
44813ce34dfbSvibisreenivasansplice=no
44823ce34dfbSvibisreenivasancat > $TMPC << EOF
44833ce34dfbSvibisreenivasan#include <unistd.h>
44843ce34dfbSvibisreenivasan#include <fcntl.h>
44853ce34dfbSvibisreenivasan#include <limits.h>
44863ce34dfbSvibisreenivasan
44873ce34dfbSvibisreenivasanint main(void)
44883ce34dfbSvibisreenivasan{
448966ea0f22SStefan Weil    int len, fd = 0;
44903ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
44913ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
44923ce34dfbSvibisreenivasan    return 0;
44933ce34dfbSvibisreenivasan}
44943ce34dfbSvibisreenivasanEOF
449552166aa0SJuan Quintelaif compile_prog "" "" ; then
44963ce34dfbSvibisreenivasan  splice=yes
44973ce34dfbSvibisreenivasanfi
44983ce34dfbSvibisreenivasan
4499dcc38d1cSMarcelo Tosatti##########################################
4500a99d57bbSWanlong Gao# libnuma probe
4501a99d57bbSWanlong Gao
4502a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4503a99d57bbSWanlong Gao  cat > $TMPC << EOF
4504a99d57bbSWanlong Gao#include <numa.h>
4505a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4506a99d57bbSWanlong GaoEOF
4507a99d57bbSWanlong Gao
4508a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4509a99d57bbSWanlong Gao    numa=yes
4510ab318051SMarc-André Lureau    numa_libs="-lnuma"
4511a99d57bbSWanlong Gao  else
4512a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4513a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4514a99d57bbSWanlong Gao    fi
4515a99d57bbSWanlong Gao    numa=no
4516a99d57bbSWanlong Gao  fi
4517a99d57bbSWanlong Gaofi
4518a99d57bbSWanlong Gao
45197b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
45207b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
45217b01cb97SAlexandre Derumier    exit 1
45227b01cb97SAlexandre Derumierfi
45237b01cb97SAlexandre Derumier
45245a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
45255a22ab71SYang Zhong# do not support it.
45265a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
45275a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
45285a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
45295a22ab71SYang Zhong    fi
45305a22ab71SYang Zhong    malloc_trim="no"
45315a22ab71SYang Zhongfi
45325a22ab71SYang Zhong
45335a22ab71SYang Zhong#######################################
45345a22ab71SYang Zhong# malloc_trim
45355a22ab71SYang Zhong
45365a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
45375a22ab71SYang Zhong    cat > $TMPC << EOF
45385a22ab71SYang Zhong#include <malloc.h>
45395a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
45405a22ab71SYang ZhongEOF
45415a22ab71SYang Zhong    if compile_prog "" "" ; then
45425a22ab71SYang Zhong        malloc_trim="yes"
45435a22ab71SYang Zhong    else
45445a22ab71SYang Zhong        malloc_trim="no"
45455a22ab71SYang Zhong    fi
45465a22ab71SYang Zhongfi
45475a22ab71SYang Zhong
4548a99d57bbSWanlong Gao##########################################
45492847b469SFam Zheng# tcmalloc probe
45502847b469SFam Zheng
45512847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
45522847b469SFam Zheng  cat > $TMPC << EOF
45532847b469SFam Zheng#include <stdlib.h>
4554f2dfe54cSLeonid Blochint main(void) {
4555f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4556f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4557f2dfe54cSLeonid Bloch        return 0;
4558f2dfe54cSLeonid Bloch    }
4559f2dfe54cSLeonid Bloch    return 1;
4560f2dfe54cSLeonid Bloch}
45612847b469SFam ZhengEOF
45622847b469SFam Zheng
45632847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
45642847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
45652847b469SFam Zheng  else
45662847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
45672847b469SFam Zheng  fi
45682847b469SFam Zhengfi
45692847b469SFam Zheng
45702847b469SFam Zheng##########################################
45717b01cb97SAlexandre Derumier# jemalloc probe
45727b01cb97SAlexandre Derumier
45737b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
45747b01cb97SAlexandre Derumier  cat > $TMPC << EOF
45757b01cb97SAlexandre Derumier#include <stdlib.h>
4576f2dfe54cSLeonid Blochint main(void) {
4577f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4578f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4579f2dfe54cSLeonid Bloch        return 0;
4580f2dfe54cSLeonid Bloch    }
4581f2dfe54cSLeonid Bloch    return 1;
4582f2dfe54cSLeonid Bloch}
45837b01cb97SAlexandre DerumierEOF
45847b01cb97SAlexandre Derumier
45857b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
45867b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
45877b01cb97SAlexandre Derumier  else
45887b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
45897b01cb97SAlexandre Derumier  fi
45907b01cb97SAlexandre Derumierfi
45917b01cb97SAlexandre Derumier
45927b01cb97SAlexandre Derumier##########################################
4593dcc38d1cSMarcelo Tosatti# signalfd probe
4594dcc38d1cSMarcelo Tosattisignalfd="no"
4595dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4596dcc38d1cSMarcelo Tosatti#include <unistd.h>
4597dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4598dcc38d1cSMarcelo Tosatti#include <signal.h>
4599dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4600dcc38d1cSMarcelo TosattiEOF
4601dcc38d1cSMarcelo Tosatti
4602dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4603dcc38d1cSMarcelo Tosatti  signalfd=yes
4604dcc38d1cSMarcelo Tosattifi
4605dcc38d1cSMarcelo Tosatti
4606d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4607d339d766SRichard W.M. Jonesoptreset="no"
4608d339d766SRichard W.M. Jonescat > $TMPC << EOF
4609d339d766SRichard W.M. Jones#include <getopt.h>
4610d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4611d339d766SRichard W.M. JonesEOF
4612d339d766SRichard W.M. Jones
4613d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4614d339d766SRichard W.M. Jones  optreset=yes
4615d339d766SRichard W.M. Jonesfi
4616d339d766SRichard W.M. Jones
4617c2882b96SRiku Voipio# check if eventfd is supported
4618c2882b96SRiku Voipioeventfd=no
4619c2882b96SRiku Voipiocat > $TMPC << EOF
4620c2882b96SRiku Voipio#include <sys/eventfd.h>
4621c2882b96SRiku Voipio
4622c2882b96SRiku Voipioint main(void)
4623c2882b96SRiku Voipio{
462455cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4625c2882b96SRiku Voipio}
4626c2882b96SRiku VoipioEOF
4627c2882b96SRiku Voipioif compile_prog "" "" ; then
4628c2882b96SRiku Voipio  eventfd=yes
4629c2882b96SRiku Voipiofi
4630c2882b96SRiku Voipio
4631751bcc39SMarc-André Lureau# check if memfd is supported
4632751bcc39SMarc-André Lureaumemfd=no
4633751bcc39SMarc-André Lureaucat > $TMPC << EOF
463475e5b70eSPaolo Bonzini#include <sys/mman.h>
4635751bcc39SMarc-André Lureau
4636751bcc39SMarc-André Lureauint main(void)
4637751bcc39SMarc-André Lureau{
4638751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4639751bcc39SMarc-André Lureau}
4640751bcc39SMarc-André LureauEOF
4641751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4642751bcc39SMarc-André Lureau  memfd=yes
4643751bcc39SMarc-André Lureaufi
4644751bcc39SMarc-André Lureau
4645955727d2SCortland Tölva# check for usbfs
4646955727d2SCortland Tölvahave_usbfs=no
4647955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
464896566d09SThomas Petazzoni  cat > $TMPC << EOF
464996566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
465096566d09SThomas Petazzoni
465196566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
465296566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
465396566d09SThomas Petazzoni#endif
465496566d09SThomas Petazzoni
465596566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
465696566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
465796566d09SThomas Petazzoni#endif
465896566d09SThomas Petazzoni
465996566d09SThomas Petazzoniint main(void)
466096566d09SThomas Petazzoni{
466196566d09SThomas Petazzoni    return 0;
466296566d09SThomas Petazzoni}
466396566d09SThomas PetazzoniEOF
466496566d09SThomas Petazzoni  if compile_prog "" ""; then
4665955727d2SCortland Tölva    have_usbfs=yes
4666955727d2SCortland Tölva  fi
4667955727d2SCortland Tölvafi
4668751bcc39SMarc-André Lureau
4669d0927938SUlrich Hecht# check for fallocate
4670d0927938SUlrich Hechtfallocate=no
4671d0927938SUlrich Hechtcat > $TMPC << EOF
4672d0927938SUlrich Hecht#include <fcntl.h>
4673d0927938SUlrich Hecht
4674d0927938SUlrich Hechtint main(void)
4675d0927938SUlrich Hecht{
4676d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4677d0927938SUlrich Hecht    return 0;
4678d0927938SUlrich Hecht}
4679d0927938SUlrich HechtEOF
46808fb03151SPeter Maydellif compile_prog "" "" ; then
4681d0927938SUlrich Hecht  fallocate=yes
4682d0927938SUlrich Hechtfi
4683d0927938SUlrich Hecht
46843d4fa43eSKusanagi Kouichi# check for fallocate hole punching
46853d4fa43eSKusanagi Kouichifallocate_punch_hole=no
46863d4fa43eSKusanagi Kouichicat > $TMPC << EOF
46873d4fa43eSKusanagi Kouichi#include <fcntl.h>
46883d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
46893d4fa43eSKusanagi Kouichi
46903d4fa43eSKusanagi Kouichiint main(void)
46913d4fa43eSKusanagi Kouichi{
46923d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
46933d4fa43eSKusanagi Kouichi    return 0;
46943d4fa43eSKusanagi Kouichi}
46953d4fa43eSKusanagi KouichiEOF
46963d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
46973d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
46983d4fa43eSKusanagi Kouichifi
46993d4fa43eSKusanagi Kouichi
4700b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4701b953f075SDenis V. Lunevfallocate_zero_range=no
4702b953f075SDenis V. Lunevcat > $TMPC << EOF
4703b953f075SDenis V. Lunev#include <fcntl.h>
4704b953f075SDenis V. Lunev#include <linux/falloc.h>
4705b953f075SDenis V. Lunev
4706b953f075SDenis V. Lunevint main(void)
4707b953f075SDenis V. Lunev{
4708b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4709b953f075SDenis V. Lunev    return 0;
4710b953f075SDenis V. Lunev}
4711b953f075SDenis V. LunevEOF
4712b953f075SDenis V. Lunevif compile_prog "" "" ; then
4713b953f075SDenis V. Lunev  fallocate_zero_range=yes
4714b953f075SDenis V. Lunevfi
4715b953f075SDenis V. Lunev
4716ed911435SKevin Wolf# check for posix_fallocate
4717ed911435SKevin Wolfposix_fallocate=no
4718ed911435SKevin Wolfcat > $TMPC << EOF
4719ed911435SKevin Wolf#include <fcntl.h>
4720ed911435SKevin Wolf
4721ed911435SKevin Wolfint main(void)
4722ed911435SKevin Wolf{
4723ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4724ed911435SKevin Wolf    return 0;
4725ed911435SKevin Wolf}
4726ed911435SKevin WolfEOF
4727ed911435SKevin Wolfif compile_prog "" "" ; then
4728ed911435SKevin Wolf    posix_fallocate=yes
4729ed911435SKevin Wolffi
4730ed911435SKevin Wolf
4731c727f47dSPeter Maydell# check for sync_file_range
4732c727f47dSPeter Maydellsync_file_range=no
4733c727f47dSPeter Maydellcat > $TMPC << EOF
4734c727f47dSPeter Maydell#include <fcntl.h>
4735c727f47dSPeter Maydell
4736c727f47dSPeter Maydellint main(void)
4737c727f47dSPeter Maydell{
4738c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4739c727f47dSPeter Maydell    return 0;
4740c727f47dSPeter Maydell}
4741c727f47dSPeter MaydellEOF
47428fb03151SPeter Maydellif compile_prog "" "" ; then
4743c727f47dSPeter Maydell  sync_file_range=yes
4744c727f47dSPeter Maydellfi
4745c727f47dSPeter Maydell
4746dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4747dace20dcSPeter Maydellfiemap=no
4748dace20dcSPeter Maydellcat > $TMPC << EOF
4749dace20dcSPeter Maydell#include <sys/ioctl.h>
4750dace20dcSPeter Maydell#include <linux/fs.h>
4751dace20dcSPeter Maydell#include <linux/fiemap.h>
4752dace20dcSPeter Maydell
4753dace20dcSPeter Maydellint main(void)
4754dace20dcSPeter Maydell{
4755dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4756dace20dcSPeter Maydell    return 0;
4757dace20dcSPeter Maydell}
4758dace20dcSPeter MaydellEOF
47598fb03151SPeter Maydellif compile_prog "" "" ; then
4760dace20dcSPeter Maydell  fiemap=yes
4761dace20dcSPeter Maydellfi
4762dace20dcSPeter Maydell
4763d0927938SUlrich Hecht# check for dup3
4764d0927938SUlrich Hechtdup3=no
4765d0927938SUlrich Hechtcat > $TMPC << EOF
4766d0927938SUlrich Hecht#include <unistd.h>
4767d0927938SUlrich Hecht
4768d0927938SUlrich Hechtint main(void)
4769d0927938SUlrich Hecht{
4770d0927938SUlrich Hecht    dup3(0, 0, 0);
4771d0927938SUlrich Hecht    return 0;
4772d0927938SUlrich Hecht}
4773d0927938SUlrich HechtEOF
477478f5d726SJan Kiszkaif compile_prog "" "" ; then
4775d0927938SUlrich Hecht  dup3=yes
4776d0927938SUlrich Hechtfi
4777d0927938SUlrich Hecht
47784e0c6529SAlex Bligh# check for ppoll support
47794e0c6529SAlex Blighppoll=no
47804e0c6529SAlex Blighcat > $TMPC << EOF
47814e0c6529SAlex Bligh#include <poll.h>
47824e0c6529SAlex Bligh
47834e0c6529SAlex Blighint main(void)
47844e0c6529SAlex Bligh{
47854e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
47864e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
47874e0c6529SAlex Bligh    return 0;
47884e0c6529SAlex Bligh}
47894e0c6529SAlex BlighEOF
47904e0c6529SAlex Blighif compile_prog "" "" ; then
47914e0c6529SAlex Bligh  ppoll=yes
47924e0c6529SAlex Blighfi
47934e0c6529SAlex Bligh
4794cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4795cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4796cd758dd0SAlex Blighcat > $TMPC << EOF
4797cd758dd0SAlex Bligh#include <sys/prctl.h>
4798cd758dd0SAlex Bligh
4799cd758dd0SAlex Blighint main(void)
4800cd758dd0SAlex Bligh{
4801cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4802cd758dd0SAlex Bligh    return 0;
4803cd758dd0SAlex Bligh}
4804cd758dd0SAlex BlighEOF
4805cd758dd0SAlex Blighif compile_prog "" "" ; then
4806cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4807cd758dd0SAlex Blighfi
4808cd758dd0SAlex Bligh
48093b6edd16SPeter Maydell# check for epoll support
48103b6edd16SPeter Maydellepoll=no
48113b6edd16SPeter Maydellcat > $TMPC << EOF
48123b6edd16SPeter Maydell#include <sys/epoll.h>
48133b6edd16SPeter Maydell
48143b6edd16SPeter Maydellint main(void)
48153b6edd16SPeter Maydell{
48163b6edd16SPeter Maydell    epoll_create(0);
48173b6edd16SPeter Maydell    return 0;
48183b6edd16SPeter Maydell}
48193b6edd16SPeter MaydellEOF
48208fb03151SPeter Maydellif compile_prog "" "" ; then
48213b6edd16SPeter Maydell  epoll=yes
48223b6edd16SPeter Maydellfi
48233b6edd16SPeter Maydell
4824227f0214SPeter Maydell# epoll_create1 is a later addition
4825227f0214SPeter Maydell# so we must check separately for its presence
48263b6edd16SPeter Maydellepoll_create1=no
48273b6edd16SPeter Maydellcat > $TMPC << EOF
48283b6edd16SPeter Maydell#include <sys/epoll.h>
48293b6edd16SPeter Maydell
48303b6edd16SPeter Maydellint main(void)
48313b6edd16SPeter Maydell{
483219e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
483319e83f6bSPeter Maydell     * a function being called. This is necessary so that on
483419e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
483519e83f6bSPeter Maydell     * the library but not declared in the header file we will
483619e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
483719e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
483819e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
483919e83f6bSPeter Maydell     */
4840c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
48413b6edd16SPeter Maydell}
48423b6edd16SPeter MaydellEOF
48438fb03151SPeter Maydellif compile_prog "" "" ; then
48443b6edd16SPeter Maydell  epoll_create1=yes
48453b6edd16SPeter Maydellfi
48463b6edd16SPeter Maydell
4847a8fd1abaSPeter Maydell# check for sendfile support
4848a8fd1abaSPeter Maydellsendfile=no
4849a8fd1abaSPeter Maydellcat > $TMPC << EOF
4850a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4851a8fd1abaSPeter Maydell
4852a8fd1abaSPeter Maydellint main(void)
4853a8fd1abaSPeter Maydell{
4854a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4855a8fd1abaSPeter Maydell}
4856a8fd1abaSPeter MaydellEOF
4857a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4858a8fd1abaSPeter Maydell  sendfile=yes
4859a8fd1abaSPeter Maydellfi
4860a8fd1abaSPeter Maydell
486151834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
486251834341SRiku Voipiotimerfd=no
486351834341SRiku Voipiocat > $TMPC << EOF
486451834341SRiku Voipio#include <sys/timerfd.h>
486551834341SRiku Voipio
486651834341SRiku Voipioint main(void)
486751834341SRiku Voipio{
486851834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
486951834341SRiku Voipio}
487051834341SRiku VoipioEOF
487151834341SRiku Voipioif compile_prog "" "" ; then
487251834341SRiku Voipio  timerfd=yes
487351834341SRiku Voipiofi
487451834341SRiku Voipio
48759af5c906SRiku Voipio# check for setns and unshare support
48769af5c906SRiku Voipiosetns=no
48779af5c906SRiku Voipiocat > $TMPC << EOF
48789af5c906SRiku Voipio#include <sched.h>
48799af5c906SRiku Voipio
48809af5c906SRiku Voipioint main(void)
48819af5c906SRiku Voipio{
48829af5c906SRiku Voipio    int ret;
48839af5c906SRiku Voipio    ret = setns(0, 0);
48849af5c906SRiku Voipio    ret = unshare(0);
48859af5c906SRiku Voipio    return ret;
48869af5c906SRiku Voipio}
48879af5c906SRiku VoipioEOF
48889af5c906SRiku Voipioif compile_prog "" "" ; then
48899af5c906SRiku Voipio  setns=yes
48909af5c906SRiku Voipiofi
48919af5c906SRiku Voipio
489238860a03SAleksandar Markovic# clock_adjtime probe
489338860a03SAleksandar Markovicclock_adjtime=no
489438860a03SAleksandar Markoviccat > $TMPC <<EOF
489538860a03SAleksandar Markovic#include <time.h>
489638860a03SAleksandar Markovic
489738860a03SAleksandar Markovicint main(void)
489838860a03SAleksandar Markovic{
489938860a03SAleksandar Markovic    return clock_adjtime(0, 0);
490038860a03SAleksandar Markovic}
490138860a03SAleksandar MarkovicEOF
490238860a03SAleksandar Markovicclock_adjtime=no
490338860a03SAleksandar Markovicif compile_prog "" "" ; then
490438860a03SAleksandar Markovic  clock_adjtime=yes
490538860a03SAleksandar Markovicfi
490638860a03SAleksandar Markovic
49075a03cd00SAleksandar Markovic# syncfs probe
49085a03cd00SAleksandar Markovicsyncfs=no
49095a03cd00SAleksandar Markoviccat > $TMPC <<EOF
49105a03cd00SAleksandar Markovic#include <unistd.h>
49115a03cd00SAleksandar Markovic
49125a03cd00SAleksandar Markovicint main(void)
49135a03cd00SAleksandar Markovic{
49145a03cd00SAleksandar Markovic    return syncfs(0);
49155a03cd00SAleksandar Markovic}
49165a03cd00SAleksandar MarkovicEOF
49175a03cd00SAleksandar Markovicsyncfs=no
49185a03cd00SAleksandar Markovicif compile_prog "" "" ; then
49195a03cd00SAleksandar Markovic  syncfs=yes
49205a03cd00SAleksandar Markovicfi
49215a03cd00SAleksandar Markovic
4922db37dd89SAleksandar Markovic# check for kcov support (kernel must be 4.4+, compiled with certain options)
4923db37dd89SAleksandar Markovickcov=no
4924db37dd89SAleksandar Markovicif check_include sys/kcov.h ; then
4925db37dd89SAleksandar Markovic    kcov=yes
4926db37dd89SAleksandar Markovicfi
4927db37dd89SAleksandar Markovic
4928516e8b7dSPeter Maydell# If we're making warnings fatal, apply this to Sphinx runs as well
4929516e8b7dSPeter Maydellsphinx_werror=""
4930516e8b7dSPeter Maydellif test "$werror" = "yes"; then
4931516e8b7dSPeter Maydell    sphinx_werror="-W"
4932516e8b7dSPeter Maydellfi
4933516e8b7dSPeter Maydell
49345f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
49355f71eac0SPeter Maydellhas_sphinx_build() {
49365f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
49375f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
49385f71eac0SPeter Maydell    # version requirement). This will fail if either
49395f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
49405f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
49415f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
4942988ae6c3SAlex Bennée    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
4943988ae6c3SAlex Bennée                    -b html "$TMPDIR1/sphinx" \
4944988ae6c3SAlex Bennée                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
49455f71eac0SPeter Maydell}
49465f71eac0SPeter Maydell
4947cc8ae6deSpbrook# Check if tools are available to build documentation.
4948a25dba17SJuan Quintelaif test "$docs" != "no" ; then
4949758b617aSPeter Maydell  if has_sphinx_build; then
4950758b617aSPeter Maydell    sphinx_ok=yes
4951758b617aSPeter Maydell  else
4952758b617aSPeter Maydell    sphinx_ok=no
4953758b617aSPeter Maydell  fi
4954758b617aSPeter Maydell  if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
4955a25dba17SJuan Quintela    docs=yes
495683a3ab8bSJuan Quintela  else
4957a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
4958758b617aSPeter Maydell      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
4959758b617aSPeter Maydell        echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
4960758b617aSPeter Maydell      fi
4961758b617aSPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
496283a3ab8bSJuan Quintela    fi
4963a25dba17SJuan Quintela    docs=no
496483a3ab8bSJuan Quintela  fi
4965cc8ae6deSpbrookfi
4966cc8ae6deSpbrook
4967f514f41cSStefan Weil# Search for bswap_32 function
49686ae9a1f4SJuan Quintelabyteswap_h=no
49696ae9a1f4SJuan Quintelacat > $TMPC << EOF
49706ae9a1f4SJuan Quintela#include <byteswap.h>
49716ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
49726ae9a1f4SJuan QuintelaEOF
497352166aa0SJuan Quintelaif compile_prog "" "" ; then
49746ae9a1f4SJuan Quintela  byteswap_h=yes
49756ae9a1f4SJuan Quintelafi
49766ae9a1f4SJuan Quintela
497775f13596SStefan Weil# Search for bswap32 function
49786ae9a1f4SJuan Quintelabswap_h=no
49796ae9a1f4SJuan Quintelacat > $TMPC << EOF
49806ae9a1f4SJuan Quintela#include <sys/endian.h>
49816ae9a1f4SJuan Quintela#include <sys/types.h>
49826ae9a1f4SJuan Quintela#include <machine/bswap.h>
49836ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
49846ae9a1f4SJuan QuintelaEOF
498552166aa0SJuan Quintelaif compile_prog "" "" ; then
49866ae9a1f4SJuan Quintela  bswap_h=yes
49876ae9a1f4SJuan Quintelafi
49886ae9a1f4SJuan Quintela
4989da93a1fdSaliguori##########################################
4990e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4991c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4992e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
49933c33ea96SPaolo Bonzini    libiscsi="yes"
4994ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4995ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4996c589b249SRonnie Sahlberg  else
4997c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4998e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4999c589b249SRonnie Sahlberg    fi
5000c589b249SRonnie Sahlberg    libiscsi="no"
5001c589b249SRonnie Sahlberg  fi
5002c589b249SRonnie Sahlbergfi
5003c589b249SRonnie Sahlberg
5004c589b249SRonnie Sahlberg##########################################
50058bacde8dSNatanael Copa# Do we need libm
50068bacde8dSNatanael Copacat > $TMPC << EOF
50078bacde8dSNatanael Copa#include <math.h>
5008f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
50098bacde8dSNatanael CopaEOF
50108bacde8dSNatanael Copaif compile_prog "" "" ; then
50118bacde8dSNatanael Copa  :
50128bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
50138bacde8dSNatanael Copa  LIBS="-lm $LIBS"
50148bacde8dSNatanael Copaelse
501576ad07a4SPeter Maydell  error_exit "libm check failed"
50168bacde8dSNatanael Copafi
50178bacde8dSNatanael Copa
50188bacde8dSNatanael Copa##########################################
5019da93a1fdSaliguori# Do we need librt
50208bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
50218bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
50228bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
50238bacde8dSNatanael Copa# function in addition.
5024da93a1fdSaliguoricat > $TMPC <<EOF
5025da93a1fdSaliguori#include <signal.h>
5026da93a1fdSaliguori#include <time.h>
50278bacde8dSNatanael Copaint main(void) {
50288bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
50298bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
50308bacde8dSNatanael Copa}
5031da93a1fdSaliguoriEOF
5032da93a1fdSaliguori
503352166aa0SJuan Quintelaif compile_prog "" "" ; then
503407ffa4bdSJuan Quintela  :
50358bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
503618e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
503718e588b1SRick Liu  LIBS="$LIBS -lrt"
5038da93a1fdSaliguorifi
5039da93a1fdSaliguori
5040d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
5041d99e97e6SThomas Huthcat > $TMPC << EOF
5042d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
5043d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
5044d99e97e6SThomas HuthEOF
5045d99e97e6SThomas Huth
50469df8b20dSThomas Huthhave_openpty="no"
50479df8b20dSThomas Huthif compile_prog "" "" ; then
50489df8b20dSThomas Huth  have_openpty="yes"
50499df8b20dSThomas Huthelse
5050d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
5051d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
50529df8b20dSThomas Huth    have_openpty="yes"
5053d99e97e6SThomas Huth  fi
50546362a53fSJuan Quintelafi
50556362a53fSJuan Quintela
5056de5071c5SBlue Swirl##########################################
5057cd4ec0b4SGerd Hoffmann# spice probe
5058cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
5059cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
5060cd4ec0b4SGerd Hoffmann#include <spice.h>
5061cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
5062cd4ec0b4SGerd HoffmannEOF
5063710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
5064710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
50651b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
506665d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
5067cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
5068cd4ec0b4SGerd Hoffmann    spice="yes"
5069cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
5070cd4ec0b4SGerd Hoffmann  else
5071cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
50728efc9363SHu Tao      feature_not_found "spice" \
50731b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
5074cd4ec0b4SGerd Hoffmann    fi
5075cd4ec0b4SGerd Hoffmann    spice="no"
5076cd4ec0b4SGerd Hoffmann  fi
5077cd4ec0b4SGerd Hoffmannfi
5078cd4ec0b4SGerd Hoffmann
50797b02f544SMarc-André Lureau# check for smartcard support
50807b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
50810f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
50827b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
50837b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
50847b02f544SMarc-André Lureau        smartcard="yes"
5085111a38b0SRobert Relyea    else
50867b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
50877b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
5088111a38b0SRobert Relyea        fi
50897b02f544SMarc-André Lureau        smartcard="no"
5090111a38b0SRobert Relyea    fi
5091111a38b0SRobert Relyeafi
5092111a38b0SRobert Relyea
50932b2325ffSGerd Hoffmann# check for libusb
50942b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
509565d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
50962b2325ffSGerd Hoffmann        libusb="yes"
5097ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
5098ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
50992b2325ffSGerd Hoffmann    else
51002b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
51018efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
51022b2325ffSGerd Hoffmann        fi
51032b2325ffSGerd Hoffmann        libusb="no"
51042b2325ffSGerd Hoffmann    fi
51052b2325ffSGerd Hoffmannfi
51062b2325ffSGerd Hoffmann
510769354a83SHans de Goede# check for usbredirparser for usb network redirection support
510869354a83SHans de Goedeif test "$usb_redir" != "no" ; then
510965d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
511069354a83SHans de Goede        usb_redir="yes"
5111ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
5112ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
511369354a83SHans de Goede    else
511469354a83SHans de Goede        if test "$usb_redir" = "yes"; then
511521684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
511669354a83SHans de Goede        fi
511769354a83SHans de Goede        usb_redir="no"
511869354a83SHans de Goede    fi
511969354a83SHans de Goedefi
512069354a83SHans de Goede
5121cd4ec0b4SGerd Hoffmann##########################################
5122d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
5123d9840e25STomoki Sekiyama
5124e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5125e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
5126d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
5127690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
5128d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5129d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
5130690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
5131d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5132d9840e25STomoki Sekiyama	  ;;
5133690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
5134d9840e25STomoki Sekiyama  esac
5135d9840e25STomoki Sekiyama  cat > $TMPC << EOF
5136d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
5137d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
5138d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
5139d9840e25STomoki SekiyamaEOF
5140d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
5141d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
5142d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5143315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5144f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5145d9840e25STomoki Sekiyama  else
5146d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
5147d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
5148d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5149d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5150d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
5151d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
5152d9840e25STomoki Sekiyama      feature_not_found "VSS support"
5153d9840e25STomoki Sekiyama    fi
5154d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
5155d9840e25STomoki Sekiyama  fi
5156d9840e25STomoki Sekiyamafi
5157d9840e25STomoki Sekiyama
5158d9840e25STomoki Sekiyama##########################################
5159d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
5160d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
5161d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
5162d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
5163d9840e25STomoki Sekiyama
5164e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5165e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
5166d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
5167d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
5168d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5169d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
5170d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5171d9840e25STomoki Sekiyama    else
5172d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
5173d9840e25STomoki Sekiyama    fi
5174d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
5175d9840e25STomoki Sekiyama    win_sdk=""
5176d9840e25STomoki Sekiyama  fi
5177d9840e25STomoki Sekiyamafi
5178d9840e25STomoki Sekiyama
5179d9840e25STomoki Sekiyama##########################################
518050cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
5181e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
518250cbebb9SMichael Roth  cat > $TMPC << EOF
518350cbebb9SMichael Roth#include <windows.h>
518450cbebb9SMichael Roth#include <ntddscsi.h>
518550cbebb9SMichael Rothint main(void) {
518650cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
518750cbebb9SMichael Roth#error Missing required ioctl definitions
518850cbebb9SMichael Roth#endif
518950cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
519050cbebb9SMichael Roth  return addr.Lun;
519150cbebb9SMichael Roth}
519250cbebb9SMichael RothEOF
519350cbebb9SMichael Roth  if compile_prog "" "" ; then
519450cbebb9SMichael Roth    guest_agent_ntddscsi=yes
5195996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
519650cbebb9SMichael Roth  fi
519750cbebb9SMichael Rothfi
519850cbebb9SMichael Roth
519950cbebb9SMichael Roth##########################################
52009d9e1521SGerd Hoffmann# virgl renderer probe
52019d9e1521SGerd Hoffmann
52029d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
52039d9e1521SGerd Hoffmann  cat > $TMPC << EOF
52049d9e1521SGerd Hoffmann#include <virglrenderer.h>
52059d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
52069d9e1521SGerd HoffmannEOF
52079d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
52089d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
520947479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
52109d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
52119d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
52129d9e1521SGerd Hoffmann    virglrenderer="yes"
52139d9e1521SGerd Hoffmann  else
52149d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
52159d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
52169d9e1521SGerd Hoffmann    fi
52179d9e1521SGerd Hoffmann    virglrenderer="no"
52189d9e1521SGerd Hoffmann  fi
52199d9e1521SGerd Hoffmannfi
52209d9e1521SGerd Hoffmann
52219d9e1521SGerd Hoffmann##########################################
52228ca80760SRichard Henderson# capstone
52238ca80760SRichard Henderson
5224e219c499SRichard Hendersoncase "$capstone" in
5225e219c499SRichard Henderson  "" | yes)
52268ca80760SRichard Henderson    if $pkg_config capstone; then
5227e219c499SRichard Henderson      capstone=system
5228e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5229e219c499SRichard Henderson      capstone=git
5230e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
5231e219c499SRichard Henderson      capstone=internal
5232e219c499SRichard Henderson    elif test -z "$capstone" ; then
5233e219c499SRichard Henderson      capstone=no
5234e219c499SRichard Henderson    else
5235e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
5236e219c499SRichard Henderson    fi
5237e219c499SRichard Henderson    ;;
5238e219c499SRichard Henderson
5239e219c499SRichard Henderson  system)
5240e219c499SRichard Henderson    if ! $pkg_config capstone; then
5241e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
5242e219c499SRichard Henderson    fi
5243e219c499SRichard Henderson    ;;
5244e219c499SRichard Hendersonesac
5245e219c499SRichard Henderson
5246e219c499SRichard Hendersoncase "$capstone" in
5247e219c499SRichard Henderson  git | internal)
5248e219c499SRichard Henderson    if test "$capstone" = git; then
5249e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
5250e219c499SRichard Henderson    fi
5251e219c499SRichard Henderson    mkdir -p capstone
525225211446SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include"
5253e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
5254e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
5255e219c499SRichard Henderson    else
5256e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
5257e219c499SRichard Henderson    fi
5258c9322ab5SMarc-André Lureau    capstone_libs="-L$PWD/capstone -lcapstone"
5259c9322ab5SMarc-André Lureau    capstone_cflags="-I${source_path}/capstone/include"
5260e219c499SRichard Henderson    ;;
5261e219c499SRichard Henderson
5262e219c499SRichard Henderson  system)
5263c9322ab5SMarc-André Lureau    capstone_libs="$($pkg_config --libs capstone)"
5264c9322ab5SMarc-André Lureau    capstone_cflags="$($pkg_config --cflags capstone)"
52658ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
5266e219c499SRichard Henderson    ;;
5267e219c499SRichard Henderson
5268e219c499SRichard Henderson  no)
5269e219c499SRichard Henderson    ;;
5270e219c499SRichard Henderson  *)
5271e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
5272e219c499SRichard Henderson    ;;
5273e219c499SRichard Hendersonesac
52748ca80760SRichard Henderson
52758ca80760SRichard Henderson##########################################
52765f6b9e8fSBlue Swirl# check if we have fdatasync
52775f6b9e8fSBlue Swirl
52785f6b9e8fSBlue Swirlfdatasync=no
52795f6b9e8fSBlue Swirlcat > $TMPC << EOF
52805f6b9e8fSBlue Swirl#include <unistd.h>
5281d1722a27SAlexandre Raymondint main(void) {
5282d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5283d1722a27SAlexandre Raymondreturn fdatasync(0);
5284d1722a27SAlexandre Raymond#else
5285e172fe11SStefan Weil#error Not supported
5286d1722a27SAlexandre Raymond#endif
5287d1722a27SAlexandre Raymond}
52885f6b9e8fSBlue SwirlEOF
52895f6b9e8fSBlue Swirlif compile_prog "" "" ; then
52905f6b9e8fSBlue Swirl    fdatasync=yes
52915f6b9e8fSBlue Swirlfi
52925f6b9e8fSBlue Swirl
529394a420b1SStefan Hajnoczi##########################################
5294e78815a5SAndreas Färber# check if we have madvise
5295e78815a5SAndreas Färber
5296e78815a5SAndreas Färbermadvise=no
5297e78815a5SAndreas Färbercat > $TMPC << EOF
5298e78815a5SAndreas Färber#include <sys/types.h>
5299e78815a5SAndreas Färber#include <sys/mman.h>
5300832ce9c2SScott Wood#include <stddef.h>
5301e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5302e78815a5SAndreas FärberEOF
5303e78815a5SAndreas Färberif compile_prog "" "" ; then
5304e78815a5SAndreas Färber    madvise=yes
5305e78815a5SAndreas Färberfi
5306e78815a5SAndreas Färber
5307e78815a5SAndreas Färber##########################################
5308e78815a5SAndreas Färber# check if we have posix_madvise
5309e78815a5SAndreas Färber
5310e78815a5SAndreas Färberposix_madvise=no
5311e78815a5SAndreas Färbercat > $TMPC << EOF
5312e78815a5SAndreas Färber#include <sys/mman.h>
5313832ce9c2SScott Wood#include <stddef.h>
5314e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5315e78815a5SAndreas FärberEOF
5316e78815a5SAndreas Färberif compile_prog "" "" ; then
5317e78815a5SAndreas Färber    posix_madvise=yes
5318e78815a5SAndreas Färberfi
5319e78815a5SAndreas Färber
5320e78815a5SAndreas Färber##########################################
53219bc5a719SAndreas Gustafsson# check if we have posix_memalign()
53229bc5a719SAndreas Gustafsson
53239bc5a719SAndreas Gustafssonposix_memalign=no
53249bc5a719SAndreas Gustafssoncat > $TMPC << EOF
53259bc5a719SAndreas Gustafsson#include <stdlib.h>
53269bc5a719SAndreas Gustafssonint main(void) {
53279bc5a719SAndreas Gustafsson    void *p;
53289bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
53299bc5a719SAndreas Gustafsson}
53309bc5a719SAndreas GustafssonEOF
53319bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
53329bc5a719SAndreas Gustafsson    posix_memalign=yes
53339bc5a719SAndreas Gustafssonfi
53349bc5a719SAndreas Gustafsson
53359bc5a719SAndreas Gustafsson##########################################
53360a852417SPaul Durrant# check if we have posix_syslog
53370a852417SPaul Durrant
53380a852417SPaul Durrantposix_syslog=no
53390a852417SPaul Durrantcat > $TMPC << EOF
53400a852417SPaul Durrant#include <syslog.h>
53410a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
53420a852417SPaul DurrantEOF
53430a852417SPaul Durrantif compile_prog "" "" ; then
53440a852417SPaul Durrant    posix_syslog=yes
53450a852417SPaul Durrantfi
53460a852417SPaul Durrant
53470a852417SPaul Durrant##########################################
5348401bc051SPeter Maydell# check if we have sem_timedwait
5349401bc051SPeter Maydell
5350401bc051SPeter Maydellsem_timedwait=no
5351401bc051SPeter Maydellcat > $TMPC << EOF
5352401bc051SPeter Maydell#include <semaphore.h>
5353811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5354401bc051SPeter MaydellEOF
5355401bc051SPeter Maydellif compile_prog "" "" ; then
5356401bc051SPeter Maydell    sem_timedwait=yes
5357401bc051SPeter Maydellfi
5358401bc051SPeter Maydell
5359401bc051SPeter Maydell##########################################
53605c99fa37SKeno Fischer# check if we have strchrnul
53615c99fa37SKeno Fischer
53625c99fa37SKeno Fischerstrchrnul=no
53635c99fa37SKeno Fischercat > $TMPC << EOF
53645c99fa37SKeno Fischer#include <string.h>
53655c99fa37SKeno Fischerint main(void);
53665c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
53675c99fa37SKeno Fischerchar *haystack = (char*)&main;
53685c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
53695c99fa37SKeno FischerEOF
53705c99fa37SKeno Fischerif compile_prog "" "" ; then
53715c99fa37SKeno Fischer    strchrnul=yes
53725c99fa37SKeno Fischerfi
53735c99fa37SKeno Fischer
53748a792b03SJiufei Xue#########################################
53758a792b03SJiufei Xue# check if we have st_atim
53768a792b03SJiufei Xue
53778a792b03SJiufei Xuest_atim=no
53788a792b03SJiufei Xuecat > $TMPC << EOF
53798a792b03SJiufei Xue#include <sys/stat.h>
53808a792b03SJiufei Xue#include <stddef.h>
53818a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
53828a792b03SJiufei XueEOF
53838a792b03SJiufei Xueif compile_prog "" "" ; then
53848a792b03SJiufei Xue    st_atim=yes
53858a792b03SJiufei Xuefi
53868a792b03SJiufei Xue
53875c99fa37SKeno Fischer##########################################
538894a420b1SStefan Hajnoczi# check if trace backend exists
538994a420b1SStefan Hajnoczi
53905b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
539194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
53925b808275SLluís Vilanova  error_exit "invalid trace backends" \
53935b808275SLluís Vilanova      "Please choose supported trace backends."
539494a420b1SStefan Hajnoczifi
539594a420b1SStefan Hajnoczi
53967e24e92aSStefan Hajnoczi##########################################
53977e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
53985b808275SLluís Vilanovaif have_backend "ust"; then
53997e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5400bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
54017e24e92aSStefan Hajnocziint main(void) { return 0; }
54027e24e92aSStefan HajnocziEOF
5403c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5404bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
540589138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
54067e24e92aSStefan Hajnoczi    else
5407c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5408bf15f63cSMohamad Gebai    fi
5409bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
541089138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5411bf15f63cSMohamad Gebai    else
5412bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5413bf15f63cSMohamad Gebai    fi
5414bf15f63cSMohamad Gebai
5415bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5416bf15f63cSMohamad Gebai  else
5417bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
54187e24e92aSStefan Hajnoczi  fi
54197e24e92aSStefan Hajnoczifi
5420b3d08c02SDaniel P. Berrange
5421b3d08c02SDaniel P. Berrange##########################################
5422b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
54235b808275SLluís Vilanovaif have_backend "dtrace"; then
5424b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
542576ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5426b3d08c02SDaniel P. Berrange  fi
5427c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5428c276b17dSDaniel P. Berrange  if has 'stap' ; then
5429c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5430c276b17dSDaniel P. Berrange  fi
5431b3d08c02SDaniel P. Berrangefi
5432b3d08c02SDaniel P. Berrange
54337e24e92aSStefan Hajnoczi##########################################
5434519175a2SAlex Barcelo# check and set a backend for coroutine
5435d0e2fce5SAneesh Kumar K.V
54367c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
543733c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
543833c53c54SDaniel P. Berrange# specific one.
54397c2acc70SPeter Maydell
54407c2acc70SPeter Maydellucontext_works=no
5441d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5442d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5443d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5444cdf84806SPeter Maydell#ifdef __stub_makecontext
5445cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5446cdf84806SPeter Maydell#endif
544775cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5448d0e2fce5SAneesh Kumar K.VEOF
5449d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
54507c2acc70SPeter Maydell    ucontext_works=yes
5451d0e2fce5SAneesh Kumar K.V  fi
5452519175a2SAlex Barcelofi
54537c2acc70SPeter Maydell
54547c2acc70SPeter Maydellif test "$coroutine" = ""; then
54557c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
54567c2acc70SPeter Maydell    coroutine=win32
54577c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
54587c2acc70SPeter Maydell    coroutine=ucontext
5459519175a2SAlex Barcelo  else
54607c2acc70SPeter Maydell    coroutine=sigaltstack
54617c2acc70SPeter Maydell  fi
54627c2acc70SPeter Maydellelse
54637c2acc70SPeter Maydell  case $coroutine in
54647c2acc70SPeter Maydell  windows)
54657c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
54667c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
54677c2acc70SPeter Maydell    fi
54687c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
54697c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
54707c2acc70SPeter Maydell    coroutine=win32
54717c2acc70SPeter Maydell    ;;
54727c2acc70SPeter Maydell  ucontext)
54737c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
54747c2acc70SPeter Maydell      feature_not_found "ucontext"
54757c2acc70SPeter Maydell    fi
54767c2acc70SPeter Maydell    ;;
547733c53c54SDaniel P. Berrange  sigaltstack)
54787c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
54797c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
54807c2acc70SPeter Maydell    fi
54817c2acc70SPeter Maydell    ;;
54827c2acc70SPeter Maydell  *)
548376ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
54847c2acc70SPeter Maydell    ;;
54857c2acc70SPeter Maydell  esac
5486d0e2fce5SAneesh Kumar K.Vfi
5487d0e2fce5SAneesh Kumar K.V
548870c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
548970c60c08SStefan Hajnoczi  coroutine_pool=yes
549070c60c08SStefan Hajnoczifi
549170c60c08SStefan Hajnoczi
54927d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
54937d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
54947d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
54957d992e4dSPeter Lieven    coroutine_pool=no
54967d992e4dSPeter Lieven  fi
54977d992e4dSPeter Lievenfi
54987d992e4dSPeter Lieven
54991e4f6065SDaniele Buono##################################################
55001e4f6065SDaniele Buono# SafeStack
55011e4f6065SDaniele Buono
55021e4f6065SDaniele Buono
55031e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
55041e4f6065SDaniele Buonocat > $TMPC << EOF
55051e4f6065SDaniele Buonoint main(int argc, char *argv[])
55061e4f6065SDaniele Buono{
55071e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
55081e4f6065SDaniele Buono#error SafeStack Disabled
55091e4f6065SDaniele Buono#endif
55101e4f6065SDaniele Buono    return 0;
55111e4f6065SDaniele Buono}
55121e4f6065SDaniele BuonoEOF
55131e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
55141e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
55151e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
55161e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
55171e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
55181e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
55191e4f6065SDaniele Buono  else
55201e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
55211e4f6065SDaniele Buono  fi
55221e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
55231e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
55241e4f6065SDaniele Buono  fi
55251e4f6065SDaniele Buonoelse
55261e4f6065SDaniele Buonocat > $TMPC << EOF
55271e4f6065SDaniele Buonoint main(int argc, char *argv[])
55281e4f6065SDaniele Buono{
55291e4f6065SDaniele Buono#if defined(__has_feature)
55301e4f6065SDaniele Buono#if __has_feature(safe_stack)
55311e4f6065SDaniele Buono#error SafeStack Enabled
55321e4f6065SDaniele Buono#endif
55331e4f6065SDaniele Buono#endif
55341e4f6065SDaniele Buono    return 0;
55351e4f6065SDaniele Buono}
55361e4f6065SDaniele BuonoEOF
55371e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
55381e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
55391e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
55401e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
55411e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
55421e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
55431e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
55441e4f6065SDaniele Buono    fi
55451e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
55461e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
55471e4f6065SDaniele Buono  fi
55481e4f6065SDaniele Buonoelse # "$safe_stack" = ""
55491e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
55501e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
55511e4f6065SDaniele Buono    safe_stack="no"
55521e4f6065SDaniele Buono  else
55531e4f6065SDaniele Buono    safe_stack="yes"
55541e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
55551e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
55561e4f6065SDaniele Buono    fi
55571e4f6065SDaniele Buono  fi
55581e4f6065SDaniele Buonofi
55591e4f6065SDaniele Buonofi
55607d992e4dSPeter Lieven
5561d0e2fce5SAneesh Kumar K.V##########################################
5562d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5563d2042378SAneesh Kumar K.V
55644e1797f9SStefan Weilopen_by_handle_at=no
5565d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5566d2042378SAneesh Kumar K.V#include <fcntl.h>
5567acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5568acc55ba8SStefan Weil# error missing definition
5569acc55ba8SStefan Weil#else
557075cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5571acc55ba8SStefan Weil#endif
5572d2042378SAneesh Kumar K.VEOF
5573d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5574d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5575d2042378SAneesh Kumar K.Vfi
5576d2042378SAneesh Kumar K.V
5577e06a765eSHarsh Prateek Bora########################################
5578e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5579e06a765eSHarsh Prateek Bora
5580e06a765eSHarsh Prateek Boralinux_magic_h=no
5581e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5582e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5583e06a765eSHarsh Prateek Boraint main(void) {
558475cafad7SStefan Weil  return 0;
5585e06a765eSHarsh Prateek Bora}
5586e06a765eSHarsh Prateek BoraEOF
5587e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5588e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5589e06a765eSHarsh Prateek Borafi
5590e06a765eSHarsh Prateek Bora
55918ab1bf12SLuiz Capitulino########################################
5592541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
55933f4349dcSKevin Wolf
55943f4349dcSKevin Wolfvalgrind_h=no
55953f4349dcSKevin Wolfcat > $TMPC << EOF
55963f4349dcSKevin Wolf#include <valgrind/valgrind.h>
55973f4349dcSKevin Wolfint main(void) {
55983f4349dcSKevin Wolf  return 0;
55993f4349dcSKevin Wolf}
56003f4349dcSKevin WolfEOF
56013f4349dcSKevin Wolfif compile_prog "" "" ; then
56023f4349dcSKevin Wolf    valgrind_h=yes
56033f4349dcSKevin Wolffi
56043f4349dcSKevin Wolf
56053f4349dcSKevin Wolf########################################
56068ab1bf12SLuiz Capitulino# check if environ is declared
56078ab1bf12SLuiz Capitulino
56088ab1bf12SLuiz Capitulinohas_environ=no
56098ab1bf12SLuiz Capitulinocat > $TMPC << EOF
56108ab1bf12SLuiz Capitulino#include <unistd.h>
56118ab1bf12SLuiz Capitulinoint main(void) {
5612c075a723SBlue Swirl    environ = 0;
56138ab1bf12SLuiz Capitulino    return 0;
56148ab1bf12SLuiz Capitulino}
56158ab1bf12SLuiz CapitulinoEOF
56168ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
56178ab1bf12SLuiz Capitulino    has_environ=yes
56188ab1bf12SLuiz Capitulinofi
56198ab1bf12SLuiz Capitulino
562076a347e1SRichard Henderson########################################
562176a347e1SRichard Henderson# check if cpuid.h is usable.
562276a347e1SRichard Henderson
562376a347e1SRichard Hendersoncat > $TMPC << EOF
562476a347e1SRichard Henderson#include <cpuid.h>
562576a347e1SRichard Hendersonint main(void) {
5626774d566cSPeter Maydell    unsigned a, b, c, d;
5627774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5628774d566cSPeter Maydell
5629774d566cSPeter Maydell    if (max >= 1) {
5630774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5631774d566cSPeter Maydell    }
5632774d566cSPeter Maydell
5633774d566cSPeter Maydell    if (max >= 7) {
5634774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5635774d566cSPeter Maydell    }
5636774d566cSPeter Maydell
563776a347e1SRichard Henderson    return 0;
563876a347e1SRichard Henderson}
563976a347e1SRichard HendersonEOF
564076a347e1SRichard Hendersonif compile_prog "" "" ; then
564176a347e1SRichard Henderson    cpuid_h=yes
564276a347e1SRichard Hendersonfi
564376a347e1SRichard Henderson
56445dd89908SRichard Henderson##########################################
56455dd89908SRichard Henderson# avx2 optimization requirement check
56465dd89908SRichard Henderson#
56475dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
56485dd89908SRichard Henderson# since we won't be able to select the new routines.
56495dd89908SRichard Henderson
5650e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
56515dd89908SRichard Henderson  cat > $TMPC << EOF
56525dd89908SRichard Henderson#pragma GCC push_options
56535dd89908SRichard Henderson#pragma GCC target("avx2")
56545dd89908SRichard Henderson#include <cpuid.h>
56555dd89908SRichard Henderson#include <immintrin.h>
56565dd89908SRichard Hendersonstatic int bar(void *a) {
56575dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
56585dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
56595dd89908SRichard Henderson}
56605dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
56615dd89908SRichard HendersonEOF
56625dd89908SRichard Henderson  if compile_object "" ; then
56635dd89908SRichard Henderson    avx2_opt="yes"
566486583a07SLiam Merwick  else
566586583a07SLiam Merwick    avx2_opt="no"
56665dd89908SRichard Henderson  fi
56675dd89908SRichard Hendersonfi
56685dd89908SRichard Henderson
56696b8cd447SRobert Hoo##########################################
56706b8cd447SRobert Hoo# avx512f optimization requirement check
56716b8cd447SRobert Hoo#
56726b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
56736b8cd447SRobert Hoo# since we won't be able to select the new routines.
56746b8cd447SRobert Hoo# by default, it is turned off.
56756b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
56766b8cd447SRobert Hoo
56776b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
56786b8cd447SRobert Hoo  cat > $TMPC << EOF
56796b8cd447SRobert Hoo#pragma GCC push_options
56806b8cd447SRobert Hoo#pragma GCC target("avx512f")
56816b8cd447SRobert Hoo#include <cpuid.h>
56826b8cd447SRobert Hoo#include <immintrin.h>
56836b8cd447SRobert Hoostatic int bar(void *a) {
56846b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
56856b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
56866b8cd447SRobert Hoo}
56876b8cd447SRobert Hooint main(int argc, char *argv[])
56886b8cd447SRobert Hoo{
56896b8cd447SRobert Hoo	return bar(argv[0]);
56906b8cd447SRobert Hoo}
56916b8cd447SRobert HooEOF
56926b8cd447SRobert Hoo  if ! compile_object "" ; then
56936b8cd447SRobert Hoo    avx512f_opt="no"
56946b8cd447SRobert Hoo  fi
56956b8cd447SRobert Hooelse
56966b8cd447SRobert Hoo  avx512f_opt="no"
56976b8cd447SRobert Hoofi
56986b8cd447SRobert Hoo
5699f540166bSRichard Henderson########################################
5700f540166bSRichard Henderson# check if __[u]int128_t is usable.
5701f540166bSRichard Henderson
5702f540166bSRichard Hendersonint128=no
5703f540166bSRichard Hendersoncat > $TMPC << EOF
5704f540166bSRichard Henderson__int128_t a;
5705f540166bSRichard Henderson__uint128_t b;
5706f540166bSRichard Hendersonint main (void) {
5707f540166bSRichard Henderson  a = a + b;
5708f540166bSRichard Henderson  b = a * b;
5709464e3671SPeter Maydell  a = a * a;
5710f540166bSRichard Henderson  return 0;
5711f540166bSRichard Henderson}
5712f540166bSRichard HendersonEOF
5713f540166bSRichard Hendersonif compile_prog "" "" ; then
5714f540166bSRichard Henderson    int128=yes
5715f540166bSRichard Hendersonfi
571676a347e1SRichard Henderson
57177ebee43eSRichard Henderson#########################################
57187ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
57197ebee43eSRichard Henderson
57207ebee43eSRichard Hendersonatomic128=no
57217ebee43eSRichard Hendersonif test "$int128" = "yes"; then
57227ebee43eSRichard Henderson  cat > $TMPC << EOF
57237ebee43eSRichard Hendersonint main(void)
57247ebee43eSRichard Henderson{
57257ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
57267ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
57277ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
57287ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
57297ebee43eSRichard Henderson  return 0;
57307ebee43eSRichard Henderson}
57317ebee43eSRichard HendersonEOF
57327ebee43eSRichard Henderson  if compile_prog "" "" ; then
57337ebee43eSRichard Henderson    atomic128=yes
57347ebee43eSRichard Henderson  fi
57357ebee43eSRichard Hendersonfi
57367ebee43eSRichard Henderson
5737e6cd4bb5SRichard Hendersoncmpxchg128=no
5738e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5739e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5740e6cd4bb5SRichard Hendersonint main(void)
5741e6cd4bb5SRichard Henderson{
5742e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5743e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5744e6cd4bb5SRichard Henderson  return 0;
5745e6cd4bb5SRichard Henderson}
5746e6cd4bb5SRichard HendersonEOF
5747e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5748e6cd4bb5SRichard Henderson    cmpxchg128=yes
5749e6cd4bb5SRichard Henderson  fi
5750e6cd4bb5SRichard Hendersonfi
5751e6cd4bb5SRichard Henderson
5752df79b996SRichard Henderson#########################################
5753df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5754df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5755df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5756df79b996SRichard Henderson
5757df79b996SRichard Hendersoncat > $TMPC << EOF
5758df79b996SRichard Henderson#include <stdint.h>
5759df79b996SRichard Hendersonint main(void)
5760df79b996SRichard Henderson{
5761df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5762df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5763df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5764df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5765df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5766df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5767df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5768df79b996SRichard Henderson#else
5769df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5770df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5771df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5772df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5773df79b996SRichard Henderson#endif
5774df79b996SRichard Henderson  return 0;
5775df79b996SRichard Henderson}
5776df79b996SRichard HendersonEOF
5777df79b996SRichard Hendersonif compile_prog "" "" ; then
5778df79b996SRichard Henderson  atomic64=yes
5779df79b996SRichard Hendersonfi
5780df79b996SRichard Henderson
578126fffe29SEmilio G. Cota#########################################
578226fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
578326fffe29SEmilio G. Cotald_dynamic_list="no"
578426fffe29SEmilio G. Cotaif test "$static" = "no" ; then
578526fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
578626fffe29SEmilio G. Cota{
578726fffe29SEmilio G. Cota  foo;
578826fffe29SEmilio G. Cota};
578926fffe29SEmilio G. CotaEOF
579026fffe29SEmilio G. Cota
579126fffe29SEmilio G. Cota    cat > $TMPC <<EOF
579226fffe29SEmilio G. Cota#include <stdio.h>
579326fffe29SEmilio G. Cotavoid foo(void);
579426fffe29SEmilio G. Cota
579526fffe29SEmilio G. Cotavoid foo(void)
579626fffe29SEmilio G. Cota{
579726fffe29SEmilio G. Cota  printf("foo\n");
579826fffe29SEmilio G. Cota}
579926fffe29SEmilio G. Cota
580026fffe29SEmilio G. Cotaint main(void)
580126fffe29SEmilio G. Cota{
580226fffe29SEmilio G. Cota  foo();
580326fffe29SEmilio G. Cota  return 0;
580426fffe29SEmilio G. Cota}
580526fffe29SEmilio G. CotaEOF
580626fffe29SEmilio G. Cota
580726fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
580826fffe29SEmilio G. Cota        ld_dynamic_list="yes"
580926fffe29SEmilio G. Cota    fi
581026fffe29SEmilio G. Cotafi
581126fffe29SEmilio G. Cota
581226fffe29SEmilio G. Cota#########################################
581326fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
581426fffe29SEmilio G. Cota
581526fffe29SEmilio G. Cotald_exported_symbols_list="no"
581626fffe29SEmilio G. Cotaif test "$static" = "no" ; then
581726fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
581826fffe29SEmilio G. Cota  _foo
581926fffe29SEmilio G. CotaEOF
582026fffe29SEmilio G. Cota
582126fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
582226fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
582326fffe29SEmilio G. Cota    fi
582426fffe29SEmilio G. Cotafi
582526fffe29SEmilio G. Cota
582626fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
582726fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
582826fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
582926fffe29SEmilio G. Cota  error_exit \
583026fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
583126fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
583226fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
583326fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
583426fffe29SEmilio G. Cotafi
583526fffe29SEmilio G. Cota
58361e6e9acaSRichard Henderson########################################
5837db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
5838db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
5839db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
5840db8aaae8SRichard Henderson
5841db8aaae8SRichard Hendersonattralias=no
5842db8aaae8SRichard Hendersoncat > $TMPC << EOF
5843db8aaae8SRichard Hendersonint x = 1;
5844db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
5845db8aaae8SRichard Hendersonint main(void) { return 0; }
5846db8aaae8SRichard HendersonEOF
5847db8aaae8SRichard Hendersonif compile_prog "" "" ; then
5848db8aaae8SRichard Henderson    attralias=yes
5849db8aaae8SRichard Hendersonfi
5850db8aaae8SRichard Henderson
5851db8aaae8SRichard Henderson########################################
58521e6e9acaSRichard Henderson# check if getauxval is available.
58531e6e9acaSRichard Henderson
58541e6e9acaSRichard Hendersongetauxval=no
58551e6e9acaSRichard Hendersoncat > $TMPC << EOF
58561e6e9acaSRichard Henderson#include <sys/auxv.h>
58571e6e9acaSRichard Hendersonint main(void) {
58581e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
58591e6e9acaSRichard Henderson}
58601e6e9acaSRichard HendersonEOF
58611e6e9acaSRichard Hendersonif compile_prog "" "" ; then
58621e6e9acaSRichard Henderson    getauxval=yes
58631e6e9acaSRichard Hendersonfi
58641e6e9acaSRichard Henderson
5865fd0e6053SJohn Snow########################################
5866fd0e6053SJohn Snow# check if ccache is interfering with
5867fd0e6053SJohn Snow# semantic analysis of macros
5868fd0e6053SJohn Snow
58695e4dfd3dSJohn Snowunset CCACHE_CPP2
5870fd0e6053SJohn Snowccache_cpp2=no
5871fd0e6053SJohn Snowcat > $TMPC << EOF
5872fd0e6053SJohn Snowstatic const int Z = 1;
5873fd0e6053SJohn Snow#define fn() ({ Z; })
5874fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5875fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5876fd0e6053SJohn Snow#define ID(X) (X)
5877fd0e6053SJohn Snowint main(int argc, char *argv[])
5878fd0e6053SJohn Snow{
5879fd0e6053SJohn Snow    int x = 0, y = 0;
5880fd0e6053SJohn Snow    x = ID(x);
5881fd0e6053SJohn Snow    x = fn();
5882fd0e6053SJohn Snow    fn();
5883fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5884fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5885fd0e6053SJohn Snow    return 0;
5886fd0e6053SJohn Snow}
5887fd0e6053SJohn SnowEOF
5888fd0e6053SJohn Snow
5889fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5890fd0e6053SJohn Snow    ccache_cpp2=yes
5891fd0e6053SJohn Snowfi
5892fd0e6053SJohn Snow
5893b553a042SJohn Snow#################################################
5894b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5895b553a042SJohn Snow
5896b553a042SJohn Snowif test "$fortify_source" != "no"; then
5897b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5898b553a042SJohn Snow    fortify_source="no";
5899e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5900cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5901b553a042SJohn Snow    fortify_source="no";
5902b553a042SJohn Snow  else
5903b553a042SJohn Snow    fortify_source="yes"
5904b553a042SJohn Snow  fi
5905b553a042SJohn Snowfi
5906b553a042SJohn Snow
59071efad060SFam Zheng###############################################
59081efad060SFam Zheng# Check if copy_file_range is provided by glibc
59091efad060SFam Zhenghave_copy_file_range=no
59101efad060SFam Zhengcat > $TMPC << EOF
59111efad060SFam Zheng#include <unistd.h>
59121efad060SFam Zhengint main(void) {
59131efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
59141efad060SFam Zheng  return 0;
59151efad060SFam Zheng}
59161efad060SFam ZhengEOF
59171efad060SFam Zhengif compile_prog "" "" ; then
59181efad060SFam Zheng    have_copy_file_range=yes
59191efad060SFam Zhengfi
59201efad060SFam Zheng
5921d2042378SAneesh Kumar K.V##########################################
5922277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5923277abf15SJan Vesely
5924277abf15SJan Veselyhave_fsxattr=no
5925277abf15SJan Veselycat > $TMPC << EOF
5926277abf15SJan Vesely#include <linux/fs.h>
5927277abf15SJan Veselystruct fsxattr foo;
5928277abf15SJan Veselyint main(void) {
5929277abf15SJan Vesely  return 0;
5930277abf15SJan Vesely}
5931277abf15SJan VeselyEOF
5932277abf15SJan Veselyif compile_prog "" "" ; then
5933277abf15SJan Vesely    have_fsxattr=yes
5934277abf15SJan Veselyfi
5935277abf15SJan Vesely
5936b66e10e4SPeter Maydell##########################################
5937a40161cbSPaolo Bonzini# check for usable membarrier system call
5938a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5939a40161cbSPaolo Bonzini    have_membarrier=no
5940a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5941a40161cbSPaolo Bonzini        have_membarrier=yes
5942a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5943a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5944a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5945a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5946a40161cbSPaolo Bonzini    #include <unistd.h>
5947a40161cbSPaolo Bonzini    #include <stdlib.h>
5948a40161cbSPaolo Bonzini    int main(void) {
5949a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5950a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5951a40161cbSPaolo Bonzini	exit(0);
5952a40161cbSPaolo Bonzini    }
5953a40161cbSPaolo BonziniEOF
5954a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5955a40161cbSPaolo Bonzini            have_membarrier=yes
5956a40161cbSPaolo Bonzini        fi
5957a40161cbSPaolo Bonzini    fi
5958a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5959a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5960a40161cbSPaolo Bonzini    fi
5961a40161cbSPaolo Bonzinielse
5962a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5963a40161cbSPaolo Bonzini    # work on Wine.
5964a40161cbSPaolo Bonzini    membarrier=no
5965a40161cbSPaolo Bonzinifi
5966a40161cbSPaolo Bonzini
5967a40161cbSPaolo Bonzini##########################################
5968b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5969575b22b1SLaurent Vivierhave_rtnetlink=no
5970575b22b1SLaurent Viviercat > $TMPC << EOF
5971575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5972575b22b1SLaurent Vivierint main(void) {
5973575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5974575b22b1SLaurent Vivier}
5975575b22b1SLaurent VivierEOF
5976575b22b1SLaurent Vivierif compile_prog "" "" ; then
5977575b22b1SLaurent Vivier    have_rtnetlink=yes
5978575b22b1SLaurent Vivierfi
5979575b22b1SLaurent Vivier
59806a02c806SStefan Hajnoczi##########################################
59816a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
59826a02c806SStefan Hajnoczihave_af_vsock=no
59836a02c806SStefan Hajnoczicat > $TMPC << EOF
59846a02c806SStefan Hajnoczi#include <errno.h>
59856a02c806SStefan Hajnoczi#include <sys/types.h>
59866a02c806SStefan Hajnoczi#include <sys/socket.h>
59876a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
59886a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
59896a02c806SStefan Hajnoczi#endif
59906a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
59916a02c806SStefan Hajnocziint main(void) {
59926a02c806SStefan Hajnoczi    int sock, ret;
59936a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
59946a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
59956a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
59966a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
59976a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
59986a02c806SStefan Hajnoczi        return 0;
59996a02c806SStefan Hajnoczi    }
60006a02c806SStefan Hajnoczi    return -1;
60016a02c806SStefan Hajnoczi}
60026a02c806SStefan HajnocziEOF
60036a02c806SStefan Hajnocziif compile_prog "" "" ; then
60046a02c806SStefan Hajnoczi    have_af_vsock=yes
60056a02c806SStefan Hajnoczifi
60066a02c806SStefan Hajnoczi
6007f0d92b56SLongpeng(Mike)##########################################
6008f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
60094f67366eSThomas Huthhave_afalg=no
6010f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
6011f0d92b56SLongpeng(Mike)#include <errno.h>
6012f0d92b56SLongpeng(Mike)#include <sys/types.h>
6013f0d92b56SLongpeng(Mike)#include <sys/socket.h>
6014f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
6015f0d92b56SLongpeng(Mike)int main(void) {
6016f0d92b56SLongpeng(Mike)    int sock;
6017f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
6018f0d92b56SLongpeng(Mike)    return sock;
6019f0d92b56SLongpeng(Mike)}
6020f0d92b56SLongpeng(Mike)EOF
6021f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
6022f0d92b56SLongpeng(Mike)    have_afalg=yes
6023f0d92b56SLongpeng(Mike)fi
6024f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
6025f0d92b56SLongpeng(Mike)then
6026f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
6027f0d92b56SLongpeng(Mike)    then
6028f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
6029f0d92b56SLongpeng(Mike)    fi
6030f0d92b56SLongpeng(Mike)fi
6031f0d92b56SLongpeng(Mike)
6032f0d92b56SLongpeng(Mike)
60336969ec6cSJames Clarke#################################################
6034c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
6035d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
6036c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
6037c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
6038c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
6039c97d6d2cSSergio Andres Gomez Del RealEOF
6040c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
6041c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
6042c97d6d2cSSergio Andres Gomez Del Real  else
6043c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
6044db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-framework Hypervisor $QEMU_LDFLAGS"
6045c97d6d2cSSergio Andres Gomez Del Real  fi
6046c97d6d2cSSergio Andres Gomez Del Realfi
6047c97d6d2cSSergio Andres Gomez Del Real
6048277abf15SJan Vesely##########################################
60494d04351fSChristopher Covington# check for sysmacros.h
60504d04351fSChristopher Covington
60514d04351fSChristopher Covingtonhave_sysmacros=no
60524d04351fSChristopher Covingtoncat > $TMPC << EOF
60534d04351fSChristopher Covington#include <sys/sysmacros.h>
60544d04351fSChristopher Covingtonint main(void) {
60554d04351fSChristopher Covington    return makedev(0, 0);
60564d04351fSChristopher Covington}
60574d04351fSChristopher CovingtonEOF
60584d04351fSChristopher Covingtonif compile_prog "" "" ; then
60594d04351fSChristopher Covington    have_sysmacros=yes
60604d04351fSChristopher Covingtonfi
60614d04351fSChristopher Covington
60624d04351fSChristopher Covington##########################################
606349e00a18SAndreas Grapentin# check for _Static_assert()
606449e00a18SAndreas Grapentin
606549e00a18SAndreas Grapentinhave_static_assert=no
606649e00a18SAndreas Grapentincat > $TMPC << EOF
606749e00a18SAndreas Grapentin_Static_assert(1, "success");
606849e00a18SAndreas Grapentinint main(void) {
606949e00a18SAndreas Grapentin    return 0;
607049e00a18SAndreas Grapentin}
607149e00a18SAndreas GrapentinEOF
607249e00a18SAndreas Grapentinif compile_prog "" "" ; then
607349e00a18SAndreas Grapentin    have_static_assert=yes
607449e00a18SAndreas Grapentinfi
607549e00a18SAndreas Grapentin
607649e00a18SAndreas Grapentin##########################################
6077e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
6078e674605fSTomáš Golembiovský
6079e674605fSTomáš Golembiovskýhave_utmpx=no
6080e674605fSTomáš Golembiovskýcat > $TMPC << EOF
6081e674605fSTomáš Golembiovský#include <utmpx.h>
6082e674605fSTomáš Golembiovskýstruct utmpx user_info;
6083e674605fSTomáš Golembiovskýint main(void) {
6084e674605fSTomáš Golembiovský    return 0;
6085e674605fSTomáš Golembiovský}
6086e674605fSTomáš GolembiovskýEOF
6087e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
6088e674605fSTomáš Golembiovský    have_utmpx=yes
6089e674605fSTomáš Golembiovskýfi
6090e674605fSTomáš Golembiovský
6091e674605fSTomáš Golembiovský##########################################
6092db1ed1abSRichard Henderson# check for getrandom()
6093db1ed1abSRichard Henderson
6094db1ed1abSRichard Hendersonhave_getrandom=no
6095db1ed1abSRichard Hendersoncat > $TMPC << EOF
6096db1ed1abSRichard Henderson#include <sys/random.h>
6097db1ed1abSRichard Hendersonint main(void) {
6098db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
6099db1ed1abSRichard Henderson}
6100db1ed1abSRichard HendersonEOF
6101db1ed1abSRichard Hendersonif compile_prog "" "" ; then
6102db1ed1abSRichard Henderson    have_getrandom=yes
6103db1ed1abSRichard Hendersonfi
6104db1ed1abSRichard Henderson
6105db1ed1abSRichard Henderson##########################################
6106247724cbSMarc-André Lureau# checks for sanitizers
6107247724cbSMarc-André Lureau
6108247724cbSMarc-André Lureauhave_asan=no
6109247724cbSMarc-André Lureauhave_ubsan=no
6110d83414e1SMarc-André Lureauhave_asan_iface_h=no
6111d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
6112247724cbSMarc-André Lureau
6113247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
6114b9f44da2SMarc-André Lureau  write_c_skeleton
6115247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6116247724cbSMarc-André Lureau      have_asan=yes
6117247724cbSMarc-André Lureau  fi
6118b9f44da2SMarc-André Lureau
6119b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
6120b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
6121b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6122b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
6123b9f44da2SMarc-André Lureau#include <stdlib.h>
6124b9f44da2SMarc-André Lureauint main(void) {
6125b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
6126f2dfe54cSLeonid Bloch    if (tmp != NULL) {
6127b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
6128b9f44da2SMarc-André Lureau    }
6129d1abf3fcSOlaf Hering    return 1;
6130f2dfe54cSLeonid Bloch}
6131b9f44da2SMarc-André LureauEOF
6132247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6133247724cbSMarc-André Lureau      have_ubsan=yes
6134247724cbSMarc-André Lureau  fi
6135d83414e1SMarc-André Lureau
6136d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
6137d83414e1SMarc-André Lureau      have_asan_iface_h=yes
6138d83414e1SMarc-André Lureau  fi
6139d83414e1SMarc-André Lureau
6140d83414e1SMarc-André Lureau  cat > $TMPC << EOF
6141d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
6142d83414e1SMarc-André Lureauint main(void) {
6143d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
6144d83414e1SMarc-André Lureau  return 0;
6145d83414e1SMarc-André Lureau}
6146d83414e1SMarc-André LureauEOF
6147d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6148d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
6149d83414e1SMarc-André Lureau  fi
6150247724cbSMarc-André Lureaufi
6151247724cbSMarc-André Lureau
6152247724cbSMarc-André Lureau##########################################
6153adc28027SAlexander Bulekov# checks for fuzzer
6154adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
6155adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
6156dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
6157adc28027SAlexander Bulekov    have_fuzzer=yes
615864ed6f92SPaolo Bonzini  else
615964ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
616064ed6f92SPaolo Bonzini    exit 1
6161adc28027SAlexander Bulekov  fi
6162adc28027SAlexander Bulekovfi
6163adc28027SAlexander Bulekov
61640aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
61650aebab04SLingfeng Yang# keep it separate until that is not the case.
61660aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
61670aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
61680aebab04SLingfeng Yangfi
61690aebab04SLingfeng Yanghave_tsan=no
61700aebab04SLingfeng Yanghave_tsan_iface_fiber=no
61710aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
61720aebab04SLingfeng Yang  write_c_skeleton
61730aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
61740aebab04SLingfeng Yang      have_tsan=yes
61750aebab04SLingfeng Yang  fi
61760aebab04SLingfeng Yang  cat > $TMPC << EOF
61770aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
61780aebab04SLingfeng Yangint main(void) {
61790aebab04SLingfeng Yang  __tsan_create_fiber(0);
61800aebab04SLingfeng Yang  return 0;
61810aebab04SLingfeng Yang}
61820aebab04SLingfeng YangEOF
61830aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
61840aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
61850aebab04SLingfeng Yang  fi
61860aebab04SLingfeng Yangfi
61870aebab04SLingfeng Yang
6188adc28027SAlexander Bulekov##########################################
618917824406SJunyan He# check for libpmem
619017824406SJunyan He
619117824406SJunyan Heif test "$libpmem" != "no"; then
619217824406SJunyan He	if $pkg_config --exists "libpmem"; then
619317824406SJunyan He		libpmem="yes"
619417824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
619517824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
619617824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
619717824406SJunyan He	else
619817824406SJunyan He		if test "$libpmem" = "yes" ; then
619917824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
620017824406SJunyan He		fi
620117824406SJunyan He		libpmem="no"
620217824406SJunyan He	fi
620317824406SJunyan Hefi
620417824406SJunyan He
620517824406SJunyan He##########################################
620621b2eca6SJingqi Liu# check for libdaxctl
620721b2eca6SJingqi Liu
620821b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
620921b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
621021b2eca6SJingqi Liu		libdaxctl="yes"
621121b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
621221b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
621321b2eca6SJingqi Liu		QEMU_CFLAGS="$QEMU_CFLAGS $libdaxctl_cflags"
621421b2eca6SJingqi Liu	else
621521b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
621621b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
621721b2eca6SJingqi Liu		fi
621821b2eca6SJingqi Liu		libdaxctl="no"
621921b2eca6SJingqi Liu	fi
622021b2eca6SJingqi Liufi
622121b2eca6SJingqi Liu
622221b2eca6SJingqi Liu##########################################
6223675b9b53SMarc-André Lureau# check for slirp
6224675b9b53SMarc-André Lureau
6225d599938aSLaurent Vivier# slirp is only required when building softmmu targets
6226d599938aSLaurent Vivierif test -z "$slirp" -a "$softmmu" != "yes" ; then
6227d599938aSLaurent Vivier    slirp="no"
6228d599938aSLaurent Vivierfi
6229d599938aSLaurent Vivier
6230675b9b53SMarc-André Lureaucase "$slirp" in
6231675b9b53SMarc-André Lureau  "" | yes)
6232675b9b53SMarc-André Lureau    if $pkg_config slirp; then
6233675b9b53SMarc-André Lureau      slirp=system
62347c57bdd8SMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
62357c57bdd8SMarc-André Lureau      slirp=git
6236675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
6237675b9b53SMarc-André Lureau      slirp=internal
6238675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
6239675b9b53SMarc-André Lureau      slirp=no
6240675b9b53SMarc-André Lureau    else
6241675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
6242675b9b53SMarc-André Lureau    fi
6243675b9b53SMarc-André Lureau    ;;
6244675b9b53SMarc-André Lureau
6245675b9b53SMarc-André Lureau  system)
6246675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
6247675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
6248675b9b53SMarc-André Lureau    fi
6249675b9b53SMarc-André Lureau    ;;
6250675b9b53SMarc-André Lureauesac
6251675b9b53SMarc-André Lureau
6252675b9b53SMarc-André Lureaucase "$slirp" in
62537c57bdd8SMarc-André Lureau  git | internal)
62547c57bdd8SMarc-André Lureau    if test "$slirp" = git; then
62557c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
62567c57bdd8SMarc-André Lureau    fi
6257675b9b53SMarc-André Lureau    mkdir -p slirp
625825211446SPaolo Bonzini    slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
625925211446SPaolo Bonzini    slirp_libs="-L$PWD/slirp -lslirp"
6260b965e8c5SPaolo Bonzini    if test "$mingw32" = "yes" ; then
6261b965e8c5SPaolo Bonzini      slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6262b965e8c5SPaolo Bonzini    fi
6263675b9b53SMarc-André Lureau    ;;
6264675b9b53SMarc-André Lureau
6265675b9b53SMarc-André Lureau  system)
6266675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6267675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6268675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6269675b9b53SMarc-André Lureau    ;;
6270675b9b53SMarc-André Lureau
6271675b9b53SMarc-André Lureau  no)
6272675b9b53SMarc-André Lureau    ;;
6273675b9b53SMarc-André Lureau  *)
6274675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
6275675b9b53SMarc-André Lureau    ;;
6276675b9b53SMarc-André Lureauesac
6277675b9b53SMarc-André Lureau
627854e7aac0SAlexey Krasikov##########################################
627954e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
628054e7aac0SAlexey Krasikov
628154e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
628254e7aac0SAlexey Krasikov
628354e7aac0SAlexey Krasikov    have_keyring=no
628454e7aac0SAlexey Krasikov    cat > $TMPC << EOF
628554e7aac0SAlexey Krasikov#include <errno.h>
628654e7aac0SAlexey Krasikov#include <asm/unistd.h>
628754e7aac0SAlexey Krasikov#include <linux/keyctl.h>
628854e7aac0SAlexey Krasikov#include <unistd.h>
628954e7aac0SAlexey Krasikovint main(void) {
629054e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
629154e7aac0SAlexey Krasikov}
629254e7aac0SAlexey KrasikovEOF
629354e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
629454e7aac0SAlexey Krasikov        have_keyring=yes
629554e7aac0SAlexey Krasikov    fi
629654e7aac0SAlexey Krasikovfi
629754e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
629854e7aac0SAlexey Krasikovthen
6299b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
630054e7aac0SAlexey Krasikov    then
630154e7aac0SAlexey Krasikov	secret_keyring=yes
630254e7aac0SAlexey Krasikov    else
630354e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
630454e7aac0SAlexey Krasikov	then
630554e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
630654e7aac0SAlexey Krasikovbut not implemented on your system"
630754e7aac0SAlexey Krasikov	else
630854e7aac0SAlexey Krasikov	    secret_keyring=no
630954e7aac0SAlexey Krasikov	fi
631054e7aac0SAlexey Krasikov    fi
631154e7aac0SAlexey Krasikovfi
631254e7aac0SAlexey Krasikov
631392500362SAlexey Krasikov##########################################
631492500362SAlexey Krasikov# check for usable keyutils.h
631592500362SAlexey Krasikov
631692500362SAlexey Krasikovif test "$linux" = "yes" ; then
631792500362SAlexey Krasikov
631892500362SAlexey Krasikov    have_keyutils=no
631992500362SAlexey Krasikov    cat > $TMPC << EOF
632092500362SAlexey Krasikov#include <errno.h>
632192500362SAlexey Krasikov#include <asm/unistd.h>
632292500362SAlexey Krasikov#include <unistd.h>
632392500362SAlexey Krasikov#include <sys/types.h>
632492500362SAlexey Krasikov#include <keyutils.h>
632592500362SAlexey Krasikovint main(void) {
632692500362SAlexey Krasikov    return request_key("user", NULL, NULL, 0);
632792500362SAlexey Krasikov}
632892500362SAlexey KrasikovEOF
632992500362SAlexey Krasikov    if compile_prog "" "-lkeyutils"; then
633092500362SAlexey Krasikov        have_keyutils=yes
633192500362SAlexey Krasikov    fi
633292500362SAlexey Krasikovfi
633392500362SAlexey Krasikov
6334675b9b53SMarc-André Lureau
6335675b9b53SMarc-André Lureau##########################################
6336e86ecd4bSJuan Quintela# End of CC checks
6337e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
6338e86ecd4bSJuan Quintela
6339d83414e1SMarc-André Lureauwrite_c_skeleton
6340d83414e1SMarc-André Lureau
63411d728c39SBlue Swirlif test "$gcov" = "yes" ; then
6342bf0e56a3SMarc-André Lureau  :
6343b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
6344086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
6345086d5f75SPaolo Bonzini  debug=no
6346086d5f75SPaolo Bonzinifi
6347086d5f75SPaolo Bonziniif test "$debug_info" = "yes"; then
6348086d5f75SPaolo Bonzini  CFLAGS="-g $CFLAGS"
6349086d5f75SPaolo Bonzini  LDFLAGS="-g $LDFLAGS"
6350086d5f75SPaolo Bonzinifi
6351a5665051SPaolo Bonziniif test "$debug" = "no"; then
6352a5665051SPaolo Bonzini  CFLAGS="-O2 $CFLAGS"
6353a5665051SPaolo Bonzinifi
6354086d5f75SPaolo Bonzini
6355086d5f75SPaolo Bonzinicase "$ARCH" in
6356086d5f75SPaolo Bonzinialpha)
6357086d5f75SPaolo Bonzini  # Ensure there's only a single GP
6358086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
6359086d5f75SPaolo Bonzini;;
6360086d5f75SPaolo Bonziniesac
6361086d5f75SPaolo Bonzini
6362086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
6363086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
6364086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
6365086d5f75SPaolo Bonzinifi
6366a316e378SJuan Quintela
6367247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
6368db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
6369db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
6370d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
6371d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
6372d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6373d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
6374d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
6375d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6376d83414e1SMarc-André Lureau  fi
6377247724cbSMarc-André Lureaufi
63780aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
63790aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
63800aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
63810aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
63820aebab04SLingfeng Yang  else
63830aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
63840aebab04SLingfeng Yang  fi
63850aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
63860aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
63870aebab04SLingfeng Yangfi
6388247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
6389db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
6390db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
6391247724cbSMarc-André Lureaufi
6392247724cbSMarc-André Lureau
63936542aa9cSPeter Lieven##########################################
63946542aa9cSPeter Lieven# Do we have libnfs
63956542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
6396b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
63976542aa9cSPeter Lieven    libnfs="yes"
63986542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
63996542aa9cSPeter Lieven  else
64006542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
64018efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
64026542aa9cSPeter Lieven    fi
64036542aa9cSPeter Lieven    libnfs="no"
64046542aa9cSPeter Lieven  fi
64056542aa9cSPeter Lievenfi
64061d728c39SBlue Swirl
64073efac6ebSTomáš Golembiovský##########################################
64083efac6ebSTomáš Golembiovský# Do we have libudev
64093efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
64103efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
64113efac6ebSTomáš Golembiovský    libudev="yes"
64123efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
64133efac6ebSTomáš Golembiovský  else
64143efac6ebSTomáš Golembiovský    libudev="no"
64153efac6ebSTomáš Golembiovský  fi
64163efac6ebSTomáš Golembiovskýfi
64173efac6ebSTomáš Golembiovský
64186ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
64196ca026cbSPeter Maydellif test "$werror" = "yes"; then
64206ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
64216ca026cbSPeter Maydellfi
64226ca026cbSPeter Maydell
64230aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
64240aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
6425e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6426db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
6427e86ecd4bSJuan Quintela    fi
6428e86ecd4bSJuan Quintelafi
6429e86ecd4bSJuan Quintela
643094dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
643194dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
643294dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
643394dd53c5SGerd Hoffmannelse
643494dd53c5SGerd Hoffmann    POD2MAN="pod2man"
643594dd53c5SGerd Hoffmannfi
643694dd53c5SGerd Hoffmann
6437952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
6438952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
6439952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
6440e9a3591fSChristian Borntraeger        if ld_has $flag ; then
6441db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
6442952afb71SBlue Swirl        fi
6443952afb71SBlue Swirl    done
6444952afb71SBlue Swirlfi
6445952afb71SBlue Swirl
64467776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
64477776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
64487776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
64497776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
64507776ea6bSPhilippe Mathieu-DaudéEOF
64517776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
64527776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
64537776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
64547776ea6bSPhilippe Mathieu-Daudé    fi
64557776ea6bSPhilippe Mathieu-Daudéfi
64567776ea6bSPhilippe Mathieu-Daudé
645710ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
6458e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
6459528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
6460834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
6461a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
646267ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
64635a67135aSbellard
6464e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
6465e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
6466e0580342SKamil Rytarowski  ivshmem=yes
6467e0580342SKamil Rytarowskifi
6468e0580342SKamil Rytarowski
64694b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
6470b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
64717e462613SPaolo Bonzini    if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6472983eef5aSMeador Inge      virtfs=yes
6473983eef5aSMeador Inge    else
6474983eef5aSMeador Inge      if test "$virtfs" = yes; then
64757e462613SPaolo Bonzini        error_exit "VirtFS requires libcap-ng devel and libattr devel"
6476983eef5aSMeador Inge      fi
647717500370SAndreas Färber      virtfs=no
6478983eef5aSMeador Inge    fi
6479fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
6480fe8fc5aeSPaolo Bonzini      mpath=yes
6481fe8fc5aeSPaolo Bonzini    else
6482fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
6483fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
6484fe8fc5aeSPaolo Bonzini      fi
6485fe8fc5aeSPaolo Bonzini      mpath=no
6486fe8fc5aeSPaolo Bonzini    fi
6487b855f8d1SPaolo Bonzini  else
6488b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
6489b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
6490b855f8d1SPaolo Bonzini    fi
6491b855f8d1SPaolo Bonzini    virtfs=no
6492fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
6493fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
6494fe8fc5aeSPaolo Bonzini    fi
6495fe8fc5aeSPaolo Bonzini    mpath=no
649617bff52bSM. Mohan Kumar  fi
6497ff69fd8cSLaurent Vivierfi
64989d6bc27bSMichael Roth
64999d6bc27bSMichael Roth# Probe for guest agent support/options
65009d6bc27bSMichael Roth
6501e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
6502a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6503a5125905SLaurent Vivier      guest_agent=no
6504a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6505e8ef31a3SMichael Tokarev      guest_agent=yes
6506e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
6507e8ef31a3SMichael Tokarev      guest_agent=no
6508e8ef31a3SMichael Tokarev  else
6509e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
6510ca35f780SPaolo Bonzini  fi
65114b1c11fdSDaniel P. Berrangefi
6512ca35f780SPaolo Bonzini
65139d6bc27bSMichael Roth# Guest agent Window MSI  package
65149d6bc27bSMichael Roth
65159d6bc27bSMichael Rothif test "$guest_agent" != yes; then
65169d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
65179d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
65189d6bc27bSMichael Roth  fi
65199d6bc27bSMichael Roth  guest_agent_msi=no
65209d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
65219d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
65229d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
65239d6bc27bSMichael Roth  fi
65249d6bc27bSMichael Roth  guest_agent_msi=no
65259d6bc27bSMichael Rothelif ! has wixl; then
65269d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
65279d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
65289d6bc27bSMichael Roth  fi
65299d6bc27bSMichael Roth  guest_agent_msi=no
65301a34904eSMichael Rothelse
65311a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
65321a34904eSMichael Roth  # disabled explicitly
65331a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
65341a34904eSMichael Roth    guest_agent_msi=yes
65351a34904eSMichael Roth  fi
65369d6bc27bSMichael Rothfi
65379d6bc27bSMichael Roth
65381a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
65399d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
65409d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
65419d6bc27bSMichael Roth  fi
65429d6bc27bSMichael Roth
65439d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
65449d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
65459d6bc27bSMichael Roth  fi
65469d6bc27bSMichael Roth
65479d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
65489d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
65499d6bc27bSMichael Roth  fi
65509d6bc27bSMichael Roth
65519d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
655289138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
65539d6bc27bSMichael Roth  fi
65549d6bc27bSMichael Roth
655589138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
65569d6bc27bSMichael Roth
65579d6bc27bSMichael Roth  case "$cpu" in
65589d6bc27bSMichael Roth  x86_64)
65599d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
65609d6bc27bSMichael Roth    ;;
65619d6bc27bSMichael Roth  i386)
65629d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
65639d6bc27bSMichael Roth    ;;
65649d6bc27bSMichael Roth  *)
65659d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
65669d6bc27bSMichael Roth    ;;
65679d6bc27bSMichael Roth  esac
65689d6bc27bSMichael Rothfi
65699d6bc27bSMichael Roth
6570ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6571ca35f780SPaolo Bonziniroms=
6572e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6573e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6574e633a5c6SEric Blake        test "$softmmu" = yes ; then
6575e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6576c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6577c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6578c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6579e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6580e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6581ca35f780SPaolo Bonzini            roms="optionrom"
6582e57218b6SPeter Maydell            break
6583e57218b6SPeter Maydell        fi
6584e57218b6SPeter Maydell    done
6585ca35f780SPaolo Bonzinifi
6586ca35f780SPaolo Bonzini
65872e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
65889933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
65892e33c3f8SThomas Huth  write_c_skeleton
65902e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
65919933c305SChristian Borntraeger    roms="$roms s390-ccw"
65921ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
65931ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
65941ef6bfc2SPhilippe Mathieu-Daudé    if test -e "${source_path}/.git" ; then
65951ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
65961ef6bfc2SPhilippe Mathieu-Daudé    fi
65979933c305SChristian Borntraeger  fi
65982e33c3f8SThomas Huthfi
65999933c305SChristian Borntraeger
660011cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
660111cde1c8SBruno 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.
660211cde1c8SBruno Dominguezif has $cxx; then
660311cde1c8SBruno Dominguez    cat > $TMPC <<EOF
660411cde1c8SBruno Dominguezint c_function(void);
660511cde1c8SBruno Dominguezint main(void) { return c_function(); }
660611cde1c8SBruno DominguezEOF
660711cde1c8SBruno Dominguez
660811cde1c8SBruno Dominguez    compile_object
660911cde1c8SBruno Dominguez
661011cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
661111cde1c8SBruno Dominguezextern "C" {
661211cde1c8SBruno Dominguez   int c_function(void);
661311cde1c8SBruno Dominguez}
661411cde1c8SBruno Dominguezint c_function(void) { return 42; }
661511cde1c8SBruno DominguezEOF
661611cde1c8SBruno Dominguez
661711cde1c8SBruno Dominguez    update_cxxflags
661811cde1c8SBruno Dominguez
6619086d5f75SPaolo Bonzini    if do_cxx $CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
662011cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
662111cde1c8SBruno Dominguez        :
662211cde1c8SBruno Dominguez    else
662311cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
662411cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
662511cde1c8SBruno Dominguez        cxx=
662611cde1c8SBruno Dominguez    fi
662711cde1c8SBruno Dominguezelse
662811cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
662911cde1c8SBruno Dominguez    cxx=
663011cde1c8SBruno Dominguezfi
663111cde1c8SBruno Dominguez
663202d34f62SCole Robinsonecho_version() {
663302d34f62SCole Robinson    if test "$1" = "yes" ; then
663402d34f62SCole Robinson        echo "($2)"
663502d34f62SCole Robinson    fi
663602d34f62SCole Robinson}
663702d34f62SCole Robinson
6638*b7612f45SPaolo Bonzini# prepend ftd flags after all config tests are done
6639*b7612f45SPaolo BonziniQEMU_CFLAGS="$fdt_cflags $QEMU_CFLAGS"
66408a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
66415ca9388aSGerd Hoffmann
664298ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
664397a847bcSbellard
6644dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6645dbd99ae3SStefan Weil
664698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
664798ec69acSJuan Quintelaecho >> $config_host_mak
664898ec69acSJuan Quintela
6649e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
665099d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
665199d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
66523aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
66538bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
66540f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
665599d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
665699d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
665722d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
66589afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
66593d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
66609afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6661e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
66625a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6663785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
66645a699bbbSLaszlo Ersekfi
6665f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6666834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6667a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
666867ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6669cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6670aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6671f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6672804edf29SJuan Quintela
667398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6674727e5283SPaolo Bonzini
6675f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6676f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6677f3494749SPaolo Bonzinielse
6678f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6679f3494749SPaolo Bonzinifi
6680f8393946Saurel32if test "$debug_tcg" = "yes" ; then
66812358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6682f8393946Saurel32fi
66831625af87Saliguoriif test "$strip_opt" = "yes" ; then
668452ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
66851625af87Saliguorifi
66867d13299dSbellardif test "$bigendian" = "yes" ; then
6687e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
668897a847bcSbellardfi
668967b915a5Sbellardif test "$mingw32" = "yes" ; then
669098ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
669189138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
66929fe6de94SBlue Swirl  version_major=${rc_version%%.*}
66939fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66949fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
66959fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66969fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
66979fe6de94SBlue Swirl  version_micro=0
66989fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
66999fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6700d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6701d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6702f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6703d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6704d9840e25STomoki Sekiyama  fi
670550cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
670676dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
670750cbebb9SMichael Roth  fi
67081a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
67099dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
67109dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
67119dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
67129dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
67139dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
67149dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
67159dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
67169dacf32dSYossi Hindin  fi
6717210fa556Spbrookelse
671835f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6719210fa556Spbrookfi
6720128ab2ffSblueswir1
6721dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6722dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6723dffcb71cSMark McLoughlinfi
6724dffcb71cSMark McLoughlin
672583fb7adfSbellardif test "$darwin" = "yes" ; then
672698ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
672783fb7adfSbellardfi
6728b29fe3edSmalc
6729ec530c81Sbellardif test "$solaris" = "yes" ; then
673098ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6731ec530c81Sbellardfi
6732179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6733179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6734179cf400SAndreas Färberfi
673597a847bcSbellardif test "$static" = "yes" ; then
673698ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
673797a847bcSbellardfi
67381ba16968SStefan Weilif test "$profiler" = "yes" ; then
67392358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
674005c2a3e7Sbellardfi
6741c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
6742c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
6743c932ce31SPaolo Bonzinifi
6744f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
6745f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
6746f15bff25SPaolo Bonzinifi
6747675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
674898ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6749e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6750675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6751675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6752675b9b53SMarc-André Lureaufi
6753859aef02SPaolo Bonzinisubdirs=
67547c57bdd8SMarc-André Lureauif [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
6755859aef02SPaolo Bonzini  subdirs="$subdirs slirp"
6756c20709aaSbellardfi
67578a16d273Sthsif test "$vde" = "yes" ; then
675898ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6759e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
67608a16d273Sthsfi
676158952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
676258952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
676358952137SVincenzo Maffionefi
6764015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6765015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6766015a33bdSGongleifi
67674cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
67684cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
67694cc600d2SPaolo Bonzinifi
677047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
6771a358bca2SPaolo Bonzini  echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
67723f99cf57SPaolo Bonzini  echo "LIBCAP_NG_LIBS=$cap_libs" >> $config_host_mak
677347e98658SCorey Bryantfi
67742358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
67750c58ac1cSmalcfor drv in $audio_drv_list; do
67761ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6777484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
67780c58ac1cSmalcdone
6779478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
6780478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
6781478e943fSPaolo Bonzinifi
6782b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6783478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
6784478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
6785478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
6786478e943fSPaolo Bonzinifi
6787b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6788478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
6789b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6790b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6791b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
6792478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
6793478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
6794478e943fSPaolo Bonzinifi
67952e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
6796d5631638Smalcif test "$audio_win_int" = "yes" ; then
6797d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6798d5631638Smalcfi
6799b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6800b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6801dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6802dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6803dce512deSChristoph Hellwigfi
680489138857SStefan Weilqemu_version=$(head $source_path/VERSION)
68052358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
680698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
68072b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6808a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
680998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6810cc8ae6deSpbrookfi
681117969268SFam Zhengif test "$modules" = "yes"; then
6812e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6813e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
681489138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
681517969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
681617969268SFam Zhengfi
6817bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
6818bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
6819bd83c861SChristian Ehrhardtfi
6820e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
68218781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
68228781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
68238781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
68248781595bSGerd Hoffmannfi
682549ecc3faSbellardif test "$cocoa" = "yes" ; then
682698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
682749ecc3faSbellardfi
6828e08bb301SSamuel Thibaultif test "$iconv" = "yes" ; then
6829e08bb301SSamuel Thibault  echo "CONFIG_ICONV=y" >> $config_host_mak
6830e08bb301SSamuel Thibault  echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
6831e08bb301SSamuel Thibault  echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
6832e08bb301SSamuel Thibaultfi
68334d3b6f6eSbalrogif test "$curses" = "yes" ; then
6834484e2cc7SPaolo Bonzini  echo "CONFIG_CURSES=y" >> $config_host_mak
68352373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
68362373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6837ab4e5602SJan Kiszkafi
6838099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
68392358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6840099d6b0fSRiku Voipiofi
684140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
684240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
684340ff6d7eSKevin Wolffi
68443ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
68452358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
68463ce34dfbSvibisreenivasanfi
6847c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6848c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6849c2882b96SRiku Voipiofi
6850751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6851751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6852751bcc39SMarc-André Lureaufi
6853955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6854955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6855955727d2SCortland Tölvafi
6856d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6857d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6858d0927938SUlrich Hechtfi
68593d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
68603d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
68613d4fa43eSKusanagi Kouichifi
6862b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6863b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6864b953f075SDenis V. Lunevfi
6865ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6866ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6867ed911435SKevin Wolffi
6868c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6869c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6870c727f47dSPeter Maydellfi
6871dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6872dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6873dace20dcSPeter Maydellfi
6874d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6875d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6876d0927938SUlrich Hechtfi
68774e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
68784e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
68794e0c6529SAlex Blighfi
6880cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6881cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6882cd758dd0SAlex Blighfi
68833b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
68843b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
68853b6edd16SPeter Maydellfi
68863b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
68873b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
68883b6edd16SPeter Maydellfi
6889a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6890a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6891a8fd1abaSPeter Maydellfi
689251834341SRiku Voipioif test "$timerfd" = "yes" ; then
689351834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
689451834341SRiku Voipiofi
68959af5c906SRiku Voipioif test "$setns" = "yes" ; then
68969af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
68979af5c906SRiku Voipiofi
689838860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
689938860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
690038860a03SAleksandar Markovicfi
69015a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
69025a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
69035a03cd00SAleksandar Markovicfi
6904db37dd89SAleksandar Markovicif test "$kcov" = "yes" ; then
6905db37dd89SAleksandar Markovic  echo "CONFIG_KCOV=y" >> $config_host_mak
6906db37dd89SAleksandar Markovicfi
69073b3f24adSaurel32if test "$inotify" = "yes" ; then
69082358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
69093b3f24adSaurel32fi
6910c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6911c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6912c05c7a73SRiku Voipiofi
6913401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6914401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6915401bc051SPeter Maydellfi
69165c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
69175c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
69185c99fa37SKeno Fischerfi
69198a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
69208a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
69218a792b03SJiufei Xuefi
69226ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
69236ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
69246ae9a1f4SJuan Quintelafi
69256ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
69266ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
69276ae9a1f4SJuan Quintelafi
6928769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6929484e2cc7SPaolo Bonzini  echo "CONFIG_CURL=y" >> $config_host_mak
6930b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
69316ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6932769ce76dSAlexander Graffi
69332e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
693498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
69358eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
69362e4d9fb1Saurel32fi
6937a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6938484e2cc7SPaolo Bonzini  echo "CONFIG_GTK=y" >> $config_host_mak
6939a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6940014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6941925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6942925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6943925a0400SGerd Hoffmann  fi
6944bbbf9bfbSStefan Weilfi
6945f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6946f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6947f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6948f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
694925a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
6950f876b765SMarc-André Lureaufi
6951a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6952ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6953ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6954a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
6955a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
6956ddbb0d09SDaniel P. Berrangefi
695791bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
695891bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
69591f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
69601f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
69611f923c70SLongpeng(Mike)  fi
696262893b67SDaniel P. Berrangefi
696391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
696491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6965becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6966a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
6967a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
6968ed754746SDaniel P. Berrangefi
6969e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
6970e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
6971e0576942SDaniel P. Berrangéfi
69729a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
69739a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
69749a2fd434SDaniel P. Berrangefi
69758953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
69768953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
69778953caf3SDaniel P. Berrangefi
6978559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6979559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6980559607eaSDaniel P. Berrangefi
6981e865b97fSChen Gangif test "$have_drm_h" = "yes" ; then
6982e865b97fSChen Gang  echo "HAVE_DRM_H=y" >> $config_host_mak
6983e865b97fSChen Gangfi
69846b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
69856b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
69866b39b063SEric Blakefi
69879df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
69889df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
69899df8b20dSThomas Huthfi
69902a4b472cSDavid CARLIERif test "$have_sys_signal_h" = "yes" ; then
69912a4b472cSDavid CARLIER    echo "HAVE_SYS_SIGNAL_H=y" >> $config_host_mak
69922a4b472cSDavid CARLIERfi
6993277abf15SJan Vesely
6994277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6995277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6996277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6997277abf15SJan Vesely# if this macro is set.
6998277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6999277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
7000277abf15SJan Veselyfi
70011efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
70021efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
70031efad060SFam Zhengfi
7004bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
7005bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
7006a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
7007e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
7008a4ccabcfSAnthony Liguorifi
70099d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
70109d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
70119d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
70129d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
70139d9e1521SGerd Hoffmannfi
7014e37630caSaliguoriif test "$xen" = "yes" ; then
70156dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
7016d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
7017582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
7018582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
7019e37630caSaliguorifi
70205c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
70215c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
70225c6c3a6cSChristoph Hellwigfi
7023c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
7024c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
7025c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
7026c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
7027c10dd856SAarushi Mehtafi
7028758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
7029758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
7030ec0d5893SMarc-André Lureau  echo "LIBATTR_LIBS=$libattr_libs" >> $config_host_mak
7031758e8e38SVenkateswararao Jujjuri (JV)fi
70324f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
70334f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
70344f26f2b6SAvi Kivityfi
7035983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
7036758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
7037758e8e38SVenkateswararao Jujjuri (JV)fi
7038fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
7039fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
70401b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
70411b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
70421b0578f5SMurilo Opsfelder Araujo  fi
7043fe8fc5aeSPaolo Bonzinifi
70445e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
70455e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
70465e9be92dSNicholas Bellingerfi
7047af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
7048af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
7049af3bba76SPaolo Bonzinifi
7050af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
705156f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
705203ce5744SNikolay Nikolaevfi
7053108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
7054108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
7055108a6481SCindy Lufi
7056042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
7057042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
7058042cea27SGongleifi
7059fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
7060fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
70615fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
70625fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
70635fe97d88SStefano Garzarella  fi
7064fc0b9b0eSStefan Hajnoczifi
7065299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
7066299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
7067299e6f19SPaolo Bonzinifi
7068e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
7069e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7070e6a74868SMarc-André Lureaufi
7071108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
7072108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
7073108a6481SCindy Lufi
707498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
707598fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
707698fc1adaSDr. David Alan Gilbertfi
707777755340Sthsif test "$blobs" = "yes" ; then
707898ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
707977755340Sthsfi
7080bf9298b9Saliguoriif test "$iovec" = "yes" ; then
70812358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
7082bf9298b9Saliguorifi
7083ceb42de8Saliguoriif test "$preadv" = "yes" ; then
70842358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
7085ceb42de8Saliguorifi
7086e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
70873f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
70884a96337dSPaolo Bonzini  echo "FDT_CFLAGS=$fdt_cflags" >> $config_host_mak
70894a96337dSPaolo Bonzini  echo "FDT_LIBS=$fdt_ldflags $fdt_libs" >> $config_host_mak
7090f652e6afSaurel32fi
7091a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
7092a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7093a40161cbSPaolo Bonzinifi
7094dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
7095dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7096dcc38d1cSMarcelo Tosattifi
7097d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
7098d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
7099d339d766SRichard W.M. Jonesfi
7100b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
7101b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
71029195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
71039195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
71049195b2c2SStefan Weil  fi
7105b3f6ea7eSPaolo Bonzinifi
71065f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
71075f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
71085f6b9e8fSBlue Swirlfi
7109e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
7110e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
7111e78815a5SAndreas Färberfi
7112e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
7113e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7114e78815a5SAndreas Färberfi
71159bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
71169bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
71179bc5a719SAndreas Gustafssonfi
71185e5733e5SMarc-André Lureauif test "$zlib" != "no" ; then
71195e5733e5SMarc-André Lureau    echo "CONFIG_ZLIB=y" >> $config_host_mak
71205e5733e5SMarc-André Lureau    echo "ZLIB_CFLAGS=$zlib_cflags" >> $config_host_mak
71215e5733e5SMarc-André Lureau    echo "ZLIB_LIBS=$zlib_libs" >> $config_host_mak
71225e5733e5SMarc-André Lureaufi
7123cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
7124cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
71252634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
71262634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
7127cd4ec0b4SGerd Hoffmannfi
7128cd4ec0b4SGerd Hoffmann
71297b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
71307b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
71317b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
71327b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7133111a38b0SRobert Relyeafi
7134111a38b0SRobert Relyea
71352b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
71362b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7137b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7138b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
71392b2325ffSGerd Hoffmannfi
71402b2325ffSGerd Hoffmann
714169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
714269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7143cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7144cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
714569354a83SHans de Goedefi
714669354a83SHans de Goede
7147da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
7148da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
7149da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7150014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
7151014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7152014cb152SGerd Hoffmann  fi
715320ff075bSMichael Wallefi
715420ff075bSMichael Walle
7155d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
7156d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
7157d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7158d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7159d52c454aSMarc-André Lureaufi
7160d52c454aSMarc-André Lureau
7161d52c454aSMarc-André Lureau
71625a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
71635a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
71645a22ab71SYang Zhongfi
71655a22ab71SYang Zhong
716699f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
716799f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
716899f2dbd3SLiang Lifi
716999f2dbd3SLiang Li
71706b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
71716b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
71726b8cd447SRobert Hoofi
71736b8cd447SRobert Hoo
7174607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
7175607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
7176708eab42SMarc-André Lureau  echo "LZO_LIBS=$lzo_libs" >> $config_host_mak
7177607dacd0Sqiaonuohanfi
7178607dacd0Sqiaonuohan
7179607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
7180607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
7181708eab42SMarc-André Lureau  echo "SNAPPY_LIBS=$snappy_libs" >> $config_host_mak
7182607dacd0Sqiaonuohanfi
7183607dacd0Sqiaonuohan
71846b383c08SPeter Wuif test "$bzip2" = "yes" ; then
71856b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
71866b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
71876b383c08SPeter Wufi
71886b383c08SPeter Wu
718983bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
719083bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
719183bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
719283bc1f97SJulio Faraccofi
719383bc1f97SJulio Faracco
71943a678481SJuan Quintelaif test "$zstd" = "yes" ; then
71953a678481SJuan Quintela  echo "CONFIG_ZSTD=y" >> $config_host_mak
71965e5733e5SMarc-André Lureau  echo "ZSTD_CFLAGS=$zstd_cflags" >> $config_host_mak
71975e5733e5SMarc-André Lureau  echo "ZSTD_LIBS=$zstd_libs" >> $config_host_mak
71983a678481SJuan Quintelafi
71993a678481SJuan Quintela
7200c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
7201484e2cc7SPaolo Bonzini  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
72026ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
72036ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7204c589b249SRonnie Sahlbergfi
7205c589b249SRonnie Sahlberg
72066542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
7207484e2cc7SPaolo Bonzini  echo "CONFIG_LIBNFS=y" >> $config_host_mak
72084be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
72096542aa9cSPeter Lievenfi
72106542aa9cSPeter Lieven
7211f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
7212f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
7213c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7214c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7215f794573eSEduardo Otubofi
7216f794573eSEduardo Otubo
721783fb7adfSbellard# XXX: suppress that
72187d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
72192358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
72207d3505c5Sbellardfi
72217d3505c5Sbellard
72224d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
72234d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
72244d9310f4SDaniel P. Berrangefi
72253556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
72263556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
72273556c233SPaolo Bonzinifi
7228f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
7229484e2cc7SPaolo Bonzini  echo "CONFIG_RBD=y" >> $config_host_mak
72306ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7231f27aaf4bSChristian Brunnerfi
723220ff6c80SAnthony Liguori
72337c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
723470c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
723570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
723670c60c08SStefan Hajnoczielse
723770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
723870c60c08SStefan Hajnoczifi
7239d0e2fce5SAneesh Kumar K.V
72407d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
72417d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
72427d992e4dSPeter Lievenfi
72437d992e4dSPeter Lieven
7244f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
7245f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
7246f0d92b56SLongpeng(Mike)fi
7247f0d92b56SLongpeng(Mike)
7248d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
7249d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7250d2042378SAneesh Kumar K.Vfi
7251d2042378SAneesh Kumar K.V
7252e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
7253e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7254e06a765eSHarsh Prateek Borafi
7255e06a765eSHarsh Prateek Bora
72563f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
72573f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
72583f4349dcSKevin Wolffi
72593f4349dcSKevin Wolf
7260d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
7261d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7262d83414e1SMarc-André Lureaufi
7263d83414e1SMarc-André Lureau
72640aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
72650aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
72660aebab04SLingfeng Yangfi
72670aebab04SLingfeng Yang
72688ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
72698ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
72708ab1bf12SLuiz Capitulinofi
72718ab1bf12SLuiz Capitulino
727276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
727376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
727476a347e1SRichard Hendersonfi
727576a347e1SRichard Henderson
7276f540166bSRichard Hendersonif test "$int128" = "yes" ; then
7277f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
7278f540166bSRichard Hendersonfi
7279f540166bSRichard Henderson
72807ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
72817ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
72827ebee43eSRichard Hendersonfi
72837ebee43eSRichard Henderson
7284e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
7285e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7286e6cd4bb5SRichard Hendersonfi
7287e6cd4bb5SRichard Henderson
7288df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
7289df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7290df79b996SRichard Hendersonfi
7291df79b996SRichard Henderson
7292db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
7293db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7294db8aaae8SRichard Hendersonfi
7295db8aaae8SRichard Henderson
72961e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
72971e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
72981e6e9acaSRichard Hendersonfi
72991e6e9acaSRichard Henderson
7300eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
7301484e2cc7SPaolo Bonzini  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
73026ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
73036ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7304eb100396SBharata B Raofi
7305eb100396SBharata B Rao
7306d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
7307d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7308d85fa9ebSJeff Codyfi
7309d85fa9ebSJeff Cody
73100c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
73110c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
73120c14fb47SBharata B Raofi
73130c14fb47SBharata B Rao
7314df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
7315df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7316df3a429aSNiels de Vosfi
7317df3a429aSNiels de Vos
73187c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
73197c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
73207c815372SBharata B Raofi
73217c815372SBharata B Rao
7322e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7323e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7324e014dbe7SPrasanna Kumar Kaleverfi
7325e014dbe7SPrasanna Kumar Kalever
73260e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
73270e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
73280e3b891fSNiels de Vosfi
73290e3b891fSNiels de Vos
7330b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
7331484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
7332b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7333b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
73340a12ec87SRichard W.M. Jonesfi
73350a12ec87SRichard W.M. Jones
7336ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
7337ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7338ed1701c6SDr. David Alan Gilbertfi
7339ed1701c6SDr. David Alan Gilbert
73403b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
73413cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
73423b8acc11SPaolo Bonzinifi
73433b8acc11SPaolo Bonzini
73445b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
73455b808275SLluís Vilanovaif have_backend "nop"; then
73466d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
734722890ab5SPrerna Saxenafi
73485b808275SLluís Vilanovaif have_backend "simple"; then
73496d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
73506d8a764eSLluís  # Set the appropriate trace file.
7351953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
73529410b56cSPrerna Saxenafi
7353ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7354ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
73556d8a764eSLluísfi
73565b808275SLluís Vilanovaif have_backend "ust"; then
73576d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7358a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
7359a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
73606d8a764eSLluísfi
73615b808275SLluís Vilanovaif have_backend "dtrace"; then
73626d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
73636d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
73646d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
73656d8a764eSLluís  fi
7366c276b17dSDaniel P. Berrangefi
73675b808275SLluís Vilanovaif have_backend "ftrace"; then
7368781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7369781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7370781e9545SEiichi Tsukata  else
737121684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7372781e9545SEiichi Tsukata  fi
7373781e9545SEiichi Tsukatafi
73740a852417SPaul Durrantif have_backend "syslog"; then
73750a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
73760a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
73770a852417SPaul Durrant  else
73780a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
73790a852417SPaul Durrant  fi
73800a852417SPaul Durrantfi
73819410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
73829410b56cSPrerna Saxena
73832da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
73842da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7385392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
73862da776dbSMichael R. Hinesfi
73872da776dbSMichael R. Hines
738821ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
738921ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
739021ab34c9SMarcel Apfelbaumfi
739121ab34c9SMarcel Apfelbaum
7392575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7393575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7394575b22b1SLaurent Vivierfi
7395575b22b1SLaurent Vivier
7396ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7397ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7398ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7399ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7400ed279a06SKlim Kireevfi
7401ed279a06SKlim Kireev
7402a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7403a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7404a6b1d4c0SChanglong Xiefi
7405a6b1d4c0SChanglong Xie
74066a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
74076a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
74086a02c806SStefan Hajnoczifi
74096a02c806SStefan Hajnoczi
74104d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
74114d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
74124d04351fSChristopher Covingtonfi
74134d04351fSChristopher Covington
741449e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
741549e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
741649e00a18SAndreas Grapentinfi
741749e00a18SAndreas Grapentin
7418e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7419e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7420e674605fSTomáš Golembiovskýfi
7421db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
7422db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7423db1ed1abSRichard Hendersonfi
7424e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7425e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7426e0580342SKamil Rytarowskifi
7427e219c499SRichard Hendersonif test "$capstone" != "no" ; then
74288ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7429c9322ab5SMarc-André Lureau  echo "CAPSTONE_CFLAGS=$capstone_cflags" >> $config_host_mak
7430c9322ab5SMarc-André Lureau  echo "CAPSTONE_LIBS=$capstone_libs" >> $config_host_mak
74318ca80760SRichard Hendersonfi
7432ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7433ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7434ba59fb77SPaolo Bonzinifi
7435e0580342SKamil Rytarowski
74365c312079SDr. David Alan Gilbert# Hold two types of flag:
74375c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
74385c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7439479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
74405c312079SDr. David Alan Gilbert#                                     platform
7441479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
74425c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7443479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7444479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7445479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7446479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
74475c312079SDr. David Alan Gilbertfi
74485c312079SDr. David Alan Gilbert
744917824406SJunyan Heif test "$libpmem" = "yes" ; then
745017824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7451c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
7452c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
745317824406SJunyan Hefi
745417824406SJunyan He
745521b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
745621b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
7457c7c91a74SBruce Rogers  echo "LIBDAXCTL_LIBS=$libdaxctl_libs" >> $config_host_mak
745821b2eca6SJingqi Liufi
745921b2eca6SJingqi Liu
74602f740136SJeff Codyif test "$bochs" = "yes" ; then
74612f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
74622f740136SJeff Codyfi
74632f740136SJeff Codyif test "$cloop" = "yes" ; then
74642f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
74652f740136SJeff Codyfi
74662f740136SJeff Codyif test "$dmg" = "yes" ; then
74672f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
74682f740136SJeff Codyfi
74692f740136SJeff Codyif test "$qcow1" = "yes" ; then
74702f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
74712f740136SJeff Codyfi
74722f740136SJeff Codyif test "$vdi" = "yes" ; then
74732f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
74742f740136SJeff Codyfi
74752f740136SJeff Codyif test "$vvfat" = "yes" ; then
74762f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
74772f740136SJeff Codyfi
74782f740136SJeff Codyif test "$qed" = "yes" ; then
74792f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
74802f740136SJeff Codyfi
74812f740136SJeff Codyif test "$parallels" = "yes" ; then
74822f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
74832f740136SJeff Codyfi
74842f740136SJeff Codyif test "$sheepdog" = "yes" ; then
74852f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
74862f740136SJeff Codyfi
7487c9c8b88fSDavid CARLIERif test "$pty_h" = "yes" ; then
7488c9c8b88fSDavid CARLIER  echo "HAVE_PTY_H=y" >> $config_host_mak
7489c9c8b88fSDavid CARLIERfi
7490195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
7491195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
7492195588ccSDavid CARLIERfi
7493adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
7494086d5f75SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
7495adc28027SAlexander Bulekovfi
74962f740136SJeff Cody
749740e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
749840e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
749940e8c6f4SAlex Bennée    LIBS="-ldl $LIBS"
750026fffe29SEmilio G. Cota    # Copy the export object list to the build dir
750126fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
750226fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
750326fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
750426fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
750526fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
750626fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
750726fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
750826fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
750926fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
751026fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
751126fffe29SEmilio G. Cota    else
751226fffe29SEmilio G. Cota	error_exit \
751326fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
751426fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
751526fffe29SEmilio G. Cota    fi
751640e8c6f4SAlex Bennéefi
751740e8c6f4SAlex Bennée
7518f48e590aSAlex Bennéeif test -n "$gdb_bin" ; then
7519f48e590aSAlex Bennée    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
7520f48e590aSAlex Bennéefi
7521f48e590aSAlex Bennée
752254e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
752354e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
752492500362SAlexey Krasikov  if test "$have_keyutils" = "yes" ; then
752592500362SAlexey Krasikov    echo "CONFIG_TEST_SECRET_KEYRING=y" >> $config_host_mak
752692500362SAlexey Krasikov  fi
752754e7aac0SAlexey Krasikovfi
752854e7aac0SAlexey Krasikov
75295b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
753025211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
75315b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
753225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
75335b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
753425211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
7535e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
753625211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
753740d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
753825211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
7539e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
754025211446SPaolo Bonzini  QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
75415b5e3037SPaolo Bonzinielse
754225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
75435b5e3037SPaolo Bonzinifi
75445b5e3037SPaolo Bonzini
754598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7546804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7547804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
75481901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
75491901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
75501901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
755121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7552c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
75532eb054c2SPeter Maydellecho "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
755439d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
7555a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
7556804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7557a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7558859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
7559a31a8642SMichael S. Tsirkinfi
756083f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
75613c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7562804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
756345d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7564cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
75655f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
75663dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7567804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7568804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
75699f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
75704852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
7571daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
75729fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7573e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
7574086d5f75SPaolo Bonziniecho "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
757546eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7576a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
757711cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7578f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7579a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
7580a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
7581e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7582968b4db3SPaolo Bonzini  echo "SPARSE_CFLAGS = -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7583e39f0062SPaolo Bonzinifi
75848a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7585db5adeaaSPaolo Bonziniecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
75866969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7587e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
758873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
75893e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7590409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7591804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
7592484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
759317969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7594f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
759590246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
759690246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
759794dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
75981d728c39SBlue Swirlif test "$gcov" = "yes" ; then
75991d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
76001d728c39SBlue Swirlfi
7601804edf29SJuan Quintela
76023efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
76033efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
76043efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
76053efac6ebSTomáš Golembiovskýfi
7606adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
7607adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
7608adc28027SAlexander Bulekovfi
76093efac6ebSTomáš Golembiovský
761005dfa22bSPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" ; then
761105dfa22bSPhilippe Mathieu-Daudé  echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
761205dfa22bSPhilippe Mathieu-Daudéfi
761305dfa22bSPhilippe Mathieu-Daudé
7614b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
7615b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
7616b767d257SMarek Marczykowski-Góreckifi
7617b767d257SMarek Marczykowski-Górecki
76186efd7517SPeter Maydell# use included Linux headers
76196efd7517SPeter Maydellif test "$linux" = "yes" ; then
7620a307beb6SAndreas Färber  mkdir -p linux-headers
76216efd7517SPeter Maydell  case "$cpu" in
7622c72b26ecSRichard Henderson  i386|x86_64|x32)
762308312a63SPeter Maydell    linux_arch=x86
76246efd7517SPeter Maydell    ;;
7625f8378accSRichard Henderson  ppc|ppc64|ppc64le)
762608312a63SPeter Maydell    linux_arch=powerpc
76276efd7517SPeter Maydell    ;;
76286efd7517SPeter Maydell  s390x)
762908312a63SPeter Maydell    linux_arch=s390
763008312a63SPeter Maydell    ;;
76311f080313SClaudio Fontana  aarch64)
76321f080313SClaudio Fontana    linux_arch=arm64
76331f080313SClaudio Fontana    ;;
7634222e7d11SSanjay Lal  mips64)
7635222e7d11SSanjay Lal    linux_arch=mips
7636222e7d11SSanjay Lal    ;;
763708312a63SPeter Maydell  *)
763808312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
763908312a63SPeter Maydell    linux_arch="$cpu"
76406efd7517SPeter Maydell    ;;
76416efd7517SPeter Maydell  esac
764208312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
764308312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
764408312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
764508312a63SPeter Maydell    fi
76466efd7517SPeter Maydellfi
76476efd7517SPeter Maydell
764897a847bcSbellardfor target in $target_list; do
764997a847bcSbellardtarget_dir="$target"
765025be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
765189138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
765252bf9771Stony.nguyen@bt.comtarget_aligned_only="no"
765352bf9771Stony.nguyen@bt.comcase "$target_name" in
765452bf9771Stony.nguyen@bt.com  alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
765552bf9771Stony.nguyen@bt.com  target_aligned_only="yes"
765652bf9771Stony.nguyen@bt.com  ;;
765752bf9771Stony.nguyen@bt.comesac
765897a847bcSbellardtarget_bigendian="no"
7659c1799a84SPaolo Bonzinicase "$target_name" in
7660a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
766152bf9771Stony.nguyen@bt.com  target_bigendian="yes"
7662ea2d6a39SJuan Quintela  ;;
7663ea2d6a39SJuan Quintelaesac
766497a847bcSbellardtarget_softmmu="no"
7665997344f3Sbellardtarget_user_only="no"
7666831b7825Sthstarget_linux_user="no"
766784778508Sblueswir1target_bsd_user="no"
76689e407a85Spbrookcase "$target" in
7669c1799a84SPaolo Bonzini  ${target_name}-softmmu)
76709e407a85Spbrook    target_softmmu="yes"
76719e407a85Spbrook    ;;
7672c1799a84SPaolo Bonzini  ${target_name}-linux-user)
76739e407a85Spbrook    target_user_only="yes"
76749e407a85Spbrook    target_linux_user="yes"
76759e407a85Spbrook    ;;
7676c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
767784778508Sblueswir1    target_user_only="yes"
767884778508Sblueswir1    target_bsd_user="yes"
767984778508Sblueswir1    ;;
76809e407a85Spbrook  *)
768176ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
76829e407a85Spbrook    exit 1
76839e407a85Spbrook    ;;
76849e407a85Spbrookesac
7685831b7825Sths
768697a847bcSbellardmkdir -p $target_dir
768725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
768897a847bcSbellard
7689e5fe0c52Spbrookbflt="no"
7690ca759f9eSAlex Bennéemttcg="no"
769189138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
769256aebc89Spbrookgdb_xml_files=""
76937ba1e619Saliguori
7694c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
76956acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7696e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
76973a30446aSMarc-André LureauTARGET_SYSTBL_ABI=""
76983a30446aSMarc-André LureauTARGET_SYSTBL=""
7699e73aae67SJuan Quintela
7700c1799a84SPaolo Bonzinicase "$target_name" in
77012408a527Saurel32  i386)
77020a7fa00aSEmilio G. Cota    mttcg="yes"
77037b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
770428988117SLaurent Vivier    TARGET_SYSTBL_ABI=i386
77053a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_32.tbl
77062408a527Saurel32  ;;
77072408a527Saurel32  x86_64)
77086acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
77098d62f35aSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
77103a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_64.tbl
77110a7fa00aSEmilio G. Cota    mttcg="yes"
77127b0f97baSDoug Gale    gdb_xml_files="i386-64bit.xml"
77132408a527Saurel32  ;;
77142408a527Saurel32  alpha)
77155ee4f3c2SRichard Henderson    mttcg="yes"
77166116aea9SLaurent Vivier    TARGET_SYSTBL_ABI=common
77172408a527Saurel32  ;;
77182408a527Saurel32  arm|armeb)
7719b498c8a0SJuan Quintela    TARGET_ARCH=arm
77205bcb4986SLaurent Vivier    TARGET_SYSTBL_ABI=common,oabi
7721e5fe0c52Spbrook    bflt="yes"
7722ca759f9eSAlex Bennée    mttcg="yes"
7723c888f7e0SPeter Maydell    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
77242408a527Saurel32  ;;
7725722dd7beSMichael Weiser  aarch64|aarch64_be)
7726722dd7beSMichael Weiser    TARGET_ARCH=aarch64
77276a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
77286a49fa95SAlexander Graf    bflt="yes"
7729ca759f9eSAlex Bennée    mttcg="yes"
7730c888f7e0SPeter 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"
77316a49fa95SAlexander Graf  ;;
773242f3ff00SMichael Rolnik  avr)
773342f3ff00SMichael Rolnik    gdb_xml_files="avr-cpu.xml"
773442f3ff00SMichael Rolnik    target_compiler=$cross_cc_avr
773542f3ff00SMichael Rolnik  ;;
77362408a527Saurel32  cris)
77372408a527Saurel32  ;;
773861766fe9SRichard Henderson  hppa)
77397b93dab5SRichard Henderson    mttcg="yes"
77409566f4c6SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
774161766fe9SRichard Henderson  ;;
7742613a22c9SMichael Walle  lm32)
7743613a22c9SMichael Walle  ;;
77442408a527Saurel32  m68k)
77450938cda5Saurel32    bflt="yes"
7746a976ed3fSKONRAD Frederic    gdb_xml_files="cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml"
77475b85cae9SLaurent Vivier    TARGET_SYSTBL_ABI=common
77482408a527Saurel32  ;;
7749877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7750877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
7751ddf0c4cdSLaurent Vivier    TARGET_SYSTBL_ABI=common
7752d449561bSEdgar E. Iglesias    mttcg="yes"
775372b675caSEdgar E. Iglesias    bflt="yes"
7754be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
775572b675caSEdgar E. Iglesias  ;;
77562408a527Saurel32  mips|mipsel)
77570454728cSAleksandar Markovic    mttcg="yes"
7758b498c8a0SJuan Quintela    TARGET_ARCH=mips
775925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
7760c59716fcSLaurent Vivier    TARGET_SYSTBL_ABI=o32
77613a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_o32.tbl
77622408a527Saurel32  ;;
77632408a527Saurel32  mipsn32|mipsn32el)
77640454728cSAleksandar Markovic    mttcg="yes"
7765597e2cecSRichard Henderson    TARGET_ARCH=mips64
77666acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
776725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7768597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
7769686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n32
77703a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_n32.tbl
77712408a527Saurel32  ;;
77722408a527Saurel32  mips64|mips64el)
7773a092a955SAlex Bennée    mttcg="no"
7774b498c8a0SJuan Quintela    TARGET_ARCH=mips64
77756acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
777625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
7777686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n64
77783a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_n64.tbl
77792408a527Saurel32  ;;
7780d15a9c23SAnthony Green  moxie)
7781d15a9c23SAnthony Green  ;;
7782e671711cSMarek Vasut  nios2)
7783e671711cSMarek Vasut  ;;
77844a09d0bbSRichard Henderson  or1k)
7785e67db06eSJia Liu    TARGET_ARCH=openrisc
7786e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7787e67db06eSJia Liu  ;;
77882408a527Saurel32  ppc)
7789c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
779076a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
77912408a527Saurel32  ;;
77922408a527Saurel32  ppc64)
77936acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7794e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
779576a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
7796f0b0685dSNikunj A Dadhania    mttcg=yes
77971438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
77982408a527Saurel32  ;;
77999c35126cSDoug Kwan  ppc64le)
78009c35126cSDoug Kwan    TARGET_ARCH=ppc64
78019c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
78029c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
780376a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
7804f0b0685dSNikunj A Dadhania    mttcg=yes
78051438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
78069c35126cSDoug Kwan  ;;
78072408a527Saurel32  ppc64abi32)
7808b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
78096acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7810e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
781176a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
781225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
78131438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
78142408a527Saurel32  ;;
781525fa194bSMichael Clark  riscv32)
781625fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
781725fa194bSMichael Clark    TARGET_ABI_DIR=riscv
781825fa194bSMichael Clark    mttcg=yes
7819ae4a70c0SKeith Packard    gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
782025fa194bSMichael Clark  ;;
782125fa194bSMichael Clark  riscv64)
782225fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
782325fa194bSMichael Clark    TARGET_ABI_DIR=riscv
782425fa194bSMichael Clark    mttcg=yes
7825ae4a70c0SKeith Packard    gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
782625fa194bSMichael Clark  ;;
7827c8c35e5fSYoshinori Sato  rx)
7828c8c35e5fSYoshinori Sato    TARGET_ARCH=rx
7829c8c35e5fSYoshinori Sato    bflt="yes"
7830c8c35e5fSYoshinori Sato    target_compiler=$cross_cc_rx
7831c8c35e5fSYoshinori Sato    gdb_xml_files="rx-core.xml"
7832c8c35e5fSYoshinori Sato  ;;
78332408a527Saurel32  sh4|sh4eb)
7834b498c8a0SJuan Quintela    TARGET_ARCH=sh4
7835d0c832f6SLaurent Vivier    TARGET_SYSTBL_ABI=common
78364dbed897Spbrook    bflt="yes"
78372408a527Saurel32  ;;
78382408a527Saurel32  sparc)
7839bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
78402408a527Saurel32  ;;
78412408a527Saurel32  sparc64)
78426acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7843bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,64
78442408a527Saurel32  ;;
78452408a527Saurel32  sparc32plus)
7846b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
78476acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7848e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7849bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
785025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
78512408a527Saurel32  ;;
785224e804ecSAlexander Graf  s390x)
7853318f371dSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
785463685bc4SDavid Hildenbrand    mttcg=yes
785586158a2aSChristian 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"
785624e804ecSAlexander Graf  ;;
7857444e06b1SChen Gang  tilegx)
7858444e06b1SChen Gang  ;;
78595ecaa4edSPeter Crosthwaite  tricore)
78605ecaa4edSPeter Crosthwaite  ;;
7861d2fbca94SGuan Xuetao  unicore32)
7862d2fbca94SGuan Xuetao  ;;
7863cfa550c6SMax Filippov  xtensa|xtensaeb)
7864cfa550c6SMax Filippov    TARGET_ARCH=xtensa
7865a4a93592SLaurent Vivier    TARGET_SYSTBL_ABI=common
786602e33e9fSMax Filippov    bflt="yes"
78679fb40342SMax Filippov    mttcg="yes"
7868cfa550c6SMax Filippov  ;;
78692408a527Saurel32  *)
787076ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
78712408a527Saurel32  ;;
78722408a527Saurel32esac
78735e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
78745e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
78755e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
78765e8861a0SPaolo Bonzinifi
78773a30446aSMarc-André Lureauif [ "$TARGET_SYSTBL_ABI" != "" ] && [ "$TARGET_SYSTBL" = "" ]; then
78783a30446aSMarc-André Lureau  TARGET_SYSTBL=syscall.tbl
78793a30446aSMarc-André Lureaufi
78805e8861a0SPaolo Bonzini
788199afc91dSDaniel P. Berrangeupper() {
788299afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
788399afc91dSDaniel P. Berrange}
788499afc91dSDaniel P. Berrange
788589138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
788625be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7887c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
788825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7889e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7890e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7891e6e91b9cSJuan Quintelafi
789225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7893adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7894adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7895adfc3e91SStacey Sonfi
78964d6a835dSLaurent Vivierif [ "$TARGET_SYSTBL_ABI" != "" ]; then
78974d6a835dSLaurent Vivier    echo "TARGET_SYSTBL_ABI=$TARGET_SYSTBL_ABI" >> $config_target_mak
78983a30446aSMarc-André Lureau    echo "TARGET_SYSTBL=$TARGET_SYSTBL" >> $config_target_mak
78994d6a835dSLaurent Vivierfi
79003b6b7550SPaolo Bonzini
79013b6b7550SPaolo Bonziniif supported_xen_target $target; then
790225be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7903eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7904eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7905eb6fda0fSAnthony PERARD    fi
7906432d268cSJun Nakajimafi
79073b6b7550SPaolo Bonziniif supported_kvm_target $target; then
790825be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
7909c59249f9SJuan Quintelafi
79103b6b7550SPaolo Bonziniif supported_hax_target $target; then
7911b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7912b0cb0a66SVincent Palatinfi
7913c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7914c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7915c97d6d2cSSergio Andres Gomez Del Realfi
7916d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7917d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7918d661d9a4SJustin Terry (VM)fi
791952bf9771Stony.nguyen@bt.comif test "$target_aligned_only" = "yes" ; then
792052bf9771Stony.nguyen@bt.com  echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
792152bf9771Stony.nguyen@bt.comfi
7922de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
792325be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
792497a847bcSbellardfi
792597a847bcSbellardif test "$target_softmmu" = "yes" ; then
792625be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7927ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7928ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7929ca759f9eSAlex Bennée  fi
7930de83cd02Sbellardfi
7931997344f3Sbellardif test "$target_user_only" = "yes" ; then
793225be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7933a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
79342898503cSPaolo Bonzini  symlink "../qemu-$target_name" "$target_dir/qemu-$target_name"
79352898503cSPaolo Bonzinielse
79362898503cSPaolo Bonzini  symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name"
7937997344f3Sbellardfi
7938831b7825Sthsif test "$target_linux_user" = "yes" ; then
793925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7940831b7825Sthsfi
794156aebc89Spbrooklist=""
794256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
794356aebc89Spbrook  for x in $gdb_xml_files; do
7944c9322ab5SMarc-André Lureau    list="$list gdb-xml/$x"
794556aebc89Spbrook  done
794625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
79473d0f1517SJuan Quintelafi
7948de83cd02Sbellard
7949e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
795025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7951e5fe0c52Spbrookfi
795284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
795325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
795484778508Sblueswir1fi
79555b0753e0Sbellard
7956d75402b5SAlex Bennée
7957db5adeaaSPaolo Bonzini# generate QEMU_CFLAGS/QEMU_LDFLAGS for targets
7958fa282484SJuan Quintela
7959c765fcacSPeter Crosthwaitedisas_config() {
7960c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7961c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7962c765fcacSPeter Crosthwaite}
7963c765fcacSPeter Crosthwaite
796464656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
796564656024SJuan Quintela  case "$i" in
796664656024SJuan Quintela  alpha)
7967c765fcacSPeter Crosthwaite    disas_config "ALPHA"
796864656024SJuan Quintela  ;;
796982295d8aSRichard Henderson  aarch64)
797082295d8aSRichard Henderson    if test -n "${cxx}"; then
7971c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
797282295d8aSRichard Henderson    fi
797382295d8aSRichard Henderson  ;;
797464656024SJuan Quintela  arm)
7975c765fcacSPeter Crosthwaite    disas_config "ARM"
7976999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7977c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7978999b53ecSClaudio Fontana    fi
797964656024SJuan Quintela  ;;
798042f3ff00SMichael Rolnik  avr)
798142f3ff00SMichael Rolnik    disas_config "AVR"
798242f3ff00SMichael Rolnik  ;;
798364656024SJuan Quintela  cris)
7984c765fcacSPeter Crosthwaite    disas_config "CRIS"
798564656024SJuan Quintela  ;;
7986429b31a2SRichard Henderson  hppa)
7987429b31a2SRichard Henderson    disas_config "HPPA"
7988429b31a2SRichard Henderson  ;;
7989c72b26ecSRichard Henderson  i386|x86_64|x32)
7990c765fcacSPeter Crosthwaite    disas_config "I386"
799164656024SJuan Quintela  ;;
799279368f49SMichael Walle  lm32)
7993c765fcacSPeter Crosthwaite    disas_config "LM32"
799479368f49SMichael Walle  ;;
799564656024SJuan Quintela  m68k)
7996c765fcacSPeter Crosthwaite    disas_config "M68K"
799764656024SJuan Quintela  ;;
7998877fdc12SEdgar E. Iglesias  microblaze*)
7999c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
800064656024SJuan Quintela  ;;
800164656024SJuan Quintela  mips*)
8002c765fcacSPeter Crosthwaite    disas_config "MIPS"
800389a955e8SAleksandar Markovic    if test -n "${cxx}"; then
800489a955e8SAleksandar Markovic      disas_config "NANOMIPS"
800589a955e8SAleksandar Markovic    fi
800664656024SJuan Quintela  ;;
8007d15a9c23SAnthony Green  moxie*)
8008c765fcacSPeter Crosthwaite    disas_config "MOXIE"
8009d15a9c23SAnthony Green  ;;
8010e671711cSMarek Vasut  nios2)
8011e671711cSMarek Vasut    disas_config "NIOS2"
8012e671711cSMarek Vasut  ;;
80134a09d0bbSRichard Henderson  or1k)
8014c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
8015e67db06eSJia Liu  ;;
801664656024SJuan Quintela  ppc*)
8017c765fcacSPeter Crosthwaite    disas_config "PPC"
801864656024SJuan Quintela  ;;
8019c4f80543SAlistair Francis  riscv*)
802025fa194bSMichael Clark    disas_config "RISCV"
802125fa194bSMichael Clark  ;;
8022c8c35e5fSYoshinori Sato  rx)
8023c8c35e5fSYoshinori Sato    disas_config "RX"
8024c8c35e5fSYoshinori Sato  ;;
802524e804ecSAlexander Graf  s390*)
8026c765fcacSPeter Crosthwaite    disas_config "S390"
802764656024SJuan Quintela  ;;
802864656024SJuan Quintela  sh4)
8029c765fcacSPeter Crosthwaite    disas_config "SH4"
803064656024SJuan Quintela  ;;
803164656024SJuan Quintela  sparc*)
8032c765fcacSPeter Crosthwaite    disas_config "SPARC"
803364656024SJuan Quintela  ;;
8034cfa550c6SMax Filippov  xtensa*)
8035c765fcacSPeter Crosthwaite    disas_config "XTENSA"
8036cfa550c6SMax Filippov  ;;
803764656024SJuan Quintela  esac
803864656024SJuan Quinteladone
80399195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
8040c765fcacSPeter Crosthwaite  disas_config "TCI"
80419195b2c2SStefan Weilfi
804264656024SJuan Quintela
804397a847bcSbellarddone # for target in $targets
80447d13299dSbellard
8045e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
8046859aef02SPaolo Bonzini  subdirs="$subdirs dtc"
8047a540f158SPeter Crosthwaitefi
8048e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
8049859aef02SPaolo Bonzini  subdirs="$subdirs capstone"
8050e219c499SRichard Hendersonfi
8051859aef02SPaolo Bonziniecho "SUBDIRS=$subdirs" >> $config_host_mak
8052e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
8053e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
8054e219c499SRichard Hendersonfi
8055a540f158SPeter Crosthwaite
8056a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
8057a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
8058ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
8059a99d57bbSWanlong Gaofi
8060a99d57bbSWanlong Gao
8061fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
8062fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
8063fd0e6053SJohn Snowfi
8064fd0e6053SJohn Snow
80651e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
80661e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
80671e4f6065SDaniele Buonofi
80681e4f6065SDaniele Buono
8069e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
8070e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
8071e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
8072e29e5c6eSPeter Maydell# (these can be both files and directories).
8073e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
8074e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
8075e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
8076e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
8077e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
8078e29e5c6eSPeter Maydell# directory and symlink the directory instead.
80791cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
80801cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
8081b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
8082744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
80838db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
80842038f8c8SPaolo BonziniLINKS="Makefile"
8085e8f3bd71SMarc-André LureauLINKS="$LINKS tests/tcg/lm32/Makefile"
80863941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
8087ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
8088e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
80898db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
8090e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
8091e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
809239950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
809339950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
80948f8fd9edSCleber RosaLINKS="$LINKS python"
8095753d11f2SRichard Hendersonfor bios_file in \
8096753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
80973a631b8eSBin Meng    $source_path/pc-bios/*.elf \
8098225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
8099753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
8100753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
8101e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
8102753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
81034e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
810426ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
8105753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
8106753d11f2SRichard Hendersondo
8107e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
81087ea78b74SJan Kiszkadone
8109d1807a4fSPaolo Bonzinimkdir -p $DIRS
8110e29e5c6eSPeter Maydellfor f in $LINKS ; do
8111cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
8112f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
8113f9245e10SPeter Maydell    fi
81147d13299dSbellarddone
81151ad2134fSPaul Brook
81162038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
81172038f8c8SPaolo Bonzini  export $i
81182038f8c8SPaolo Bonzinidone
8119afc3a8f9SAlex Bennéeexport target_list source_path use_containers
81202038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
81212038f8c8SPaolo Bonzini
8122c34ebfdcSAnthony Liguori# temporary config to build submodules
81238db2a4fdSGerd Hoffmannfor rom in seabios; do
8124c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
812537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
8126c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8127cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
81285f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
8129c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
8130c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
81313dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
8132c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
8133a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
8134c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
81359f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
8136c34ebfdcSAnthony Liguoridone
8137c34ebfdcSAnthony Liguori
813876c7560aSMax Reitz# set up qemu-iotests in this build directory
813976c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
814076c7560aSMax Reitz
814176c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
814276c7560aSMax Reitzecho >> "$iotests_common_env"
814376c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
814476c7560aSMax Reitz
8145a5665051SPaolo Bonziniif test "$skip_meson" = no; then
8146fc929892SMarc-André Lureaucross="config-meson.cross.new"
8147fc929892SMarc-André Lureaumeson_quote() {
8148fc929892SMarc-André Lureau    echo "['$(echo $* | sed "s/ /','/g")']"
8149fc929892SMarc-André Lureau}
8150fc929892SMarc-André Lureau
8151fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
8152fc929892SMarc-André Lureauecho "[properties]" >> $cross
8153fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
8154fc929892SMarc-André Lureauecho "[binaries]" >> $cross
8155fc929892SMarc-André Lureauecho "c = $(meson_quote $cc)" >> $cross
8156fc929892SMarc-André Lureautest -n "$cxx" && echo "cpp = $(meson_quote $cxx)" >> $cross
8157fc929892SMarc-André Lureauecho "ar = $(meson_quote $ar)" >> $cross
8158fc929892SMarc-André Lureauecho "nm = $(meson_quote $nm)" >> $cross
8159fc929892SMarc-André Lureauecho "pkgconfig = $(meson_quote $pkg_config_exe)" >> $cross
8160fc929892SMarc-André Lureauecho "ranlib = $(meson_quote $ranlib)" >> $cross
8161fc929892SMarc-André Lureauecho "strip = $(meson_quote $strip)" >> $cross
8162fc929892SMarc-André Lureauecho "windres = $(meson_quote $windres)" >> $cross
8163fc929892SMarc-André Lureauif test -n "$cross_prefix"; then
8164fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
8165fc929892SMarc-André Lureau    # Hack: Meson expects an absolute path for the *build* machine
8166fc929892SMarc-André Lureau    # for the prefix, so add a slash in front of a Windows path that
8167fc929892SMarc-André Lureau    # includes a drive letter.
8168fc929892SMarc-André Lureau    #
8169fc929892SMarc-André Lureau    # See https://github.com/mesonbuild/meson/issues/7577.
8170fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
8171fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
8172fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
8173fc929892SMarc-André Lureau        case $prefix in
8174fc929892SMarc-André Lureau            ?:*) pre_prefix=/ ;;
8175fc929892SMarc-André Lureau        esac
8176fc929892SMarc-André Lureau    fi
8177fc929892SMarc-André Lureau    case "$ARCH" in
8178fc929892SMarc-André Lureau        i386|x86_64)
8179fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
8180fc929892SMarc-André Lureau            ;;
8181fc929892SMarc-André Lureau        ppc64le)
8182fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
8183fc929892SMarc-André Lureau            ;;
8184fc929892SMarc-André Lureau        *)
8185fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
8186fc929892SMarc-André Lureau            ;;
8187fc929892SMarc-André Lureau    esac
8188fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
8189fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
8190fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
8191fc929892SMarc-André Lureau    else
8192fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
8193fc929892SMarc-André Lureau    fi
8194fc929892SMarc-André Lureauelse
8195fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
8196fc929892SMarc-André Lureaufi
8197fc929892SMarc-André Lureaumv $cross config-meson.cross
8198fc929892SMarc-André Lureau
8199a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
8200a5665051SPaolo BonziniNINJA=$PWD/ninjatool $meson setup \
8201fc929892SMarc-André Lureau        --prefix "${pre_prefix}$prefix" \
8202fc929892SMarc-André Lureau        --libdir "${pre_prefix}$libdir" \
8203fc929892SMarc-André Lureau        --libexecdir "${pre_prefix}$libexecdir" \
8204fc929892SMarc-André Lureau        --bindir "${pre_prefix}$bindir" \
8205fc929892SMarc-André Lureau        --includedir "${pre_prefix}$includedir" \
8206fc929892SMarc-André Lureau        --datadir "${pre_prefix}$datadir" \
8207fc929892SMarc-André Lureau        --mandir "${pre_prefix}$mandir" \
8208fc929892SMarc-André Lureau        --sysconfdir "${pre_prefix}$sysconfdir" \
8209fc929892SMarc-André Lureau        --localstatedir "${pre_prefix}$local_statedir" \
8210a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
8211a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
8212a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
8213a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
8214da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
8215bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
821635be72baSPaolo Bonzini	-Dsdl=$sdl -Dsdl_image=$sdl_image \
8217a0b93237SPaolo Bonzini	-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
82184113f4cfSLaurent Vivier	-Dgettext=$gettext -Dxkbcommon=$xkbcommon \
8219fc929892SMarc-André Lureau        $cross_arg \
8220a5665051SPaolo Bonzini        "$PWD" "$source_path"
8221a5665051SPaolo Bonzini
8222a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
8223a5665051SPaolo Bonzini    error_exit "meson setup failed"
8224a5665051SPaolo Bonzinifi
8225a5665051SPaolo Bonzinitouch ninjatool.stamp
8226a5665051SPaolo Bonzinifi
8227a5665051SPaolo Bonzini
8228dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
8229dc655404SMichael S. Tsirkincat <<EOD >config.status
8230dc655404SMichael S. Tsirkin#!/bin/sh
8231dc655404SMichael S. Tsirkin# Generated by configure.
8232dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
8233dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
8234dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
8235dc655404SMichael S. TsirkinEOD
8236e811da7fSDaniel P. Berrangé
8237e811da7fSDaniel P. Berrangépreserve_env() {
8238e811da7fSDaniel P. Berrangé    envname=$1
8239e811da7fSDaniel P. Berrangé
8240e811da7fSDaniel P. Berrangé    eval envval=\$$envname
8241e811da7fSDaniel P. Berrangé
8242e811da7fSDaniel P. Berrangé    if test -n "$envval"
8243e811da7fSDaniel P. Berrangé    then
8244e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
8245e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
8246e811da7fSDaniel P. Berrangé    else
8247e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
8248e811da7fSDaniel P. Berrangé    fi
8249e811da7fSDaniel P. Berrangé}
8250e811da7fSDaniel P. Berrangé
8251e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
8252e811da7fSDaniel P. Berrangé# features/build target configure will detect
8253e811da7fSDaniel P. Berrangépreserve_env AR
8254e811da7fSDaniel P. Berrangépreserve_env AS
8255e811da7fSDaniel P. Berrangépreserve_env CC
8256e811da7fSDaniel P. Berrangépreserve_env CPP
8257e811da7fSDaniel P. Berrangépreserve_env CXX
8258e811da7fSDaniel P. Berrangépreserve_env INSTALL
8259e811da7fSDaniel P. Berrangépreserve_env LD
8260e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
8261e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
8262e811da7fSDaniel P. Berrangépreserve_env MAKE
8263e811da7fSDaniel P. Berrangépreserve_env NM
8264e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
8265e811da7fSDaniel P. Berrangépreserve_env PATH
8266e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
8267e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
8268e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
8269e811da7fSDaniel P. Berrangépreserve_env PYTHON
8270e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
8271e811da7fSDaniel P. Berrangépreserve_env SMBD
8272e811da7fSDaniel P. Berrangépreserve_env STRIP
8273e811da7fSDaniel P. Berrangépreserve_env WINDRES
8274e811da7fSDaniel P. Berrangé
8275dc655404SMichael S. Tsirkinprintf "exec" >>config.status
8276a5665051SPaolo Bonzinifor i in "$0" "$@"; do
8277a5665051SPaolo Bonzini  test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
8278a5665051SPaolo Bonzinidone
8279cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
8280dc655404SMichael S. Tsirkinchmod +x config.status
8281dc655404SMichael S. Tsirkin
82828cd05ab6SPeter Maydellrm -r "$TMPDIR1"
8283