xref: /openbmc/qemu/configure (revision 95c5f2de)
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
148cd05ab6SPeter Maydell# Temporary directory used for files created while
158cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
168cd05ab6SPeter Maydell# we can safely blow away any previous version of it
178cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
188cd05ab6SPeter Maydell# it when configure exits.)
198cd05ab6SPeter MaydellTMPDIR1="config-temp"
208cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
218cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
228cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
238cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
248cd05ab6SPeter Maydell    exit 1
257d13299dSbellardfi
267d13299dSbellard
278cd05ab6SPeter MaydellTMPB="qemu-conf"
288cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
2966518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
309c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
318cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
326969ec6cSJames ClarkeTMPMO="${TMPDIR1}/${TMPB}.mo"
3326fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
347d13299dSbellard
35da1d85e3SGerd Hoffmannrm -f config.log
369ac81bbbSmalc
37b48e3611SPeter Maydell# Print a helpful header at the top of config.log
38b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
39979ae168SPeter Maydellprintf "# Configured with:" >> config.log
40979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
41979ae168SPeter Maydellecho >> config.log
42b48e3611SPeter Maydellecho "#" >> config.log
43b48e3611SPeter Maydell
44d880a3baSPaolo Bonziniprint_error() {
45d880a3baSPaolo Bonzini    (echo
4676ad07a4SPeter Maydell    echo "ERROR: $1"
4776ad07a4SPeter Maydell    while test -n "$2"; do
4876ad07a4SPeter Maydell        echo "       $2"
4976ad07a4SPeter Maydell        shift
5076ad07a4SPeter Maydell    done
51d880a3baSPaolo Bonzini    echo) >&2
52d880a3baSPaolo Bonzini}
53d880a3baSPaolo Bonzini
54d880a3baSPaolo Bonzinierror_exit() {
55d880a3baSPaolo Bonzini    print_error "$@"
5676ad07a4SPeter Maydell    exit 1
5776ad07a4SPeter Maydell}
5876ad07a4SPeter Maydell
599c83ffd8SPeter Maydelldo_compiler() {
609c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
619c83ffd8SPeter Maydell    # is compiler binary to execute.
629c83ffd8SPeter Maydell    local compiler="$1"
639c83ffd8SPeter Maydell    shift
648bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
658bbe05d7SIan Jackson        echo >>config.log "
668bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
678bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
688bbe05d7SIan Jackson    '; fi
699c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
709c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
718dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
728dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
738dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
748dc38a78SPeter Maydell    # obvious to developers.
758dc38a78SPeter Maydell    if test "$werror" != "yes"; then
768dc38a78SPeter Maydell        return 0
778dc38a78SPeter Maydell    fi
788dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
798dc38a78SPeter Maydell    case "$*" in
808dc38a78SPeter Maydell        *-Werror*)
818dc38a78SPeter Maydell           return 0
828dc38a78SPeter Maydell        ;;
838dc38a78SPeter Maydell    esac
849c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
859c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
8676ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
8776ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8876ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8976ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
908dc38a78SPeter Maydell}
918dc38a78SPeter Maydell
929c83ffd8SPeter Maydelldo_cc() {
939c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
949c83ffd8SPeter Maydell}
959c83ffd8SPeter Maydell
969c83ffd8SPeter Maydelldo_cxx() {
979c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
989c83ffd8SPeter Maydell}
999c83ffd8SPeter Maydell
1009c83ffd8SPeter Maydellupdate_cxxflags() {
1019c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1029c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1039c83ffd8SPeter Maydell    # because they only make sense for C programs.
10453422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
10511cde1c8SBruno Dominguez
1069c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1079c83ffd8SPeter Maydell        case $arg in
1089c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1099c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1109c83ffd8SPeter Maydell                ;;
1117be41675SThomas Huth            -std=gnu99)
1127be41675SThomas Huth                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
1137be41675SThomas Huth                ;;
1149c83ffd8SPeter Maydell            *)
1159c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1169c83ffd8SPeter Maydell                ;;
1179c83ffd8SPeter Maydell        esac
1189c83ffd8SPeter Maydell    done
1199c83ffd8SPeter Maydell}
1209c83ffd8SPeter Maydell
12152166aa0SJuan Quintelacompile_object() {
122fd0e6053SJohn Snow  local_cflags="$1"
123fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
12452166aa0SJuan Quintela}
12552166aa0SJuan Quintela
12652166aa0SJuan Quintelacompile_prog() {
12752166aa0SJuan Quintela  local_cflags="$1"
12852166aa0SJuan Quintela  local_ldflags="$2"
1298dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
13052166aa0SJuan Quintela}
13152166aa0SJuan Quintela
13211568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
13311568d6dSPaolo Bonzinisymlink() {
13472b8b5a1SStefan Weil  rm -rf "$2"
135ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
13672b8b5a1SStefan Weil  ln -s "$1" "$2"
13711568d6dSPaolo Bonzini}
13811568d6dSPaolo Bonzini
1390dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1400dba6195SLoïc Minier# executable or a builtin)
1410dba6195SLoïc Minierhas() {
1420dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1430dba6195SLoïc Minier}
1440dba6195SLoïc Minier
1450dba6195SLoïc Minier# search for an executable in PATH
1460dba6195SLoïc Minierpath_of() {
1470dba6195SLoïc Minier    local_command="$1"
1480dba6195SLoïc Minier    local_ifs="$IFS"
1490dba6195SLoïc Minier    local_dir=""
1500dba6195SLoïc Minier
1510dba6195SLoïc Minier    # pathname has a dir component?
1520dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1530dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1540dba6195SLoïc Minier            echo "$local_command"
1550dba6195SLoïc Minier            return 0
1560dba6195SLoïc Minier        fi
1570dba6195SLoïc Minier    fi
1580dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1590dba6195SLoïc Minier        return 1
1600dba6195SLoïc Minier    fi
1610dba6195SLoïc Minier
1620dba6195SLoïc Minier    IFS=:
1630dba6195SLoïc Minier    for local_dir in $PATH; do
1640dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1650dba6195SLoïc Minier            echo "$local_dir/$local_command"
1660dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1670dba6195SLoïc Minier            return 0
1680dba6195SLoïc Minier        fi
1690dba6195SLoïc Minier    done
1700dba6195SLoïc Minier    # not found
1710dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1720dba6195SLoïc Minier    return 1
1730dba6195SLoïc Minier}
1740dba6195SLoïc Minier
1755b808275SLluís Vilanovahave_backend () {
1765b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1775b808275SLluís Vilanova}
1785b808275SLluís Vilanova
1793b6b7550SPaolo Bonziniglob() {
1803b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1813b6b7550SPaolo Bonzini}
1823b6b7550SPaolo Bonzini
1833b6b7550SPaolo Bonzinisupported_hax_target() {
1843b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1853b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1863b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1873b6b7550SPaolo Bonzini        i386|x86_64)
1883b6b7550SPaolo Bonzini            return 0
1893b6b7550SPaolo Bonzini        ;;
1903b6b7550SPaolo Bonzini    esac
1913b6b7550SPaolo Bonzini    return 1
1923b6b7550SPaolo Bonzini}
1933b6b7550SPaolo Bonzini
1943b6b7550SPaolo Bonzinisupported_kvm_target() {
1953b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1963b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1973b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1983b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1993b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
2003b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
2013b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
202f8378accSRichard Henderson        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
2033b6b7550SPaolo Bonzini        s390x:s390x)
2043b6b7550SPaolo Bonzini            return 0
2053b6b7550SPaolo Bonzini        ;;
2063b6b7550SPaolo Bonzini    esac
2073b6b7550SPaolo Bonzini    return 1
2083b6b7550SPaolo Bonzini}
2093b6b7550SPaolo Bonzini
2103b6b7550SPaolo Bonzinisupported_xen_target() {
2113b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2123b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
213b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
214b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
215b5ed2e11SPaolo Bonzini        i386|x86_64)
2163b6b7550SPaolo Bonzini            return 0
2173b6b7550SPaolo Bonzini        ;;
2183b6b7550SPaolo Bonzini    esac
2193b6b7550SPaolo Bonzini    return 1
2203b6b7550SPaolo Bonzini}
2213b6b7550SPaolo Bonzini
222c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
223c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
224c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
225c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
226c97d6d2cSSergio Andres Gomez Del Real        x86_64)
227c97d6d2cSSergio Andres Gomez Del Real            return 0
228c97d6d2cSSergio Andres Gomez Del Real        ;;
229c97d6d2cSSergio Andres Gomez Del Real    esac
230c97d6d2cSSergio Andres Gomez Del Real    return 1
231c97d6d2cSSergio Andres Gomez Del Real}
232c97d6d2cSSergio Andres Gomez Del Real
233d661d9a4SJustin Terry (VM)supported_whpx_target() {
234d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
235d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
236d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
237d661d9a4SJustin Terry (VM)        i386|x86_64)
238d661d9a4SJustin Terry (VM)            return 0
239d661d9a4SJustin Terry (VM)        ;;
240d661d9a4SJustin Terry (VM)    esac
241d661d9a4SJustin Terry (VM)    return 1
242d661d9a4SJustin Terry (VM)}
243d661d9a4SJustin Terry (VM)
244d880a3baSPaolo Bonzinisupported_target() {
245d880a3baSPaolo Bonzini    case "$1" in
246d880a3baSPaolo Bonzini        *-softmmu)
247d880a3baSPaolo Bonzini            ;;
248d880a3baSPaolo Bonzini        *-linux-user)
249d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
250d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
251d880a3baSPaolo Bonzini                return 1
252d880a3baSPaolo Bonzini            fi
253d880a3baSPaolo Bonzini            ;;
254d880a3baSPaolo Bonzini        *-bsd-user)
255d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
256d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
257d880a3baSPaolo Bonzini                return 1
258d880a3baSPaolo Bonzini            fi
259d880a3baSPaolo Bonzini            ;;
260d880a3baSPaolo Bonzini        *)
261d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
262d880a3baSPaolo Bonzini            return 1
263d880a3baSPaolo Bonzini            ;;
264d880a3baSPaolo Bonzini    esac
265b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
266b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
267b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
268b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
269c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
270d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
271b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
272b3f6ea7eSPaolo Bonzini    return 1
273d880a3baSPaolo Bonzini}
274d880a3baSPaolo Bonzini
275e9a3591fSChristian Borntraeger
276e9a3591fSChristian Borntraegerld_has() {
277e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
278e9a3591fSChristian Borntraeger}
279e9a3591fSChristian Borntraeger
28079d77bcdSPeter Maydell# make source path absolute
28114211825SAntonio Ospitesource_path=$(cd "$(dirname -- "$0")"; pwd)
28214211825SAntonio Ospite
2834ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2844ace32e2SAntonio Ospitethen
2854ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2864ace32e2SAntonio Ospitefi
2874ace32e2SAntonio Ospite
28814211825SAntonio Ospite# default parameters
2892ff6b91eSJuan Quintelacpu=""
290a31a8642SMichael S. Tsirkiniasl="iasl"
2911e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
29243ce4dfeSbellardstatic="no"
2937d13299dSbellardcross_prefix=""
2940c58ac1cSmalcaudio_drv_list=""
295b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
296b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
297e49d021eSPeter Maydellhost_cc="cc"
29802f9135bSDaniel P. Berrangélibs_cpu=""
29973da375eSJuan Quintelalibs_softmmu=""
3003e2e0e6bSJuan Quintelalibs_tools=""
301d5631638Smalcaudio_win_int=""
302957f1f99SMichael Rothlibs_qga=""
3035bc62e01SGerd Hoffmanndebug_info="yes"
30463678e17SSteven Noonanstack_protector=""
305ac0df51dSaliguori
30692712822SDaniel P. Berrangeif test -e "$source_path/.git"
30792712822SDaniel P. Berrangethen
308f62bbee5SDaniel P. Berrange    git_update=yes
30992712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
3103ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3113ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
31292712822SDaniel P. Berrangeelse
313f62bbee5SDaniel P. Berrange    git_update=no
314aef45d51SDaniel P. Berrange    git_submodules=""
3155c0ef67aSDaniel P. Berrangé
3165c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3175c0ef67aSDaniel P. Berrangé    then
3185c0ef67aSDaniel P. Berrangé        echo
3195c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3205c0ef67aSDaniel P. Berrangé        echo
3215c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3225c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3235c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3245c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3255c0ef67aSDaniel P. Berrangé        echo
326a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
3275c0ef67aSDaniel P. Berrangé        echo
3285c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3295c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3305c0ef67aSDaniel P. Berrangé        echo
3315c0ef67aSDaniel P. Berrangé        exit 1
3325c0ef67aSDaniel P. Berrangé    fi
33392712822SDaniel P. Berrangefi
334cc84d63aSDaniel P. Berrangegit="git"
335ac0df51dSaliguori
336afb63ebdSStefan Weil# Don't accept a target_list environment variable.
337afb63ebdSStefan Weilunset target_list
338447e133fSAlex Bennéeunset target_list_exclude
339377529c0SPaolo Bonzini
340377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
341377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
342377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
343377529c0SPaolo Bonzini#              unless --disable-foo is given
344377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
345377529c0SPaolo Bonzini#              feature will searched for,
346377529c0SPaolo Bonzini#              if not found, configure exits with error
347377529c0SPaolo Bonzini#
348377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
349377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
350377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
351377529c0SPaolo Bonzini
352377529c0SPaolo Bonzinibrlapi=""
353377529c0SPaolo Bonzinicurl=""
354377529c0SPaolo Bonzinicurses=""
355377529c0SPaolo Bonzinidocs=""
356377529c0SPaolo Bonzinifdt=""
35758952137SVincenzo Maffionenetmap="no"
358377529c0SPaolo Bonzinisdl=""
359a442fe2fSDaniel P. Berrangésdl_image=""
360983eef5aSMeador Ingevirtfs=""
361fe8fc5aeSPaolo Bonzinimpath=""
362821601eaSJes Sorensenvnc="yes"
363377529c0SPaolo Bonzinisparse="no"
364377529c0SPaolo Bonzinivde=""
365377529c0SPaolo Bonzinivnc_sasl=""
366377529c0SPaolo Bonzinivnc_jpeg=""
367377529c0SPaolo Bonzinivnc_png=""
3686a021536SGerd Hoffmannxkbcommon=""
369377529c0SPaolo Bonzinixen=""
370d5b93ddfSAnthony PERARDxen_ctrl_version=""
371eb6fda0fSAnthony PERARDxen_pci_passthrough=""
372377529c0SPaolo Bonzinilinux_aio=""
37347e98658SCorey Bryantcap_ng=""
374377529c0SPaolo Bonziniattr=""
3754f26f2b6SAvi Kivitylibattr=""
376377529c0SPaolo Bonzinixfs=""
377b3f6ea7eSPaolo Bonzinitcg="yes"
378a40161cbSPaolo Bonzinimembarrier=""
379299e6f19SPaolo Bonzinivhost_net=""
380299e6f19SPaolo Bonzinivhost_crypto=""
381299e6f19SPaolo Bonzinivhost_scsi=""
382299e6f19SPaolo Bonzinivhost_vsock=""
383e6a74868SMarc-André Lureauvhost_user=""
38498fc1adaSDr. David Alan Gilbertvhost_user_fs=""
385d41a75a2SBradkvm="no"
386b0cb0a66SVincent Palatinhax="no"
387c97d6d2cSSergio Andres Gomez Del Realhvf="no"
388d661d9a4SJustin Terry (VM)whpx="no"
3892da776dbSMichael R. Hinesrdma=""
39021ab34c9SMarcel Apfelbaumpvrdma=""
391377529c0SPaolo Bonzinigprof="no"
392377529c0SPaolo Bonzinidebug_tcg="no"
393377529c0SPaolo Bonzinidebug="no"
394247724cbSMarc-André Lureausanitizers="no"
395b553a042SJohn Snowfortify_source=""
396377529c0SPaolo Bonzinistrip_opt="yes"
3979195b2c2SStefan Weiltcg_interpreter="no"
398377529c0SPaolo Bonzinibigendian="no"
399377529c0SPaolo Bonzinimingw32="no"
4001d728c39SBlue Swirlgcov="no"
4011d728c39SBlue Swirlgcov_tool="gcov"
402377529c0SPaolo BonziniEXESUF=""
40317969268SFam ZhengDSOSUF=".so"
40417969268SFam ZhengLDFLAGS_SHARED="-shared"
40517969268SFam Zhengmodules="no"
406377529c0SPaolo Bonziniprefix="/usr/local"
407377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
408528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
4093d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
410850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
411377529c0SPaolo Bonzinibindir="\${prefix}/bin"
4123aa5d2beSAlon Levylibdir="\${prefix}/lib"
4138bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
4140f94d6daSAlon Levyincludedir="\${prefix}/include"
415377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
416785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
417377529c0SPaolo Bonziniconfsuffix="/qemu"
418675b9b53SMarc-André Lureauslirp=""
419377529c0SPaolo Bonzinioss_lib=""
420377529c0SPaolo Bonzinibsd="no"
421377529c0SPaolo Bonzinilinux="no"
422377529c0SPaolo Bonzinisolaris="no"
423377529c0SPaolo Bonziniprofiler="no"
424377529c0SPaolo Bonzinicocoa="no"
425377529c0SPaolo Bonzinisoftmmu="yes"
426377529c0SPaolo Bonzinilinux_user="no"
427377529c0SPaolo Bonzinibsd_user="no"
428377529c0SPaolo Bonziniblobs="yes"
42905dfa22bSPhilippe Mathieu-Daudéedk2_blobs="no"
430377529c0SPaolo Bonzinipkgversion=""
43140d6444eSAvi Kivitypie=""
4323556c233SPaolo Bonziniqom_cast_debug="yes"
433baf86d6bSPaolo Bonzinitrace_backends="log"
434377529c0SPaolo Bonzinitrace_file="trace"
435377529c0SPaolo Bonzinispice=""
436377529c0SPaolo Bonzinirbd=""
4377b02f544SMarc-André Lureausmartcard=""
4382b2325ffSGerd Hoffmannlibusb=""
43969354a83SHans de Goedeusb_redir=""
440da076ffeSGerd Hoffmannopengl=""
441014cb152SGerd Hoffmannopengl_dmabuf="no"
4425dd89908SRichard Hendersoncpuid_h="no"
44386583a07SLiam Merwickavx2_opt=""
4441ece9905SAlon Levyzlib="yes"
4458ca80760SRichard Hendersoncapstone=""
446b25c9dffSStefan Weillzo=""
447b25c9dffSStefan Weilsnappy=""
4486b383c08SPeter Wubzip2=""
44983bc1f97SJulio Faraccolzfse=""
450e8ef31a3SMichael Tokarevguest_agent=""
451d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
45250cbebb9SMichael Rothguest_agent_ntddscsi="no"
4539dacf32dSYossi Hindinguest_agent_msi=""
454d9840e25STomoki Sekiyamavss_win32_sdk=""
455d9840e25STomoki Sekiyamawin_sdk="no"
4564b1c11fdSDaniel P. Berrangewant_tools="yes"
457c589b249SRonnie Sahlberglibiscsi=""
4586542aa9cSPeter Lievenlibnfs=""
459519175a2SAlex Barcelocoroutine=""
46070c60c08SStefan Hajnoczicoroutine_pool=""
4617d992e4dSPeter Lievendebug_stack_usage="no"
462f0d92b56SLongpeng(Mike)crypto_afalg="no"
463f794573eSEduardo Otuboseccomp=""
464eb100396SBharata B Raoglusterfs=""
465d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4660c14fb47SBharata B Raoglusterfs_discard="no"
467df3a429aSNiels de Vosglusterfs_fallocate="no"
4687c815372SBharata B Raoglusterfs_zerofill="no"
469e014dbe7SPrasanna Kumar Kaleverglusterfs_ftruncate_has_stat="no"
4700e3b891fSNiels de Vosglusterfs_iocb_has_stat="no"
471a4ccabcfSAnthony Liguorigtk=""
472925a0400SGerd Hoffmanngtk_gl="no"
473a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
474ddbb0d09SDaniel P. Berrangegnutls=""
47591bfcdb0SDaniel P. Berrangenettle=""
476dc2207afSDaniel P. Berrangénettle_xts="no"
47791bfcdb0SDaniel P. Berrangegcrypt=""
4781f923c70SLongpeng(Mike)gcrypt_hmac="no"
479e0576942SDaniel P. Berrangégcrypt_xts="no"
480e0576942SDaniel P. Berrangéqemu_private_xts="yes"
4818953caf3SDaniel P. Berrangeauth_pam=""
482bbbf9bfbSStefan Weilvte=""
4839d9e1521SGerd Hoffmannvirglrenderer=""
4847aaa6a16SPaolo Bonzinitpm=""
485b10d49d7SPino Toscanolibssh=""
486ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
487a99d57bbSWanlong Gaonuma=""
4882847b469SFam Zhengtcmalloc="no"
4897b01cb97SAlexandre Derumierjemalloc="no"
490a6b1d4c0SChanglong Xiereplication="yes"
491da92c3ffSAshish Mittalvxhs=""
4922f740136SJeff Codybochs="yes"
4932f740136SJeff Codycloop="yes"
4942f740136SJeff Codydmg="yes"
4952f740136SJeff Codyqcow1="yes"
4962f740136SJeff Codyvdi="yes"
4972f740136SJeff Codyvvfat="yes"
4982f740136SJeff Codyqed="yes"
4992f740136SJeff Codyparallels="yes"
5002f740136SJeff Codysheepdog="yes"
501ed279a06SKlim Kireevlibxml2=""
502ba59fb77SPaolo Bonzinidebug_mutex="no"
50317824406SJunyan Helibpmem=""
504f3494749SPaolo Bonzinidefault_devices="yes"
50540e8c6f4SAlex Bennéeplugins="no"
506377529c0SPaolo Bonzini
507898be3e0SPeter Maydellsupported_cpu="no"
508898be3e0SPeter Maydellsupported_os="no"
509fb59dabdSPeter Maydellbogus_os="no"
5105a22ab71SYang Zhongmalloc_trim=""
511898be3e0SPeter Maydell
512ac0df51dSaliguori# parse CC options first
513ac0df51dSaliguorifor opt do
51489138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
515ac0df51dSaliguori  case "$opt" in
516ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
517ac0df51dSaliguori  ;;
5183d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
519ac0df51dSaliguori  ;;
52083f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
52183f73fceSTomoki Sekiyama  ;;
5222ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5232ff6b91eSJuan Quintela  ;;
524de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
525e2a2ed06SJuan Quintela  ;;
52611cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
52711cde1c8SBruno Dominguez  ;;
528a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
529f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
530e2a2ed06SJuan Quintela  ;;
5315bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5325bc62e01SGerd Hoffmann  ;;
5335bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
5345bc62e01SGerd Hoffmann  ;;
535d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
536d75402b5SAlex Bennée  ;;
537d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
538d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
5392038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
540d422b2bcSAlex Bennée  ;;
541d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
5422038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
543d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
5442038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
545d75402b5SAlex Bennée  ;;
546ac0df51dSaliguori  esac
547ac0df51dSaliguoridone
548ac0df51dSaliguori# OS specific
549ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
55093148aa5SStefan Weil# we can eliminate its usage altogether.
551ac0df51dSaliguori
552e49d021eSPeter Maydell# Preferred compiler:
553e49d021eSPeter Maydell#  ${CC} (if set)
554e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
555e49d021eSPeter Maydell#  system compiler
556e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
557e49d021eSPeter Maydell  cc="$host_cc"
558e49d021eSPeter Maydellelse
559b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
560e49d021eSPeter Maydellfi
561e49d021eSPeter Maydell
56283f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
56383f73fceSTomoki Sekiyama  cxx="c++"
56483f73fceSTomoki Sekiyamaelse
56583f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
56683f73fceSTomoki Sekiyamafi
56783f73fceSTomoki Sekiyama
568b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
569cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5705f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5713dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
572b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
573b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5749f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5754852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
576b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
577b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
57817884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
57917884d7bSSergei Trofimovichquery_pkg_config() {
58017884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
58117884d7bSSergei Trofimovich}
58217884d7bSSergei Trofimovichpkg_config=query_pkg_config
58347c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
584ac0df51dSaliguori
58545d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
58645d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
58745d285abSPeter Maydell
588be17dc90SMichael S. Tsirkin# default flags for all hosts
5892d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5902d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5912d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5922d31515bSPeter Maydell# provides these semantics.)
5937be41675SThomas HuthQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
594f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
595c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
596be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5979edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
59853422040SPaolo BonziniQEMU_INCLUDES="$QEMU_INCLUDES -iquote \$(SRC_PATH)/disas/libvixl"
5995bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
6005bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
601be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
6025bc62e01SGerd Hoffmannfi
603be17dc90SMichael S. Tsirkin
604cab00a5aSMichael S. Tsirkin# running configure in the source tree?
605cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
606cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
607cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
608cab00a5aSMichael S. Tsirkinelse
609cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
610cab00a5aSMichael S. Tsirkinfi
611cab00a5aSMichael S. Tsirkin
612ac0df51dSaliguoricheck_define() {
613ac0df51dSaliguoricat > $TMPC <<EOF
614ac0df51dSaliguori#if !defined($1)
615fd786e1aSPeter Maydell#error $1 not defined
616ac0df51dSaliguori#endif
617ac0df51dSaliguoriint main(void) { return 0; }
618ac0df51dSaliguoriEOF
61952166aa0SJuan Quintela  compile_object
620ac0df51dSaliguori}
621ac0df51dSaliguori
622307119e7SGerd Hoffmanncheck_include() {
623307119e7SGerd Hoffmanncat > $TMPC <<EOF
624307119e7SGerd Hoffmann#include <$1>
625307119e7SGerd Hoffmannint main(void) { return 0; }
626307119e7SGerd HoffmannEOF
627307119e7SGerd Hoffmann  compile_object
628307119e7SGerd Hoffmann}
629307119e7SGerd Hoffmann
63093b25869SJohn Snowwrite_c_skeleton() {
63193b25869SJohn Snow    cat > $TMPC <<EOF
63293b25869SJohn Snowint main(void) { return 0; }
63393b25869SJohn SnowEOF
63493b25869SJohn Snow}
63593b25869SJohn Snow
636bbea4050SPeter Maydellif check_define __linux__ ; then
637bbea4050SPeter Maydell  targetos="Linux"
638bbea4050SPeter Maydellelif check_define _WIN32 ; then
639bbea4050SPeter Maydell  targetos='MINGW32'
640bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
641bbea4050SPeter Maydell  targetos='OpenBSD'
642bbea4050SPeter Maydellelif check_define __sun__ ; then
643bbea4050SPeter Maydell  targetos='SunOS'
644bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
645bbea4050SPeter Maydell  targetos='Haiku'
646951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
647951fedfcSPeter Maydell  targetos='FreeBSD'
648951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
649951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
650951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
651951fedfcSPeter Maydell  targetos='DragonFly'
652951fedfcSPeter Maydellelif check_define __NetBSD__; then
653951fedfcSPeter Maydell  targetos='NetBSD'
654951fedfcSPeter Maydellelif check_define __APPLE__; then
655951fedfcSPeter Maydell  targetos='Darwin'
656bbea4050SPeter Maydellelse
657951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
658951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
659951fedfcSPeter Maydell  # be the result of a missing compiler.
660951fedfcSPeter Maydell  targetos='bogus'
661951fedfcSPeter Maydell  bogus_os='yes'
662bbea4050SPeter Maydellfi
663bbea4050SPeter Maydell
664bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
665bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
666bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
667bbea4050SPeter Maydell# the correct CPU with the --cpu option.
668bbea4050SPeter Maydellcase $targetos in
669bbea4050SPeter MaydellDarwin)
670bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
671bbea4050SPeter Maydell  # run 64-bit userspace code.
672bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
673bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
674bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
675bbea4050SPeter Maydell    cpu="x86_64"
676bbea4050SPeter Maydell  fi
677bbea4050SPeter Maydell  ;;
678bbea4050SPeter MaydellSunOS)
67989138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
680bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
681bbea4050SPeter Maydell    cpu="x86_64"
682bbea4050SPeter Maydell  fi
683bbea4050SPeter Maydellesac
684bbea4050SPeter Maydell
6852ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6862ff6b91eSJuan Quintela  # command line argument
6872ff6b91eSJuan Quintela  :
6882ff6b91eSJuan Quintelaelif check_define __i386__ ; then
689ac0df51dSaliguori  cpu="i386"
690ac0df51dSaliguorielif check_define __x86_64__ ; then
691c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
692c72b26ecSRichard Henderson    cpu="x32"
693c72b26ecSRichard Henderson  else
694ac0df51dSaliguori    cpu="x86_64"
695c72b26ecSRichard Henderson  fi
6963aa9bd6cSblueswir1elif check_define __sparc__ ; then
6973aa9bd6cSblueswir1  if check_define __arch64__ ; then
6983aa9bd6cSblueswir1    cpu="sparc64"
6993aa9bd6cSblueswir1  else
7003aa9bd6cSblueswir1    cpu="sparc"
7013aa9bd6cSblueswir1  fi
702fdf7ed96Smalcelif check_define _ARCH_PPC ; then
703fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
704f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
705f8378accSRichard Henderson      cpu="ppc64le"
706f8378accSRichard Henderson    else
707fdf7ed96Smalc      cpu="ppc64"
708f8378accSRichard Henderson    fi
709ac0df51dSaliguori  else
710fdf7ed96Smalc    cpu="ppc"
711fdf7ed96Smalc  fi
712afa05235SAurelien Jarnoelif check_define __mips__ ; then
713afa05235SAurelien Jarno  cpu="mips"
714d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
715d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
716d66ed0eaSAurelien Jarno    cpu="s390x"
717d66ed0eaSAurelien Jarno  else
718d66ed0eaSAurelien Jarno    cpu="s390"
719d66ed0eaSAurelien Jarno  fi
720c4f80543SAlistair Franciselif check_define __riscv ; then
721c4f80543SAlistair Francis  if check_define _LP64 ; then
722c4f80543SAlistair Francis    cpu="riscv64"
723c4f80543SAlistair Francis  else
724c4f80543SAlistair Francis    cpu="riscv32"
725c4f80543SAlistair Francis  fi
72621d89f84SPeter Maydellelif check_define __arm__ ; then
72721d89f84SPeter Maydell  cpu="arm"
7281f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7291f080313SClaudio Fontana  cpu="aarch64"
730fdf7ed96Smalcelse
73189138857SStefan Weil  cpu=$(uname -m)
732ac0df51dSaliguorifi
733ac0df51dSaliguori
734359bc95dSPeter MaydellARCH=
735359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
736359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7377d13299dSbellardcase "$cpu" in
738ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
739898be3e0SPeter Maydell    supported_cpu="yes"
740898be3e0SPeter Maydell  ;;
741f8378accSRichard Henderson  ppc64le)
742f8378accSRichard Henderson    ARCH="ppc64"
743f8378accSRichard Henderson    supported_cpu="yes"
744f8378accSRichard Henderson  ;;
7457d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
74697a847bcSbellard    cpu="i386"
747898be3e0SPeter Maydell    supported_cpu="yes"
7487d13299dSbellard  ;;
749aaa5fa14Saurel32  x86_64|amd64)
750aaa5fa14Saurel32    cpu="x86_64"
751898be3e0SPeter Maydell    supported_cpu="yes"
752aaa5fa14Saurel32  ;;
75321d89f84SPeter Maydell  armv*b|armv*l|arm)
75421d89f84SPeter Maydell    cpu="arm"
755898be3e0SPeter Maydell    supported_cpu="yes"
7567d13299dSbellard  ;;
7571f080313SClaudio Fontana  aarch64)
7581f080313SClaudio Fontana    cpu="aarch64"
759898be3e0SPeter Maydell    supported_cpu="yes"
7601f080313SClaudio Fontana  ;;
761afa05235SAurelien Jarno  mips*)
762afa05235SAurelien Jarno    cpu="mips"
763898be3e0SPeter Maydell    supported_cpu="yes"
764afa05235SAurelien Jarno  ;;
7653142255cSblueswir1  sparc|sun4[cdmuv])
766ae228531Sbellard    cpu="sparc"
7676499fd15SPeter Maydell    supported_cpu="yes"
768ae228531Sbellard  ;;
7697d13299dSbellard  *)
770359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
771359bc95dSPeter Maydell    ARCH=unknown
7727d13299dSbellard  ;;
7737d13299dSbellardesac
774359bc95dSPeter Maydellif test -z "$ARCH"; then
775359bc95dSPeter Maydell  ARCH="$cpu"
776359bc95dSPeter Maydellfi
777e2d52ad3SJuan Quintela
7787d13299dSbellard# OS specific
7790dbfc675SJuan Quintela
780adfc3e91SStacey Son# host *BSD for user mode
781adfc3e91SStacey SonHOST_VARIANT_DIR=""
782adfc3e91SStacey Son
7837d13299dSbellardcase $targetos in
78467b915a5SbellardMINGW32*)
78567b915a5Sbellard  mingw32="yes"
786b0cb0a66SVincent Palatin  hax="yes"
787299e6f19SPaolo Bonzini  vhost_user="no"
7883cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
789307119e7SGerd Hoffmann  if check_include dsound.h; then
7903cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
791307119e7SGerd Hoffmann  else
792307119e7SGerd Hoffmann    audio_drv_list=""
793307119e7SGerd Hoffmann  fi
794898be3e0SPeter Maydell  supported_os="yes"
79567b915a5Sbellard;;
7965c40d2bdSthsGNU/kFreeBSD)
797a167ba50SAurelien Jarno  bsd="yes"
7986a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7990bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
8005c40d2bdSths;;
8017d3505c5SbellardFreeBSD)
8027d3505c5Sbellard  bsd="yes"
8030db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8046a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8050bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
806f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
807f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
808a7764f15SEd Maste  # needed for kinfo_getproc
809a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
81058952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
811adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
812898be3e0SPeter Maydell  supported_os="yes"
8137d3505c5Sbellard;;
814c5e97233Sblueswir1DragonFly)
815c5e97233Sblueswir1  bsd="yes"
8160db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8176a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8180bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
819adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
820c5e97233Sblueswir1;;
8217d3505c5SbellardNetBSD)
8227d3505c5Sbellard  bsd="yes"
823604a5b99SKamil Rytarowski  hax="yes"
8240db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8256a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8260bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8278ef92a88Sblueswir1  oss_lib="-lossaudio"
828adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8293c2bdbc1SKamil Rytarowski  supported_os="yes"
8307d3505c5Sbellard;;
8317d3505c5SbellardOpenBSD)
8327d3505c5Sbellard  bsd="yes"
8330db4a067SPaolo Bonzini  make="${MAKE-gmake}"
834f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8350bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
836adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8370a773d55SBrad Smith  supported_os="yes"
8387d3505c5Sbellard;;
83983fb7adfSbellardDarwin)
84083fb7adfSbellard  bsd="yes"
84183fb7adfSbellard  darwin="yes"
842b0cb0a66SVincent Palatin  hax="yes"
843c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
84417969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8451b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
846a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
8470c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8481b0f9cc2Saliguori  fi
849fd677642Sths  cocoa="yes"
8506a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
85114382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8520c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8537973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
854a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
855a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
856a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
857adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
858898be3e0SPeter Maydell  supported_os="yes"
85983fb7adfSbellard;;
860ec530c81SbellardSunOS)
861ec530c81Sbellard  solaris="yes"
8620db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8630db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
864e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8656b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8666a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
8676b4d2ba1Sths  fi
868c2de5c91Smalc  audio_possible_drivers="oss sdl"
869d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
870d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
871d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
872d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
873a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
874560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
875560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
876560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
877ec530c81Sbellard;;
878179cf400SAndreas FärberHaiku)
879179cf400SAndreas Färber  haiku="yes"
880179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
881179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
882179cf400SAndreas Färber;;
883898be3e0SPeter MaydellLinux)
8847183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
8850bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8865327cf48Sbellard  linux="yes"
887831b7825Sths  linux_user="yes"
888af2be207SJan Kiszka  kvm="yes"
889e8d81a61SMao Zhongyi  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
890898be3e0SPeter Maydell  supported_os="yes"
8913efac6ebSTomáš Golembiovský  libudev="yes"
892898be3e0SPeter Maydell;;
8937d13299dSbellardesac
8947d13299dSbellard
8957d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
896b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
89784778508Sblueswir1    bsd_user="yes"
8987d3505c5Sbellard  fi
89908de3949SAndreas Färberfi
9007d3505c5Sbellard
9010db4a067SPaolo Bonzini: ${make=${MAKE-make}}
9020db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
903faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
904faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
905faf44142SDaniel P. Berrangé# we check that before python2
906faf44142SDaniel P. Berrangépython=
907faf44142SDaniel P. Berrangéfor binary in "${PYTHON-python3}" python python2
908faf44142SDaniel P. Berrangédo
909faf44142SDaniel P. Berrangé    if has "$binary"
910faf44142SDaniel P. Berrangé    then
911*95c5f2deSPaolo Bonzini        python=$(command -v "$binary")
912faf44142SDaniel P. Berrangé        break
913faf44142SDaniel P. Berrangé    fi
914faf44142SDaniel P. Berrangédone
915e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9160db4a067SPaolo Bonzini
9173c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9183c4a4d0dSPeter Maydellif has clang; then
9193c4a4d0dSPeter Maydell  objcc=clang
9203c4a4d0dSPeter Maydellelse
9213c4a4d0dSPeter Maydell  objcc="$cc"
9223c4a4d0dSPeter Maydellfi
9233c4a4d0dSPeter Maydell
9243457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
9253457a3f8SJuan Quintela  EXESUF=".exe"
92617969268SFam Zheng  DSOSUF=".dll"
92778e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
92878e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
929b965e8c5SPaolo Bonzini  LIBS="-lwinmm -lws2_32 $LIBS"
93093b25869SJohn Snow  write_c_skeleton;
931f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
932f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
933f7cf5d5bSStefan Weil  fi
934c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
935683035deSPaolo Bonzini  mandir="\${prefix}"
936528ae5b8SEduardo Habkost  datadir="\${prefix}"
937850da188SEduardo Habkost  qemu_docdir="\${prefix}"
938683035deSPaolo Bonzini  bindir="\${prefix}"
939683035deSPaolo Bonzini  sysconfdir="\${prefix}"
9405a699bbbSLaszlo Ersek  local_statedir=
941683035deSPaolo Bonzini  confsuffix=""
942105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9433457a3f8SJuan Quintelafi
9443457a3f8SJuan Quintela
945487fefdbSAnthony Liguoriwerror=""
94685aa5189Sbellard
9477d13299dSbellardfor opt do
94889138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9497d13299dSbellard  case "$opt" in
9502efc3265Sbellard  --help|-h) show_help=yes
9512efc3265Sbellard  ;;
95299123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
95399123e13SMike Frysinger  ;;
954b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9557d13299dSbellard  ;;
956b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
95732ce6337Sbellard  ;;
958ac0df51dSaliguori  --cross-prefix=*)
9597d13299dSbellard  ;;
960ac0df51dSaliguori  --cc=*)
9617d13299dSbellard  ;;
962b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
96383469015Sbellard  ;;
96483f73fceSTomoki Sekiyama  --cxx=*)
96583f73fceSTomoki Sekiyama  ;;
966e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
967e007dbecSMichael S. Tsirkin  ;;
9683c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9693c4a4d0dSPeter Maydell  ;;
970b1a550a0Spbrook  --make=*) make="$optarg"
9717d13299dSbellard  ;;
9726a882643Spbrook  --install=*) install="$optarg"
9736a882643Spbrook  ;;
974c886edfbSBlue Swirl  --python=*) python="$optarg"
975c886edfbSBlue Swirl  ;;
9761d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9771d728c39SBlue Swirl  ;;
978e2d8830eSBrad  --smbd=*) smbd="$optarg"
979e2d8830eSBrad  ;;
980e2a2ed06SJuan Quintela  --extra-cflags=*)
9817d13299dSbellard  ;;
98211cde1c8SBruno Dominguez  --extra-cxxflags=*)
98311cde1c8SBruno Dominguez  ;;
984e2a2ed06SJuan Quintela  --extra-ldflags=*)
9857d13299dSbellard  ;;
9865bc62e01SGerd Hoffmann  --enable-debug-info)
9875bc62e01SGerd Hoffmann  ;;
9885bc62e01SGerd Hoffmann  --disable-debug-info)
9895bc62e01SGerd Hoffmann  ;;
990d75402b5SAlex Bennée  --cross-cc-*)
991d75402b5SAlex Bennée  ;;
99217969268SFam Zheng  --enable-modules)
99317969268SFam Zheng      modules="yes"
99417969268SFam Zheng  ;;
9953aa88b31SStefan Hajnoczi  --disable-modules)
9963aa88b31SStefan Hajnoczi      modules="no"
9973aa88b31SStefan Hajnoczi  ;;
9982ff6b91eSJuan Quintela  --cpu=*)
9997d13299dSbellard  ;;
1000b1a550a0Spbrook  --target-list=*) target_list="$optarg"
1001447e133fSAlex Bennée                   if test "$target_list_exclude"; then
1002447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
1003447e133fSAlex Bennée                   fi
1004447e133fSAlex Bennée  ;;
1005447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
1006447e133fSAlex Bennée                   if test "$target_list"; then
1007447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
1008447e133fSAlex Bennée                   fi
1009de83cd02Sbellard  ;;
10105b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
10115b808275SLluís Vilanova  ;;
10125b808275SLluís Vilanova  # XXX: backwards compatibility
10135b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
101494a420b1SStefan Hajnoczi  ;;
101574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
10169410b56cSPrerna Saxena  ;;
1017f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1018f3494749SPaolo Bonzini  ;;
1019f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1020f3494749SPaolo Bonzini  ;;
10217d13299dSbellard  --enable-gprof) gprof="yes"
10227d13299dSbellard  ;;
10231d728c39SBlue Swirl  --enable-gcov) gcov="yes"
10241d728c39SBlue Swirl  ;;
102579427693SLoïc Minier  --static)
102679427693SLoïc Minier    static="yes"
102779427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
102817884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
102943ce4dfeSbellard  ;;
10300b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
10310b24e75fSPaolo Bonzini  ;;
10320b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
10330b24e75fSPaolo Bonzini  ;;
10343aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10353aa5d2beSAlon Levy  ;;
10368bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10378bf188aaSMichael Tokarev  ;;
10380f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10390f94d6daSAlon Levy  ;;
1040528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10410b24e75fSPaolo Bonzini  ;;
1042023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1043023d3d67SEduardo Habkost  ;;
1044850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10450b24e75fSPaolo Bonzini  ;;
1046ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
104707381cc1SAnthony Liguori  ;;
1048785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1049785c23aeSLuiz Capitulino  ;;
10503d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10513d5eecabSGerd Hoffmann  ;;
1052181ce1d0SOlaf Hering  --host=*|--build=*|\
1053181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1054785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1055023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1056023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1057023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1058023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1059023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1060023ddd74SMax Filippov    # lots of directory switches by default.
1061023ddd74SMax Filippov  ;;
106297a847bcSbellard  --disable-sdl) sdl="no"
106397a847bcSbellard  ;;
1064c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1065c4198157SJuan Quintela  ;;
1066a442fe2fSDaniel P. Berrangé  --disable-sdl-image) sdl_image="no"
1067a442fe2fSDaniel P. Berrangé  ;;
1068a442fe2fSDaniel P. Berrangé  --enable-sdl-image) sdl_image="yes"
1069a442fe2fSDaniel P. Berrangé  ;;
10703556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10713556c233SPaolo Bonzini  ;;
10723556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10733556c233SPaolo Bonzini  ;;
1074983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1075983eef5aSMeador Inge  ;;
1076983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1077983eef5aSMeador Inge  ;;
1078fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1079fe8fc5aeSPaolo Bonzini  ;;
1080fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1081fe8fc5aeSPaolo Bonzini  ;;
1082821601eaSJes Sorensen  --disable-vnc) vnc="no"
1083821601eaSJes Sorensen  ;;
1084821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1085821601eaSJes Sorensen  ;;
10862f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10872f6a1ab0Sblueswir1  ;;
10880c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10890c58ac1cSmalc  ;;
109089138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1091b64ec4e4SFam Zheng  ;;
109289138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1093eb852011SMarkus Armbruster  ;;
1094f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1095f8393946Saurel32  ;;
1096f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1097f8393946Saurel32  ;;
1098f3d08ee6SPaul Brook  --enable-debug)
1099f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1100f3d08ee6SPaul Brook      debug_tcg="yes"
11011fcc6d42SPeter Xu      debug_mutex="yes"
1102f3d08ee6SPaul Brook      debug="yes"
1103f3d08ee6SPaul Brook      strip_opt="no"
1104b553a042SJohn Snow      fortify_source="no"
1105f3d08ee6SPaul Brook  ;;
1106247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1107247724cbSMarc-André Lureau  ;;
1108247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1109247724cbSMarc-André Lureau  ;;
111003b4fe7dSaliguori  --enable-sparse) sparse="yes"
111103b4fe7dSaliguori  ;;
111203b4fe7dSaliguori  --disable-sparse) sparse="no"
111303b4fe7dSaliguori  ;;
11141625af87Saliguori  --disable-strip) strip_opt="no"
11151625af87Saliguori  ;;
11162f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
11172f9606b3Saliguori  ;;
1118ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1119ea784e3bSJuan Quintela  ;;
11202f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
11212f6f5c7aSCorentin Chary  ;;
11222f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
11232f6f5c7aSCorentin Chary  ;;
1124efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1125efe556adSCorentin Chary  ;;
1126efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1127efe556adSCorentin Chary  ;;
1128443f1376Sbellard  --disable-slirp) slirp="no"
1129c20709aaSbellard  ;;
11307c57bdd8SMarc-André Lureau  --enable-slirp=git) slirp="git"
11317c57bdd8SMarc-André Lureau  ;;
1132675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1133675b9b53SMarc-André Lureau  ;;
1134e0e6c8c0Saliguori  --disable-vde) vde="no"
11358a16d273Sths  ;;
1136dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1137dfb278bdSJuan Quintela  ;;
113858952137SVincenzo Maffione  --disable-netmap) netmap="no"
113958952137SVincenzo Maffione  ;;
114058952137SVincenzo Maffione  --enable-netmap) netmap="yes"
114158952137SVincenzo Maffione  ;;
1142e37630caSaliguori  --disable-xen) xen="no"
1143e37630caSaliguori  ;;
1144fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1145fc321b4bSJuan Quintela  ;;
1146eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1147eb6fda0fSAnthony PERARD  ;;
1148eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1149eb6fda0fSAnthony PERARD  ;;
11502e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
11512e4d9fb1Saurel32  ;;
11524ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
11534ffcedb6SJuan Quintela  ;;
11547ba1e619Saliguori  --disable-kvm) kvm="no"
11557ba1e619Saliguori  ;;
1156b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1157b31a0277SJuan Quintela  ;;
1158b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1159180fb750Szhanghailiang  ;;
1160b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1161180fb750Szhanghailiang  ;;
1162c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1163c97d6d2cSSergio Andres Gomez Del Real  ;;
1164c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1165c97d6d2cSSergio Andres Gomez Del Real  ;;
1166d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1167d661d9a4SJustin Terry (VM)  ;;
1168d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1169d661d9a4SJustin Terry (VM)  ;;
11709195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11719195b2c2SStefan Weil  ;;
11729195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11739195b2c2SStefan Weil  ;;
117447e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
117547e98658SCorey Bryant  ;;
117647e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
117747e98658SCorey Bryant  ;;
1178b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1179b3f6ea7eSPaolo Bonzini  ;;
1180b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1181b3f6ea7eSPaolo Bonzini  ;;
11825a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11835a22ab71SYang Zhong  ;;
11845a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11855a22ab71SYang Zhong  ;;
1186cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1187cd4ec0b4SGerd Hoffmann  ;;
1188cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1189cd4ec0b4SGerd Hoffmann  ;;
1190c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1191c589b249SRonnie Sahlberg  ;;
1192c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1193c589b249SRonnie Sahlberg  ;;
11946542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11956542aa9cSPeter Lieven  ;;
11966542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11976542aa9cSPeter Lieven  ;;
119805c2a3e7Sbellard  --enable-profiler) profiler="yes"
119905c2a3e7Sbellard  ;;
120014821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
120114821030SPavel Borzenkov  ;;
1202c2de5c91Smalc  --enable-cocoa)
1203c2de5c91Smalc      cocoa="yes" ;
120489138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
12055b0753e0Sbellard  ;;
1206cad25d69Spbrook  --disable-system) softmmu="no"
12070a8e90f4Spbrook  ;;
1208cad25d69Spbrook  --enable-system) softmmu="yes"
12090a8e90f4Spbrook  ;;
12100953a80fSZachary Amsden  --disable-user)
12110953a80fSZachary Amsden      linux_user="no" ;
12120953a80fSZachary Amsden      bsd_user="no" ;
12130953a80fSZachary Amsden  ;;
12140953a80fSZachary Amsden  --enable-user) ;;
1215831b7825Sths  --disable-linux-user) linux_user="no"
12160a8e90f4Spbrook  ;;
1217831b7825Sths  --enable-linux-user) linux_user="yes"
1218831b7825Sths  ;;
121984778508Sblueswir1  --disable-bsd-user) bsd_user="no"
122084778508Sblueswir1  ;;
122184778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
122284778508Sblueswir1  ;;
122340d6444eSAvi Kivity  --enable-pie) pie="yes"
122434005a00SKirill A. Shutemov  ;;
122540d6444eSAvi Kivity  --disable-pie) pie="no"
122634005a00SKirill A. Shutemov  ;;
122785aa5189Sbellard  --enable-werror) werror="yes"
122885aa5189Sbellard  ;;
122985aa5189Sbellard  --disable-werror) werror="no"
123085aa5189Sbellard  ;;
123163678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
123263678e17SSteven Noonan  ;;
123363678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
123463678e17SSteven Noonan  ;;
12354d3b6f6eSbalrog  --disable-curses) curses="no"
12364d3b6f6eSbalrog  ;;
1237c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1238c584a6d0SJuan Quintela  ;;
1239e08bb301SSamuel Thibault  --disable-iconv) iconv="no"
1240e08bb301SSamuel Thibault  ;;
1241e08bb301SSamuel Thibault  --enable-iconv) iconv="yes"
1242e08bb301SSamuel Thibault  ;;
1243769ce76dSAlexander Graf  --disable-curl) curl="no"
1244769ce76dSAlexander Graf  ;;
1245788c8196SJuan Quintela  --enable-curl) curl="yes"
1246788c8196SJuan Quintela  ;;
12472df87df7SJuan Quintela  --disable-fdt) fdt="no"
12482df87df7SJuan Quintela  ;;
12492df87df7SJuan Quintela  --enable-fdt) fdt="yes"
12502df87df7SJuan Quintela  ;;
12515c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12525c6c3a6cSChristoph Hellwig  ;;
12535c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12545c6c3a6cSChristoph Hellwig  ;;
1255758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1256758e8e38SVenkateswararao Jujjuri (JV)  ;;
1257758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1258758e8e38SVenkateswararao Jujjuri (JV)  ;;
1259a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1260a40161cbSPaolo Bonzini  ;;
1261a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1262a40161cbSPaolo Bonzini  ;;
126377755340Sths  --disable-blobs) blobs="no"
126477755340Sths  ;;
12657e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12664a19f1ecSpbrook  ;;
1267519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1268519175a2SAlex Barcelo  ;;
126970c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
127070c60c08SStefan Hajnoczi  ;;
127170c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
127270c60c08SStefan Hajnoczi  ;;
12737d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12747d992e4dSPeter Lieven  ;;
1275f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1276f0d92b56SLongpeng(Mike)  ;;
1277f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1278f0d92b56SLongpeng(Mike)  ;;
1279a25dba17SJuan Quintela  --disable-docs) docs="no"
128070ec5dc0SAnthony Liguori  ;;
1281a25dba17SJuan Quintela  --enable-docs) docs="yes"
128283a3ab8bSJuan Quintela  ;;
1283d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1284d5970055SMichael S. Tsirkin  ;;
1285d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1286d5970055SMichael S. Tsirkin  ;;
1287042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1288042cea27SGonglei  ;;
1289299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1290042cea27SGonglei  ;;
12915e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12925e9be92dSNicholas Bellinger  ;;
12935e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12945e9be92dSNicholas Bellinger  ;;
1295fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1296fc0b9b0eSStefan Hajnoczi  ;;
1297fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1298fc0b9b0eSStefan Hajnoczi  ;;
129998fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
130098fc1adaSDr. David Alan Gilbert  ;;
130198fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
130298fc1adaSDr. David Alan Gilbert  ;;
1303da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
130420ff075bSMichael Walle  ;;
1305da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
130620ff075bSMichael Walle  ;;
1307f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1308f27aaf4bSChristian Brunner  ;;
1309f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1310f27aaf4bSChristian Brunner  ;;
13118c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
13128c84cf11SSergei Trofimovich  ;;
13138c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
13148c84cf11SSergei Trofimovich  ;;
13157b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1316111a38b0SRobert Relyea  ;;
13177b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1318111a38b0SRobert Relyea  ;;
13192b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
13202b2325ffSGerd Hoffmann  ;;
13212b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
13222b2325ffSGerd Hoffmann  ;;
132369354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
132469354a83SHans de Goede  ;;
132569354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
132669354a83SHans de Goede  ;;
13271ece9905SAlon Levy  --disable-zlib-test) zlib="no"
13281ece9905SAlon Levy  ;;
1329b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1330b25c9dffSStefan Weil  ;;
1331607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1332607dacd0Sqiaonuohan  ;;
1333b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1334b25c9dffSStefan Weil  ;;
1335607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1336607dacd0Sqiaonuohan  ;;
13376b383c08SPeter Wu  --disable-bzip2) bzip2="no"
13386b383c08SPeter Wu  ;;
13396b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13406b383c08SPeter Wu  ;;
134183bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
134283bc1f97SJulio Faracco  ;;
134383bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
134483bc1f97SJulio Faracco  ;;
1345d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1346d138cee9SMichael Roth  ;;
1347d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1348d138cee9SMichael Roth  ;;
13499dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13509dacf32dSYossi Hindin  ;;
13519dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13529dacf32dSYossi Hindin  ;;
1353d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1354d9840e25STomoki Sekiyama  ;;
1355d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1356d9840e25STomoki Sekiyama  ;;
1357d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1358d9840e25STomoki Sekiyama  ;;
1359d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1360d9840e25STomoki Sekiyama  ;;
1361d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1362d9840e25STomoki Sekiyama  ;;
1363d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1364d9840e25STomoki Sekiyama  ;;
13654b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13664b1c11fdSDaniel P. Berrange  ;;
13674b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13684b1c11fdSDaniel P. Berrange  ;;
1369f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1370f794573eSEduardo Otubo  ;;
1371f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1372f794573eSEduardo Otubo  ;;
1373eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1374eb100396SBharata B Rao  ;;
137586583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
137686583a07SLiam Merwick  ;;
137786583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
137886583a07SLiam Merwick  ;;
1379eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1380eb100396SBharata B Rao  ;;
138152b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
138252b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1383583f6e7bSStefan Hajnoczi  ;;
1384cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1385cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1386cb6414dfSFam Zheng  ;;
1387315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1388315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1389315d3184SFam Zheng  ;;
1390a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1391a4ccabcfSAnthony Liguori  ;;
1392a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1393a4ccabcfSAnthony Liguori  ;;
1394a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1395a1c5e949SDaniel P. Berrange  ;;
1396ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1397ddbb0d09SDaniel P. Berrange  ;;
1398ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1399ddbb0d09SDaniel P. Berrange  ;;
140091bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
140191bfcdb0SDaniel P. Berrange  ;;
140291bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
140391bfcdb0SDaniel P. Berrange  ;;
140491bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
140591bfcdb0SDaniel P. Berrange  ;;
140691bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
140791bfcdb0SDaniel P. Berrange  ;;
14088953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
14098953caf3SDaniel P. Berrange  ;;
14108953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
14118953caf3SDaniel P. Berrange  ;;
14122da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14132da776dbSMichael R. Hines  ;;
14142da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14152da776dbSMichael R. Hines  ;;
141621ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
141721ab34c9SMarcel Apfelbaum  ;;
141821ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
141921ab34c9SMarcel Apfelbaum  ;;
1420bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1421bbbf9bfbSStefan Weil  ;;
1422bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1423bbbf9bfbSStefan Weil  ;;
14249d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14259d9e1521SGerd Hoffmann  ;;
14269d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
14279d9e1521SGerd Hoffmann  ;;
1428e91c793cSCole Robinson  --disable-tpm) tpm="no"
1429e91c793cSCole Robinson  ;;
1430ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1431ab214c29SStefan Berger  ;;
1432b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14330a12ec87SRichard W.M. Jones  ;;
1434b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14350a12ec87SRichard W.M. Jones  ;;
1436ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1437ed1701c6SDr. David Alan Gilbert  ;;
1438ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1439ed1701c6SDr. David Alan Gilbert  ;;
1440a99d57bbSWanlong Gao  --disable-numa) numa="no"
1441a99d57bbSWanlong Gao  ;;
1442a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1443a99d57bbSWanlong Gao  ;;
1444ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1445ed279a06SKlim Kireev  ;;
1446ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1447ed279a06SKlim Kireev  ;;
14482847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14492847b469SFam Zheng  ;;
14502847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14512847b469SFam Zheng  ;;
14527b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14537b01cb97SAlexandre Derumier  ;;
14547b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14557b01cb97SAlexandre Derumier  ;;
1456a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1457a6b1d4c0SChanglong Xie  ;;
1458a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1459a6b1d4c0SChanglong Xie  ;;
1460da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1461da92c3ffSAshish Mittal  ;;
1462da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1463da92c3ffSAshish Mittal  ;;
14642f740136SJeff Cody  --disable-bochs) bochs="no"
14652f740136SJeff Cody  ;;
14662f740136SJeff Cody  --enable-bochs) bochs="yes"
14672f740136SJeff Cody  ;;
14682f740136SJeff Cody  --disable-cloop) cloop="no"
14692f740136SJeff Cody  ;;
14702f740136SJeff Cody  --enable-cloop) cloop="yes"
14712f740136SJeff Cody  ;;
14722f740136SJeff Cody  --disable-dmg) dmg="no"
14732f740136SJeff Cody  ;;
14742f740136SJeff Cody  --enable-dmg) dmg="yes"
14752f740136SJeff Cody  ;;
14762f740136SJeff Cody  --disable-qcow1) qcow1="no"
14772f740136SJeff Cody  ;;
14782f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14792f740136SJeff Cody  ;;
14802f740136SJeff Cody  --disable-vdi) vdi="no"
14812f740136SJeff Cody  ;;
14822f740136SJeff Cody  --enable-vdi) vdi="yes"
14832f740136SJeff Cody  ;;
14842f740136SJeff Cody  --disable-vvfat) vvfat="no"
14852f740136SJeff Cody  ;;
14862f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14872f740136SJeff Cody  ;;
14882f740136SJeff Cody  --disable-qed) qed="no"
14892f740136SJeff Cody  ;;
14902f740136SJeff Cody  --enable-qed) qed="yes"
14912f740136SJeff Cody  ;;
14922f740136SJeff Cody  --disable-parallels) parallels="no"
14932f740136SJeff Cody  ;;
14942f740136SJeff Cody  --enable-parallels) parallels="yes"
14952f740136SJeff Cody  ;;
14962f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14972f740136SJeff Cody  ;;
14982f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14992f740136SJeff Cody  ;;
1500e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1501e6a74868SMarc-André Lureau  ;;
1502299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1503299e6f19SPaolo Bonzini  ;;
1504299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1505299e6f19SPaolo Bonzini  ;;
1506299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1507e6a74868SMarc-André Lureau  ;;
15088ca80760SRichard Henderson  --disable-capstone) capstone="no"
15098ca80760SRichard Henderson  ;;
15108ca80760SRichard Henderson  --enable-capstone) capstone="yes"
15118ca80760SRichard Henderson  ;;
1512e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1513e219c499SRichard Henderson  ;;
1514e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1515e219c499SRichard Henderson  ;;
1516cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1517cc84d63aSDaniel P. Berrange  ;;
1518f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1519f62bbee5SDaniel P. Berrange  ;;
1520f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1521f62bbee5SDaniel P. Berrange  ;;
1522ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1523ba59fb77SPaolo Bonzini  ;;
1524ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1525ba59fb77SPaolo Bonzini  ;;
152617824406SJunyan He  --enable-libpmem) libpmem=yes
152717824406SJunyan He  ;;
152817824406SJunyan He  --disable-libpmem) libpmem=no
152917824406SJunyan He  ;;
153075411919SJames Le Cuirot  --enable-xkbcommon) xkbcommon=yes
153175411919SJames Le Cuirot  ;;
153275411919SJames Le Cuirot  --disable-xkbcommon) xkbcommon=no
153375411919SJames Le Cuirot  ;;
153440e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
153540e8c6f4SAlex Bennée  ;;
153640e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
153740e8c6f4SAlex Bennée  ;;
15382d2ad6d0SFam Zheng  *)
15392d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15402d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15412d2ad6d0SFam Zheng      exit 1
15427f1559c6Sbalrog  ;;
15437d13299dSbellard  esac
15447d13299dSbellarddone
15457d13299dSbellard
154640293e58Sbellardcase "$cpu" in
1547e3608d66SRichard Henderson    ppc)
1548e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1549e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1550e3608d66SRichard Henderson           ;;
1551e3608d66SRichard Henderson    ppc64)
1552e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1553e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1554e3608d66SRichard Henderson           ;;
15559b9c37c3SRichard Henderson    sparc)
1556f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1557f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
15583142255cSblueswir1           ;;
1559ed968ff1SJuan Quintela    sparc64)
156079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1561f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
15623142255cSblueswir1           ;;
156376d83bdeSths    s390)
1564061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
156528d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
156628d7cc49SRichard Henderson           ;;
156728d7cc49SRichard Henderson    s390x)
1568061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
156928d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
157076d83bdeSths           ;;
157140293e58Sbellard    i386)
157279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
15730c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
157440293e58Sbellard           ;;
157540293e58Sbellard    x86_64)
15767ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15777ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
15787ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
15797ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
15800c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
1581379f6698SPaul Brook           ;;
1582c72b26ecSRichard Henderson    x32)
1583c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1584c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1585c72b26ecSRichard Henderson           ;;
158630163d89SPeter Maydell    # No special flags required for other host CPUs
15873142255cSblueswir1esac
15883142255cSblueswir1
15892038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
15902038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
159179f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
159279f3b12fSPeter Crosthwaite
1593affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1594affc88ccSPeter Maydell# support, even if we're using TCI.
1595affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1596affc88ccSPeter Maydell  bsd_user="no"
1597affc88ccSPeter Maydell  linux_user="no"
1598affc88ccSPeter Maydellfi
1599affc88ccSPeter Maydell
160060e0df25SPeter Maydelldefault_target_list=""
160160e0df25SPeter Maydell
16026e92f823SPeter Maydellmak_wilds=""
16036e92f823SPeter Maydell
160460e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
16056e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
160660e0df25SPeter Maydellfi
160760e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
16086e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
160960e0df25SPeter Maydellfi
161060e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
16116e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
161260e0df25SPeter Maydellfi
161360e0df25SPeter Maydell
1614447e133fSAlex Bennéeif test -z "$target_list_exclude"; then
16156e92f823SPeter Maydell    for config in $mak_wilds; do
16166e92f823SPeter Maydell        default_target_list="${default_target_list} $(basename "$config" .mak)"
16176e92f823SPeter Maydell    done
1618447e133fSAlex Bennéeelse
1619447e133fSAlex Bennée    exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1620447e133fSAlex Bennée    for config in $mak_wilds; do
1621447e133fSAlex Bennée        target="$(basename "$config" .mak)"
1622447e133fSAlex Bennée        exclude="no"
1623447e133fSAlex Bennée        for excl in $exclude_list; do
1624447e133fSAlex Bennée            if test "$excl" = "$target"; then
1625447e133fSAlex Bennée                exclude="yes"
1626447e133fSAlex Bennée                break;
1627447e133fSAlex Bennée            fi
1628447e133fSAlex Bennée        done
1629447e133fSAlex Bennée        if test "$exclude" = "no"; then
1630447e133fSAlex Bennée            default_target_list="${default_target_list} $target"
1631447e133fSAlex Bennée        fi
1632447e133fSAlex Bennée    done
1633447e133fSAlex Bennéefi
16346e92f823SPeter Maydell
1635c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
163664a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1637c53eeaf7SStefan Hajnoczi
1638af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1639af5db58eSpbrookcat << EOF
1640af5db58eSpbrook
1641af5db58eSpbrookUsage: configure [options]
1642af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1643af5db58eSpbrook
164408fb77edSStefan WeilStandard options:
164508fb77edSStefan Weil  --help                   print this message
164608fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
164708fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
164808fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
164908fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
165008fb77edSStefan Weil$(echo Available targets: $default_target_list | \
165108fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1652447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
165308fb77edSStefan Weil
165408fb77edSStefan WeilAdvanced options (experts only):
165508fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
165608fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
165708fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
165808fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
165908fb77edSStefan Weil                           build time
166008fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
166108fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
166208fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
166311cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
166408fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1665d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1666d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
166708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
166808fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
166908fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
167008fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1671db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
167208fb77edSStefan Weil  --static                 enable static build [$static]
167308fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
167408fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
167508fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
167608fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
167708fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1678db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
167908fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
168008fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
16813d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1682e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1683db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
168408fb77edSStefan Weil  --enable-debug           enable common debug build options
1685247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
168608fb77edSStefan Weil  --disable-strip          disable stripping binaries
168708fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
168863678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
168908fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
169008fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
169108fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
169208fb77edSStefan Weil  --block-drv-rw-whitelist=L
169308fb77edSStefan Weil                           set block driver read-write whitelist
169408fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
169508fb77edSStefan Weil  --block-drv-ro-whitelist=L
169608fb77edSStefan Weil                           set block driver read-only whitelist
169708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
16985b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1699c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
170008fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
170108fb77edSStefan Weil                           Default:trace-<pid>
1702c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1703c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
17045a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1705c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1706c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
170708fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
170833c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
170908fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
171008fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1711c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1712c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1713c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1714a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1715c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1716c12d66aaSLin Ma  --enable-profiler        profiler support
1717c12d66aaSLin Ma  --enable-debug-stack-usage
1718c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
171940e8c6f4SAlex Bennée  --enable-plugins
172040e8c6f4SAlex Bennée                           enable plugins via shared library loading
1721c23f23b9SMichael Tokarev
1722c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1723c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1724c23f23b9SMichael Tokarev
1725c23f23b9SMichael Tokarev  system          all system emulation targets
1726c23f23b9SMichael Tokarev  user            supported user emulation targets
1727c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1728c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1729c23f23b9SMichael Tokarev  docs            build documentation
1730c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1731c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1732c23f23b9SMichael Tokarev  pie             Position Independent Executables
173321e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1734c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1735c23f23b9SMichael Tokarev  debug-info      debugging information
1736c23f23b9SMichael Tokarev  sparse          sparse checker
1737c23f23b9SMichael Tokarev
1738ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
173991bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
174091bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
17418953caf3SDaniel P. Berrange  auth-pam        PAM access control
1742c23f23b9SMichael Tokarev  sdl             SDL UI
174304c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1744c23f23b9SMichael Tokarev  gtk             gtk UI
1745c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1746c23f23b9SMichael Tokarev  curses          curses UI
1747e08bb301SSamuel Thibault  iconv           font glyph conversion support
1748c23f23b9SMichael Tokarev  vnc             VNC UI support
1749c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1750c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1751c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1752c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1753c23f23b9SMichael Tokarev  virtfs          VirtFS
1754fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1755c23f23b9SMichael Tokarev  xen             xen backend driver support
175670c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1757c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1758c23f23b9SMichael Tokarev  curl            curl connectivity
1759a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1760c23f23b9SMichael Tokarev  fdt             fdt device tree
1761c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1762b0cb0a66SVincent Palatin  hax             HAX acceleration support
1763c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1764d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
176521ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
176621ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1767c23f23b9SMichael Tokarev  vde             support for vde network
1768c23f23b9SMichael Tokarev  netmap          support for netmap network
1769c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1770c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1771c23f23b9SMichael Tokarev  attr            attr and xattr support
1772299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1773299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1774299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1775299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1776299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1777299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1778c23f23b9SMichael Tokarev  spice           spice
1779c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1780c23f23b9SMichael Tokarev  libiscsi        iscsi support
1781c23f23b9SMichael Tokarev  libnfs          nfs support
17827b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1783c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1784ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1785c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1786c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1787c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1788c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1789c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
179083bc1f97SJulio Faracco  lzfse           support of lzfse compression library
179183bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
1792c23f23b9SMichael Tokarev  seccomp         seccomp support
1793c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1794c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1795c23f23b9SMichael Tokarev  tpm             TPM support
1796b10d49d7SPino Toscano  libssh          ssh block device support
1797c23f23b9SMichael Tokarev  numa            libnuma support
1798ed279a06SKlim Kireev  libxml2         for Parallels image format
1799c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
18007b01cb97SAlexandre Derumier  jemalloc        jemalloc support
180186583a07SLiam Merwick  avx2            AVX2 optimization support
1802a6b1d4c0SChanglong Xie  replication     replication support
1803c12d66aaSLin Ma  opengl          opengl support
1804c12d66aaSLin Ma  virglrenderer   virgl rendering support
1805c12d66aaSLin Ma  xfsctl          xfsctl support
1806c12d66aaSLin Ma  qom-cast-debug  cast debugging support
18078de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
1808da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
18092f740136SJeff Cody  bochs           bochs image format support
18102f740136SJeff Cody  cloop           cloop image format support
18112f740136SJeff Cody  dmg             dmg image format support
18122f740136SJeff Cody  qcow1           qcow v1 image format support
18132f740136SJeff Cody  vdi             vdi image format support
18142f740136SJeff Cody  vvfat           vvfat image format support
18152f740136SJeff Cody  qed             qed image format support
18162f740136SJeff Cody  parallels       parallels image format support
18172f740136SJeff Cody  sheepdog        sheepdog block driver support
1818f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
18198ca80760SRichard Henderson  capstone        capstone disassembler support
1820ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
182117824406SJunyan He  libpmem         libpmem support
182275411919SJames Le Cuirot  xkbcommon       xkbcommon support
182308fb77edSStefan Weil
182408fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1825af5db58eSpbrookEOF
18262d2ad6d0SFam Zhengexit 0
1827af5db58eSpbrookfi
1828af5db58eSpbrook
18299c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1830bb768f71SThomas Huthrm -f */config-devices.mak.d
18319c790242SThomas Huth
1832faf44142SDaniel P. Berrangéif test -z "$python"
1833faf44142SDaniel P. Berrangéthen
1834c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1835c53eeaf7SStefan Hajnoczifi
1836c53eeaf7SStefan Hajnoczi
1837c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1838c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
18397f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
18407f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1841c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1842c53eeaf7SStefan Hajnoczifi
1843c53eeaf7SStefan Hajnoczi
1844755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1845406ab2f3SCleber 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)
1846755ee70fSCleber Rosa
1847c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1848c53eeaf7SStefan Hajnoczipython="$python -B"
1849c53eeaf7SStefan Hajnoczi
18509aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
18519aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
18529aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
18539aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
18549aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
18559aae6e54SDaniel Henrique Barbozaif compile_object ; then
18569aae6e54SDaniel Henrique Barboza  : C compiler works ok
18579aae6e54SDaniel Henrique Barbozaelse
18589aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
18599aae6e54SDaniel Henrique Barbozafi
18609aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
18619aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
18629aae6e54SDaniel Henrique Barbozafi
18639aae6e54SDaniel Henrique Barboza
1864359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1865359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1866359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1867359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1868359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1869359bc95dSPeter Maydell    else
187076ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1871359bc95dSPeter Maydell    fi
1872359bc95dSPeter Maydellfi
1873359bc95dSPeter Maydell
18749c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
18759c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
18769c83ffd8SPeter Maydellif test -z "$werror" ; then
1877fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
1878e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
18799c83ffd8SPeter Maydell        werror="yes"
18809c83ffd8SPeter Maydell    else
18819c83ffd8SPeter Maydell        werror="no"
18829c83ffd8SPeter Maydell    fi
18839c83ffd8SPeter Maydellfi
18849c83ffd8SPeter Maydell
1885fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1886fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1887fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1888fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1889fb59dabdSPeter Maydell    # host OS we should stop now.
1890951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1891fb59dabdSPeter Maydellfi
1892fb59dabdSPeter Maydell
1893efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1894efc6c070SThomas Huthcat > $TMPC << EOF
1895efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1896efc6c070SThomas Huth# ifdef __apple_build_version__
1897efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1898efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
1899efc6c070SThomas Huth#  endif
1900efc6c070SThomas Huth# else
1901efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1902efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
1903efc6c070SThomas Huth#  endif
1904efc6c070SThomas Huth# endif
1905efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1906efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1907efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
1908efc6c070SThomas Huth# endif
1909efc6c070SThomas Huth#else
1910efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1911efc6c070SThomas Huth#endif
1912efc6c070SThomas Huthint main (void) { return 0; }
1913efc6c070SThomas HuthEOF
1914efc6c070SThomas Huthif ! compile_prog "" "" ; then
1915efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1916efc6c070SThomas Huthfi
1917efc6c070SThomas Huth
19188d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
19198d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1920ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1921435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1922b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1923e6e90feeSThomas Huthgcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
19246ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
19256ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
19266ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
19276ca026cbSPeter Maydell# so it's too error prone.
192893b25869SJohn Snow
192993b25869SJohn Snowcc_has_warning_flag() {
193093b25869SJohn Snow    write_c_skeleton;
193193b25869SJohn Snow
1932a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1933a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1934a1d29d6cSPeter Maydell    # warning options).
193593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
193693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
193793b25869SJohn Snow}
193893b25869SJohn Snow
193993b25869SJohn Snowfor flag in $gcc_flags; do
194093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
19418d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19428d05095cSPaolo Bonzini    fi
19438d05095cSPaolo Bonzinidone
19448d05095cSPaolo Bonzini
194563678e17SSteven Noonanif test "$stack_protector" != "no"; then
1946fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1947fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1948fccd35a0SRodrigo Rebello{
1949fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1950fccd35a0SRodrigo Rebello    while (*c) {
1951fccd35a0SRodrigo Rebello        *p++ = *c++;
1952fccd35a0SRodrigo Rebello    }
1953fccd35a0SRodrigo Rebello    return 0;
1954fccd35a0SRodrigo Rebello}
1955fccd35a0SRodrigo RebelloEOF
195663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
19573b463a3fSMiroslav Rezanina  sp_on=0
195863678e17SSteven Noonan  for flag in $gcc_flags; do
1959590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1960590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1961590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1962590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
196363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19643b463a3fSMiroslav Rezanina      sp_on=1
196563678e17SSteven Noonan      break
196663678e17SSteven Noonan    fi
196763678e17SSteven Noonan  done
19683b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
19693b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
19703b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
19713b463a3fSMiroslav Rezanina    fi
19723b463a3fSMiroslav Rezanina  fi
197337746c5eSMarc-André Lureaufi
197437746c5eSMarc-André Lureau
197520bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
197620bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
197720bc94a2SPaolo Bonzinicat > $TMPC << EOF
197820bc94a2SPaolo Bonzinistruct {
197920bc94a2SPaolo Bonzini  int a[2];
198020bc94a2SPaolo Bonzini} x = {0};
198120bc94a2SPaolo BonziniEOF
198220bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
198320bc94a2SPaolo Bonzini  :
198420bc94a2SPaolo Bonzinielse
198520bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
198620bc94a2SPaolo Bonzinifi
198720bc94a2SPaolo Bonzini
198821e709aaSMarc-André Lureau# Our module code doesn't support Windows
198921e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
199021e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
199121e709aaSMarc-André Lureaufi
199221e709aaSMarc-André Lureau
1993d376e9deSThomas Huth# Static linking is not possible with modules or PIE
199440d6444eSAvi Kivityif test "$static" = "yes" ; then
1995aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1996aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1997aa0d1f44SPaolo Bonzini  fi
199840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
199976ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
200040d6444eSAvi Kivity  else
200140d6444eSAvi Kivity    pie="no"
200240d6444eSAvi Kivity  fi
200340d6444eSAvi Kivityfi
200440d6444eSAvi Kivity
2005768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2006768b7855SEmilio G. Cota  cat > $TMPC << EOF
2007768b7855SEmilio G. Cotastatic __thread int tls_var;
2008768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2009768b7855SEmilio G. CotaEOF
2010768b7855SEmilio G. Cota
2011768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2012768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2013768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2014768b7855SEmilio G. Cotafi
2015768b7855SEmilio G. Cota
201640d6444eSAvi Kivityif test "$pie" = ""; then
201740d6444eSAvi Kivity  case "$cpu-$targetos" in
2018c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
201940d6444eSAvi Kivity      ;;
202040d6444eSAvi Kivity    *)
202140d6444eSAvi Kivity      pie="no"
202240d6444eSAvi Kivity      ;;
202340d6444eSAvi Kivity  esac
202440d6444eSAvi Kivityfi
202540d6444eSAvi Kivity
202640d6444eSAvi Kivityif test "$pie" != "no" ; then
202740d6444eSAvi Kivity  cat > $TMPC << EOF
202821d4a791SAvi Kivity
202921d4a791SAvi Kivity#ifdef __linux__
203021d4a791SAvi Kivity#  define THREAD __thread
203121d4a791SAvi Kivity#else
203221d4a791SAvi Kivity#  define THREAD
203321d4a791SAvi Kivity#endif
203421d4a791SAvi Kivity
203521d4a791SAvi Kivitystatic THREAD int tls_var;
203621d4a791SAvi Kivity
203721d4a791SAvi Kivityint main(void) { return tls_var; }
203821d4a791SAvi Kivity
203940d6444eSAvi KivityEOF
2040412aeacdSAlex Bennée  # check we support --no-pie first...
2041412aeacdSAlex Bennée  if compile_prog "-Werror -fno-pie" "-no-pie"; then
2042412aeacdSAlex Bennée    CFLAGS_NOPIE="-fno-pie"
2043412aeacdSAlex Bennée    LDFLAGS_NOPIE="-nopie"
2044412aeacdSAlex Bennée  fi
2045412aeacdSAlex Bennée
204640d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
204740d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
204840d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
204940d6444eSAvi Kivity    pie="yes"
205040d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
205140d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
205240d6444eSAvi Kivity    fi
205340d6444eSAvi Kivity  else
205440d6444eSAvi Kivity    if test "$pie" = "yes"; then
205576ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
205640d6444eSAvi Kivity    else
205740d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
205840d6444eSAvi Kivity      pie="no"
205940d6444eSAvi Kivity    fi
206040d6444eSAvi Kivity  fi
206140d6444eSAvi Kivityfi
206240d6444eSAvi Kivity
206309dada40SPaolo Bonzini##########################################
206409dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
206509dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
206609dada40SPaolo Bonzini# specification is necessary
206709dada40SPaolo Bonzini
206809dada40SPaolo Bonziniif test "$cpu" = "i386"; then
206909dada40SPaolo Bonzini  cat > $TMPC << EOF
207009dada40SPaolo Bonzinistatic int sfaa(int *ptr)
207109dada40SPaolo Bonzini{
207209dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
207309dada40SPaolo Bonzini}
207409dada40SPaolo Bonzini
207509dada40SPaolo Bonziniint main(void)
207609dada40SPaolo Bonzini{
207709dada40SPaolo Bonzini  int val = 42;
20781405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
207909dada40SPaolo Bonzini  sfaa(&val);
208009dada40SPaolo Bonzini  return val;
208109dada40SPaolo Bonzini}
208209dada40SPaolo BonziniEOF
208309dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
208409dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
208509dada40SPaolo Bonzini  fi
208609dada40SPaolo Bonzinifi
208709dada40SPaolo Bonzini
208809dada40SPaolo Bonzini#########################################
2089ec530c81Sbellard# Solaris specific configure tool chain decisions
209009dada40SPaolo Bonzini
2091ec530c81Sbellardif test "$solaris" = "yes" ; then
20926792aa11SLoïc Minier  if has $install; then
20936792aa11SLoïc Minier    :
20946792aa11SLoïc Minier  else
209576ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
209676ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
209776ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2098ec530c81Sbellard  fi
209989138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
210076ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
210176ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
210276ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2103ec530c81Sbellard  fi
21046792aa11SLoïc Minier  if has ar; then
21056792aa11SLoïc Minier    :
21066792aa11SLoïc Minier  else
2107ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
210876ad07a4SPeter Maydell      error_exit "No path includes ar" \
210976ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2110ec530c81Sbellard    fi
211176ad07a4SPeter Maydell    error_exit "No path includes ar"
2112ec530c81Sbellard  fi
2113ec530c81Sbellardfi
2114ec530c81Sbellard
2115afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2116d880a3baSPaolo Bonzini    for target in $default_target_list; do
2117d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2118d880a3baSPaolo Bonzini            target_list="$target_list $target"
2119d880a3baSPaolo Bonzini    done
2120d880a3baSPaolo Bonzini    target_list="${target_list# }"
2121121afa9eSAnthony Liguorielse
212289138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2123d880a3baSPaolo Bonzini    for target in $target_list; do
212425b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
212525b48338SPeter Maydell        # friendly error message than if we let it fall through.
212625b48338SPeter Maydell        case " $default_target_list " in
212725b48338SPeter Maydell            *" $target "*)
212825b48338SPeter Maydell                ;;
212925b48338SPeter Maydell            *)
213025b48338SPeter Maydell                error_exit "Unknown target name '$target'"
213125b48338SPeter Maydell                ;;
213225b48338SPeter Maydell        esac
2133d880a3baSPaolo Bonzini        supported_target $target || exit 1
213425b48338SPeter Maydell    done
2135d880a3baSPaolo Bonzinifi
213625b48338SPeter Maydell
2137f55fe278SPaolo Bonzini# see if system emulation was really requested
2138f55fe278SPaolo Bonzinicase " $target_list " in
2139f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2140f55fe278SPaolo Bonzini  ;;
2141f55fe278SPaolo Bonzini  *) softmmu=no
2142f55fe278SPaolo Bonzini  ;;
2143f55fe278SPaolo Bonziniesac
21445327cf48Sbellard
214505dfa22bSPhilippe Mathieu-Daudéfor target in $target_list; do
214605dfa22bSPhilippe Mathieu-Daudé  case "$target" in
214705dfa22bSPhilippe Mathieu-Daudé    arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
214805dfa22bSPhilippe Mathieu-Daudé      edk2_blobs="yes"
214905dfa22bSPhilippe Mathieu-Daudé      ;;
215005dfa22bSPhilippe Mathieu-Daudé  esac
215105dfa22bSPhilippe Mathieu-Daudédone
2152623ef637SPhilippe Mathieu-Daudé# The EDK2 binaries are compressed with bzip2
2153623ef637SPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" && ! has bzip2; then
2154623ef637SPhilippe Mathieu-Daudé  error_exit "The bzip2 program is required for building QEMU"
2155623ef637SPhilippe Mathieu-Daudéfi
215605dfa22bSPhilippe Mathieu-Daudé
2157249247c9SJuan Quintelafeature_not_found() {
2158249247c9SJuan Quintela  feature=$1
215921684af0SStewart Smith  remedy=$2
2160249247c9SJuan Quintela
216176ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
216221684af0SStewart Smith      "configure was not able to find it." \
216321684af0SStewart Smith      "$remedy"
2164249247c9SJuan Quintela}
2165249247c9SJuan Quintela
21667d13299dSbellard# ---
21677d13299dSbellard# big/little endian test
21687d13299dSbellardcat > $TMPC << EOF
216961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
217061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
217161cc919fSMike Frysingerextern int foo(short *, short *);
217261cc919fSMike Frysingerint main(int argc, char *argv[]) {
217361cc919fSMike Frysinger    return foo(big_endian, little_endian);
21747d13299dSbellard}
21757d13299dSbellardEOF
21767d13299dSbellard
217761cc919fSMike Frysingerif compile_object ; then
217812f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
217961cc919fSMike Frysinger        bigendian="yes"
218012f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
218161cc919fSMike Frysinger        bigendian="no"
21827d13299dSbellard    else
21837d13299dSbellard        echo big/little test failed
21847d13299dSbellard    fi
21857d13299dSbellardelse
218661cc919fSMike Frysinger    echo big/little test failed
21877d13299dSbellardfi
21887d13299dSbellard
2189b0a47e79SJuan Quintela##########################################
2190a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2191a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2192a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2193a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2194a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2195a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2196a30878e7SPeter Maydell    fi
2197a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2198a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2199a30878e7SPeter Maydell    fi
2200a30878e7SPeter Maydell    gtk=no
2201a30878e7SPeter Maydell    sdl=no
2202a30878e7SPeter Maydellfi
2203a30878e7SPeter Maydell
22046b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
22056b39b063SEric Blakecat > $TMPC << EOF
22066b39b063SEric Blake#include <stdint.h>
22076b39b063SEric Blake#include <stdio.h>
22086b39b063SEric Blakeint main(int argc, char *argv[]) {
22096b39b063SEric Blake    return printf("%zu", SIZE_MAX);
22106b39b063SEric Blake}
22116b39b063SEric BlakeEOF
22126b39b063SEric Blakehave_broken_size_max=no
22136b39b063SEric Blakeif ! compile_object -Werror ; then
22146b39b063SEric Blake    have_broken_size_max=yes
22156b39b063SEric Blakefi
22166b39b063SEric Blake
2217a30878e7SPeter Maydell##########################################
2218015a33bdSGonglei# L2TPV3 probe
2219015a33bdSGonglei
2220015a33bdSGongleicat > $TMPC <<EOF
2221015a33bdSGonglei#include <sys/socket.h>
2222bff6cb72SMichael Tokarev#include <linux/ip.h>
2223015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2224015a33bdSGongleiEOF
2225015a33bdSGongleiif compile_prog "" "" ; then
2226015a33bdSGonglei  l2tpv3=yes
2227015a33bdSGongleielse
2228015a33bdSGonglei  l2tpv3=no
2229015a33bdSGongleifi
2230015a33bdSGonglei
2231299e6f19SPaolo Bonzini#########################################
2232299e6f19SPaolo Bonzini# vhost interdependencies and host support
2233299e6f19SPaolo Bonzini
2234299e6f19SPaolo Bonzini# vhost backends
2235299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2236299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2237299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2238299e6f19SPaolo Bonzinifi
2239299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2240299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2241299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2242299e6f19SPaolo Bonzinifi
2243299e6f19SPaolo Bonzini
2244299e6f19SPaolo Bonzini# vhost-kernel devices
2245299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2246299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2247299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2248299e6f19SPaolo Bonzinifi
2249299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2250299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2251299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2252299e6f19SPaolo Bonzinifi
2253299e6f19SPaolo Bonzini
2254299e6f19SPaolo Bonzini# vhost-user backends
2255299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2256299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2257299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2258299e6f19SPaolo Bonzinifi
2259299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2260299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2261299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2262299e6f19SPaolo Bonzinifi
226398fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
226498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
226598fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
226698fc1adaSDr. David Alan Gilbertfi
2267299e6f19SPaolo Bonzini
2268299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2269299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2270299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2271299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2272299e6f19SPaolo Bonzinifi
2273299e6f19SPaolo Bonzini
2274015a33bdSGonglei##########################################
22754d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
22764d9310f4SDaniel P. Berrange
22774d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
22784d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
22794d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
22804d9310f4SDaniel P. Berrange    #
22814d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
22824d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
22834d9310f4SDaniel P. Berrange    #
22844d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
22854d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
22864d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
22874d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
22884d9310f4SDaniel P. Berrange    # that for you.
22894d9310f4SDaniel P. Berrange    #
22904d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
22914d9310f4SDaniel P. Berrange    # are not in fact redundant.
22924d9310f4SDaniel P. Berrangecat > $TMPC << EOF
22934d9310f4SDaniel P. Berrange#include <unistd.h>
22944d9310f4SDaniel P. Berrange#include <time.h>
22954d9310f4SDaniel P. Berrange#undef localtime_r
22964d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
22974d9310f4SDaniel P. BerrangeEOF
22984d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
22994d9310f4SDaniel P. Berrange        localtime_r="yes"
23004d9310f4SDaniel P. Berrange    else
23014d9310f4SDaniel P. Berrange        localtime_r="no"
23024d9310f4SDaniel P. Berrange    fi
23034d9310f4SDaniel P. Berrangefi
23044d9310f4SDaniel P. Berrange
23054d9310f4SDaniel P. Berrange##########################################
2306779ab5e3SStefan Weil# pkg-config probe
2307779ab5e3SStefan Weil
2308779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
230976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2310779ab5e3SStefan Weilfi
2311779ab5e3SStefan Weil
2312779ab5e3SStefan Weil##########################################
2313b0a47e79SJuan Quintela# NPTL probe
2314b0a47e79SJuan Quintela
231524cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2316bd0c5661Spbrook  cat > $TMPC <<EOF
2317bd0c5661Spbrook#include <sched.h>
231830813ceaSpbrook#include <linux/futex.h>
2319182eacc0SStefan Weilint main(void) {
2320bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2321bd0c5661Spbrook#error bork
2322bd0c5661Spbrook#endif
2323182eacc0SStefan Weil  return 0;
2324bd0c5661Spbrook}
2325bd0c5661SpbrookEOF
232624cb36a6SPeter Maydell  if ! compile_object ; then
232721684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2328b0a47e79SJuan Quintela  fi
2329bd0c5661Spbrookfi
2330bd0c5661Spbrook
2331ac62922eSbalrog##########################################
2332607dacd0Sqiaonuohan# lzo check
2333607dacd0Sqiaonuohan
2334607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2335607dacd0Sqiaonuohan    cat > $TMPC << EOF
2336607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2337607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2338607dacd0SqiaonuohanEOF
2339607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2340607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2341b25c9dffSStefan Weil        lzo="yes"
2342b25c9dffSStefan Weil    else
2343b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2344b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2345b25c9dffSStefan Weil        fi
2346b25c9dffSStefan Weil        lzo="no"
2347b25c9dffSStefan Weil    fi
2348607dacd0Sqiaonuohanfi
2349607dacd0Sqiaonuohan
2350607dacd0Sqiaonuohan##########################################
2351607dacd0Sqiaonuohan# snappy check
2352607dacd0Sqiaonuohan
2353607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2354607dacd0Sqiaonuohan    cat > $TMPC << EOF
2355607dacd0Sqiaonuohan#include <snappy-c.h>
2356607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2357607dacd0SqiaonuohanEOF
2358607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2359607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2360b25c9dffSStefan Weil        snappy="yes"
2361b25c9dffSStefan Weil    else
2362b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2363b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2364b25c9dffSStefan Weil        fi
2365b25c9dffSStefan Weil        snappy="no"
2366b25c9dffSStefan Weil    fi
2367607dacd0Sqiaonuohanfi
2368607dacd0Sqiaonuohan
2369607dacd0Sqiaonuohan##########################################
23706b383c08SPeter Wu# bzip2 check
23716b383c08SPeter Wu
23726b383c08SPeter Wuif test "$bzip2" != "no" ; then
23736b383c08SPeter Wu    cat > $TMPC << EOF
23746b383c08SPeter Wu#include <bzlib.h>
23756b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
23766b383c08SPeter WuEOF
23776b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
23786b383c08SPeter Wu        bzip2="yes"
23796b383c08SPeter Wu    else
23806b383c08SPeter Wu        if test "$bzip2" = "yes"; then
23816b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
23826b383c08SPeter Wu        fi
23836b383c08SPeter Wu        bzip2="no"
23846b383c08SPeter Wu    fi
23856b383c08SPeter Wufi
23866b383c08SPeter Wu
23876b383c08SPeter Wu##########################################
238883bc1f97SJulio Faracco# lzfse check
238983bc1f97SJulio Faracco
239083bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
239183bc1f97SJulio Faracco    cat > $TMPC << EOF
239283bc1f97SJulio Faracco#include <lzfse.h>
239383bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
239483bc1f97SJulio FaraccoEOF
239583bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
239683bc1f97SJulio Faracco        lzfse="yes"
239783bc1f97SJulio Faracco    else
239883bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
239983bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
240083bc1f97SJulio Faracco        fi
240183bc1f97SJulio Faracco        lzfse="no"
240283bc1f97SJulio Faracco    fi
240383bc1f97SJulio Faraccofi
240483bc1f97SJulio Faracco
240583bc1f97SJulio Faracco##########################################
2406f794573eSEduardo Otubo# libseccomp check
2407f794573eSEduardo Otubo
2408f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
24093e684455SMichael Strosaker    libseccomp_minver="2.3.0"
241025ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2411c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2412c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2413f794573eSEduardo Otubo        seccomp="yes"
2414f794573eSEduardo Otubo    else
2415f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2416693e5910SAndrew Jones            feature_not_found "libseccomp" \
2417693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2418896848f0SEduardo Otubo        fi
2419e84d5956SYann E. MORIN        seccomp="no"
2420f794573eSEduardo Otubo    fi
2421f794573eSEduardo Otubofi
2422f794573eSEduardo Otubo##########################################
2423e37630caSaliguori# xen probe
2424e37630caSaliguori
2425fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2426c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2427c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2428c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2429c1cdd9d5SJuergen Gross
2430c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2431c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2432c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2433c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2434c1cdd9d5SJuergen Gross    xen=yes
2435c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2436c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
243758ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
243858ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
243958ea9a7aSAnthony PERARD    fi
2440c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2441c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2442c1cdd9d5SJuergen Gross  else
2443c1cdd9d5SJuergen Gross
2444b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2445d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2446d5b93ddfSAnthony PERARD
244750ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
244850ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
244950ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
245050ced5b3SStefan Weil
245150ced5b3SStefan Weil    # Xen (any)
245250ced5b3SStefan Weil    cat > $TMPC <<EOF
245350ced5b3SStefan Weil#include <xenctrl.h>
245450ced5b3SStefan Weilint main(void) {
245550ced5b3SStefan Weil  return 0;
245650ced5b3SStefan Weil}
245750ced5b3SStefan WeilEOF
245850ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
245950ced5b3SStefan Weil      # Xen not found
246050ced5b3SStefan Weil      if test "$xen" = "yes" ; then
246121684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
246250ced5b3SStefan Weil      fi
246350ced5b3SStefan Weil      xen=no
246450ced5b3SStefan Weil
2465d5b93ddfSAnthony PERARD    # Xen unstable
246669deef08SPeter Maydell    elif
246769deef08SPeter Maydell        cat > $TMPC <<EOF &&
24682cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
24692cbf8903SRoss Lagerwall#define __XEN_TOOLS__
24702cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2471d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
24722cbf8903SRoss Lagerwallint main(void) {
24732cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2474d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
24752cbf8903SRoss Lagerwall
24762cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
24772cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
24782cbf8903SRoss Lagerwall
2479d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2480d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2481d3c49ebbSPaul Durrant
24822cbf8903SRoss Lagerwall  return 0;
24832cbf8903SRoss Lagerwall}
24842cbf8903SRoss LagerwallEOF
24852cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24862cbf8903SRoss Lagerwall      then
24872cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24882cbf8903SRoss Lagerwall      xen_ctrl_version=41100
24892cbf8903SRoss Lagerwall      xen=yes
24902cbf8903SRoss Lagerwall    elif
24912cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
24925ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
24935ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
249458ea9a7aSAnthony PERARD#include <xentoolcore.h>
24955ba3d756SIgor Druzhininint main(void) {
24965ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
24975ba3d756SIgor Druzhinin
24985ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
24995ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
250058ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25015ba3d756SIgor Druzhinin
25025ba3d756SIgor Druzhinin  return 0;
25035ba3d756SIgor Druzhinin}
25045ba3d756SIgor DruzhininEOF
250558ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25065ba3d756SIgor Druzhinin      then
250758ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25085ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25095ba3d756SIgor Druzhinin      xen=yes
25105ba3d756SIgor Druzhinin    elif
25115ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2512da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2513da8090ccSPaul Durrant#define __XEN_TOOLS__
2514da8090ccSPaul Durrant#include <xendevicemodel.h>
2515da8090ccSPaul Durrantint main(void) {
2516da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2517da8090ccSPaul Durrant
2518da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2519da8090ccSPaul Durrant  xendevicemodel_close(xd);
2520da8090ccSPaul Durrant
2521da8090ccSPaul Durrant  return 0;
2522da8090ccSPaul Durrant}
2523da8090ccSPaul DurrantEOF
2524da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2525da8090ccSPaul Durrant      then
2526da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2527f1167ee6SJuergen Gross      xen_ctrl_version=40900
2528da8090ccSPaul Durrant      xen=yes
2529da8090ccSPaul Durrant    elif
2530da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
25315eeb39c2SIan Campbell/*
25325eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
25335eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2534b6eb9b45SPaulina Szubarczyk *
2535b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2536b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2537b6eb9b45SPaulina Szubarczyk */
2538b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2539b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2540b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2541b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2542b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2543b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2544b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2545b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2546b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2547b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2548b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2549b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2550b6eb9b45SPaulina Szubarczyk#endif
2551b6eb9b45SPaulina Szubarczykint main(void) {
2552b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2553b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2554b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2555b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2556b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2557b6eb9b45SPaulina Szubarczyk
2558b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2559b6eb9b45SPaulina Szubarczyk
2560b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2561b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2562b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2563b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2564b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2565b6eb9b45SPaulina Szubarczyk
2566b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2567b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2568b6eb9b45SPaulina Szubarczyk
2569b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2570b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2571b6eb9b45SPaulina Szubarczyk
2572b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2573b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2574b6eb9b45SPaulina Szubarczyk
2575b6eb9b45SPaulina Szubarczyk  return 0;
2576b6eb9b45SPaulina Szubarczyk}
2577b6eb9b45SPaulina SzubarczykEOF
2578b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2579b6eb9b45SPaulina Szubarczyk      then
2580f1167ee6SJuergen Gross      xen_ctrl_version=40800
2581b6eb9b45SPaulina Szubarczyk      xen=yes
2582b6eb9b45SPaulina Szubarczyk    elif
2583b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2584b6eb9b45SPaulina Szubarczyk/*
2585b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2586b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
25875eeb39c2SIan Campbell */
25885eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
25895eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
25905eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25915eeb39c2SIan Campbell#include <xenctrl.h>
25925eeb39c2SIan Campbell#include <xenstore.h>
25935eeb39c2SIan Campbell#include <xenevtchn.h>
25945eeb39c2SIan Campbell#include <xengnttab.h>
25955eeb39c2SIan Campbell#include <xenforeignmemory.h>
25965eeb39c2SIan Campbell#include <stdint.h>
25975eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
25985eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
25995eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26005eeb39c2SIan Campbell#endif
26015eeb39c2SIan Campbellint main(void) {
26025eeb39c2SIan Campbell  xc_interface *xc = NULL;
26035eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26045eeb39c2SIan Campbell  xenevtchn_handle *xe;
26055eeb39c2SIan Campbell  xengnttab_handle *xg;
26065eeb39c2SIan Campbell
26075eeb39c2SIan Campbell  xs_daemon_open();
26085eeb39c2SIan Campbell
26095eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26105eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26115eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26125eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26135eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26145eeb39c2SIan Campbell
26155eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26165eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26175eeb39c2SIan Campbell
26185eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26195eeb39c2SIan Campbell  xenevtchn_fd(xe);
26205eeb39c2SIan Campbell
26215eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26225eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26235eeb39c2SIan Campbell
26245eeb39c2SIan Campbell  return 0;
26255eeb39c2SIan Campbell}
26265eeb39c2SIan CampbellEOF
26275eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26285eeb39c2SIan Campbell      then
2629f1167ee6SJuergen Gross      xen_ctrl_version=40701
26305eeb39c2SIan Campbell      xen=yes
2631cdadde39SRoger Pau Monne
2632cdadde39SRoger Pau Monne    # Xen 4.6
2633cdadde39SRoger Pau Monne    elif
2634cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2635cdadde39SRoger Pau Monne#include <xenctrl.h>
2636e108a3c1SAnthony PERARD#include <xenstore.h>
2637d5b93ddfSAnthony PERARD#include <stdint.h>
2638d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2639d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2640d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2641d5b93ddfSAnthony PERARD#endif
2642d5b93ddfSAnthony PERARDint main(void) {
2643d5b93ddfSAnthony PERARD  xc_interface *xc;
2644d5b93ddfSAnthony PERARD  xs_daemon_open();
2645d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2646d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2647d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2648b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26498688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2650d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
265120a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2652d8b441a3SJan Beulich  return 0;
2653d8b441a3SJan Beulich}
2654d8b441a3SJan BeulichEOF
2655d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2656d8b441a3SJan Beulich      then
2657f1167ee6SJuergen Gross      xen_ctrl_version=40600
2658d8b441a3SJan Beulich      xen=yes
2659d8b441a3SJan Beulich
2660d8b441a3SJan Beulich    # Xen 4.5
2661d8b441a3SJan Beulich    elif
2662d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2663d8b441a3SJan Beulich#include <xenctrl.h>
2664d8b441a3SJan Beulich#include <xenstore.h>
2665d8b441a3SJan Beulich#include <stdint.h>
2666d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2667d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2668d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2669d8b441a3SJan Beulich#endif
2670d8b441a3SJan Beulichint main(void) {
2671d8b441a3SJan Beulich  xc_interface *xc;
2672d8b441a3SJan Beulich  xs_daemon_open();
2673d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2674d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2675d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2676d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2677d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26783996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
26793996e85cSPaul Durrant  return 0;
26803996e85cSPaul Durrant}
26813996e85cSPaul DurrantEOF
26823996e85cSPaul Durrant        compile_prog "" "$xen_libs"
26833996e85cSPaul Durrant      then
2684f1167ee6SJuergen Gross      xen_ctrl_version=40500
26853996e85cSPaul Durrant      xen=yes
26863996e85cSPaul Durrant
26873996e85cSPaul Durrant    elif
26883996e85cSPaul Durrant        cat > $TMPC <<EOF &&
26893996e85cSPaul Durrant#include <xenctrl.h>
26903996e85cSPaul Durrant#include <xenstore.h>
26913996e85cSPaul Durrant#include <stdint.h>
26923996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
26933996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
26943996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
26953996e85cSPaul Durrant#endif
26963996e85cSPaul Durrantint main(void) {
26973996e85cSPaul Durrant  xc_interface *xc;
26983996e85cSPaul Durrant  xs_daemon_open();
26993996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27003996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27013996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27023996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27033996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27048688e065SStefano Stabellini  return 0;
27058688e065SStefano Stabellini}
27068688e065SStefano StabelliniEOF
27078688e065SStefano Stabellini        compile_prog "" "$xen_libs"
270869deef08SPeter Maydell      then
2709f1167ee6SJuergen Gross      xen_ctrl_version=40200
27108688e065SStefano Stabellini      xen=yes
27118688e065SStefano Stabellini
2712e37630caSaliguori    else
2713fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2714edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2715edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2716fc321b4bSJuan Quintela      fi
2717fc321b4bSJuan Quintela      xen=no
2718e37630caSaliguori    fi
2719d5b93ddfSAnthony PERARD
2720d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2721f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
27225eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
27235eeb39c2SIan Campbell      fi
2724d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2725d5b93ddfSAnthony PERARD    fi
2726e37630caSaliguori  fi
2727c1cdd9d5SJuergen Grossfi
2728e37630caSaliguori
2729eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2730edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2731eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2732eb6fda0fSAnthony PERARD  else
2733eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
273476ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
273576ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2736eb6fda0fSAnthony PERARD    fi
2737eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2738eb6fda0fSAnthony PERARD  fi
2739eb6fda0fSAnthony PERARDfi
2740eb6fda0fSAnthony PERARD
2741e37630caSaliguori##########################################
2742d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2743d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2744327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2745d661d9a4SJustin Terry (VM)        whpx="yes"
2746d661d9a4SJustin Terry (VM)    else
2747d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
274853537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2749d661d9a4SJustin Terry (VM)        fi
2750d661d9a4SJustin Terry (VM)        whpx="no"
2751d661d9a4SJustin Terry (VM)    fi
2752d661d9a4SJustin Terry (VM)fi
2753d661d9a4SJustin Terry (VM)
2754d661d9a4SJustin Terry (VM)##########################################
2755dfffc653SJuan Quintela# Sparse probe
2756dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
27570dba6195SLoïc Minier  if has cgcc; then
2758dfffc653SJuan Quintela    sparse=yes
2759dfffc653SJuan Quintela  else
2760dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
276121684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2762dfffc653SJuan Quintela    fi
2763dfffc653SJuan Quintela    sparse=no
2764dfffc653SJuan Quintela  fi
2765dfffc653SJuan Quintelafi
2766dfffc653SJuan Quintela
2767dfffc653SJuan Quintela##########################################
2768f676c67eSJeremy White# X11 probe
2769f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
27708781595bSGerd Hoffmann    have_x11=yes
277189138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
277289138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2773f676c67eSJeremy Whitefi
2774f676c67eSJeremy White
2775f676c67eSJeremy White##########################################
2776a4ccabcfSAnthony Liguori# GTK probe
2777a4ccabcfSAnthony Liguori
27785a464e6cSPeter Xuif test "$gtk" != "no"; then
277989d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
278089d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
278158296cb6SDaniel P. Berrangé    gtkversion="3.14.0"
2782bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
278389138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
278489138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
278589138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
27860a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
27878781595bSGerd Hoffmann            need_x11=yes
2788f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2789f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
27900a337ed0SGerd Hoffmann        fi
2791bbbf9bfbSStefan Weil        gtk="yes"
2792bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
27935fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2794bbbf9bfbSStefan Weil    else
2795bbbf9bfbSStefan Weil        gtk="no"
2796bbbf9bfbSStefan Weil    fi
2797bbbf9bfbSStefan Weilfi
2798bbbf9bfbSStefan Weil
2799ddbb0d09SDaniel P. Berrange
2800ddbb0d09SDaniel P. Berrange##########################################
2801ddbb0d09SDaniel P. Berrange# GNUTLS probe
2802ddbb0d09SDaniel P. Berrange
2803ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2804a73e82efSRichard Henderson    pass="no"
2805a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
280689138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
280789138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2808a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
2809a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
2810a73e82efSRichard Henderson        write_c_skeleton
2811a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
2812243dc2cfSRichard Henderson            LIBS="$gnutls_libs $LIBS"
2813ddbb0d09SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2814a73e82efSRichard Henderson            pass="yes"
2815a73e82efSRichard Henderson        fi
2816a73e82efSRichard Henderson    fi
2817a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
2818a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2819ddbb0d09SDaniel P. Berrange    else
2820a73e82efSRichard Henderson        gnutls="$pass"
2821ddbb0d09SDaniel P. Berrange    fi
2822ddbb0d09SDaniel P. Berrangefi
2823ddbb0d09SDaniel P. Berrange
282491bfcdb0SDaniel P. Berrange
282591bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
282691bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2827a0722409SDaniel P. Berrangé# explicitly
282891bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
282991bfcdb0SDaniel P. Berrangethen
2830a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
283191bfcdb0SDaniel P. Berrange    then
283291bfcdb0SDaniel P. Berrange        gcrypt="no"
283391bfcdb0SDaniel P. Berrange    fi
283491bfcdb0SDaniel P. Berrangefi
283591bfcdb0SDaniel P. Berrange
283691bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
283791bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2838a0722409SDaniel P. Berrangé# explicitly
283991bfcdb0SDaniel P. Berrangeif test -z "$nettle"
284091bfcdb0SDaniel P. Berrangethen
2841a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
284291bfcdb0SDaniel P. Berrange    then
284391bfcdb0SDaniel P. Berrange        nettle="no"
284491bfcdb0SDaniel P. Berrange    fi
284591bfcdb0SDaniel P. Berrangefi
284691bfcdb0SDaniel P. Berrange
2847dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
284891bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
284991bfcdb0SDaniel P. Berrange    then
285091bfcdb0SDaniel P. Berrange	return 1
285191bfcdb0SDaniel P. Berrange    fi
285291bfcdb0SDaniel P. Berrange
285391bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
285491bfcdb0SDaniel P. Berrange    then
285589138857SStefan Weil	host=$(libgcrypt-config --host)
285691bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
285791bfcdb0SDaniel P. Berrange	then
285891bfcdb0SDaniel P. Berrange	    return 1
285991bfcdb0SDaniel P. Berrange	fi
286091bfcdb0SDaniel P. Berrange    fi
286191bfcdb0SDaniel P. Berrange
2862dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2863dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2864dea7a64eSDaniel P. Berrangé
2865dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2866dea7a64eSDaniel P. Berrangé    then
2867dea7a64eSDaniel P. Berrangé       return 1
2868dea7a64eSDaniel P. Berrangé    fi
2869dea7a64eSDaniel P. Berrangé
287091bfcdb0SDaniel P. Berrange    return 0
287191bfcdb0SDaniel P. Berrange}
287291bfcdb0SDaniel P. Berrange
2873a0722409SDaniel P. Berrangé
2874a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
2875a73e82efSRichard Henderson    pass="no"
287664dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2877a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2878a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2879a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2880a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2881a73e82efSRichard Henderson        write_c_skeleton
2882a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
2883243dc2cfSRichard Henderson            LIBS="$nettle_libs $LIBS"
2884a0722409SDaniel P. Berrangé            QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2885a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
2886a0722409SDaniel P. Berrangé               gcrypt="no"
2887a0722409SDaniel P. Berrangé            fi
2888a73e82efSRichard Henderson            pass="yes"
2889a73e82efSRichard Henderson        fi
2890a73e82efSRichard Henderson    fi
2891dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
2892dc2207afSDaniel P. Berrangé    then
2893dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
2894dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
2895dc2207afSDaniel P. Berrangéint main(void) {
2896dc2207afSDaniel P. Berrangé  return 0;
2897dc2207afSDaniel P. Berrangé}
2898dc2207afSDaniel P. BerrangéEOF
2899dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2900dc2207afSDaniel P. Berrangé            nettle_xts=yes
2901dc2207afSDaniel P. Berrangé            qemu_private_xts=no
2902dc2207afSDaniel P. Berrangé        fi
2903dc2207afSDaniel P. Berrangé    fi
2904a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
290564dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2906a0722409SDaniel P. Berrangé    else
2907a73e82efSRichard Henderson        nettle="$pass"
2908a0722409SDaniel P. Berrangé    fi
2909a0722409SDaniel P. Berrangéfi
2910a0722409SDaniel P. Berrangé
291191bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2912a73e82efSRichard Henderson    pass="no"
2913dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
291489138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
291589138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
2916a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
291791bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
291891bfcdb0SDaniel P. Berrange        # turn breaks static builds...
291991bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
292091bfcdb0SDaniel P. Berrange        then
292191bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
292291bfcdb0SDaniel P. Berrange        fi
29231f923c70SLongpeng(Mike)
2924a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2925a73e82efSRichard Henderson        write_c_skeleton
2926a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
2927243dc2cfSRichard Henderson            LIBS="$gcrypt_libs $LIBS"
292837788f25SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2929a73e82efSRichard Henderson            pass="yes"
2930a73e82efSRichard Henderson        fi
2931a73e82efSRichard Henderson    fi
2932a73e82efSRichard Henderson    if test "$pass" = "yes"; then
293337788f25SDaniel P. Berrange        gcrypt="yes"
29341f923c70SLongpeng(Mike)        cat > $TMPC << EOF
29351f923c70SLongpeng(Mike)#include <gcrypt.h>
29361f923c70SLongpeng(Mike)int main(void) {
29371f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
29381f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
29391f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
29401f923c70SLongpeng(Mike)  return 0;
29411f923c70SLongpeng(Mike)}
29421f923c70SLongpeng(Mike)EOF
29431f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
29441f923c70SLongpeng(Mike)            gcrypt_hmac=yes
29451f923c70SLongpeng(Mike)        fi
2946e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
2947e0576942SDaniel P. Berrangé#include <gcrypt.h>
2948e0576942SDaniel P. Berrangéint main(void) {
2949e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
2950e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
2951e0576942SDaniel P. Berrangé  return 0;
2952e0576942SDaniel P. Berrangé}
2953e0576942SDaniel P. BerrangéEOF
2954e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2955e0576942SDaniel P. Berrangé            gcrypt_xts=yes
2956e0576942SDaniel P. Berrangé            qemu_private_xts=no
2957e0576942SDaniel P. Berrangé        fi
2958a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
2959dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
296091bfcdb0SDaniel P. Berrange    else
296191bfcdb0SDaniel P. Berrange        gcrypt="no"
296291bfcdb0SDaniel P. Berrange    fi
296362893b67SDaniel P. Berrangefi
296462893b67SDaniel P. Berrange
2965ddbb0d09SDaniel P. Berrange
296691bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
296791bfcdb0SDaniel P. Berrangethen
296891bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
296991bfcdb0SDaniel P. Berrangefi
2970ed754746SDaniel P. Berrange
29719a2fd434SDaniel P. Berrange##########################################
29729a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
29739a2fd434SDaniel P. Berrange
29749a2fd434SDaniel P. Berrangetasn1=yes
297590246037SDaniel P. Berrangetasn1_cflags=""
297690246037SDaniel P. Berrangetasn1_libs=""
29779a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
297889138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
297989138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
29809a2fd434SDaniel P. Berrangeelse
29819a2fd434SDaniel P. Berrange    tasn1=no
29829a2fd434SDaniel P. Berrangefi
29839a2fd434SDaniel P. Berrange
2984ed754746SDaniel P. Berrange
2985bbbf9bfbSStefan Weil##########################################
29868953caf3SDaniel P. Berrange# PAM probe
29878953caf3SDaniel P. Berrange
29888953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
29898953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
29908953caf3SDaniel P. Berrange#include <security/pam_appl.h>
29918953caf3SDaniel P. Berrange#include <stdio.h>
29928953caf3SDaniel P. Berrangeint main(void) {
29938953caf3SDaniel P. Berrange   const char *service_name = "qemu";
29948953caf3SDaniel P. Berrange   const char *user = "frank";
29959c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
29968953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
29979c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
29988953caf3SDaniel P. Berrange   return 0;
29998953caf3SDaniel P. Berrange}
30008953caf3SDaniel P. BerrangeEOF
30018953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
30028953caf3SDaniel P. Berrange        auth_pam=yes
30038953caf3SDaniel P. Berrange    else
30048953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
30058953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
30068953caf3SDaniel P. Berrange        else
30078953caf3SDaniel P. Berrange            auth_pam=no
30088953caf3SDaniel P. Berrange        fi
30098953caf3SDaniel P. Berrange    fi
30108953caf3SDaniel P. Berrangefi
30118953caf3SDaniel P. Berrange
30128953caf3SDaniel P. Berrange##########################################
3013559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
3014559607eaSDaniel P. Berrange
3015559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
3016559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
3017559607eaSDaniel P. Berrange  have_ifaddrs_h=no
3018559607eaSDaniel P. Berrangefi
3019559607eaSDaniel P. Berrange
3020559607eaSDaniel P. Berrange##########################################
3021bbbf9bfbSStefan Weil# VTE probe
3022bbbf9bfbSStefan Weil
3023bbbf9bfbSStefan Weilif test "$vte" != "no"; then
3024c6feff9eSCole Robinson    vteminversion="0.32.0"
3025c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3026c6feff9eSCole Robinson      vtepackage="vte-2.91"
3027c6feff9eSCole Robinson    else
3028528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3029c6feff9eSCole Robinson    fi
3030c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
303189138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
303289138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
303389138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3034bbbf9bfbSStefan Weil        vte="yes"
3035bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3036c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
30379e04c683SStefan Weil    else
3038bbbf9bfbSStefan Weil        vte="no"
3039a4ccabcfSAnthony Liguori    fi
3040a4ccabcfSAnthony Liguorifi
3041a4ccabcfSAnthony Liguori
3042a4ccabcfSAnthony Liguori##########################################
304311d9f695Sbellard# SDL probe
304411d9f695Sbellard
3045aee8a619SCarlo Marcelo Arenas Belón# Look for sdl configuration program (pkg-config or sdl2-config).  Try
3046aee8a619SCarlo Marcelo Arenas Belón# sdl2-config even without cross prefix, and favour pkg-config over sdl2-config.
304747c03744SDave Airlie
3048c6093a05SPeter Xusdl_probe ()
3049c6093a05SPeter Xu{
30500015ca5cSDaniel P. Berrangé  if $pkg_config sdl2 --exists; then
30510015ca5cSDaniel P. Berrangé    sdlconfig="$pkg_config sdl2"
305289138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
3053aee8a619SCarlo Marcelo Arenas Belón  elif has "$sdl2_config"; then
30540015ca5cSDaniel P. Berrangé    sdlconfig="$sdl2_config"
305589138857SStefan Weil    sdlversion=$($sdlconfig --version)
3056a0dfd8a4SLoïc Minier  else
3057a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
30588f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
3059a0dfd8a4SLoïc Minier    fi
3060a0dfd8a4SLoïc Minier    sdl=no
3061c6093a05SPeter Xu    # no need to do the rest
3062c6093a05SPeter Xu    return
30639316f803SPaolo Bonzini  fi
3064aee8a619SCarlo Marcelo Arenas Belón  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then
30653ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
30663ec87ffeSPaolo Bonzini  fi
306711d9f695Sbellard
306811d9f695Sbellard  cat > $TMPC << EOF
306911d9f695Sbellard#include <SDL.h>
307011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
307111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
307211d9f695SbellardEOF
307389138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
30742ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
307574f42e18STeLeMan  if test "$static" = "yes" ; then
30760015ca5cSDaniel P. Berrangé    if $pkg_config sdl2 --exists; then
30770015ca5cSDaniel P. Berrangé      sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
30785f37e6d4SThomas Huth    else
307989138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
30805f37e6d4SThomas Huth    fi
308174f42e18STeLeMan  else
308289138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
308374f42e18STeLeMan  fi
308452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
308511d9f695Sbellard    sdl=yes
30867c1f25b4Sbellard
308767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3088e633a5c6SEric Blake    if test "$sdl" = "yes" && test "$static" = "yes" ; then
308967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
309089138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
309189138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
309211d9f695Sbellard      fi
309352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
30941ac88f28SJuan Quintela	:
30951ac88f28SJuan Quintela      else
30961ac88f28SJuan Quintela        sdl=no
30977c1f25b4Sbellard      fi
30987c1f25b4Sbellard    fi # static link
3099c4198157SJuan Quintela  else # sdl not found
3100c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
31010015ca5cSDaniel P. Berrangé      feature_not_found "sdl" "Install SDL2 devel"
3102c4198157SJuan Quintela    fi
3103c4198157SJuan Quintela    sdl=no
31047c1f25b4Sbellard  fi # sdl compile test
3105c6093a05SPeter Xu}
3106c6093a05SPeter Xu
3107a442fe2fSDaniel P. Berrangésdl_image_probe ()
3108a442fe2fSDaniel P. Berrangé{
3109a442fe2fSDaniel P. Berrangé    if test "$sdl_image" != "no" ; then
3110a442fe2fSDaniel P. Berrangé        if $pkg_config SDL2_image --exists; then
3111a442fe2fSDaniel P. Berrangé            if test "$static" = "yes"; then
3112a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3113a442fe2fSDaniel P. Berrangé            else
3114a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3115a442fe2fSDaniel P. Berrangé            fi
3116a442fe2fSDaniel P. Berrangé            sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3117a442fe2fSDaniel P. Berrangé            sdl_image=yes
3118a442fe2fSDaniel P. Berrangé
3119a442fe2fSDaniel P. Berrangé            sdl_cflags="$sdl_cflags $sdl_image_cflags"
3120a442fe2fSDaniel P. Berrangé            sdl_libs="$sdl_libs $sdl_image_libs"
3121a442fe2fSDaniel P. Berrangé        else
3122a442fe2fSDaniel P. Berrangé            if test "$sdl_image" = "yes" ; then
3123a442fe2fSDaniel P. Berrangé                feature_not_found "sdl_image" "Install SDL Image devel"
3124a442fe2fSDaniel P. Berrangé            else
3125a442fe2fSDaniel P. Berrangé                sdl_image=no
3126a442fe2fSDaniel P. Berrangé            fi
3127a442fe2fSDaniel P. Berrangé        fi
3128a442fe2fSDaniel P. Berrangé    fi
3129a442fe2fSDaniel P. Berrangé}
3130a442fe2fSDaniel P. Berrangé
3131c6093a05SPeter Xuif test "$sdl" != "no" ; then
3132c6093a05SPeter Xu  sdl_probe
3133fd677642Sthsfi
313411d9f695Sbellard
31355368a422Saliguoriif test "$sdl" = "yes" ; then
3136a442fe2fSDaniel P. Berrangé  sdl_image_probe
3137a442fe2fSDaniel P. Berrangéelse
3138a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes"; then
3139a442fe2fSDaniel P. Berrangé    echo "warning: SDL Image requested, but SDL is not available, disabling"
3140a442fe2fSDaniel P. Berrangé  fi
3141a442fe2fSDaniel P. Berrangé  sdl_image=no
3142a442fe2fSDaniel P. Berrangéfi
3143a442fe2fSDaniel P. Berrangé
3144a442fe2fSDaniel P. Berrangéif test "$sdl" = "yes" ; then
31455368a422Saliguori  cat > $TMPC <<EOF
31465368a422Saliguori#include <SDL.h>
31475368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
31485368a422Saliguori#include <X11/XKBlib.h>
31495368a422Saliguori#else
31505368a422Saliguori#error No x11 support
31515368a422Saliguori#endif
31525368a422Saliguoriint main(void) { return 0; }
31535368a422SaliguoriEOF
3154f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
31558781595bSGerd Hoffmann    need_x11=yes
3156f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3157f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
31585368a422Saliguori  fi
31595368a422Saliguorifi
31605368a422Saliguori
31618f28f3fbSths##########################################
31622da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
31632da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
31642da776dbSMichael R. Hines  cat > $TMPC <<EOF
31652da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
31662da776dbSMichael R. Hinesint main(void) { return 0; }
31672da776dbSMichael R. HinesEOF
3168ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
31692da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
31702da776dbSMichael R. Hines    rdma="yes"
3171ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
31722da776dbSMichael R. Hines  else
31732da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
31742da776dbSMichael R. Hines        error_exit \
3175ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
31762da776dbSMichael R. Hines            " Your options:" \
3177ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
31782da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
31792da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
31802da776dbSMichael R. Hines    fi
31812da776dbSMichael R. Hines    rdma="no"
31822da776dbSMichael R. Hines  fi
31832da776dbSMichael R. Hinesfi
31842da776dbSMichael R. Hines
318521ab34c9SMarcel Apfelbaum##########################################
318621ab34c9SMarcel Apfelbaum# PVRDMA detection
318721ab34c9SMarcel Apfelbaum
318821ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
318921ab34c9SMarcel Apfelbaum#include <sys/mman.h>
319021ab34c9SMarcel Apfelbaum
319121ab34c9SMarcel Apfelbaumint
319221ab34c9SMarcel Apfelbaummain(void)
319321ab34c9SMarcel Apfelbaum{
319421ab34c9SMarcel Apfelbaum    char buf = 0;
319521ab34c9SMarcel Apfelbaum    void *addr = &buf;
319621ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
319721ab34c9SMarcel Apfelbaum
319821ab34c9SMarcel Apfelbaum    return 0;
319921ab34c9SMarcel Apfelbaum}
320021ab34c9SMarcel ApfelbaumEOF
320121ab34c9SMarcel Apfelbaum
320221ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
320321ab34c9SMarcel Apfelbaum    case "$pvrdma" in
320421ab34c9SMarcel Apfelbaum    "")
320521ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
320621ab34c9SMarcel Apfelbaum            pvrdma="yes"
320721ab34c9SMarcel Apfelbaum        else
320821ab34c9SMarcel Apfelbaum            pvrdma="no"
320921ab34c9SMarcel Apfelbaum        fi
321021ab34c9SMarcel Apfelbaum        ;;
321121ab34c9SMarcel Apfelbaum    "yes")
321221ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
321321ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
321421ab34c9SMarcel Apfelbaum        fi
321521ab34c9SMarcel Apfelbaum        pvrdma="yes"
321621ab34c9SMarcel Apfelbaum        ;;
321721ab34c9SMarcel Apfelbaum    "no")
321821ab34c9SMarcel Apfelbaum        pvrdma="no"
321921ab34c9SMarcel Apfelbaum        ;;
322021ab34c9SMarcel Apfelbaum    esac
322121ab34c9SMarcel Apfelbaumelse
322221ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
322321ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
322421ab34c9SMarcel Apfelbaum    fi
322521ab34c9SMarcel Apfelbaum    pvrdma="no"
322621ab34c9SMarcel Apfelbaumfi
322795c6bff3SBenoît Canet
3228ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3229ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3230ee108585SYuval Shaia
3231ee108585SYuval Shaiacat > $TMPC <<EOF &&
3232ee108585SYuval Shaia#include <infiniband/verbs.h>
3233ee108585SYuval Shaia
3234ee108585SYuval Shaiaint
3235ee108585SYuval Shaiamain(void)
3236ee108585SYuval Shaia{
3237ee108585SYuval Shaia    struct ibv_mr *mr;
3238ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3239ee108585SYuval Shaia    size_t length = 10;
3240ee108585SYuval Shaia    uint64_t iova = 0;
3241ee108585SYuval Shaia    int access = 0;
3242ee108585SYuval Shaia    void *addr = NULL;
3243ee108585SYuval Shaia
3244ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3245ee108585SYuval Shaia
3246ee108585SYuval Shaia    ibv_dereg_mr(mr);
3247ee108585SYuval Shaia
3248ee108585SYuval Shaia    return 0;
3249ee108585SYuval Shaia}
3250ee108585SYuval ShaiaEOF
3251ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3252ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3253ee108585SYuval Shaia    fi
3254ee108585SYuval Shaiafi
3255ee108585SYuval Shaia
325695c6bff3SBenoît Canet##########################################
32572f9606b3Saliguori# VNC SASL detection
3258e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
32592f9606b3Saliguori  cat > $TMPC <<EOF
32602f9606b3Saliguori#include <sasl/sasl.h>
32612f9606b3Saliguori#include <stdio.h>
32622f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
32632f9606b3SaliguoriEOF
32642f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
32652f9606b3Saliguori  vnc_sasl_cflags=""
32662f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
326752166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3268ea784e3bSJuan Quintela    vnc_sasl=yes
3269fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3270ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
32712f9606b3Saliguori  else
3272ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
327321684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3274ea784e3bSJuan Quintela    fi
3275ea784e3bSJuan Quintela    vnc_sasl=no
32762f9606b3Saliguori  fi
32772f9606b3Saliguorifi
32782f9606b3Saliguori
32792f9606b3Saliguori##########################################
32802f6f5c7aSCorentin Chary# VNC JPEG detection
3281e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
32822f6f5c7aSCorentin Charycat > $TMPC <<EOF
32832f6f5c7aSCorentin Chary#include <stdio.h>
32842f6f5c7aSCorentin Chary#include <jpeglib.h>
32852f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
32862f6f5c7aSCorentin CharyEOF
32872f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
32882f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
32892f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
32902f6f5c7aSCorentin Chary    vnc_jpeg=yes
32912f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3292ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
32932f6f5c7aSCorentin Chary  else
32942f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
329521684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
32962f6f5c7aSCorentin Chary    fi
32972f6f5c7aSCorentin Chary    vnc_jpeg=no
32982f6f5c7aSCorentin Chary  fi
32992f6f5c7aSCorentin Charyfi
33002f6f5c7aSCorentin Chary
33012f6f5c7aSCorentin Chary##########################################
3302efe556adSCorentin Chary# VNC PNG detection
3303e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3304efe556adSCorentin Charycat > $TMPC <<EOF
3305efe556adSCorentin Chary//#include <stdio.h>
3306efe556adSCorentin Chary#include <png.h>
3307832ce9c2SScott Wood#include <stddef.h>
3308efe556adSCorentin Charyint main(void) {
3309efe556adSCorentin Chary    png_structp png_ptr;
3310efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
33117edc3fedSPeter Maydell    return png_ptr != 0;
3312efe556adSCorentin Chary}
3313efe556adSCorentin CharyEOF
331465d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
331589138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
331689138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
33179af8025eSBrad  else
3318efe556adSCorentin Chary    vnc_png_cflags=""
3319efe556adSCorentin Chary    vnc_png_libs="-lpng"
33209af8025eSBrad  fi
3321efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3322efe556adSCorentin Chary    vnc_png=yes
3323efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
33249af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3325efe556adSCorentin Chary  else
3326efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
332721684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3328efe556adSCorentin Chary    fi
3329efe556adSCorentin Chary    vnc_png=no
3330efe556adSCorentin Chary  fi
3331efe556adSCorentin Charyfi
3332efe556adSCorentin Chary
3333efe556adSCorentin Chary##########################################
33346a021536SGerd Hoffmann# xkbcommon probe
33356a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
33366a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
33376a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
33386a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
33396a021536SGerd Hoffmann    xkbcommon=yes
33406a021536SGerd Hoffmann  else
33416a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
33426a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
33436a021536SGerd Hoffmann    fi
33446a021536SGerd Hoffmann    xkbcommon=no
33456a021536SGerd Hoffmann  fi
33466a021536SGerd Hoffmannfi
33476a021536SGerd Hoffmann
334876655d6dSaliguori
334976655d6dSaliguori##########################################
3350c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3351dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3352dce512deSChristoph Hellwig  cat > $TMPC << EOF
3353ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3354dce512deSChristoph Hellwig#include <xfs/xfs.h>
3355dce512deSChristoph Hellwigint main(void)
3356dce512deSChristoph Hellwig{
3357dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3358dce512deSChristoph Hellwig    return 0;
3359dce512deSChristoph Hellwig}
3360dce512deSChristoph HellwigEOF
3361dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3362dce512deSChristoph Hellwig    xfs="yes"
3363dce512deSChristoph Hellwig  else
3364dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
336521684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3366dce512deSChristoph Hellwig    fi
3367dce512deSChristoph Hellwig    xfs=no
3368dce512deSChristoph Hellwig  fi
3369dce512deSChristoph Hellwigfi
3370dce512deSChristoph Hellwig
3371dce512deSChristoph Hellwig##########################################
33728a16d273Sths# vde libraries probe
3373dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
33744baae0acSJuan Quintela  vde_libs="-lvdeplug"
33758a16d273Sths  cat > $TMPC << EOF
33768a16d273Sths#include <libvdeplug.h>
33774a7f0e06Spbrookint main(void)
33784a7f0e06Spbrook{
33794a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3380fea08e08SPeter Maydell    char s[] = "";
3381fea08e08SPeter Maydell    vde_open(s, s, &a);
33824a7f0e06Spbrook    return 0;
33834a7f0e06Spbrook}
33848a16d273SthsEOF
338552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
33864baae0acSJuan Quintela    vde=yes
3387dfb278bdSJuan Quintela  else
3388dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
338921684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3390dfb278bdSJuan Quintela    fi
3391dfb278bdSJuan Quintela    vde=no
33928a16d273Sths  fi
33938a16d273Sthsfi
33948a16d273Sths
33958a16d273Sths##########################################
33960a985b37SVincenzo Maffione# netmap support probe
33970a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
33980a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
33990a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
34000a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
34010a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
340258952137SVincenzo Maffioneif test "$netmap" != "no" ; then
340358952137SVincenzo Maffione  cat > $TMPC << EOF
340458952137SVincenzo Maffione#include <inttypes.h>
340558952137SVincenzo Maffione#include <net/if.h>
340658952137SVincenzo Maffione#include <net/netmap.h>
340758952137SVincenzo Maffione#include <net/netmap_user.h>
34080a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
34090a985b37SVincenzo Maffione#error
34100a985b37SVincenzo Maffione#endif
341158952137SVincenzo Maffioneint main(void) { return 0; }
341258952137SVincenzo MaffioneEOF
341358952137SVincenzo Maffione  if compile_prog "" "" ; then
341458952137SVincenzo Maffione    netmap=yes
341558952137SVincenzo Maffione  else
341658952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
341758952137SVincenzo Maffione      feature_not_found "netmap"
341858952137SVincenzo Maffione    fi
341958952137SVincenzo Maffione    netmap=no
342058952137SVincenzo Maffione  fi
342158952137SVincenzo Maffionefi
342258952137SVincenzo Maffione
342358952137SVincenzo Maffione##########################################
342447e98658SCorey Bryant# libcap-ng library probe
342547e98658SCorey Bryantif test "$cap_ng" != "no" ; then
342647e98658SCorey Bryant  cap_libs="-lcap-ng"
342747e98658SCorey Bryant  cat > $TMPC << EOF
342847e98658SCorey Bryant#include <cap-ng.h>
342947e98658SCorey Bryantint main(void)
343047e98658SCorey Bryant{
343147e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
343247e98658SCorey Bryant    return 0;
343347e98658SCorey Bryant}
343447e98658SCorey BryantEOF
343547e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
343647e98658SCorey Bryant    cap_ng=yes
343747e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
343847e98658SCorey Bryant  else
343947e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
344021684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
344147e98658SCorey Bryant    fi
344247e98658SCorey Bryant    cap_ng=no
344347e98658SCorey Bryant  fi
344447e98658SCorey Bryantfi
344547e98658SCorey Bryant
344647e98658SCorey Bryant##########################################
3447c2de5c91Smalc# Sound support libraries probe
34488f28f3fbSths
344989138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3450c2de5c91Smalcfor drv in $audio_drv_list; do
3451c2de5c91Smalc    case $drv in
3452e42975a1SGerd Hoffmann    alsa | try-alsa)
3453c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3454c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3455e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3456e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3457e42975a1SGerd Hoffmann        fi
3458e42975a1SGerd Hoffmann    else
3459e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3460e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3461c80a867fSGerd Hoffmann        else
3462c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3463c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3464c80a867fSGerd Hoffmann        fi
3465e42975a1SGerd Hoffmann    fi
3466c2de5c91Smalc    ;;
3467c2de5c91Smalc
3468e42975a1SGerd Hoffmann    pa | try-pa)
3469c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3470c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3471e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3472e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3473e42975a1SGerd Hoffmann        fi
3474e42975a1SGerd Hoffmann    else
3475e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3476e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3477c80a867fSGerd Hoffmann        else
3478c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3479c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3480c80a867fSGerd Hoffmann        fi
3481e42975a1SGerd Hoffmann    fi
3482b8e59f18Smalc    ;;
3483b8e59f18Smalc
3484373967b2SGerd Hoffmann    sdl)
3485373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3486373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3487373967b2SGerd Hoffmann    fi
3488373967b2SGerd Hoffmann    ;;
3489373967b2SGerd Hoffmann
3490e42975a1SGerd Hoffmann    try-sdl)
3491e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3492e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3493e42975a1SGerd Hoffmann    else
3494e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3495e42975a1SGerd Hoffmann    fi
3496e42975a1SGerd Hoffmann    ;;
3497e42975a1SGerd Hoffmann
3498997e690aSJuan Quintela    coreaudio)
3499b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3500997e690aSJuan Quintela    ;;
3501997e690aSJuan Quintela
3502a4bf6780SJuan Quintela    dsound)
3503b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3504d5631638Smalc      audio_win_int="yes"
3505a4bf6780SJuan Quintela    ;;
3506a4bf6780SJuan Quintela
3507a4bf6780SJuan Quintela    oss)
3508b1149911SFam Zheng      oss_libs="$oss_lib"
3509a4bf6780SJuan Quintela    ;;
3510a4bf6780SJuan Quintela
3511e4c63a6aSmalc    *)
35121c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
351376ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
351476ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3515e4c63a6aSmalc    }
3516e4c63a6aSmalc    ;;
3517c2de5c91Smalc    esac
3518c2de5c91Smalcdone
35198f28f3fbSths
35204d3b6f6eSbalrog##########################################
35212e4d9fb1Saurel32# BrlAPI probe
35222e4d9fb1Saurel32
35234ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3524eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
35252e4d9fb1Saurel32  cat > $TMPC << EOF
35262e4d9fb1Saurel32#include <brlapi.h>
3527832ce9c2SScott Wood#include <stddef.h>
35282e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
35292e4d9fb1Saurel32EOF
353052166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
35312e4d9fb1Saurel32    brlapi=yes
35324ffcedb6SJuan Quintela  else
35334ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
353421684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
35354ffcedb6SJuan Quintela    fi
35364ffcedb6SJuan Quintela    brlapi=no
3537eb82284fSJuan Quintela  fi
3538eb82284fSJuan Quintelafi
35392e4d9fb1Saurel32
35402e4d9fb1Saurel32##########################################
3541e08bb301SSamuel Thibault# iconv probe
3542e08bb301SSamuel Thibaultif test "$iconv" != "no" ; then
3543e08bb301SSamuel Thibault  cat > $TMPC << EOF
3544e08bb301SSamuel Thibault#include <iconv.h>
3545e08bb301SSamuel Thibaultint main(void) {
3546e08bb301SSamuel Thibault  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3547e08bb301SSamuel Thibault  return conv != (iconv_t) -1;
3548e08bb301SSamuel Thibault}
3549e08bb301SSamuel ThibaultEOF
3550e08bb301SSamuel Thibault  iconv_prefix_list="/usr/local:/usr"
3551e08bb301SSamuel Thibault  iconv_lib_list=":-liconv"
3552e08bb301SSamuel Thibault  IFS=:
3553e08bb301SSamuel Thibault  for iconv_prefix in $iconv_prefix_list; do
3554e08bb301SSamuel Thibault    IFS=:
3555e08bb301SSamuel Thibault    iconv_cflags="-I$iconv_prefix/include"
3556e08bb301SSamuel Thibault    iconv_ldflags="-L$iconv_prefix/lib"
3557e08bb301SSamuel Thibault    for iconv_link in $iconv_lib_list; do
3558e08bb301SSamuel Thibault      unset IFS
3559e08bb301SSamuel Thibault      iconv_lib="$iconv_ldflags $iconv_link"
3560e08bb301SSamuel Thibault      echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3561e08bb301SSamuel Thibault      if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3562e08bb301SSamuel Thibault        iconv_found=yes
3563e08bb301SSamuel Thibault        break
3564e08bb301SSamuel Thibault      fi
3565e08bb301SSamuel Thibault    done
3566e08bb301SSamuel Thibault    if test "$iconv_found" = yes ; then
3567e08bb301SSamuel Thibault      break
3568e08bb301SSamuel Thibault    fi
3569e08bb301SSamuel Thibault  done
3570e08bb301SSamuel Thibault  if test "$iconv_found" = "yes" ; then
3571e08bb301SSamuel Thibault    iconv=yes
3572e08bb301SSamuel Thibault  else
3573e08bb301SSamuel Thibault    if test "$iconv" = "yes" ; then
3574e08bb301SSamuel Thibault      feature_not_found "iconv" "Install iconv devel"
3575e08bb301SSamuel Thibault    fi
3576e08bb301SSamuel Thibault    iconv=no
3577e08bb301SSamuel Thibault  fi
3578e08bb301SSamuel Thibaultfi
3579e08bb301SSamuel Thibault
3580e08bb301SSamuel Thibault##########################################
35814d3b6f6eSbalrog# curses probe
3582e08bb301SSamuel Thibaultif test "$iconv" = "no" ; then
3583e08bb301SSamuel Thibault  # curses will need iconv
3584e08bb301SSamuel Thibault  curses=no
3585e08bb301SSamuel Thibaultfi
3586a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3587e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
35888ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
35898ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3590e095e2f3SStefan Weil  else
35917c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
35928ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3593e095e2f3SStefan Weil  fi
3594c584a6d0SJuan Quintela  curses_found=no
35954d3b6f6eSbalrog  cat > $TMPC << EOF
35968ddc5bf9SSamuel Thibault#include <locale.h>
35974d3b6f6eSbalrog#include <curses.h>
35988ddc5bf9SSamuel Thibault#include <wchar.h>
35992f8b7cd5SSamuel Thibault#include <langinfo.h>
3600ef9a2524SStefan Weilint main(void) {
36012f8b7cd5SSamuel Thibault  const char *codeset;
36028ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
36038ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3604ef9a2524SStefan Weil  resize_term(0, 0);
36058ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
36068ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
36077c703002SSamuel Thibault  add_wch(WACS_DEGREE);
36082f8b7cd5SSamuel Thibault  codeset = nl_langinfo(CODESET);
36092f8b7cd5SSamuel Thibault  return codeset != 0;
3610ef9a2524SStefan Weil}
36114d3b6f6eSbalrogEOF
3612ecbe251fSVadim Evard  IFS=:
36138ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3614b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3615b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
36167c703002SSamuel Thibault    IFS=:
36178ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3618ecbe251fSVadim Evard      unset IFS
36198ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3620c584a6d0SJuan Quintela        curses_found=yes
36214f78ef9aSJuan Quintela        break
36224d3b6f6eSbalrog      fi
36234f78ef9aSJuan Quintela    done
36247c703002SSamuel Thibault    if test "$curses_found" = yes ; then
36257c703002SSamuel Thibault      break
36267c703002SSamuel Thibault    fi
36278ddc5bf9SSamuel Thibault  done
3628ecbe251fSVadim Evard  unset IFS
3629c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3630c584a6d0SJuan Quintela    curses=yes
3631c584a6d0SJuan Quintela  else
3632c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
363321684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3634c584a6d0SJuan Quintela    fi
3635c584a6d0SJuan Quintela    curses=no
3636c584a6d0SJuan Quintela  fi
36374f78ef9aSJuan Quintelafi
36384d3b6f6eSbalrog
3639414f0dabSblueswir1##########################################
3640769ce76dSAlexander Graf# curl probe
3641a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
364265d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3643a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
36444e2b0658SPaolo Bonzini  else
36454e2b0658SPaolo Bonzini    curlconfig=curl-config
36464e2b0658SPaolo Bonzini  fi
3647769ce76dSAlexander Graf  cat > $TMPC << EOF
3648769ce76dSAlexander Graf#include <curl/curl.h>
36490b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3650769ce76dSAlexander GrafEOF
365189138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
365289138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3653b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3654769ce76dSAlexander Graf    curl=yes
3655788c8196SJuan Quintela  else
3656788c8196SJuan Quintela    if test "$curl" = "yes" ; then
365721684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3658788c8196SJuan Quintela    fi
3659788c8196SJuan Quintela    curl=no
3660769ce76dSAlexander Graf  fi
3661769ce76dSAlexander Graffi # test "$curl"
3662769ce76dSAlexander Graf
3663769ce76dSAlexander Graf##########################################
3664e18df141SAnthony Liguori# glib support probe
3665a52d28afSPaolo Bonzini
366600f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3667aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3668aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3669a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3670aa0d1f44SPaolo Bonzinifi
367154cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
367254cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
367354cb65d8SEmilio G. Cotafi
3674e26110cfSFam Zheng
36754eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
36764eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
36774eaf7202SSameeh Jubran
3678e633a5c6SEric Blakeif test "$static" = yes && test "$mingw32" = yes; then
36794eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
36804eaf7202SSameeh Jubranfi
36814eaf7202SSameeh Jubran
3682aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3683e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
368489138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
368589138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
36864a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
368714015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3688957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3689e18df141SAnthony Liguori    else
3690e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3691e26110cfSFam Zheng    fi
3692e26110cfSFam Zhengdone
3693e26110cfSFam Zheng
3694f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3695f876b765SMarc-André Lureau    gio=yes
3696f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3697f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
3698f876b765SMarc-André Lureauelse
3699f876b765SMarc-André Lureau    gio=no
3700f876b765SMarc-André Lureaufi
3701f876b765SMarc-André Lureau
3702977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3703977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3704977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3705977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3706977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3707977a82abSDaniel P. Berrange#include <glib.h>
3708977a82abSDaniel P. Berrange#include <unistd.h>
3709977a82abSDaniel P. Berrange
3710977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3711977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3712977a82abSDaniel P. Berrange
3713977a82abSDaniel P. Berrangeint main(void) {
3714977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3715977a82abSDaniel P. Berrange   return 0;
3716977a82abSDaniel P. Berrange}
3717977a82abSDaniel P. BerrangeEOF
3718977a82abSDaniel P. Berrange
37195919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3720977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3721977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3722977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3723977a82abSDaniel P. Berrange	       "build target"
3724977a82abSDaniel P. Berrangefi
3725977a82abSDaniel P. Berrange
3726bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3727bbbf2e04SJohn Snowcat > $TMPC << EOF
3728bbbf2e04SJohn Snow#include <glib.h>
3729bbbf2e04SJohn Snowint main(void) { return 0; }
3730bbbf2e04SJohn SnowEOF
3731bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3732bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3733bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3734bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3735bbbf2e04SJohn Snow    fi
3736bbbf2e04SJohn Snowfi
3737bbbf2e04SJohn Snow
37386a1f42bdSStefan Weil#########################################
37396a1f42bdSStefan Weil# zlib check
37406a1f42bdSStefan Weil
37416a1f42bdSStefan Weilif test "$zlib" != "no" ; then
37426a1f42bdSStefan Weil    if $pkg_config --exists zlib; then
37436a1f42bdSStefan Weil        zlib_cflags=$($pkg_config --cflags zlib)
37446a1f42bdSStefan Weil        zlib_libs=$($pkg_config --libs zlib)
37456a1f42bdSStefan Weil        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
37466a1f42bdSStefan Weil        LIBS="$zlib_libs $LIBS"
37476a1f42bdSStefan Weil    else
37486a1f42bdSStefan Weil        cat > $TMPC << EOF
37496a1f42bdSStefan Weil#include <zlib.h>
37506a1f42bdSStefan Weilint main(void) { zlibVersion(); return 0; }
37516a1f42bdSStefan WeilEOF
37526a1f42bdSStefan Weil        if compile_prog "" "-lz" ; then
37536a1f42bdSStefan Weil            LIBS="$LIBS -lz"
37546a1f42bdSStefan Weil        else
37556a1f42bdSStefan Weil            error_exit "zlib check failed" \
37566a1f42bdSStefan Weil                "Make sure to have the zlib libs and headers installed."
37576a1f42bdSStefan Weil        fi
37586a1f42bdSStefan Weil    fi
37596a1f42bdSStefan Weilfi
37606a1f42bdSStefan Weil
3761e26110cfSFam Zheng##########################################
3762e26110cfSFam Zheng# SHA command probe for modules
3763e26110cfSFam Zhengif test "$modules" = yes; then
3764e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3765e26110cfSFam Zheng    for c in $shacmd_probe; do
37668ccefb91SFam Zheng        if has $c; then
3767e26110cfSFam Zheng            shacmd="$c"
3768e26110cfSFam Zheng            break
3769e26110cfSFam Zheng        fi
3770e26110cfSFam Zheng    done
3771e26110cfSFam Zheng    if test "$shacmd" = ""; then
3772e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3773e26110cfSFam Zheng    fi
3774e18df141SAnthony Liguorifi
3775e18df141SAnthony Liguori
3776e18df141SAnthony Liguori##########################################
3777e2134eb9SGerd Hoffmann# pixman support probe
3778e2134eb9SGerd Hoffmann
3779e633a5c6SEric Blakeif test "$want_tools" = "no" && test "$softmmu" = "no"; then
378074880fe2SRobert Schiele  pixman_cflags=
378174880fe2SRobert Schiele  pixman_libs=
378235c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
378389138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
378489138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3785e2134eb9SGerd Hoffmannelse
3786c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3787c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3788e2134eb9SGerd Hoffmannfi
3789e2134eb9SGerd Hoffmann
3790e2134eb9SGerd Hoffmann##########################################
3791fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3792fe8fc5aeSPaolo Bonzini
3793fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
37941b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3795fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3796fe8fc5aeSPaolo Bonzini#include <libudev.h>
3797fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3798fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3799fe8fc5aeSPaolo Bonziniint logsink;
3800b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3801b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3802b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3803b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3804b3f1c8c4SPaolo Bonzinistruct udev *udev;
3805b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3806b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3807b3f1c8c4SPaolo Bonzini
3808fe8fc5aeSPaolo Bonziniint main(void) {
3809b3f1c8c4SPaolo Bonzini    udev = udev_new();
3810b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3811fe8fc5aeSPaolo Bonzini    return 0;
3812fe8fc5aeSPaolo Bonzini}
3813fe8fc5aeSPaolo BonziniEOF
3814fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3815fe8fc5aeSPaolo Bonzini    mpathpersist=yes
38161b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
38171b0578f5SMurilo Opsfelder Araujo  else
38181b0578f5SMurilo Opsfelder Araujo    # probe for the old API
38191b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
38201b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
38211b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
38221b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
38231b0578f5SMurilo Opsfelder Araujoint logsink;
38241b0578f5SMurilo Opsfelder Araujoint main(void) {
38251b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
38261b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
38271b0578f5SMurilo Opsfelder Araujo    return 0;
38281b0578f5SMurilo Opsfelder Araujo}
38291b0578f5SMurilo Opsfelder AraujoEOF
38301b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
38311b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
38321b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3833fe8fc5aeSPaolo Bonzini    else
3834fe8fc5aeSPaolo Bonzini      mpathpersist=no
3835fe8fc5aeSPaolo Bonzini    fi
38361b0578f5SMurilo Opsfelder Araujo  fi
3837fe8fc5aeSPaolo Bonzinielse
3838fe8fc5aeSPaolo Bonzini  mpathpersist=no
3839fe8fc5aeSPaolo Bonzinifi
3840fe8fc5aeSPaolo Bonzini
3841fe8fc5aeSPaolo Bonzini##########################################
3842e5d355d1Saliguori# pthread probe
38434b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
38443c529d93Saliguori
3845e5d355d1Saliguoripthread=no
3846414f0dabSblueswir1cat > $TMPC << EOF
38473c529d93Saliguori#include <pthread.h>
38487a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
38497a42bbe4SStefan Weilint main(void) {
38507a42bbe4SStefan Weil  pthread_t thread;
38517a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
38527a42bbe4SStefan Weil  return 0;
38537a42bbe4SStefan Weil}
3854414f0dabSblueswir1EOF
3855bd00d539SAndreas Färberif compile_prog "" "" ; then
3856bd00d539SAndreas Färber  pthread=yes
3857bd00d539SAndreas Färberelse
3858de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
385952166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3860e5d355d1Saliguori      pthread=yes
3861e3c56761SPeter Portante      found=no
3862e3c56761SPeter Portante      for lib_entry in $LIBS; do
3863e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3864e3c56761SPeter Portante          found=yes
3865e3c56761SPeter Portante          break
3866e3c56761SPeter Portante        fi
3867e3c56761SPeter Portante      done
3868e3c56761SPeter Portante      if test "$found" = "no"; then
38695572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
387014ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3871e3c56761SPeter Portante      fi
3872409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3873de65fe0fSSebastian Herbszt      break
3874414f0dabSblueswir1    fi
3875de65fe0fSSebastian Herbszt  done
3876bd00d539SAndreas Färberfi
3877414f0dabSblueswir1
3878e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
387976ad07a4SPeter Maydell  error_exit "pthread check failed" \
388076ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3881e5d355d1Saliguorifi
3882e5d355d1Saliguori
3883479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3884479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
38855c312079SDr. David Alan Gilbertcat > $TMPC << EOF
38865c312079SDr. David Alan Gilbert#include <pthread.h>
38875c312079SDr. David Alan Gilbert
38885c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
38895c312079SDr. David Alan Gilbertint main(void)
38905c312079SDr. David Alan Gilbert{
38915c312079SDr. David Alan Gilbert    pthread_t thread;
38925c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
38935c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
38945c312079SDr. David Alan Gilbert    return 0;
38955c312079SDr. David Alan Gilbert}
38965c312079SDr. David Alan GilbertEOF
38975c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3898479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3899479a5747SRoman Bolshakovfi
3900479a5747SRoman Bolshakov
3901479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3902479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3903479a5747SRoman Bolshakovcat > $TMPC << EOF
3904479a5747SRoman Bolshakov#include <pthread.h>
3905479a5747SRoman Bolshakov
3906479a5747SRoman Bolshakovstatic void *f(void *p) { pthread_setname_np("QEMU"); }
3907479a5747SRoman Bolshakovint main(void)
3908479a5747SRoman Bolshakov{
3909479a5747SRoman Bolshakov    pthread_t thread;
3910479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3911479a5747SRoman Bolshakov    return 0;
3912479a5747SRoman Bolshakov}
3913479a5747SRoman BolshakovEOF
3914479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3915479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
39165c312079SDr. David Alan Gilbertfi
39175c312079SDr. David Alan Gilbert
3918bf9298b9Saliguori##########################################
3919f27aaf4bSChristian Brunner# rbd probe
3920f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3921f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3922f27aaf4bSChristian Brunner#include <stdio.h>
3923ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3924f27aaf4bSChristian Brunnerint main(void) {
3925ad32e9c0SJosh Durgin    rados_t cluster;
3926ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3927f27aaf4bSChristian Brunner    return 0;
3928f27aaf4bSChristian Brunner}
3929f27aaf4bSChristian BrunnerEOF
3930ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3931f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3932f27aaf4bSChristian Brunner    rbd=yes
3933f27aaf4bSChristian Brunner  else
3934f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
393521684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3936f27aaf4bSChristian Brunner    fi
3937f27aaf4bSChristian Brunner    rbd=no
3938f27aaf4bSChristian Brunner  fi
3939f27aaf4bSChristian Brunnerfi
3940f27aaf4bSChristian Brunner
3941f27aaf4bSChristian Brunner##########################################
3942b10d49d7SPino Toscano# libssh probe
3943b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3944b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
3945b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3946b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3947b10d49d7SPino Toscano    libssh=yes
39480a12ec87SRichard W.M. Jones  else
3949b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3950b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
39510a12ec87SRichard W.M. Jones    fi
3952b10d49d7SPino Toscano    libssh=no
39530a12ec87SRichard W.M. Jones  fi
39540a12ec87SRichard W.M. Jonesfi
39550a12ec87SRichard W.M. Jones
39560a12ec87SRichard W.M. Jones##########################################
3957b10d49d7SPino Toscano# Check for libssh 0.8
3958b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
3959b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
3960b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
3961b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
39629a2d462eSRichard W.M. Jones
3963b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
39649a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
3965b10d49d7SPino Toscano#include <libssh/libssh.h>
3966b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
39679a2d462eSRichard W.M. JonesEOF
3968b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
3969b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
39709a2d462eSRichard W.M. Jones  fi
39719a2d462eSRichard W.M. Jonesfi
39729a2d462eSRichard W.M. Jones
39739a2d462eSRichard W.M. Jones##########################################
39745c6c3a6cSChristoph Hellwig# linux-aio probe
39755c6c3a6cSChristoph Hellwig
39765c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
39775c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
39785c6c3a6cSChristoph Hellwig#include <libaio.h>
39795c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3980832ce9c2SScott Wood#include <stddef.h>
39815c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
39825c6c3a6cSChristoph HellwigEOF
39835c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
39845c6c3a6cSChristoph Hellwig    linux_aio=yes
39855c6c3a6cSChristoph Hellwig  else
39865c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
398721684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
39885c6c3a6cSChristoph Hellwig    fi
39893cfcae3cSLuiz Capitulino    linux_aio=no
39905c6c3a6cSChristoph Hellwig  fi
39915c6c3a6cSChristoph Hellwigfi
39925c6c3a6cSChristoph Hellwig
39935c6c3a6cSChristoph Hellwig##########################################
39947aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
39953b8acc11SPaolo Bonzini
39967aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
39977aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
39987aaa6a16SPaolo Bonzini    tpm=no
39993b8acc11SPaolo Bonzini  else
40007aaa6a16SPaolo Bonzini    tpm=yes
40017aaa6a16SPaolo Bonzini  fi
40027aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
40037aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
40047aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
40057aaa6a16SPaolo Bonzini  fi
40063b8acc11SPaolo Bonzinifi
40073b8acc11SPaolo Bonzini
40083b8acc11SPaolo Bonzini##########################################
4009758e8e38SVenkateswararao Jujjuri (JV)# attr probe
4010758e8e38SVenkateswararao Jujjuri (JV)
4011758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
4012758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
4013758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
4014758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
4015f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
4016f2338fb4SPavel Borzenkov#include <attr/xattr.h>
4017f2338fb4SPavel Borzenkov#else
40184f26f2b6SAvi Kivity#include <sys/xattr.h>
4019f2338fb4SPavel Borzenkov#endif
4020758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4021758e8e38SVenkateswararao Jujjuri (JV)EOF
40224f26f2b6SAvi Kivity  if compile_prog "" "" ; then
40234f26f2b6SAvi Kivity    attr=yes
40244f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
4025f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4026758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
4027758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
40284f26f2b6SAvi Kivity    libattr=yes
4029758e8e38SVenkateswararao Jujjuri (JV)  else
4030758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
403121684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
4032758e8e38SVenkateswararao Jujjuri (JV)    fi
4033758e8e38SVenkateswararao Jujjuri (JV)    attr=no
4034758e8e38SVenkateswararao Jujjuri (JV)  fi
4035758e8e38SVenkateswararao Jujjuri (JV)fi
4036758e8e38SVenkateswararao Jujjuri (JV)
4037758e8e38SVenkateswararao Jujjuri (JV)##########################################
4038bf9298b9Saliguori# iovec probe
4039bf9298b9Saliguoricat > $TMPC <<EOF
4040db34f0b3Sblueswir1#include <sys/types.h>
4041bf9298b9Saliguori#include <sys/uio.h>
4042db34f0b3Sblueswir1#include <unistd.h>
4043f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
4044bf9298b9SaliguoriEOF
4045bf9298b9Saliguoriiovec=no
404652166aa0SJuan Quintelaif compile_prog "" "" ; then
4047bf9298b9Saliguori  iovec=yes
4048bf9298b9Saliguorifi
4049bf9298b9Saliguori
4050f652e6afSaurel32##########################################
4051ceb42de8Saliguori# preadv probe
4052ceb42de8Saliguoricat > $TMPC <<EOF
4053ceb42de8Saliguori#include <sys/types.h>
4054ceb42de8Saliguori#include <sys/uio.h>
4055ceb42de8Saliguori#include <unistd.h>
4056c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
4057ceb42de8SaliguoriEOF
4058ceb42de8Saliguoripreadv=no
405952166aa0SJuan Quintelaif compile_prog "" "" ; then
4060ceb42de8Saliguori  preadv=yes
4061ceb42de8Saliguorifi
4062ceb42de8Saliguori
4063ceb42de8Saliguori##########################################
4064f652e6afSaurel32# fdt probe
4065e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
4066e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
4067e169e1e1SPeter Maydellfdt_required=no
4068e169e1e1SPeter Maydellfor target in $target_list; do
4069e169e1e1SPeter Maydell  case $target in
4070a666409fSKONRAD Frederic    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
4071e169e1e1SPeter Maydell      fdt_required=yes
4072e169e1e1SPeter Maydell    ;;
4073e169e1e1SPeter Maydell  esac
4074e169e1e1SPeter Maydelldone
4075e169e1e1SPeter Maydell
4076e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
4077e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
4078e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
4079e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
4080e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
4081e169e1e1SPeter Maydell  fi
4082e169e1e1SPeter Maydell  fdt=yes
4083e169e1e1SPeter Maydellfi
4084e169e1e1SPeter Maydell
40852df87df7SJuan Quintelaif test "$fdt" != "no" ; then
4086b41af4baSJuan Quintela  fdt_libs="-lfdt"
408796ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
40886e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
4089f652e6afSaurel32  cat > $TMPC << EOF
409031ce0adbSThomas Huth#include <libfdt.h>
409196ce6545SPeter Crosthwaite#include <libfdt_env.h>
4092fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
4093f652e6afSaurel32EOF
409452166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
4095a540f158SPeter Crosthwaite    # system DTC is good - use it
4096e3971d61SPhilippe Mathieu-Daudé    fdt=system
4097aef45d51SDaniel P. Berrange  else
4098aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
4099aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
4100aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
4101aef45d51SDaniel P. Berrange      fi
4102aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4103e3971d61SPhilippe Mathieu-Daudé          fdt=git
4104a540f158SPeter Crosthwaite          mkdir -p dtc
4105cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
4106a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
4107a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
41082df87df7SJuan Quintela          fi
4109a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
41108a99e9a3SPhilippe Mathieu-Daudé          fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
41118a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4112a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4113aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4114aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4115aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4116a540f158SPeter Crosthwaite      else
4117a540f158SPeter Crosthwaite          # don't have and don't want
4118de3a354aSMichael Walle          fdt_libs=
41192df87df7SJuan Quintela          fdt=no
4120f652e6afSaurel32      fi
4121f652e6afSaurel32  fi
4122aef45d51SDaniel P. Berrangefi
4123f652e6afSaurel32
4124a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
4125a540f158SPeter Crosthwaite
412620ff075bSMichael Walle##########################################
4127fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4128b1546f32SGerd Hoffmann
4129d52c454aSMarc-André Lureaugbm="no"
4130d52c454aSMarc-André Lureauif $pkg_config gbm; then
4131d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
4132d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
4133d52c454aSMarc-André Lureau    gbm="yes"
4134d52c454aSMarc-André Lureaufi
4135d52c454aSMarc-André Lureau
4136da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
41374939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
41385f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
41395f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
41405f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4141da076ffeSGerd Hoffmann    opengl=yes
4142925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4143925a0400SGerd Hoffmann        gtk_gl="yes"
4144925a0400SGerd Hoffmann    fi
4145cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
414620ff075bSMichael Walle  else
4147da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4148dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
414920ff075bSMichael Walle    fi
4150f676c67eSJeremy White    opengl_cflags=""
4151da076ffeSGerd Hoffmann    opengl_libs=""
4152da076ffeSGerd Hoffmann    opengl=no
415320ff075bSMichael Walle  fi
415420ff075bSMichael Wallefi
415520ff075bSMichael Walle
4156014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4157014cb152SGerd Hoffmann  cat > $TMPC << EOF
4158014cb152SGerd Hoffmann#include <epoxy/egl.h>
4159014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4160014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4161014cb152SGerd Hoffmann#endif
4162014cb152SGerd Hoffmannint main(void) { return 0; }
4163014cb152SGerd HoffmannEOF
4164014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4165014cb152SGerd Hoffmann    opengl_dmabuf=yes
4166014cb152SGerd Hoffmann  fi
4167014cb152SGerd Hoffmannfi
4168c9a12e75SChrysostomos Nanakos
4169e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
417099e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
417199e1a93bSPhilippe Mathieu-Daudé    case $target in
417299e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
417399e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
417499e1a93bSPhilippe Mathieu-Daudé      ;;
417599e1a93bSPhilippe Mathieu-Daudé    esac
417699e1a93bSPhilippe Mathieu-Daudé  done
417799e1a93bSPhilippe Mathieu-Daudéfi
417899e1a93bSPhilippe Mathieu-Daudé
4179ed279a06SKlim Kireev##########################################
4180ed279a06SKlim Kireev# libxml2 probe
4181ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4182ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4183ed279a06SKlim Kireev        libxml2="yes"
4184ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4185ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4186ed279a06SKlim Kireev    else
4187ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4188ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4189ed279a06SKlim Kireev        fi
4190ed279a06SKlim Kireev        libxml2="no"
4191ed279a06SKlim Kireev    fi
4192ed279a06SKlim Kireevfi
4193c9a12e75SChrysostomos Nanakos
4194eb100396SBharata B Rao##########################################
4195eb100396SBharata B Rao# glusterfs probe
4196eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
419765d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4198e01bee08SBharata B Rao    glusterfs="yes"
419989138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
420089138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4201d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4202d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4203d85fa9ebSJeff Cody    fi
420465d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
42050c14fb47SBharata B Rao      glusterfs_discard="yes"
42060c14fb47SBharata B Rao    fi
42077c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4208df3a429aSNiels de Vos      glusterfs_fallocate="yes"
42097c815372SBharata B Rao      glusterfs_zerofill="yes"
42107c815372SBharata B Rao    fi
4211e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
4212e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
4213e014dbe7SPrasanna Kumar Kalever
4214e014dbe7SPrasanna Kumar Kaleverint
4215e014dbe7SPrasanna Kumar Kalevermain(void)
4216e014dbe7SPrasanna Kumar Kalever{
4217e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
4218e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
4219e014dbe7SPrasanna Kumar Kalever}
4220e014dbe7SPrasanna Kumar KaleverEOF
4221e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4222e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
4223e014dbe7SPrasanna Kumar Kalever    fi
42240e3b891fSNiels de Vos    cat > $TMPC << EOF
42250e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
42260e3b891fSNiels de Vos
42270e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
42280e3b891fSNiels de Vosstatic void
42290e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
42300e3b891fSNiels de Vos{}
42310e3b891fSNiels de Vos
42320e3b891fSNiels de Vosint
42330e3b891fSNiels de Vosmain(void)
42340e3b891fSNiels de Vos{
42350e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
42360e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
42370e3b891fSNiels de Vos	return 0;
42380e3b891fSNiels de Vos}
42390e3b891fSNiels de VosEOF
42400e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
42410e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
42420e3b891fSNiels de Vos    fi
4243eb100396SBharata B Rao  else
4244eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
42458efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
42468efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4247eb100396SBharata B Rao    fi
4248e01bee08SBharata B Rao    glusterfs="no"
4249eb100396SBharata B Rao  fi
4250eb100396SBharata B Raofi
4251eb100396SBharata B Rao
425239386ac7Saurel32# Check for inotify functions when we are building linux-user
42533b3f24adSaurel32# emulator.  This is done because older glibc versions don't
42543b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
42553b3f24adSaurel32# don't provide them even if kernel supports them.
42563b3f24adSaurel32#
42573b3f24adSaurel32inotify=no
42583b3f24adSaurel32cat > $TMPC << EOF
42593b3f24adSaurel32#include <sys/inotify.h>
42603b3f24adSaurel32
42613b3f24adSaurel32int
42623b3f24adSaurel32main(void)
42633b3f24adSaurel32{
42643b3f24adSaurel32	/* try to start inotify */
42658690e420Saurel32	return inotify_init();
42663b3f24adSaurel32}
42673b3f24adSaurel32EOF
426852166aa0SJuan Quintelaif compile_prog "" "" ; then
42693b3f24adSaurel32  inotify=yes
42703b3f24adSaurel32fi
42713b3f24adSaurel32
4272c05c7a73SRiku Voipioinotify1=no
4273c05c7a73SRiku Voipiocat > $TMPC << EOF
4274c05c7a73SRiku Voipio#include <sys/inotify.h>
4275c05c7a73SRiku Voipio
4276c05c7a73SRiku Voipioint
4277c05c7a73SRiku Voipiomain(void)
4278c05c7a73SRiku Voipio{
4279c05c7a73SRiku Voipio    /* try to start inotify */
4280c05c7a73SRiku Voipio    return inotify_init1(0);
4281c05c7a73SRiku Voipio}
4282c05c7a73SRiku VoipioEOF
4283c05c7a73SRiku Voipioif compile_prog "" "" ; then
4284c05c7a73SRiku Voipio  inotify1=yes
4285c05c7a73SRiku Voipiofi
4286c05c7a73SRiku Voipio
4287099d6b0fSRiku Voipio# check if pipe2 is there
4288099d6b0fSRiku Voipiopipe2=no
4289099d6b0fSRiku Voipiocat > $TMPC << EOF
4290099d6b0fSRiku Voipio#include <unistd.h>
4291099d6b0fSRiku Voipio#include <fcntl.h>
4292099d6b0fSRiku Voipio
4293099d6b0fSRiku Voipioint main(void)
4294099d6b0fSRiku Voipio{
4295099d6b0fSRiku Voipio    int pipefd[2];
42969bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4297099d6b0fSRiku Voipio}
4298099d6b0fSRiku VoipioEOF
429952166aa0SJuan Quintelaif compile_prog "" "" ; then
4300099d6b0fSRiku Voipio  pipe2=yes
4301099d6b0fSRiku Voipiofi
4302099d6b0fSRiku Voipio
430340ff6d7eSKevin Wolf# check if accept4 is there
430440ff6d7eSKevin Wolfaccept4=no
430540ff6d7eSKevin Wolfcat > $TMPC << EOF
430640ff6d7eSKevin Wolf#include <sys/socket.h>
430740ff6d7eSKevin Wolf#include <stddef.h>
430840ff6d7eSKevin Wolf
430940ff6d7eSKevin Wolfint main(void)
431040ff6d7eSKevin Wolf{
431140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
431240ff6d7eSKevin Wolf    return 0;
431340ff6d7eSKevin Wolf}
431440ff6d7eSKevin WolfEOF
431540ff6d7eSKevin Wolfif compile_prog "" "" ; then
431640ff6d7eSKevin Wolf  accept4=yes
431740ff6d7eSKevin Wolffi
431840ff6d7eSKevin Wolf
43193ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
43203ce34dfbSvibisreenivasansplice=no
43213ce34dfbSvibisreenivasancat > $TMPC << EOF
43223ce34dfbSvibisreenivasan#include <unistd.h>
43233ce34dfbSvibisreenivasan#include <fcntl.h>
43243ce34dfbSvibisreenivasan#include <limits.h>
43253ce34dfbSvibisreenivasan
43263ce34dfbSvibisreenivasanint main(void)
43273ce34dfbSvibisreenivasan{
432866ea0f22SStefan Weil    int len, fd = 0;
43293ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
43303ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
43313ce34dfbSvibisreenivasan    return 0;
43323ce34dfbSvibisreenivasan}
43333ce34dfbSvibisreenivasanEOF
433452166aa0SJuan Quintelaif compile_prog "" "" ; then
43353ce34dfbSvibisreenivasan  splice=yes
43363ce34dfbSvibisreenivasanfi
43373ce34dfbSvibisreenivasan
4338dcc38d1cSMarcelo Tosatti##########################################
4339a99d57bbSWanlong Gao# libnuma probe
4340a99d57bbSWanlong Gao
4341a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4342a99d57bbSWanlong Gao  cat > $TMPC << EOF
4343a99d57bbSWanlong Gao#include <numa.h>
4344a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4345a99d57bbSWanlong GaoEOF
4346a99d57bbSWanlong Gao
4347a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4348a99d57bbSWanlong Gao    numa=yes
4349a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4350a99d57bbSWanlong Gao  else
4351a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4352a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4353a99d57bbSWanlong Gao    fi
4354a99d57bbSWanlong Gao    numa=no
4355a99d57bbSWanlong Gao  fi
4356a99d57bbSWanlong Gaofi
4357a99d57bbSWanlong Gao
43587b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
43597b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
43607b01cb97SAlexandre Derumier    exit 1
43617b01cb97SAlexandre Derumierfi
43627b01cb97SAlexandre Derumier
43635a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
43645a22ab71SYang Zhong# do not support it.
43655a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
43665a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
43675a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
43685a22ab71SYang Zhong    fi
43695a22ab71SYang Zhong    malloc_trim="no"
43705a22ab71SYang Zhongfi
43715a22ab71SYang Zhong
43725a22ab71SYang Zhong#######################################
43735a22ab71SYang Zhong# malloc_trim
43745a22ab71SYang Zhong
43755a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
43765a22ab71SYang Zhong    cat > $TMPC << EOF
43775a22ab71SYang Zhong#include <malloc.h>
43785a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
43795a22ab71SYang ZhongEOF
43805a22ab71SYang Zhong    if compile_prog "" "" ; then
43815a22ab71SYang Zhong        malloc_trim="yes"
43825a22ab71SYang Zhong    else
43835a22ab71SYang Zhong        malloc_trim="no"
43845a22ab71SYang Zhong    fi
43855a22ab71SYang Zhongfi
43865a22ab71SYang Zhong
4387a99d57bbSWanlong Gao##########################################
43882847b469SFam Zheng# tcmalloc probe
43892847b469SFam Zheng
43902847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
43912847b469SFam Zheng  cat > $TMPC << EOF
43922847b469SFam Zheng#include <stdlib.h>
43932847b469SFam Zhengint main(void) { malloc(1); return 0; }
43942847b469SFam ZhengEOF
43952847b469SFam Zheng
43962847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
43972847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
43982847b469SFam Zheng  else
43992847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
44002847b469SFam Zheng  fi
44012847b469SFam Zhengfi
44022847b469SFam Zheng
44032847b469SFam Zheng##########################################
44047b01cb97SAlexandre Derumier# jemalloc probe
44057b01cb97SAlexandre Derumier
44067b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
44077b01cb97SAlexandre Derumier  cat > $TMPC << EOF
44087b01cb97SAlexandre Derumier#include <stdlib.h>
44097b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
44107b01cb97SAlexandre DerumierEOF
44117b01cb97SAlexandre Derumier
44127b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
44137b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
44147b01cb97SAlexandre Derumier  else
44157b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
44167b01cb97SAlexandre Derumier  fi
44177b01cb97SAlexandre Derumierfi
44187b01cb97SAlexandre Derumier
44197b01cb97SAlexandre Derumier##########################################
4420dcc38d1cSMarcelo Tosatti# signalfd probe
4421dcc38d1cSMarcelo Tosattisignalfd="no"
4422dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4423dcc38d1cSMarcelo Tosatti#include <unistd.h>
4424dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4425dcc38d1cSMarcelo Tosatti#include <signal.h>
4426dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4427dcc38d1cSMarcelo TosattiEOF
4428dcc38d1cSMarcelo Tosatti
4429dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4430dcc38d1cSMarcelo Tosatti  signalfd=yes
4431dcc38d1cSMarcelo Tosattifi
4432dcc38d1cSMarcelo Tosatti
4433d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4434d339d766SRichard W.M. Jonesoptreset="no"
4435d339d766SRichard W.M. Jonescat > $TMPC << EOF
4436d339d766SRichard W.M. Jones#include <getopt.h>
4437d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4438d339d766SRichard W.M. JonesEOF
4439d339d766SRichard W.M. Jones
4440d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4441d339d766SRichard W.M. Jones  optreset=yes
4442d339d766SRichard W.M. Jonesfi
4443d339d766SRichard W.M. Jones
4444c2882b96SRiku Voipio# check if eventfd is supported
4445c2882b96SRiku Voipioeventfd=no
4446c2882b96SRiku Voipiocat > $TMPC << EOF
4447c2882b96SRiku Voipio#include <sys/eventfd.h>
4448c2882b96SRiku Voipio
4449c2882b96SRiku Voipioint main(void)
4450c2882b96SRiku Voipio{
445155cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4452c2882b96SRiku Voipio}
4453c2882b96SRiku VoipioEOF
4454c2882b96SRiku Voipioif compile_prog "" "" ; then
4455c2882b96SRiku Voipio  eventfd=yes
4456c2882b96SRiku Voipiofi
4457c2882b96SRiku Voipio
4458751bcc39SMarc-André Lureau# check if memfd is supported
4459751bcc39SMarc-André Lureaumemfd=no
4460751bcc39SMarc-André Lureaucat > $TMPC << EOF
446175e5b70eSPaolo Bonzini#include <sys/mman.h>
4462751bcc39SMarc-André Lureau
4463751bcc39SMarc-André Lureauint main(void)
4464751bcc39SMarc-André Lureau{
4465751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4466751bcc39SMarc-André Lureau}
4467751bcc39SMarc-André LureauEOF
4468751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4469751bcc39SMarc-André Lureau  memfd=yes
4470751bcc39SMarc-André Lureaufi
4471751bcc39SMarc-André Lureau
4472955727d2SCortland Tölva# check for usbfs
4473955727d2SCortland Tölvahave_usbfs=no
4474955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
447596566d09SThomas Petazzoni  cat > $TMPC << EOF
447696566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
447796566d09SThomas Petazzoni
447896566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
447996566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
448096566d09SThomas Petazzoni#endif
448196566d09SThomas Petazzoni
448296566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
448396566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
448496566d09SThomas Petazzoni#endif
448596566d09SThomas Petazzoni
448696566d09SThomas Petazzoniint main(void)
448796566d09SThomas Petazzoni{
448896566d09SThomas Petazzoni    return 0;
448996566d09SThomas Petazzoni}
449096566d09SThomas PetazzoniEOF
449196566d09SThomas Petazzoni  if compile_prog "" ""; then
4492955727d2SCortland Tölva    have_usbfs=yes
4493955727d2SCortland Tölva  fi
4494955727d2SCortland Tölvafi
4495751bcc39SMarc-André Lureau
4496d0927938SUlrich Hecht# check for fallocate
4497d0927938SUlrich Hechtfallocate=no
4498d0927938SUlrich Hechtcat > $TMPC << EOF
4499d0927938SUlrich Hecht#include <fcntl.h>
4500d0927938SUlrich Hecht
4501d0927938SUlrich Hechtint main(void)
4502d0927938SUlrich Hecht{
4503d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4504d0927938SUlrich Hecht    return 0;
4505d0927938SUlrich Hecht}
4506d0927938SUlrich HechtEOF
45078fb03151SPeter Maydellif compile_prog "" "" ; then
4508d0927938SUlrich Hecht  fallocate=yes
4509d0927938SUlrich Hechtfi
4510d0927938SUlrich Hecht
45113d4fa43eSKusanagi Kouichi# check for fallocate hole punching
45123d4fa43eSKusanagi Kouichifallocate_punch_hole=no
45133d4fa43eSKusanagi Kouichicat > $TMPC << EOF
45143d4fa43eSKusanagi Kouichi#include <fcntl.h>
45153d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
45163d4fa43eSKusanagi Kouichi
45173d4fa43eSKusanagi Kouichiint main(void)
45183d4fa43eSKusanagi Kouichi{
45193d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
45203d4fa43eSKusanagi Kouichi    return 0;
45213d4fa43eSKusanagi Kouichi}
45223d4fa43eSKusanagi KouichiEOF
45233d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
45243d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
45253d4fa43eSKusanagi Kouichifi
45263d4fa43eSKusanagi Kouichi
4527b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4528b953f075SDenis V. Lunevfallocate_zero_range=no
4529b953f075SDenis V. Lunevcat > $TMPC << EOF
4530b953f075SDenis V. Lunev#include <fcntl.h>
4531b953f075SDenis V. Lunev#include <linux/falloc.h>
4532b953f075SDenis V. Lunev
4533b953f075SDenis V. Lunevint main(void)
4534b953f075SDenis V. Lunev{
4535b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4536b953f075SDenis V. Lunev    return 0;
4537b953f075SDenis V. Lunev}
4538b953f075SDenis V. LunevEOF
4539b953f075SDenis V. Lunevif compile_prog "" "" ; then
4540b953f075SDenis V. Lunev  fallocate_zero_range=yes
4541b953f075SDenis V. Lunevfi
4542b953f075SDenis V. Lunev
4543ed911435SKevin Wolf# check for posix_fallocate
4544ed911435SKevin Wolfposix_fallocate=no
4545ed911435SKevin Wolfcat > $TMPC << EOF
4546ed911435SKevin Wolf#include <fcntl.h>
4547ed911435SKevin Wolf
4548ed911435SKevin Wolfint main(void)
4549ed911435SKevin Wolf{
4550ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4551ed911435SKevin Wolf    return 0;
4552ed911435SKevin Wolf}
4553ed911435SKevin WolfEOF
4554ed911435SKevin Wolfif compile_prog "" "" ; then
4555ed911435SKevin Wolf    posix_fallocate=yes
4556ed911435SKevin Wolffi
4557ed911435SKevin Wolf
4558c727f47dSPeter Maydell# check for sync_file_range
4559c727f47dSPeter Maydellsync_file_range=no
4560c727f47dSPeter Maydellcat > $TMPC << EOF
4561c727f47dSPeter Maydell#include <fcntl.h>
4562c727f47dSPeter Maydell
4563c727f47dSPeter Maydellint main(void)
4564c727f47dSPeter Maydell{
4565c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4566c727f47dSPeter Maydell    return 0;
4567c727f47dSPeter Maydell}
4568c727f47dSPeter MaydellEOF
45698fb03151SPeter Maydellif compile_prog "" "" ; then
4570c727f47dSPeter Maydell  sync_file_range=yes
4571c727f47dSPeter Maydellfi
4572c727f47dSPeter Maydell
4573dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4574dace20dcSPeter Maydellfiemap=no
4575dace20dcSPeter Maydellcat > $TMPC << EOF
4576dace20dcSPeter Maydell#include <sys/ioctl.h>
4577dace20dcSPeter Maydell#include <linux/fs.h>
4578dace20dcSPeter Maydell#include <linux/fiemap.h>
4579dace20dcSPeter Maydell
4580dace20dcSPeter Maydellint main(void)
4581dace20dcSPeter Maydell{
4582dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4583dace20dcSPeter Maydell    return 0;
4584dace20dcSPeter Maydell}
4585dace20dcSPeter MaydellEOF
45868fb03151SPeter Maydellif compile_prog "" "" ; then
4587dace20dcSPeter Maydell  fiemap=yes
4588dace20dcSPeter Maydellfi
4589dace20dcSPeter Maydell
4590d0927938SUlrich Hecht# check for dup3
4591d0927938SUlrich Hechtdup3=no
4592d0927938SUlrich Hechtcat > $TMPC << EOF
4593d0927938SUlrich Hecht#include <unistd.h>
4594d0927938SUlrich Hecht
4595d0927938SUlrich Hechtint main(void)
4596d0927938SUlrich Hecht{
4597d0927938SUlrich Hecht    dup3(0, 0, 0);
4598d0927938SUlrich Hecht    return 0;
4599d0927938SUlrich Hecht}
4600d0927938SUlrich HechtEOF
460178f5d726SJan Kiszkaif compile_prog "" "" ; then
4602d0927938SUlrich Hecht  dup3=yes
4603d0927938SUlrich Hechtfi
4604d0927938SUlrich Hecht
46054e0c6529SAlex Bligh# check for ppoll support
46064e0c6529SAlex Blighppoll=no
46074e0c6529SAlex Blighcat > $TMPC << EOF
46084e0c6529SAlex Bligh#include <poll.h>
46094e0c6529SAlex Bligh
46104e0c6529SAlex Blighint main(void)
46114e0c6529SAlex Bligh{
46124e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
46134e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
46144e0c6529SAlex Bligh    return 0;
46154e0c6529SAlex Bligh}
46164e0c6529SAlex BlighEOF
46174e0c6529SAlex Blighif compile_prog "" "" ; then
46184e0c6529SAlex Bligh  ppoll=yes
46194e0c6529SAlex Blighfi
46204e0c6529SAlex Bligh
4621cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4622cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4623cd758dd0SAlex Blighcat > $TMPC << EOF
4624cd758dd0SAlex Bligh#include <sys/prctl.h>
4625cd758dd0SAlex Bligh
4626cd758dd0SAlex Blighint main(void)
4627cd758dd0SAlex Bligh{
4628cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4629cd758dd0SAlex Bligh    return 0;
4630cd758dd0SAlex Bligh}
4631cd758dd0SAlex BlighEOF
4632cd758dd0SAlex Blighif compile_prog "" "" ; then
4633cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4634cd758dd0SAlex Blighfi
4635cd758dd0SAlex Bligh
46363b6edd16SPeter Maydell# check for epoll support
46373b6edd16SPeter Maydellepoll=no
46383b6edd16SPeter Maydellcat > $TMPC << EOF
46393b6edd16SPeter Maydell#include <sys/epoll.h>
46403b6edd16SPeter Maydell
46413b6edd16SPeter Maydellint main(void)
46423b6edd16SPeter Maydell{
46433b6edd16SPeter Maydell    epoll_create(0);
46443b6edd16SPeter Maydell    return 0;
46453b6edd16SPeter Maydell}
46463b6edd16SPeter MaydellEOF
46478fb03151SPeter Maydellif compile_prog "" "" ; then
46483b6edd16SPeter Maydell  epoll=yes
46493b6edd16SPeter Maydellfi
46503b6edd16SPeter Maydell
4651227f0214SPeter Maydell# epoll_create1 is a later addition
4652227f0214SPeter Maydell# so we must check separately for its presence
46533b6edd16SPeter Maydellepoll_create1=no
46543b6edd16SPeter Maydellcat > $TMPC << EOF
46553b6edd16SPeter Maydell#include <sys/epoll.h>
46563b6edd16SPeter Maydell
46573b6edd16SPeter Maydellint main(void)
46583b6edd16SPeter Maydell{
465919e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
466019e83f6bSPeter Maydell     * a function being called. This is necessary so that on
466119e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
466219e83f6bSPeter Maydell     * the library but not declared in the header file we will
466319e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
466419e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
466519e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
466619e83f6bSPeter Maydell     */
4667c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
46683b6edd16SPeter Maydell}
46693b6edd16SPeter MaydellEOF
46708fb03151SPeter Maydellif compile_prog "" "" ; then
46713b6edd16SPeter Maydell  epoll_create1=yes
46723b6edd16SPeter Maydellfi
46733b6edd16SPeter Maydell
4674a8fd1abaSPeter Maydell# check for sendfile support
4675a8fd1abaSPeter Maydellsendfile=no
4676a8fd1abaSPeter Maydellcat > $TMPC << EOF
4677a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4678a8fd1abaSPeter Maydell
4679a8fd1abaSPeter Maydellint main(void)
4680a8fd1abaSPeter Maydell{
4681a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4682a8fd1abaSPeter Maydell}
4683a8fd1abaSPeter MaydellEOF
4684a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4685a8fd1abaSPeter Maydell  sendfile=yes
4686a8fd1abaSPeter Maydellfi
4687a8fd1abaSPeter Maydell
468851834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
468951834341SRiku Voipiotimerfd=no
469051834341SRiku Voipiocat > $TMPC << EOF
469151834341SRiku Voipio#include <sys/timerfd.h>
469251834341SRiku Voipio
469351834341SRiku Voipioint main(void)
469451834341SRiku Voipio{
469551834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
469651834341SRiku Voipio}
469751834341SRiku VoipioEOF
469851834341SRiku Voipioif compile_prog "" "" ; then
469951834341SRiku Voipio  timerfd=yes
470051834341SRiku Voipiofi
470151834341SRiku Voipio
47029af5c906SRiku Voipio# check for setns and unshare support
47039af5c906SRiku Voipiosetns=no
47049af5c906SRiku Voipiocat > $TMPC << EOF
47059af5c906SRiku Voipio#include <sched.h>
47069af5c906SRiku Voipio
47079af5c906SRiku Voipioint main(void)
47089af5c906SRiku Voipio{
47099af5c906SRiku Voipio    int ret;
47109af5c906SRiku Voipio    ret = setns(0, 0);
47119af5c906SRiku Voipio    ret = unshare(0);
47129af5c906SRiku Voipio    return ret;
47139af5c906SRiku Voipio}
47149af5c906SRiku VoipioEOF
47159af5c906SRiku Voipioif compile_prog "" "" ; then
47169af5c906SRiku Voipio  setns=yes
47179af5c906SRiku Voipiofi
47189af5c906SRiku Voipio
471938860a03SAleksandar Markovic# clock_adjtime probe
472038860a03SAleksandar Markovicclock_adjtime=no
472138860a03SAleksandar Markoviccat > $TMPC <<EOF
472238860a03SAleksandar Markovic#include <time.h>
472338860a03SAleksandar Markovic
472438860a03SAleksandar Markovicint main(void)
472538860a03SAleksandar Markovic{
472638860a03SAleksandar Markovic    return clock_adjtime(0, 0);
472738860a03SAleksandar Markovic}
472838860a03SAleksandar MarkovicEOF
472938860a03SAleksandar Markovicclock_adjtime=no
473038860a03SAleksandar Markovicif compile_prog "" "" ; then
473138860a03SAleksandar Markovic  clock_adjtime=yes
473238860a03SAleksandar Markovicfi
473338860a03SAleksandar Markovic
47345a03cd00SAleksandar Markovic# syncfs probe
47355a03cd00SAleksandar Markovicsyncfs=no
47365a03cd00SAleksandar Markoviccat > $TMPC <<EOF
47375a03cd00SAleksandar Markovic#include <unistd.h>
47385a03cd00SAleksandar Markovic
47395a03cd00SAleksandar Markovicint main(void)
47405a03cd00SAleksandar Markovic{
47415a03cd00SAleksandar Markovic    return syncfs(0);
47425a03cd00SAleksandar Markovic}
47435a03cd00SAleksandar MarkovicEOF
47445a03cd00SAleksandar Markovicsyncfs=no
47455a03cd00SAleksandar Markovicif compile_prog "" "" ; then
47465a03cd00SAleksandar Markovic  syncfs=yes
47475a03cd00SAleksandar Markovicfi
47485a03cd00SAleksandar Markovic
47495f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
47505f71eac0SPeter Maydellhas_sphinx_build() {
47515f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
47525f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
47535f71eac0SPeter Maydell    # version requirement). This will fail if either
47545f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
47555f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
47565f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
47575f71eac0SPeter Maydell    sphinx-build -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
47585f71eac0SPeter Maydell}
47595f71eac0SPeter Maydell
4760cc8ae6deSpbrook# Check if tools are available to build documentation.
4761a25dba17SJuan Quintelaif test "$docs" != "no" ; then
47625f71eac0SPeter Maydell  if has makeinfo && has pod2man && has_sphinx_build; then
4763a25dba17SJuan Quintela    docs=yes
476483a3ab8bSJuan Quintela  else
4765a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
47665f71eac0SPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
476783a3ab8bSJuan Quintela    fi
4768a25dba17SJuan Quintela    docs=no
476983a3ab8bSJuan Quintela  fi
4770cc8ae6deSpbrookfi
4771cc8ae6deSpbrook
4772f514f41cSStefan Weil# Search for bswap_32 function
47736ae9a1f4SJuan Quintelabyteswap_h=no
47746ae9a1f4SJuan Quintelacat > $TMPC << EOF
47756ae9a1f4SJuan Quintela#include <byteswap.h>
47766ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
47776ae9a1f4SJuan QuintelaEOF
477852166aa0SJuan Quintelaif compile_prog "" "" ; then
47796ae9a1f4SJuan Quintela  byteswap_h=yes
47806ae9a1f4SJuan Quintelafi
47816ae9a1f4SJuan Quintela
478275f13596SStefan Weil# Search for bswap32 function
47836ae9a1f4SJuan Quintelabswap_h=no
47846ae9a1f4SJuan Quintelacat > $TMPC << EOF
47856ae9a1f4SJuan Quintela#include <sys/endian.h>
47866ae9a1f4SJuan Quintela#include <sys/types.h>
47876ae9a1f4SJuan Quintela#include <machine/bswap.h>
47886ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
47896ae9a1f4SJuan QuintelaEOF
479052166aa0SJuan Quintelaif compile_prog "" "" ; then
47916ae9a1f4SJuan Quintela  bswap_h=yes
47926ae9a1f4SJuan Quintelafi
47936ae9a1f4SJuan Quintela
4794da93a1fdSaliguori##########################################
4795e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4796c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4797e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
47983c33ea96SPaolo Bonzini    libiscsi="yes"
4799ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4800ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4801c589b249SRonnie Sahlberg  else
4802c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4803e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4804c589b249SRonnie Sahlberg    fi
4805c589b249SRonnie Sahlberg    libiscsi="no"
4806c589b249SRonnie Sahlberg  fi
4807c589b249SRonnie Sahlbergfi
4808c589b249SRonnie Sahlberg
4809c589b249SRonnie Sahlberg##########################################
48108bacde8dSNatanael Copa# Do we need libm
48118bacde8dSNatanael Copacat > $TMPC << EOF
48128bacde8dSNatanael Copa#include <math.h>
4813f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
48148bacde8dSNatanael CopaEOF
48158bacde8dSNatanael Copaif compile_prog "" "" ; then
48168bacde8dSNatanael Copa  :
48178bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
48188bacde8dSNatanael Copa  LIBS="-lm $LIBS"
48198bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
48208bacde8dSNatanael Copaelse
482176ad07a4SPeter Maydell  error_exit "libm check failed"
48228bacde8dSNatanael Copafi
48238bacde8dSNatanael Copa
48248bacde8dSNatanael Copa##########################################
4825da93a1fdSaliguori# Do we need librt
48268bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
48278bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
48288bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
48298bacde8dSNatanael Copa# function in addition.
4830da93a1fdSaliguoricat > $TMPC <<EOF
4831da93a1fdSaliguori#include <signal.h>
4832da93a1fdSaliguori#include <time.h>
48338bacde8dSNatanael Copaint main(void) {
48348bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
48358bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
48368bacde8dSNatanael Copa}
4837da93a1fdSaliguoriEOF
4838da93a1fdSaliguori
483952166aa0SJuan Quintelaif compile_prog "" "" ; then
484007ffa4bdSJuan Quintela  :
48418bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
484218e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
484318e588b1SRick Liu  LIBS="$LIBS -lrt"
484418e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4845da93a1fdSaliguorifi
4846da93a1fdSaliguori
4847d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
4848d99e97e6SThomas Huthcat > $TMPC << EOF
4849d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4850d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4851d99e97e6SThomas HuthEOF
4852d99e97e6SThomas Huth
4853d99e97e6SThomas Huthif ! compile_prog "" "" ; then
4854d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
48556362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
4856d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
4857d99e97e6SThomas Huth  fi
48586362a53fSJuan Quintelafi
48596362a53fSJuan Quintela
4860de5071c5SBlue Swirl##########################################
4861cd4ec0b4SGerd Hoffmann# spice probe
4862cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4863cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4864cd4ec0b4SGerd Hoffmann#include <spice.h>
4865cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4866cd4ec0b4SGerd HoffmannEOF
4867710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4868710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
48691b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
487065d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4871cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4872cd4ec0b4SGerd Hoffmann    spice="yes"
4873cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4874cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
48752e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
48762e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4877cd4ec0b4SGerd Hoffmann  else
4878cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
48798efc9363SHu Tao      feature_not_found "spice" \
48801b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4881cd4ec0b4SGerd Hoffmann    fi
4882cd4ec0b4SGerd Hoffmann    spice="no"
4883cd4ec0b4SGerd Hoffmann  fi
4884cd4ec0b4SGerd Hoffmannfi
4885cd4ec0b4SGerd Hoffmann
48867b02f544SMarc-André Lureau# check for smartcard support
48877b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
48880f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
48897b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
48907b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
48917b02f544SMarc-André Lureau        smartcard="yes"
4892111a38b0SRobert Relyea    else
48937b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
48947b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4895111a38b0SRobert Relyea        fi
48967b02f544SMarc-André Lureau        smartcard="no"
4897111a38b0SRobert Relyea    fi
4898111a38b0SRobert Relyeafi
4899111a38b0SRobert Relyea
49002b2325ffSGerd Hoffmann# check for libusb
49012b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
490265d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
49032b2325ffSGerd Hoffmann        libusb="yes"
4904ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4905ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
49062b2325ffSGerd Hoffmann    else
49072b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
49088efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
49092b2325ffSGerd Hoffmann        fi
49102b2325ffSGerd Hoffmann        libusb="no"
49112b2325ffSGerd Hoffmann    fi
49122b2325ffSGerd Hoffmannfi
49132b2325ffSGerd Hoffmann
491469354a83SHans de Goede# check for usbredirparser for usb network redirection support
491569354a83SHans de Goedeif test "$usb_redir" != "no" ; then
491665d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
491769354a83SHans de Goede        usb_redir="yes"
4918ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4919ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
492069354a83SHans de Goede    else
492169354a83SHans de Goede        if test "$usb_redir" = "yes"; then
492221684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
492369354a83SHans de Goede        fi
492469354a83SHans de Goede        usb_redir="no"
492569354a83SHans de Goede    fi
492669354a83SHans de Goedefi
492769354a83SHans de Goede
4928cd4ec0b4SGerd Hoffmann##########################################
4929d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4930d9840e25STomoki Sekiyama
4931e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4932e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
4933d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4934690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4935d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4936d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4937690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4938d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4939d9840e25STomoki Sekiyama	  ;;
4940690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4941d9840e25STomoki Sekiyama  esac
4942d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4943d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4944d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4945d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4946d9840e25STomoki SekiyamaEOF
4947d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4948d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4949d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4950315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4951f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4952d9840e25STomoki Sekiyama  else
4953d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4954d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4955d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4956d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4957d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4958d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4959d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4960d9840e25STomoki Sekiyama    fi
4961d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4962d9840e25STomoki Sekiyama  fi
4963d9840e25STomoki Sekiyamafi
4964d9840e25STomoki Sekiyama
4965d9840e25STomoki Sekiyama##########################################
4966d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4967d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4968d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4969d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4970d9840e25STomoki Sekiyama
4971e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4972e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4973d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4974d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4975d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4976d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4977d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4978d9840e25STomoki Sekiyama    else
4979d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4980d9840e25STomoki Sekiyama    fi
4981d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4982d9840e25STomoki Sekiyama    win_sdk=""
4983d9840e25STomoki Sekiyama  fi
4984d9840e25STomoki Sekiyamafi
4985d9840e25STomoki Sekiyama
4986d9840e25STomoki Sekiyama##########################################
498750cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4988e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
498950cbebb9SMichael Roth  cat > $TMPC << EOF
499050cbebb9SMichael Roth#include <windows.h>
499150cbebb9SMichael Roth#include <ntddscsi.h>
499250cbebb9SMichael Rothint main(void) {
499350cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
499450cbebb9SMichael Roth#error Missing required ioctl definitions
499550cbebb9SMichael Roth#endif
499650cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
499750cbebb9SMichael Roth  return addr.Lun;
499850cbebb9SMichael Roth}
499950cbebb9SMichael RothEOF
500050cbebb9SMichael Roth  if compile_prog "" "" ; then
500150cbebb9SMichael Roth    guest_agent_ntddscsi=yes
5002996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
500350cbebb9SMichael Roth  fi
500450cbebb9SMichael Rothfi
500550cbebb9SMichael Roth
500650cbebb9SMichael Roth##########################################
50079d9e1521SGerd Hoffmann# virgl renderer probe
50089d9e1521SGerd Hoffmann
50099d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
50109d9e1521SGerd Hoffmann  cat > $TMPC << EOF
50119d9e1521SGerd Hoffmann#include <virglrenderer.h>
50129d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
50139d9e1521SGerd HoffmannEOF
50149d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
50159d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
501647479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
50179d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
50189d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
50199d9e1521SGerd Hoffmann    virglrenderer="yes"
50209d9e1521SGerd Hoffmann  else
50219d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
50229d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
50239d9e1521SGerd Hoffmann    fi
50249d9e1521SGerd Hoffmann    virglrenderer="no"
50259d9e1521SGerd Hoffmann  fi
50269d9e1521SGerd Hoffmannfi
50279d9e1521SGerd Hoffmann
50289d9e1521SGerd Hoffmann##########################################
50298ca80760SRichard Henderson# capstone
50308ca80760SRichard Henderson
5031e219c499SRichard Hendersoncase "$capstone" in
5032e219c499SRichard Henderson  "" | yes)
50338ca80760SRichard Henderson    if $pkg_config capstone; then
5034e219c499SRichard Henderson      capstone=system
5035e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5036e219c499SRichard Henderson      capstone=git
5037e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
5038e219c499SRichard Henderson      capstone=internal
5039e219c499SRichard Henderson    elif test -z "$capstone" ; then
5040e219c499SRichard Henderson      capstone=no
5041e219c499SRichard Henderson    else
5042e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
5043e219c499SRichard Henderson    fi
5044e219c499SRichard Henderson    ;;
5045e219c499SRichard Henderson
5046e219c499SRichard Henderson  system)
5047e219c499SRichard Henderson    if ! $pkg_config capstone; then
5048e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
5049e219c499SRichard Henderson    fi
5050e219c499SRichard Henderson    ;;
5051e219c499SRichard Hendersonesac
5052e219c499SRichard Henderson
5053e219c499SRichard Hendersoncase "$capstone" in
5054e219c499SRichard Henderson  git | internal)
5055e219c499SRichard Henderson    if test "$capstone" = git; then
5056e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
5057e219c499SRichard Henderson    fi
5058e219c499SRichard Henderson    mkdir -p capstone
5059e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
5060e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
5061e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
5062e219c499SRichard Henderson    else
5063e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
5064e219c499SRichard Henderson    fi
506502f9135bSDaniel P. Berrangé    libs_cpu="-L\$(BUILD_DIR)/capstone -lcapstone $libs_cpu"
5066e219c499SRichard Henderson    ;;
5067e219c499SRichard Henderson
5068e219c499SRichard Henderson  system)
50698ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
507002f9135bSDaniel P. Berrangé    libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
5071e219c499SRichard Henderson    ;;
5072e219c499SRichard Henderson
5073e219c499SRichard Henderson  no)
5074e219c499SRichard Henderson    ;;
5075e219c499SRichard Henderson  *)
5076e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
5077e219c499SRichard Henderson    ;;
5078e219c499SRichard Hendersonesac
50798ca80760SRichard Henderson
50808ca80760SRichard Henderson##########################################
50815f6b9e8fSBlue Swirl# check if we have fdatasync
50825f6b9e8fSBlue Swirl
50835f6b9e8fSBlue Swirlfdatasync=no
50845f6b9e8fSBlue Swirlcat > $TMPC << EOF
50855f6b9e8fSBlue Swirl#include <unistd.h>
5086d1722a27SAlexandre Raymondint main(void) {
5087d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5088d1722a27SAlexandre Raymondreturn fdatasync(0);
5089d1722a27SAlexandre Raymond#else
5090e172fe11SStefan Weil#error Not supported
5091d1722a27SAlexandre Raymond#endif
5092d1722a27SAlexandre Raymond}
50935f6b9e8fSBlue SwirlEOF
50945f6b9e8fSBlue Swirlif compile_prog "" "" ; then
50955f6b9e8fSBlue Swirl    fdatasync=yes
50965f6b9e8fSBlue Swirlfi
50975f6b9e8fSBlue Swirl
509894a420b1SStefan Hajnoczi##########################################
5099e78815a5SAndreas Färber# check if we have madvise
5100e78815a5SAndreas Färber
5101e78815a5SAndreas Färbermadvise=no
5102e78815a5SAndreas Färbercat > $TMPC << EOF
5103e78815a5SAndreas Färber#include <sys/types.h>
5104e78815a5SAndreas Färber#include <sys/mman.h>
5105832ce9c2SScott Wood#include <stddef.h>
5106e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5107e78815a5SAndreas FärberEOF
5108e78815a5SAndreas Färberif compile_prog "" "" ; then
5109e78815a5SAndreas Färber    madvise=yes
5110e78815a5SAndreas Färberfi
5111e78815a5SAndreas Färber
5112e78815a5SAndreas Färber##########################################
5113e78815a5SAndreas Färber# check if we have posix_madvise
5114e78815a5SAndreas Färber
5115e78815a5SAndreas Färberposix_madvise=no
5116e78815a5SAndreas Färbercat > $TMPC << EOF
5117e78815a5SAndreas Färber#include <sys/mman.h>
5118832ce9c2SScott Wood#include <stddef.h>
5119e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5120e78815a5SAndreas FärberEOF
5121e78815a5SAndreas Färberif compile_prog "" "" ; then
5122e78815a5SAndreas Färber    posix_madvise=yes
5123e78815a5SAndreas Färberfi
5124e78815a5SAndreas Färber
5125e78815a5SAndreas Färber##########################################
51269bc5a719SAndreas Gustafsson# check if we have posix_memalign()
51279bc5a719SAndreas Gustafsson
51289bc5a719SAndreas Gustafssonposix_memalign=no
51299bc5a719SAndreas Gustafssoncat > $TMPC << EOF
51309bc5a719SAndreas Gustafsson#include <stdlib.h>
51319bc5a719SAndreas Gustafssonint main(void) {
51329bc5a719SAndreas Gustafsson    void *p;
51339bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
51349bc5a719SAndreas Gustafsson}
51359bc5a719SAndreas GustafssonEOF
51369bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
51379bc5a719SAndreas Gustafsson    posix_memalign=yes
51389bc5a719SAndreas Gustafssonfi
51399bc5a719SAndreas Gustafsson
51409bc5a719SAndreas Gustafsson##########################################
51410a852417SPaul Durrant# check if we have posix_syslog
51420a852417SPaul Durrant
51430a852417SPaul Durrantposix_syslog=no
51440a852417SPaul Durrantcat > $TMPC << EOF
51450a852417SPaul Durrant#include <syslog.h>
51460a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
51470a852417SPaul DurrantEOF
51480a852417SPaul Durrantif compile_prog "" "" ; then
51490a852417SPaul Durrant    posix_syslog=yes
51500a852417SPaul Durrantfi
51510a852417SPaul Durrant
51520a852417SPaul Durrant##########################################
5153401bc051SPeter Maydell# check if we have sem_timedwait
5154401bc051SPeter Maydell
5155401bc051SPeter Maydellsem_timedwait=no
5156401bc051SPeter Maydellcat > $TMPC << EOF
5157401bc051SPeter Maydell#include <semaphore.h>
5158811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5159401bc051SPeter MaydellEOF
5160401bc051SPeter Maydellif compile_prog "" "" ; then
5161401bc051SPeter Maydell    sem_timedwait=yes
5162401bc051SPeter Maydellfi
5163401bc051SPeter Maydell
5164401bc051SPeter Maydell##########################################
51655c99fa37SKeno Fischer# check if we have strchrnul
51665c99fa37SKeno Fischer
51675c99fa37SKeno Fischerstrchrnul=no
51685c99fa37SKeno Fischercat > $TMPC << EOF
51695c99fa37SKeno Fischer#include <string.h>
51705c99fa37SKeno Fischerint main(void);
51715c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
51725c99fa37SKeno Fischerchar *haystack = (char*)&main;
51735c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
51745c99fa37SKeno FischerEOF
51755c99fa37SKeno Fischerif compile_prog "" "" ; then
51765c99fa37SKeno Fischer    strchrnul=yes
51775c99fa37SKeno Fischerfi
51785c99fa37SKeno Fischer
51795c99fa37SKeno Fischer##########################################
518094a420b1SStefan Hajnoczi# check if trace backend exists
518194a420b1SStefan Hajnoczi
51825b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
518394a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
51845b808275SLluís Vilanova  error_exit "invalid trace backends" \
51855b808275SLluís Vilanova      "Please choose supported trace backends."
518694a420b1SStefan Hajnoczifi
518794a420b1SStefan Hajnoczi
51887e24e92aSStefan Hajnoczi##########################################
51897e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
51905b808275SLluís Vilanovaif have_backend "ust"; then
51917e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5192bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
51937e24e92aSStefan Hajnocziint main(void) { return 0; }
51947e24e92aSStefan HajnocziEOF
5195c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5196bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
519789138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
51987e24e92aSStefan Hajnoczi    else
5199c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5200bf15f63cSMohamad Gebai    fi
5201bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
520289138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5203bf15f63cSMohamad Gebai    else
5204bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5205bf15f63cSMohamad Gebai    fi
5206bf15f63cSMohamad Gebai
5207bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5208bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5209bf15f63cSMohamad Gebai  else
5210bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
52117e24e92aSStefan Hajnoczi  fi
52127e24e92aSStefan Hajnoczifi
5213b3d08c02SDaniel P. Berrange
5214b3d08c02SDaniel P. Berrange##########################################
5215b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
52165b808275SLluís Vilanovaif have_backend "dtrace"; then
5217b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
521876ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5219b3d08c02SDaniel P. Berrange  fi
5220c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5221c276b17dSDaniel P. Berrange  if has 'stap' ; then
5222c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5223c276b17dSDaniel P. Berrange  fi
5224b3d08c02SDaniel P. Berrangefi
5225b3d08c02SDaniel P. Berrange
52267e24e92aSStefan Hajnoczi##########################################
5227519175a2SAlex Barcelo# check and set a backend for coroutine
5228d0e2fce5SAneesh Kumar K.V
52297c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
523033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
523133c53c54SDaniel P. Berrange# specific one.
52327c2acc70SPeter Maydell
52337c2acc70SPeter Maydellucontext_works=no
5234d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5235d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5236d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5237cdf84806SPeter Maydell#ifdef __stub_makecontext
5238cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5239cdf84806SPeter Maydell#endif
524075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5241d0e2fce5SAneesh Kumar K.VEOF
5242d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
52437c2acc70SPeter Maydell    ucontext_works=yes
5244d0e2fce5SAneesh Kumar K.V  fi
5245519175a2SAlex Barcelofi
52467c2acc70SPeter Maydell
52477c2acc70SPeter Maydellif test "$coroutine" = ""; then
52487c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
52497c2acc70SPeter Maydell    coroutine=win32
52507c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
52517c2acc70SPeter Maydell    coroutine=ucontext
5252519175a2SAlex Barcelo  else
52537c2acc70SPeter Maydell    coroutine=sigaltstack
52547c2acc70SPeter Maydell  fi
52557c2acc70SPeter Maydellelse
52567c2acc70SPeter Maydell  case $coroutine in
52577c2acc70SPeter Maydell  windows)
52587c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
52597c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
52607c2acc70SPeter Maydell    fi
52617c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
52627c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
52637c2acc70SPeter Maydell    coroutine=win32
52647c2acc70SPeter Maydell    ;;
52657c2acc70SPeter Maydell  ucontext)
52667c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
52677c2acc70SPeter Maydell      feature_not_found "ucontext"
52687c2acc70SPeter Maydell    fi
52697c2acc70SPeter Maydell    ;;
527033c53c54SDaniel P. Berrange  sigaltstack)
52717c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
52727c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
52737c2acc70SPeter Maydell    fi
52747c2acc70SPeter Maydell    ;;
52757c2acc70SPeter Maydell  *)
527676ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
52777c2acc70SPeter Maydell    ;;
52787c2acc70SPeter Maydell  esac
5279d0e2fce5SAneesh Kumar K.Vfi
5280d0e2fce5SAneesh Kumar K.V
528170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
528270c60c08SStefan Hajnoczi  coroutine_pool=yes
528370c60c08SStefan Hajnoczifi
528470c60c08SStefan Hajnoczi
52857d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
52867d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
52877d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
52887d992e4dSPeter Lieven    coroutine_pool=no
52897d992e4dSPeter Lieven  fi
52907d992e4dSPeter Lievenfi
52917d992e4dSPeter Lieven
52927d992e4dSPeter Lieven
5293d0e2fce5SAneesh Kumar K.V##########################################
5294d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5295d2042378SAneesh Kumar K.V
52964e1797f9SStefan Weilopen_by_handle_at=no
5297d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5298d2042378SAneesh Kumar K.V#include <fcntl.h>
5299acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5300acc55ba8SStefan Weil# error missing definition
5301acc55ba8SStefan Weil#else
530275cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5303acc55ba8SStefan Weil#endif
5304d2042378SAneesh Kumar K.VEOF
5305d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5306d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5307d2042378SAneesh Kumar K.Vfi
5308d2042378SAneesh Kumar K.V
5309e06a765eSHarsh Prateek Bora########################################
5310e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5311e06a765eSHarsh Prateek Bora
5312e06a765eSHarsh Prateek Boralinux_magic_h=no
5313e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5314e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5315e06a765eSHarsh Prateek Boraint main(void) {
531675cafad7SStefan Weil  return 0;
5317e06a765eSHarsh Prateek Bora}
5318e06a765eSHarsh Prateek BoraEOF
5319e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5320e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5321e06a765eSHarsh Prateek Borafi
5322e06a765eSHarsh Prateek Bora
53238ab1bf12SLuiz Capitulino########################################
5324c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
5325c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
5326c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
5327c95e3080SKevin Wolf# only a warning.
5328c95e3080SKevin Wolf#
5329c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
5330c95e3080SKevin Wolf# the build doesn't fail anyway.
5331c95e3080SKevin Wolf
533206d71fa1SPeter Maydellpragma_disable_unused_but_set=no
533306d71fa1SPeter Maydellcat > $TMPC << EOF
5334e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
5335c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5336e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
5337c95e3080SKevin Wolf
533806d71fa1SPeter Maydellint main(void) {
533906d71fa1SPeter Maydell    return 0;
534006d71fa1SPeter Maydell}
534106d71fa1SPeter MaydellEOF
534206d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
5343cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
5344c95e3080SKevin Wolfelse
5345c95e3080SKevin Wolf    werror=no
534606d71fa1SPeter Maydellfi
534706d71fa1SPeter Maydell
534806d71fa1SPeter Maydell########################################
5349541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
53503f4349dcSKevin Wolf
53513f4349dcSKevin Wolfvalgrind_h=no
53523f4349dcSKevin Wolfcat > $TMPC << EOF
53533f4349dcSKevin Wolf#include <valgrind/valgrind.h>
53543f4349dcSKevin Wolfint main(void) {
53553f4349dcSKevin Wolf  return 0;
53563f4349dcSKevin Wolf}
53573f4349dcSKevin WolfEOF
53583f4349dcSKevin Wolfif compile_prog "" "" ; then
53593f4349dcSKevin Wolf    valgrind_h=yes
53603f4349dcSKevin Wolffi
53613f4349dcSKevin Wolf
53623f4349dcSKevin Wolf########################################
53638ab1bf12SLuiz Capitulino# check if environ is declared
53648ab1bf12SLuiz Capitulino
53658ab1bf12SLuiz Capitulinohas_environ=no
53668ab1bf12SLuiz Capitulinocat > $TMPC << EOF
53678ab1bf12SLuiz Capitulino#include <unistd.h>
53688ab1bf12SLuiz Capitulinoint main(void) {
5369c075a723SBlue Swirl    environ = 0;
53708ab1bf12SLuiz Capitulino    return 0;
53718ab1bf12SLuiz Capitulino}
53728ab1bf12SLuiz CapitulinoEOF
53738ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
53748ab1bf12SLuiz Capitulino    has_environ=yes
53758ab1bf12SLuiz Capitulinofi
53768ab1bf12SLuiz Capitulino
537776a347e1SRichard Henderson########################################
537876a347e1SRichard Henderson# check if cpuid.h is usable.
537976a347e1SRichard Henderson
538076a347e1SRichard Hendersoncat > $TMPC << EOF
538176a347e1SRichard Henderson#include <cpuid.h>
538276a347e1SRichard Hendersonint main(void) {
5383774d566cSPeter Maydell    unsigned a, b, c, d;
5384774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5385774d566cSPeter Maydell
5386774d566cSPeter Maydell    if (max >= 1) {
5387774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5388774d566cSPeter Maydell    }
5389774d566cSPeter Maydell
5390774d566cSPeter Maydell    if (max >= 7) {
5391774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5392774d566cSPeter Maydell    }
5393774d566cSPeter Maydell
539476a347e1SRichard Henderson    return 0;
539576a347e1SRichard Henderson}
539676a347e1SRichard HendersonEOF
539776a347e1SRichard Hendersonif compile_prog "" "" ; then
539876a347e1SRichard Henderson    cpuid_h=yes
539976a347e1SRichard Hendersonfi
540076a347e1SRichard Henderson
54015dd89908SRichard Henderson##########################################
54025dd89908SRichard Henderson# avx2 optimization requirement check
54035dd89908SRichard Henderson#
54045dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
54055dd89908SRichard Henderson# since we won't be able to select the new routines.
54065dd89908SRichard Henderson
5407e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
54085dd89908SRichard Henderson  cat > $TMPC << EOF
54095dd89908SRichard Henderson#pragma GCC push_options
54105dd89908SRichard Henderson#pragma GCC target("avx2")
54115dd89908SRichard Henderson#include <cpuid.h>
54125dd89908SRichard Henderson#include <immintrin.h>
54135dd89908SRichard Hendersonstatic int bar(void *a) {
54145dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
54155dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
54165dd89908SRichard Henderson}
54175dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
54185dd89908SRichard HendersonEOF
54195dd89908SRichard Henderson  if compile_object "" ; then
54205dd89908SRichard Henderson    avx2_opt="yes"
542186583a07SLiam Merwick  else
542286583a07SLiam Merwick    avx2_opt="no"
54235dd89908SRichard Henderson  fi
54245dd89908SRichard Hendersonfi
54255dd89908SRichard Henderson
5426f540166bSRichard Henderson########################################
5427f540166bSRichard Henderson# check if __[u]int128_t is usable.
5428f540166bSRichard Henderson
5429f540166bSRichard Hendersonint128=no
5430f540166bSRichard Hendersoncat > $TMPC << EOF
5431f540166bSRichard Henderson__int128_t a;
5432f540166bSRichard Henderson__uint128_t b;
5433f540166bSRichard Hendersonint main (void) {
5434f540166bSRichard Henderson  a = a + b;
5435f540166bSRichard Henderson  b = a * b;
5436464e3671SPeter Maydell  a = a * a;
5437f540166bSRichard Henderson  return 0;
5438f540166bSRichard Henderson}
5439f540166bSRichard HendersonEOF
5440f540166bSRichard Hendersonif compile_prog "" "" ; then
5441f540166bSRichard Henderson    int128=yes
5442f540166bSRichard Hendersonfi
544376a347e1SRichard Henderson
54447ebee43eSRichard Henderson#########################################
54457ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
54467ebee43eSRichard Henderson
54477ebee43eSRichard Hendersonatomic128=no
54487ebee43eSRichard Hendersonif test "$int128" = "yes"; then
54497ebee43eSRichard Henderson  cat > $TMPC << EOF
54507ebee43eSRichard Hendersonint main(void)
54517ebee43eSRichard Henderson{
54527ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
54537ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
54547ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
54557ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
54567ebee43eSRichard Henderson  return 0;
54577ebee43eSRichard Henderson}
54587ebee43eSRichard HendersonEOF
54597ebee43eSRichard Henderson  if compile_prog "" "" ; then
54607ebee43eSRichard Henderson    atomic128=yes
54617ebee43eSRichard Henderson  fi
54627ebee43eSRichard Hendersonfi
54637ebee43eSRichard Henderson
5464e6cd4bb5SRichard Hendersoncmpxchg128=no
5465e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5466e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5467e6cd4bb5SRichard Hendersonint main(void)
5468e6cd4bb5SRichard Henderson{
5469e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5470e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5471e6cd4bb5SRichard Henderson  return 0;
5472e6cd4bb5SRichard Henderson}
5473e6cd4bb5SRichard HendersonEOF
5474e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5475e6cd4bb5SRichard Henderson    cmpxchg128=yes
5476e6cd4bb5SRichard Henderson  fi
5477e6cd4bb5SRichard Hendersonfi
5478e6cd4bb5SRichard Henderson
5479df79b996SRichard Henderson#########################################
5480df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5481df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5482df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5483df79b996SRichard Henderson
5484df79b996SRichard Hendersoncat > $TMPC << EOF
5485df79b996SRichard Henderson#include <stdint.h>
5486df79b996SRichard Hendersonint main(void)
5487df79b996SRichard Henderson{
5488df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5489df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5490df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5491df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5492df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5493df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5494df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5495df79b996SRichard Henderson#else
5496df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5497df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5498df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5499df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5500df79b996SRichard Henderson#endif
5501df79b996SRichard Henderson  return 0;
5502df79b996SRichard Henderson}
5503df79b996SRichard HendersonEOF
5504df79b996SRichard Hendersonif compile_prog "" "" ; then
5505df79b996SRichard Henderson  atomic64=yes
5506df79b996SRichard Hendersonfi
5507df79b996SRichard Henderson
550826fffe29SEmilio G. Cota#########################################
550926fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
551026fffe29SEmilio G. Cotald_dynamic_list="no"
551126fffe29SEmilio G. Cotaif test "$static" = "no" ; then
551226fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
551326fffe29SEmilio G. Cota{
551426fffe29SEmilio G. Cota  foo;
551526fffe29SEmilio G. Cota};
551626fffe29SEmilio G. CotaEOF
551726fffe29SEmilio G. Cota
551826fffe29SEmilio G. Cota    cat > $TMPC <<EOF
551926fffe29SEmilio G. Cota#include <stdio.h>
552026fffe29SEmilio G. Cotavoid foo(void);
552126fffe29SEmilio G. Cota
552226fffe29SEmilio G. Cotavoid foo(void)
552326fffe29SEmilio G. Cota{
552426fffe29SEmilio G. Cota  printf("foo\n");
552526fffe29SEmilio G. Cota}
552626fffe29SEmilio G. Cota
552726fffe29SEmilio G. Cotaint main(void)
552826fffe29SEmilio G. Cota{
552926fffe29SEmilio G. Cota  foo();
553026fffe29SEmilio G. Cota  return 0;
553126fffe29SEmilio G. Cota}
553226fffe29SEmilio G. CotaEOF
553326fffe29SEmilio G. Cota
553426fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
553526fffe29SEmilio G. Cota        ld_dynamic_list="yes"
553626fffe29SEmilio G. Cota    fi
553726fffe29SEmilio G. Cotafi
553826fffe29SEmilio G. Cota
553926fffe29SEmilio G. Cota#########################################
554026fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
554126fffe29SEmilio G. Cota
554226fffe29SEmilio G. Cotald_exported_symbols_list="no"
554326fffe29SEmilio G. Cotaif test "$static" = "no" ; then
554426fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
554526fffe29SEmilio G. Cota  _foo
554626fffe29SEmilio G. CotaEOF
554726fffe29SEmilio G. Cota
554826fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
554926fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
555026fffe29SEmilio G. Cota    fi
555126fffe29SEmilio G. Cotafi
555226fffe29SEmilio G. Cota
555326fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
555426fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
555526fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
555626fffe29SEmilio G. Cota  error_exit \
555726fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
555826fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
555926fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
556026fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
556126fffe29SEmilio G. Cotafi
556226fffe29SEmilio G. Cota
55631e6e9acaSRichard Henderson########################################
5564db432672SRichard Henderson# See if 16-byte vector operations are supported.
5565db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5566db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5567db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5568db432672SRichard Henderson
5569db432672SRichard Hendersoncat > $TMPC << EOF
5570db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5571db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5572db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5573db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5574db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5575db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5576db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5577db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5578db432672SRichard Hendersonstatic U1 a1, b1;
5579db432672SRichard Hendersonstatic U2 a2, b2;
5580db432672SRichard Hendersonstatic U4 a4, b4;
5581db432672SRichard Hendersonstatic U8 a8, b8;
5582db432672SRichard Hendersonstatic S1 c1;
5583db432672SRichard Hendersonstatic S2 c2;
5584db432672SRichard Hendersonstatic S4 c4;
5585db432672SRichard Hendersonstatic S8 c8;
5586db432672SRichard Hendersonstatic int i;
558774912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
558874912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
558974912f6dSLaurent Vivier{
559074912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
559174912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
559274912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
559374912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
559474912f6dSLaurent Vivier}
5595db432672SRichard Hendersonint main(void)
5596db432672SRichard Henderson{
5597db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5598db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5599db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5600db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5601db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5602db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5603db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5604db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5605db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5606db432672SRichard Henderson  return 0;
5607db432672SRichard Henderson}
5608db432672SRichard HendersonEOF
5609db432672SRichard Henderson
5610db432672SRichard Hendersonvector16=no
5611db432672SRichard Hendersonif compile_prog "" "" ; then
5612db432672SRichard Henderson  vector16=yes
5613db432672SRichard Hendersonfi
5614db432672SRichard Henderson
5615db432672SRichard Henderson########################################
5616db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
5617db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
5618db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
5619db8aaae8SRichard Henderson
5620db8aaae8SRichard Hendersonattralias=no
5621db8aaae8SRichard Hendersoncat > $TMPC << EOF
5622db8aaae8SRichard Hendersonint x = 1;
5623db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
5624db8aaae8SRichard Hendersonint main(void) { return 0; }
5625db8aaae8SRichard HendersonEOF
5626db8aaae8SRichard Hendersonif compile_prog "" "" ; then
5627db8aaae8SRichard Henderson    attralias=yes
5628db8aaae8SRichard Hendersonfi
5629db8aaae8SRichard Henderson
5630db8aaae8SRichard Henderson########################################
56311e6e9acaSRichard Henderson# check if getauxval is available.
56321e6e9acaSRichard Henderson
56331e6e9acaSRichard Hendersongetauxval=no
56341e6e9acaSRichard Hendersoncat > $TMPC << EOF
56351e6e9acaSRichard Henderson#include <sys/auxv.h>
56361e6e9acaSRichard Hendersonint main(void) {
56371e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
56381e6e9acaSRichard Henderson}
56391e6e9acaSRichard HendersonEOF
56401e6e9acaSRichard Hendersonif compile_prog "" "" ; then
56411e6e9acaSRichard Henderson    getauxval=yes
56421e6e9acaSRichard Hendersonfi
56431e6e9acaSRichard Henderson
5644fd0e6053SJohn Snow########################################
5645fd0e6053SJohn Snow# check if ccache is interfering with
5646fd0e6053SJohn Snow# semantic analysis of macros
5647fd0e6053SJohn Snow
56485e4dfd3dSJohn Snowunset CCACHE_CPP2
5649fd0e6053SJohn Snowccache_cpp2=no
5650fd0e6053SJohn Snowcat > $TMPC << EOF
5651fd0e6053SJohn Snowstatic const int Z = 1;
5652fd0e6053SJohn Snow#define fn() ({ Z; })
5653fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5654fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5655fd0e6053SJohn Snow#define ID(X) (X)
5656fd0e6053SJohn Snowint main(int argc, char *argv[])
5657fd0e6053SJohn Snow{
5658fd0e6053SJohn Snow    int x = 0, y = 0;
5659fd0e6053SJohn Snow    x = ID(x);
5660fd0e6053SJohn Snow    x = fn();
5661fd0e6053SJohn Snow    fn();
5662fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5663fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5664fd0e6053SJohn Snow    return 0;
5665fd0e6053SJohn Snow}
5666fd0e6053SJohn SnowEOF
5667fd0e6053SJohn Snow
5668fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5669fd0e6053SJohn Snow    ccache_cpp2=yes
5670fd0e6053SJohn Snowfi
5671fd0e6053SJohn Snow
5672b553a042SJohn Snow#################################################
5673b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5674b553a042SJohn Snow
5675b553a042SJohn Snowif test "$fortify_source" != "no"; then
5676b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5677b553a042SJohn Snow    fortify_source="no";
5678e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5679cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5680b553a042SJohn Snow    fortify_source="no";
5681b553a042SJohn Snow  else
5682b553a042SJohn Snow    fortify_source="yes"
5683b553a042SJohn Snow  fi
5684b553a042SJohn Snowfi
5685b553a042SJohn Snow
56861efad060SFam Zheng###############################################
56871efad060SFam Zheng# Check if copy_file_range is provided by glibc
56881efad060SFam Zhenghave_copy_file_range=no
56891efad060SFam Zhengcat > $TMPC << EOF
56901efad060SFam Zheng#include <unistd.h>
56911efad060SFam Zhengint main(void) {
56921efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
56931efad060SFam Zheng  return 0;
56941efad060SFam Zheng}
56951efad060SFam ZhengEOF
56961efad060SFam Zhengif compile_prog "" "" ; then
56971efad060SFam Zheng    have_copy_file_range=yes
56981efad060SFam Zhengfi
56991efad060SFam Zheng
5700d2042378SAneesh Kumar K.V##########################################
5701277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5702277abf15SJan Vesely
5703277abf15SJan Veselyhave_fsxattr=no
5704277abf15SJan Veselycat > $TMPC << EOF
5705277abf15SJan Vesely#include <linux/fs.h>
5706277abf15SJan Veselystruct fsxattr foo;
5707277abf15SJan Veselyint main(void) {
5708277abf15SJan Vesely  return 0;
5709277abf15SJan Vesely}
5710277abf15SJan VeselyEOF
5711277abf15SJan Veselyif compile_prog "" "" ; then
5712277abf15SJan Vesely    have_fsxattr=yes
5713277abf15SJan Veselyfi
5714277abf15SJan Vesely
5715b66e10e4SPeter Maydell##########################################
5716a40161cbSPaolo Bonzini# check for usable membarrier system call
5717a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5718a40161cbSPaolo Bonzini    have_membarrier=no
5719a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5720a40161cbSPaolo Bonzini        have_membarrier=yes
5721a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5722a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5723a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5724a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5725a40161cbSPaolo Bonzini    #include <unistd.h>
5726a40161cbSPaolo Bonzini    #include <stdlib.h>
5727a40161cbSPaolo Bonzini    int main(void) {
5728a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5729a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5730a40161cbSPaolo Bonzini	exit(0);
5731a40161cbSPaolo Bonzini    }
5732a40161cbSPaolo BonziniEOF
5733a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5734a40161cbSPaolo Bonzini            have_membarrier=yes
5735a40161cbSPaolo Bonzini        fi
5736a40161cbSPaolo Bonzini    fi
5737a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5738a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5739a40161cbSPaolo Bonzini    fi
5740a40161cbSPaolo Bonzinielse
5741a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5742a40161cbSPaolo Bonzini    # work on Wine.
5743a40161cbSPaolo Bonzini    membarrier=no
5744a40161cbSPaolo Bonzinifi
5745a40161cbSPaolo Bonzini
5746a40161cbSPaolo Bonzini##########################################
5747b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5748575b22b1SLaurent Vivierhave_rtnetlink=no
5749575b22b1SLaurent Viviercat > $TMPC << EOF
5750575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5751575b22b1SLaurent Vivierint main(void) {
5752575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5753575b22b1SLaurent Vivier}
5754575b22b1SLaurent VivierEOF
5755575b22b1SLaurent Vivierif compile_prog "" "" ; then
5756575b22b1SLaurent Vivier    have_rtnetlink=yes
5757575b22b1SLaurent Vivierfi
5758575b22b1SLaurent Vivier
57596a02c806SStefan Hajnoczi##########################################
57606a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
57616a02c806SStefan Hajnoczihave_af_vsock=no
57626a02c806SStefan Hajnoczicat > $TMPC << EOF
57636a02c806SStefan Hajnoczi#include <errno.h>
57646a02c806SStefan Hajnoczi#include <sys/types.h>
57656a02c806SStefan Hajnoczi#include <sys/socket.h>
57666a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
57676a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
57686a02c806SStefan Hajnoczi#endif
57696a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
57706a02c806SStefan Hajnocziint main(void) {
57716a02c806SStefan Hajnoczi    int sock, ret;
57726a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
57736a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
57746a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
57756a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
57766a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
57776a02c806SStefan Hajnoczi        return 0;
57786a02c806SStefan Hajnoczi    }
57796a02c806SStefan Hajnoczi    return -1;
57806a02c806SStefan Hajnoczi}
57816a02c806SStefan HajnocziEOF
57826a02c806SStefan Hajnocziif compile_prog "" "" ; then
57836a02c806SStefan Hajnoczi    have_af_vsock=yes
57846a02c806SStefan Hajnoczifi
57856a02c806SStefan Hajnoczi
5786f0d92b56SLongpeng(Mike)##########################################
5787f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5788f0d92b56SLongpeng(Mike)hava_afalg=no
5789f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5790f0d92b56SLongpeng(Mike)#include <errno.h>
5791f0d92b56SLongpeng(Mike)#include <sys/types.h>
5792f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5793f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5794f0d92b56SLongpeng(Mike)int main(void) {
5795f0d92b56SLongpeng(Mike)    int sock;
5796f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5797f0d92b56SLongpeng(Mike)    return sock;
5798f0d92b56SLongpeng(Mike)}
5799f0d92b56SLongpeng(Mike)EOF
5800f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5801f0d92b56SLongpeng(Mike)    have_afalg=yes
5802f0d92b56SLongpeng(Mike)fi
5803f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5804f0d92b56SLongpeng(Mike)then
5805f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5806f0d92b56SLongpeng(Mike)    then
5807f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5808f0d92b56SLongpeng(Mike)    fi
5809f0d92b56SLongpeng(Mike)fi
5810f0d92b56SLongpeng(Mike)
5811f0d92b56SLongpeng(Mike)
58126969ec6cSJames Clarke#################################################
5813c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5814d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5815c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5816c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5817c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5818c97d6d2cSSergio Andres Gomez Del RealEOF
5819c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5820c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5821c97d6d2cSSergio Andres Gomez Del Real  else
5822c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5823c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5824c97d6d2cSSergio Andres Gomez Del Real  fi
5825c97d6d2cSSergio Andres Gomez Del Realfi
5826c97d6d2cSSergio Andres Gomez Del Real
5827c97d6d2cSSergio Andres Gomez Del Real#################################################
58286969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
58296969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
58306969ec6cSJames Clarke# given. It does no harm to give it on other
58316969ec6cSJames Clarke# platforms too.
58326969ec6cSJames Clarke
58336969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
58346969ec6cSJames Clarke#       contains -Wmissing-prototypes
58356969ec6cSJames Clarkecat > $TMPC << EOF
58366969ec6cSJames Clarkeextern int foo(void);
58376969ec6cSJames Clarkeint foo(void) { return 0; }
58386969ec6cSJames ClarkeEOF
58396969ec6cSJames Clarkeif ! compile_object ""; then
58406969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
58416969ec6cSJames Clarkefi
58427ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
58437ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
58447ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
58457ecf44a5SPaolo Bonzini    break
58467ecf44a5SPaolo Bonzini  fi
58477ecf44a5SPaolo Bonzinidone
58487ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
58497ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
58506969ec6cSJames Clarkefi
58516969ec6cSJames Clarke
5852277abf15SJan Vesely##########################################
58534d04351fSChristopher Covington# check for sysmacros.h
58544d04351fSChristopher Covington
58554d04351fSChristopher Covingtonhave_sysmacros=no
58564d04351fSChristopher Covingtoncat > $TMPC << EOF
58574d04351fSChristopher Covington#include <sys/sysmacros.h>
58584d04351fSChristopher Covingtonint main(void) {
58594d04351fSChristopher Covington    return makedev(0, 0);
58604d04351fSChristopher Covington}
58614d04351fSChristopher CovingtonEOF
58624d04351fSChristopher Covingtonif compile_prog "" "" ; then
58634d04351fSChristopher Covington    have_sysmacros=yes
58644d04351fSChristopher Covingtonfi
58654d04351fSChristopher Covington
58664d04351fSChristopher Covington##########################################
5867da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5868da92c3ffSAshish Mittal# Check if libvxhs is installed
5869da92c3ffSAshish Mittal
5870da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5871da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5872da92c3ffSAshish Mittal#include <stdint.h>
5873da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5874da92c3ffSAshish Mittal
5875da92c3ffSAshish Mittalvoid *vxhs_callback;
5876da92c3ffSAshish Mittal
5877da92c3ffSAshish Mittalint main(void) {
5878da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5879da92c3ffSAshish Mittal    return 0;
5880da92c3ffSAshish Mittal}
5881da92c3ffSAshish MittalEOF
5882da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5883da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5884da92c3ffSAshish Mittal    vxhs=yes
5885da92c3ffSAshish Mittal  else
5886da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5887da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5888da92c3ffSAshish Mittal    fi
5889da92c3ffSAshish Mittal    vxhs=no
5890da92c3ffSAshish Mittal  fi
5891da92c3ffSAshish Mittalfi
5892da92c3ffSAshish Mittal
5893da92c3ffSAshish Mittal##########################################
589449e00a18SAndreas Grapentin# check for _Static_assert()
589549e00a18SAndreas Grapentin
589649e00a18SAndreas Grapentinhave_static_assert=no
589749e00a18SAndreas Grapentincat > $TMPC << EOF
589849e00a18SAndreas Grapentin_Static_assert(1, "success");
589949e00a18SAndreas Grapentinint main(void) {
590049e00a18SAndreas Grapentin    return 0;
590149e00a18SAndreas Grapentin}
590249e00a18SAndreas GrapentinEOF
590349e00a18SAndreas Grapentinif compile_prog "" "" ; then
590449e00a18SAndreas Grapentin    have_static_assert=yes
590549e00a18SAndreas Grapentinfi
590649e00a18SAndreas Grapentin
590749e00a18SAndreas Grapentin##########################################
5908e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5909e674605fSTomáš Golembiovský
5910e674605fSTomáš Golembiovskýhave_utmpx=no
5911e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5912e674605fSTomáš Golembiovský#include <utmpx.h>
5913e674605fSTomáš Golembiovskýstruct utmpx user_info;
5914e674605fSTomáš Golembiovskýint main(void) {
5915e674605fSTomáš Golembiovský    return 0;
5916e674605fSTomáš Golembiovský}
5917e674605fSTomáš GolembiovskýEOF
5918e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5919e674605fSTomáš Golembiovský    have_utmpx=yes
5920e674605fSTomáš Golembiovskýfi
5921e674605fSTomáš Golembiovský
5922e674605fSTomáš Golembiovský##########################################
5923db1ed1abSRichard Henderson# check for getrandom()
5924db1ed1abSRichard Henderson
5925db1ed1abSRichard Hendersonhave_getrandom=no
5926db1ed1abSRichard Hendersoncat > $TMPC << EOF
5927db1ed1abSRichard Henderson#include <sys/random.h>
5928db1ed1abSRichard Hendersonint main(void) {
5929db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
5930db1ed1abSRichard Henderson}
5931db1ed1abSRichard HendersonEOF
5932db1ed1abSRichard Hendersonif compile_prog "" "" ; then
5933db1ed1abSRichard Henderson    have_getrandom=yes
5934db1ed1abSRichard Hendersonfi
5935db1ed1abSRichard Henderson
5936db1ed1abSRichard Henderson##########################################
5937247724cbSMarc-André Lureau# checks for sanitizers
5938247724cbSMarc-André Lureau
5939247724cbSMarc-André Lureauhave_asan=no
5940247724cbSMarc-André Lureauhave_ubsan=no
5941d83414e1SMarc-André Lureauhave_asan_iface_h=no
5942d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5943247724cbSMarc-André Lureau
5944247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5945b9f44da2SMarc-André Lureau  write_c_skeleton
5946247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5947247724cbSMarc-André Lureau      have_asan=yes
5948247724cbSMarc-André Lureau  fi
5949b9f44da2SMarc-André Lureau
5950b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5951b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5952b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5953b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5954b9f44da2SMarc-André Lureau#include <stdlib.h>
5955b9f44da2SMarc-André Lureauint main(void) {
5956b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5957b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5958b9f44da2SMarc-André Lureau}
5959b9f44da2SMarc-André LureauEOF
5960247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5961247724cbSMarc-André Lureau      have_ubsan=yes
5962247724cbSMarc-André Lureau  fi
5963d83414e1SMarc-André Lureau
5964d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5965d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5966d83414e1SMarc-André Lureau  fi
5967d83414e1SMarc-André Lureau
5968d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5969d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5970d83414e1SMarc-André Lureauint main(void) {
5971d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5972d83414e1SMarc-André Lureau  return 0;
5973d83414e1SMarc-André Lureau}
5974d83414e1SMarc-André LureauEOF
5975d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5976d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5977d83414e1SMarc-André Lureau  fi
5978247724cbSMarc-André Lureaufi
5979247724cbSMarc-André Lureau
5980247724cbSMarc-André Lureau##########################################
598117824406SJunyan He# check for libpmem
598217824406SJunyan He
598317824406SJunyan Heif test "$libpmem" != "no"; then
598417824406SJunyan He	if $pkg_config --exists "libpmem"; then
598517824406SJunyan He		libpmem="yes"
598617824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
598717824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
598817824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
598917824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
599017824406SJunyan He	else
599117824406SJunyan He		if test "$libpmem" = "yes" ; then
599217824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
599317824406SJunyan He		fi
599417824406SJunyan He		libpmem="no"
599517824406SJunyan He	fi
599617824406SJunyan Hefi
599717824406SJunyan He
599817824406SJunyan He##########################################
5999675b9b53SMarc-André Lureau# check for slirp
6000675b9b53SMarc-André Lureau
6001675b9b53SMarc-André Lureaucase "$slirp" in
6002675b9b53SMarc-André Lureau  "" | yes)
6003675b9b53SMarc-André Lureau    if $pkg_config slirp; then
6004675b9b53SMarc-André Lureau      slirp=system
60057c57bdd8SMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
60067c57bdd8SMarc-André Lureau      slirp=git
6007675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
6008675b9b53SMarc-André Lureau      slirp=internal
6009675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
6010675b9b53SMarc-André Lureau      slirp=no
6011675b9b53SMarc-André Lureau    else
6012675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
6013675b9b53SMarc-André Lureau    fi
6014675b9b53SMarc-André Lureau    ;;
6015675b9b53SMarc-André Lureau
6016675b9b53SMarc-André Lureau  system)
6017675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
6018675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
6019675b9b53SMarc-André Lureau    fi
6020675b9b53SMarc-André Lureau    ;;
6021675b9b53SMarc-André Lureauesac
6022675b9b53SMarc-André Lureau
6023675b9b53SMarc-André Lureaucase "$slirp" in
60247c57bdd8SMarc-André Lureau  git | internal)
60257c57bdd8SMarc-André Lureau    if test "$slirp" = git; then
60267c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
60277c57bdd8SMarc-André Lureau    fi
6028675b9b53SMarc-André Lureau    mkdir -p slirp
6029675b9b53SMarc-André Lureau    slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
6030675b9b53SMarc-André Lureau    slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
6031b965e8c5SPaolo Bonzini    if test "$mingw32" = "yes" ; then
6032b965e8c5SPaolo Bonzini      slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6033b965e8c5SPaolo Bonzini    fi
6034675b9b53SMarc-André Lureau    ;;
6035675b9b53SMarc-André Lureau
6036675b9b53SMarc-André Lureau  system)
6037675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6038675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6039675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6040675b9b53SMarc-André Lureau    ;;
6041675b9b53SMarc-André Lureau
6042675b9b53SMarc-André Lureau  no)
6043675b9b53SMarc-André Lureau    ;;
6044675b9b53SMarc-André Lureau  *)
6045675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
6046675b9b53SMarc-André Lureau    ;;
6047675b9b53SMarc-André Lureauesac
6048675b9b53SMarc-André Lureau
6049675b9b53SMarc-André Lureau
6050675b9b53SMarc-André Lureau##########################################
6051e86ecd4bSJuan Quintela# End of CC checks
6052e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
6053e86ecd4bSJuan Quintela
6054d83414e1SMarc-André Lureauwrite_c_skeleton
6055d83414e1SMarc-André Lureau
60561d728c39SBlue Swirlif test "$gcov" = "yes" ; then
60571d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
60581d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
6059b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
6060e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
606148e56d50SPaolo Bonzinielif test "$debug" = "no"; then
6062ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
6063e86ecd4bSJuan Quintelafi
6064a316e378SJuan Quintela
6065247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
6066247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
6067d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
6068d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
6069d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6070d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
6071d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
6072d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6073d83414e1SMarc-André Lureau  fi
6074247724cbSMarc-André Lureaufi
6075247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
6076247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
6077247724cbSMarc-André Lureaufi
6078247724cbSMarc-André Lureau
60796542aa9cSPeter Lieven##########################################
60806542aa9cSPeter Lieven# Do we have libnfs
60816542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
6082b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
60836542aa9cSPeter Lieven    libnfs="yes"
60846542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
60856542aa9cSPeter Lieven  else
60866542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
60878efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
60886542aa9cSPeter Lieven    fi
60896542aa9cSPeter Lieven    libnfs="no"
60906542aa9cSPeter Lieven  fi
60916542aa9cSPeter Lievenfi
60921d728c39SBlue Swirl
60933efac6ebSTomáš Golembiovský##########################################
60943efac6ebSTomáš Golembiovský# Do we have libudev
60953efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
60963efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
60973efac6ebSTomáš Golembiovský    libudev="yes"
60983efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
60993efac6ebSTomáš Golembiovský  else
61003efac6ebSTomáš Golembiovský    libudev="no"
61013efac6ebSTomáš Golembiovský  fi
61023efac6ebSTomáš Golembiovskýfi
61033efac6ebSTomáš Golembiovský
61046ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
61056ca026cbSPeter Maydellif test "$werror" = "yes"; then
61066ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
61076ca026cbSPeter Maydellfi
61086ca026cbSPeter Maydell
6109e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
6110e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
61111156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
6112e86ecd4bSJuan Quintela    fi
6113e86ecd4bSJuan Quintelafi
6114e86ecd4bSJuan Quintela
611594dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
611694dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
611794dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
611894dd53c5SGerd Hoffmannelse
611994dd53c5SGerd Hoffmann    POD2MAN="pod2man"
612094dd53c5SGerd Hoffmannfi
612194dd53c5SGerd Hoffmann
6122952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
6123952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
6124952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
6125e9a3591fSChristian Borntraeger        if ld_has $flag ; then
6126952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
6127952afb71SBlue Swirl        fi
6128952afb71SBlue Swirl    done
6129952afb71SBlue Swirlfi
6130952afb71SBlue Swirl
61317776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
61327776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
61337776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
61347776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
61357776ea6bSPhilippe Mathieu-DaudéEOF
61367776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
61377776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
61387776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
61397776ea6bSPhilippe Mathieu-Daudé    fi
61407776ea6bSPhilippe Mathieu-Daudéfi
61417776ea6bSPhilippe Mathieu-Daudé
614210ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
6143e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
6144528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
6145834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
6146a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
614767ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
61485a67135aSbellard
6149e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
6150e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
6151e0580342SKamil Rytarowski  ivshmem=yes
6152e0580342SKamil Rytarowskifi
6153e0580342SKamil Rytarowski
61544b1c11fdSDaniel P. Berrangetools=""
61554b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
615672d277a7SGerd Hoffmann  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
61574b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
61584b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
6159b1449edbSKamil Rytarowski  fi
6160b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
6161a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
61624b1c11fdSDaniel P. Berrange  fi
61631b9d35f3SViktor Prutyanov  if [ "$curl" = "yes" ]; then
61641b9d35f3SViktor Prutyanov      tools="elf2dmp\$(EXESUF) $tools"
61653fa2d384SViktor Prutyanov  fi
61664b1c11fdSDaniel P. Berrangefi
61674b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
6168b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
61697e462613SPaolo Bonzini    if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6170983eef5aSMeador Inge      virtfs=yes
617117bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
6172983eef5aSMeador Inge    else
6173983eef5aSMeador Inge      if test "$virtfs" = yes; then
61747e462613SPaolo Bonzini        error_exit "VirtFS requires libcap-ng devel and libattr devel"
6175983eef5aSMeador Inge      fi
617617500370SAndreas Färber      virtfs=no
6177983eef5aSMeador Inge    fi
6178fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
6179fe8fc5aeSPaolo Bonzini      mpath=yes
6180fe8fc5aeSPaolo Bonzini    else
6181fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
6182fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
6183fe8fc5aeSPaolo Bonzini      fi
6184fe8fc5aeSPaolo Bonzini      mpath=no
6185fe8fc5aeSPaolo Bonzini    fi
6186b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
6187b855f8d1SPaolo Bonzini  else
6188b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
6189b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
6190b855f8d1SPaolo Bonzini    fi
6191b855f8d1SPaolo Bonzini    virtfs=no
6192fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
6193fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
6194fe8fc5aeSPaolo Bonzini    fi
6195fe8fc5aeSPaolo Bonzini    mpath=no
619617bff52bSM. Mohan Kumar  fi
61976a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
61986a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
61996a021536SGerd Hoffmann  fi
6200ff69fd8cSLaurent Vivierfi
62019d6bc27bSMichael Roth
62029d6bc27bSMichael Roth# Probe for guest agent support/options
62039d6bc27bSMichael Roth
6204e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
6205a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6206a5125905SLaurent Vivier      guest_agent=no
6207a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
62080814465aSPaolo Bonzini      tools="qemu-ga\$(EXESUF) $tools"
6209e8ef31a3SMichael Tokarev      guest_agent=yes
6210e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
6211e8ef31a3SMichael Tokarev      guest_agent=no
6212e8ef31a3SMichael Tokarev  else
6213e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
6214ca35f780SPaolo Bonzini  fi
62154b1c11fdSDaniel P. Berrangefi
6216ca35f780SPaolo Bonzini
62179d6bc27bSMichael Roth# Guest agent Window MSI  package
62189d6bc27bSMichael Roth
62199d6bc27bSMichael Rothif test "$guest_agent" != yes; then
62209d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
62219d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
62229d6bc27bSMichael Roth  fi
62239d6bc27bSMichael Roth  guest_agent_msi=no
62249d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
62259d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
62269d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
62279d6bc27bSMichael Roth  fi
62289d6bc27bSMichael Roth  guest_agent_msi=no
62299d6bc27bSMichael Rothelif ! has wixl; then
62309d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
62319d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
62329d6bc27bSMichael Roth  fi
62339d6bc27bSMichael Roth  guest_agent_msi=no
62341a34904eSMichael Rothelse
62351a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
62361a34904eSMichael Roth  # disabled explicitly
62371a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
62381a34904eSMichael Roth    guest_agent_msi=yes
62391a34904eSMichael Roth  fi
62409d6bc27bSMichael Rothfi
62419d6bc27bSMichael Roth
62421a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
62439d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
62449d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
62459d6bc27bSMichael Roth  fi
62469d6bc27bSMichael Roth
62479d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
62489d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
62499d6bc27bSMichael Roth  fi
62509d6bc27bSMichael Roth
62519d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
62529d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
62539d6bc27bSMichael Roth  fi
62549d6bc27bSMichael Roth
62559d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
625689138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
62579d6bc27bSMichael Roth  fi
62589d6bc27bSMichael Roth
625989138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
62609d6bc27bSMichael Roth
62619d6bc27bSMichael Roth  case "$cpu" in
62629d6bc27bSMichael Roth  x86_64)
62639d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
62649d6bc27bSMichael Roth    ;;
62659d6bc27bSMichael Roth  i386)
62669d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
62679d6bc27bSMichael Roth    ;;
62689d6bc27bSMichael Roth  *)
62699d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
62709d6bc27bSMichael Roth    ;;
62719d6bc27bSMichael Roth  esac
62729d6bc27bSMichael Rothfi
62739d6bc27bSMichael Roth
6274ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6275ca35f780SPaolo Bonziniroms=
6276e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6277e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6278e633a5c6SEric Blake        test "$softmmu" = yes ; then
6279e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6280c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6281c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6282c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6283e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6284e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6285ca35f780SPaolo Bonzini            roms="optionrom"
6286e57218b6SPeter Maydell            break
6287e57218b6SPeter Maydell        fi
6288e57218b6SPeter Maydell    done
6289ca35f780SPaolo Bonzinifi
6290ca35f780SPaolo Bonzini
62912e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
62929933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
62932e33c3f8SThomas Huth  write_c_skeleton
62942e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
62959933c305SChristian Borntraeger    roms="$roms s390-ccw"
62969933c305SChristian Borntraeger  fi
62972e33c3f8SThomas Huthfi
62989933c305SChristian Borntraeger
6299964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
630092fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
6301964c6fa1SRichard Henderson  textseg_addr=
6302964c6fa1SRichard Henderson  case "$cpu" in
6303479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
6304479eb121SRichard Henderson      # ??? Rationale for choosing this address
6305964c6fa1SRichard Henderson      textseg_addr=0x60000000
6306964c6fa1SRichard Henderson      ;;
6307964c6fa1SRichard Henderson    mips)
6308479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
6309479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
6310479eb121SRichard Henderson      textseg_addr=0x60000000
6311964c6fa1SRichard Henderson      ;;
6312964c6fa1SRichard Henderson  esac
6313964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
6314964c6fa1SRichard Henderson    cat > $TMPC <<EOF
6315964c6fa1SRichard Henderson    int main(void) { return 0; }
6316964c6fa1SRichard HendersonEOF
6317964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
6318964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
6319964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
6320964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
6321964c6fa1SRichard Henderson      # at least.
632292fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
632392fe2ba8SPeter Maydell        error_exit \
632492fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
632592fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
632692fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
632792fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
632892fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
632992fe2ba8SPeter Maydell            "--disable-user option to configure."
633092fe2ba8SPeter Maydell      fi
633192fe2ba8SPeter Maydell
6332964c6fa1SRichard Henderson      $ld --verbose | sed \
6333964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
6334964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
6335964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
6336964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
6337964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
6338964c6fa1SRichard Henderson    fi
6339964c6fa1SRichard Henderson  fi
6340964c6fa1SRichard Hendersonfi
6341964c6fa1SRichard Henderson
634211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
634311cde1c8SBruno 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.
634411cde1c8SBruno Dominguezif has $cxx; then
634511cde1c8SBruno Dominguez    cat > $TMPC <<EOF
634611cde1c8SBruno Dominguezint c_function(void);
634711cde1c8SBruno Dominguezint main(void) { return c_function(); }
634811cde1c8SBruno DominguezEOF
634911cde1c8SBruno Dominguez
635011cde1c8SBruno Dominguez    compile_object
635111cde1c8SBruno Dominguez
635211cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
635311cde1c8SBruno Dominguezextern "C" {
635411cde1c8SBruno Dominguez   int c_function(void);
635511cde1c8SBruno Dominguez}
635611cde1c8SBruno Dominguezint c_function(void) { return 42; }
635711cde1c8SBruno DominguezEOF
635811cde1c8SBruno Dominguez
635911cde1c8SBruno Dominguez    update_cxxflags
636011cde1c8SBruno Dominguez
636111cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
636211cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
636311cde1c8SBruno Dominguez        :
636411cde1c8SBruno Dominguez    else
636511cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
636611cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
636711cde1c8SBruno Dominguez        cxx=
636811cde1c8SBruno Dominguez    fi
636911cde1c8SBruno Dominguezelse
637011cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
637111cde1c8SBruno Dominguez    cxx=
637211cde1c8SBruno Dominguezfi
637311cde1c8SBruno Dominguez
637402d34f62SCole Robinsonecho_version() {
637502d34f62SCole Robinson    if test "$1" = "yes" ; then
637602d34f62SCole Robinson        echo "($2)"
637702d34f62SCole Robinson    fi
637802d34f62SCole Robinson}
637902d34f62SCole Robinson
638050e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
638150e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
63828a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
638350e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
63845ca9388aSGerd Hoffmann
63857d13299dSbellardecho "Install prefix    $prefix"
638689138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
63873d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
638889138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
638989138857SStefan Weilecho "library directory $(eval echo $libdir)"
639089138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
639189138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
639289138857SStefan Weilecho "include directory $(eval echo $includedir)"
639389138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
639411d9f695Sbellardif test "$mingw32" = "no" ; then
639589138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
639689138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
639743ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
63985a699bbbSLaszlo Ersekelse
63995a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
6400d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
640111d9f695Sbellardfi
64025a67135aSbellardecho "Source path       $source_path"
6403cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
6404aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
64057d13299dSbellardecho "C compiler        $cc"
640683469015Sbellardecho "Host C compiler   $host_cc"
640783f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
64083c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
640945d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
64100c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
6411a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
64120c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
64138a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
64147d13299dSbellardecho "make              $make"
64156a882643Spbrookecho "install           $install"
6416755ee70fSCleber Rosaecho "python            $python ($python_version)"
6417675b9b53SMarc-André Lureauecho "slirp support     $slirp $(echo_version $slirp $slirp_version)"
6418675b9b53SMarc-André Lureauif test "$slirp" != "no" ; then
6419e2d8830eSBrad    echo "smbd              $smbd"
6420e2d8830eSBradfi
642117969268SFam Zhengecho "module support    $modules"
6422a98fd896Sbellardecho "host CPU          $cpu"
6423de83cd02Sbellardecho "host big endian   $bigendian"
642497a847bcSbellardecho "target list       $target_list"
64257d13299dSbellardecho "gprof enabled     $gprof"
642603b4fe7dSaliguoriecho "sparse enabled    $sparse"
64271625af87Saliguoriecho "strip binaries    $strip_opt"
642805c2a3e7Sbellardecho "profiler          $profiler"
642943ce4dfeSbellardecho "static build      $static"
64305b0753e0Sbellardif test "$darwin" = "yes" ; then
64315b0753e0Sbellard    echo "Cocoa support     $cocoa"
64325b0753e0Sbellardfi
643389138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
6434a442fe2fSDaniel P. Berrangéecho "SDL image support $sdl_image"
643589138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
6436925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
643789138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
6438a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
6439ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
644091bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
6441e0576942SDaniel P. Berrangéif test "$gcrypt" = "yes"
6442e0576942SDaniel P. Berrangéthen
6443e0576942SDaniel P. Berrangé   echo "  hmac            $gcrypt_hmac"
6444e0576942SDaniel P. Berrangé   echo "  XTS             $gcrypt_xts"
6445e0576942SDaniel P. Berrangéfi
644689138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
6447dc2207afSDaniel P. Berrangéif test "$nettle" = "yes"
6448dc2207afSDaniel P. Berrangéthen
6449dc2207afSDaniel P. Berrangé   echo "  XTS             $nettle_xts"
6450dc2207afSDaniel P. Berrangéfi
64519a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
64528953caf3SDaniel P. Berrangeecho "PAM               $auth_pam"
6453e08bb301SSamuel Thibaultecho "iconv support     $iconv"
64544d3b6f6eSbalrogecho "curses support    $curses"
645547479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6456769ce76dSAlexander Grafecho "curl support      $curl"
645767b915a5Sbellardecho "mingw32 support   $mingw32"
64580c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
6459b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
6460b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
6461983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
6462fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
6463821601eaSJes Sorensenecho "VNC support       $vnc"
6464821601eaSJes Sorensenif test "$vnc" = "yes" ; then
64652f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
64662f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
6467efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
6468821601eaSJes Sorensenfi
6469e37630caSaliguoriecho "xen support       $xen"
64703996e85cSPaul Durrantif test "$xen" = "yes" ; then
64713996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
64723996e85cSPaul Durrantfi
64732e4d9fb1Saurel32echo "brlapi support    $brlapi"
6474a25dba17SJuan Quintelaecho "Documentation     $docs"
647540d6444eSAvi Kivityecho "PIE               $pie"
64768a16d273Sthsecho "vde support       $vde"
647758952137SVincenzo Maffioneecho "netmap support    $netmap"
64785c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
6479758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
648077755340Sthsecho "Install blobs     $blobs"
6481b31a0277SJuan Quintelaecho "KVM support       $kvm"
6482b0cb0a66SVincent Palatinecho "HAX support       $hax"
6483c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
6484d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
6485b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
6486b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
6487b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
64889195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
6489b3f6ea7eSPaolo Bonzinifi
64905a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
6491b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
649221ab34c9SMarcel Apfelbaumecho "PVRDMA support    $pvrdma"
6493f652e6afSaurel32echo "fdt support       $fdt"
6494a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
6495ceb42de8Saliguoriecho "preadv support    $preadv"
64965f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
6497e78815a5SAndreas Färberecho "madvise           $madvise"
6498e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
64999bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
650047e98658SCorey Bryantecho "libcap-ng support $cap_ng"
6501d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
6502042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
65035e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
6504fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
6505e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
650698fc1adaSDr. David Alan Gilbertecho "vhost-user-fs support $vhost_user_fs"
65075b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
6508713572a7SMarc-André Lureauif have_backend "simple"; then
65099410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
6510e00e36fbSStefan Weilfi
651189138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6512f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
6513dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
65147b02f544SMarc-André Lureauecho "smartcard support $smartcard"
65152b2325ffSGerd Hoffmannecho "libusb            $libusb"
651669354a83SHans de Goedeecho "usb net redir     $usb_redir"
6517da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
6518014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
6519c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
65206542aa9cSPeter Lievenecho "libnfs support    $libnfs"
6521d138cee9SMichael Rothecho "build guest agent $guest_agent"
6522d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
652350cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
65244c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
6525f794573eSEduardo Otuboecho "seccomp support   $seccomp"
65267c2acc70SPeter Maydellecho "coroutine backend $coroutine"
652770c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
65287d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
6529ba59fb77SPaolo Bonziniecho "mutex debugging   $debug_mutex"
6530f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
6531eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
65321d728c39SBlue Swirlecho "gcov              $gcov_tool"
65331d728c39SBlue Swirlecho "gcov enabled      $gcov"
6534ab214c29SStefan Bergerecho "TPM support       $tpm"
6535b10d49d7SPino Toscanoecho "libssh support    $libssh"
65363556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
6537ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
6538607dacd0Sqiaonuohanecho "lzo support       $lzo"
6539607dacd0Sqiaonuohanecho "snappy support    $snappy"
65406b383c08SPeter Wuecho "bzip2 support     $bzip2"
654183bc1f97SJulio Faraccoecho "lzfse support     $lzfse"
6542a99d57bbSWanlong Gaoecho "NUMA host support $numa"
6543ed279a06SKlim Kireevecho "libxml2           $libxml2"
65442847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
65457b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
654699f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
6547a6b1d4c0SChanglong Xieecho "replication support $replication"
6548da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
65492f740136SJeff Codyecho "bochs support     $bochs"
65502f740136SJeff Codyecho "cloop support     $cloop"
65512f740136SJeff Codyecho "dmg support       $dmg"
65522f740136SJeff Codyecho "qcow v1 support   $qcow1"
65532f740136SJeff Codyecho "vdi support       $vdi"
65542f740136SJeff Codyecho "vvfat support     $vvfat"
65552f740136SJeff Codyecho "qed support       $qed"
65562f740136SJeff Codyecho "parallels support $parallels"
65572f740136SJeff Codyecho "sheepdog support  $sheepdog"
65588ca80760SRichard Hendersonecho "capstone          $capstone"
655917824406SJunyan Heecho "libpmem support   $libpmem"
65603efac6ebSTomáš Golembiovskýecho "libudev           $libudev"
6561f3494749SPaolo Bonziniecho "default devices   $default_devices"
656240e8c6f4SAlex Bennéeecho "plugin support    $plugins"
656367b915a5Sbellard
6564898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
6565898be3e0SPeter Maydell    echo
6566898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6567898be3e0SPeter Maydell    echo
6568898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
6569898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
6570898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6571898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6572898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6573898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6574898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6575898be3e0SPeter Maydellfi
6576898be3e0SPeter Maydell
6577898be3e0SPeter Maydellif test "$supported_os" = "no"; then
6578898be3e0SPeter Maydell    echo
6579898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6580898be3e0SPeter Maydell    echo
6581c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
6582c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
6583898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6584898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6585898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6586898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6587898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6588898be3e0SPeter Maydellfi
6589898be3e0SPeter Maydell
6590e5abf59eSEduardo Habkost# Note that if the Python conditional here evaluates True we will exit
6591e5abf59eSEduardo Habkost# with status 1 which is a shell 'false' value.
6592e5abf59eSEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
6593e5abf59eSEduardo Habkost  echo
6594e5abf59eSEduardo Habkost  echo "warning: Python 2 support is deprecated" >&2
6595e5abf59eSEduardo Habkost  echo "warning: Python 3 will be required for building future versions of QEMU" >&2
6596406ab2f3SCleber Rosa  python2="y"
6597e5abf59eSEduardo Habkostfi
6598e5abf59eSEduardo Habkost
659998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
660097a847bcSbellard
6601dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6602dbd99ae3SStefan Weil
660398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
660498ec69acSJuan Quintelaecho >> $config_host_mak
660598ec69acSJuan Quintela
6606e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
660799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
660899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
66093aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
66108bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
66110f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
661299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
661399d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
661422d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
66159afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
66163d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
66179afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6618e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
66195a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6620785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
66215a699bbbSLaszlo Ersekfi
6622f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6623834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6624a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
662567ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
662602f9135bSDaniel P. Berrangéecho "libs_cpu=$libs_cpu" >> $config_host_mak
6627f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6628cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6629aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6630f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6631804edf29SJuan Quintela
663298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6633727e5283SPaolo Bonzini
6634f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6635f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6636f3494749SPaolo Bonzinielse
6637f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6638f3494749SPaolo Bonzinifi
6639f8393946Saurel32if test "$debug_tcg" = "yes" ; then
66402358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6641f8393946Saurel32fi
66421625af87Saliguoriif test "$strip_opt" = "yes" ; then
664352ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
66441625af87Saliguorifi
66457d13299dSbellardif test "$bigendian" = "yes" ; then
6646e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
664797a847bcSbellardfi
664867b915a5Sbellardif test "$mingw32" = "yes" ; then
664998ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
665089138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
66519fe6de94SBlue Swirl  version_major=${rc_version%%.*}
66529fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66539fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
66549fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66559fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
66569fe6de94SBlue Swirl  version_micro=0
66579fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
66589fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6659d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6660d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6661f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6662d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6663d9840e25STomoki Sekiyama  fi
666450cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
666576dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
666650cbebb9SMichael Roth  fi
66671a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
66689dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
66699dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
66709dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
66719dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
66729dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
66739dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
66749dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
66759dacf32dSYossi Hindin  fi
6676210fa556Spbrookelse
667735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6678210fa556Spbrookfi
6679128ab2ffSblueswir1
6680dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6681dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6682dffcb71cSMark McLoughlinfi
6683dffcb71cSMark McLoughlin
668483fb7adfSbellardif test "$darwin" = "yes" ; then
668598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
668683fb7adfSbellardfi
6687b29fe3edSmalc
6688ec530c81Sbellardif test "$solaris" = "yes" ; then
668998ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6690ec530c81Sbellardfi
6691179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6692179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6693179cf400SAndreas Färberfi
669497a847bcSbellardif test "$static" = "yes" ; then
669598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
669697a847bcSbellardfi
66971ba16968SStefan Weilif test "$profiler" = "yes" ; then
66982358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
669905c2a3e7Sbellardfi
6700c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
6701c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
6702c932ce31SPaolo Bonzinifi
6703675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
670498ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6705e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6706675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6707675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6708675b9b53SMarc-André Lureaufi
67097c57bdd8SMarc-André Lureauif [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
67103b8593eeSMarkus Armbruster    echo "config-host.h: slirp/all" >> $config_host_mak
6711c20709aaSbellardfi
67128a16d273Sthsif test "$vde" = "yes" ; then
671398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6714e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
67158a16d273Sthsfi
671658952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
671758952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
671858952137SVincenzo Maffionefi
6719015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6720015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6721015a33bdSGongleifi
672247e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
672347e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
672447e98658SCorey Bryantfi
67252358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
67260c58ac1cSmalcfor drv in $audio_drv_list; do
67271ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6728ce3dc033SGerd Hoffmann    case "$drv" in
6729051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6730ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6731ce3dc033SGerd Hoffmann	*)
6732ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6733ce3dc033SGerd Hoffmann    esac
67340c58ac1cSmalcdone
6735b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6736b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6737b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6738b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6739b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
6740d5631638Smalcif test "$audio_win_int" = "yes" ; then
6741d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6742d5631638Smalcfi
6743b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6744b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6745821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6746821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6747821601eaSJes Sorensenfi
67482f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
674998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
67502f9606b3Saliguorifi
6751821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
67522f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
67532f6f5c7aSCorentin Charyfi
6754821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6755efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6756efe556adSCorentin Charyfi
67576a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
67586a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
67596a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
67606a021536SGerd Hoffmannfi
6761dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6762dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6763dce512deSChristoph Hellwigfi
676489138857SStefan Weilqemu_version=$(head $source_path/VERSION)
676598ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
67662358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
676798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
67682b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6769a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
677098ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6771cc8ae6deSpbrookfi
677217969268SFam Zhengif test "$modules" = "yes"; then
6773e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6774e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
677589138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
677617969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
677717969268SFam Zhengfi
6778e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
67798781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
67808781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
67818781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
67828781595bSGerd Hoffmannfi
67831ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
678496400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
67858ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
67868ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6787a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes" ; then
6788a442fe2fSDaniel P. Berrangé      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
6789a442fe2fSDaniel P. Berrangé  fi
679049ecc3faSbellardfi
679149ecc3faSbellardif test "$cocoa" = "yes" ; then
679298ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
679349ecc3faSbellardfi
6794e08bb301SSamuel Thibaultif test "$iconv" = "yes" ; then
6795e08bb301SSamuel Thibault  echo "CONFIG_ICONV=y" >> $config_host_mak
6796e08bb301SSamuel Thibault  echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
6797e08bb301SSamuel Thibault  echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
6798e08bb301SSamuel Thibaultfi
67994d3b6f6eSbalrogif test "$curses" = "yes" ; then
68002373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
68012373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
68022373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6803ab4e5602SJan Kiszkafi
6804099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
68052358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6806099d6b0fSRiku Voipiofi
680740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
680840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
680940ff6d7eSKevin Wolffi
68103ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
68112358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
68123ce34dfbSvibisreenivasanfi
6813c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6814c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6815c2882b96SRiku Voipiofi
6816751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6817751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6818751bcc39SMarc-André Lureaufi
6819955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6820955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6821955727d2SCortland Tölvafi
6822d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6823d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6824d0927938SUlrich Hechtfi
68253d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
68263d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
68273d4fa43eSKusanagi Kouichifi
6828b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6829b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6830b953f075SDenis V. Lunevfi
6831ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6832ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6833ed911435SKevin Wolffi
6834c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6835c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6836c727f47dSPeter Maydellfi
6837dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6838dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6839dace20dcSPeter Maydellfi
6840d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6841d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6842d0927938SUlrich Hechtfi
68434e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
68444e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
68454e0c6529SAlex Blighfi
6846cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6847cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6848cd758dd0SAlex Blighfi
68493b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
68503b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
68513b6edd16SPeter Maydellfi
68523b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
68533b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
68543b6edd16SPeter Maydellfi
6855a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6856a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6857a8fd1abaSPeter Maydellfi
685851834341SRiku Voipioif test "$timerfd" = "yes" ; then
685951834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
686051834341SRiku Voipiofi
68619af5c906SRiku Voipioif test "$setns" = "yes" ; then
68629af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
68639af5c906SRiku Voipiofi
686438860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
686538860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
686638860a03SAleksandar Markovicfi
68675a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
68685a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
68695a03cd00SAleksandar Markovicfi
68703b3f24adSaurel32if test "$inotify" = "yes" ; then
68712358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
68723b3f24adSaurel32fi
6873c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6874c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6875c05c7a73SRiku Voipiofi
6876401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6877401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6878401bc051SPeter Maydellfi
68795c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
68805c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
68815c99fa37SKeno Fischerfi
68826ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
68836ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
68846ae9a1f4SJuan Quintelafi
68856ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
68866ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
68876ae9a1f4SJuan Quintelafi
6888769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6889d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6890b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
68916ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6892769ce76dSAlexander Graffi
68932e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
689498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
68958eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
68962e4d9fb1Saurel32fi
6897a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6898e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6899a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6900014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6901925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6902925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6903925a0400SGerd Hoffmann  fi
6904bbbf9bfbSStefan Weilfi
6905f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6906f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6907f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6908f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
6909f876b765SMarc-André Lureaufi
6910a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6911ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6912ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6913ddbb0d09SDaniel P. Berrangefi
691491bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
691591bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
69161f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
69171f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
69181f923c70SLongpeng(Mike)  fi
691962893b67SDaniel P. Berrangefi
692091bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
692191bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6922becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6923ed754746SDaniel P. Berrangefi
6924e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
6925e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
6926e0576942SDaniel P. Berrangéfi
69279a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
69289a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
69299a2fd434SDaniel P. Berrangefi
69308953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
69318953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
69328953caf3SDaniel P. Berrangefi
6933559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6934559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6935559607eaSDaniel P. Berrangefi
69366b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
69376b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
69386b39b063SEric Blakefi
6939277abf15SJan Vesely
6940277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6941277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6942277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6943277abf15SJan Vesely# if this macro is set.
6944277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6945277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6946277abf15SJan Veselyfi
69471efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
69481efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
69491efad060SFam Zhengfi
6950bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6951bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6952a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6953e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6954a4ccabcfSAnthony Liguorifi
69559d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
69569d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
69579d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
69589d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
69599d9e1521SGerd Hoffmannfi
6960e37630caSaliguoriif test "$xen" = "yes" ; then
69616dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6962d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6963e37630caSaliguorifi
69645c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
69655c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
69665c6c3a6cSChristoph Hellwigfi
6967758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6968758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6969758e8e38SVenkateswararao Jujjuri (JV)fi
69704f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
69714f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
69724f26f2b6SAvi Kivityfi
6973983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6974758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6975758e8e38SVenkateswararao Jujjuri (JV)fi
6976fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6977fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
69781b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
69791b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
69801b0578f5SMurilo Opsfelder Araujo  fi
6981fe8fc5aeSPaolo Bonzinifi
69825e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
69835e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
69845e9be92dSNicholas Bellingerfi
6985af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
6986af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
6987af3bba76SPaolo Bonzinifi
6988af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
698956f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
699003ce5744SNikolay Nikolaevfi
6991042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6992042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6993042cea27SGongleifi
6994fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6995fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6996fc0b9b0eSStefan Hajnoczifi
6997299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
6998299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
6999299e6f19SPaolo Bonzinifi
7000e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
7001e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7002e6a74868SMarc-André Lureaufi
700398fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
700498fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
700598fc1adaSDr. David Alan Gilbertfi
700677755340Sthsif test "$blobs" = "yes" ; then
700798ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
700877755340Sthsfi
7009bf9298b9Saliguoriif test "$iovec" = "yes" ; then
70102358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
7011bf9298b9Saliguorifi
7012ceb42de8Saliguoriif test "$preadv" = "yes" ; then
70132358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
7014ceb42de8Saliguorifi
7015e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
70163f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
7017f652e6afSaurel32fi
7018a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
7019a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7020a40161cbSPaolo Bonzinifi
7021dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
7022dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7023dcc38d1cSMarcelo Tosattifi
7024d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
7025d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
7026d339d766SRichard W.M. Jonesfi
7027b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
7028b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
70299195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
70309195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
70319195b2c2SStefan Weil  fi
7032b3f6ea7eSPaolo Bonzinifi
70335f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
70345f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
70355f6b9e8fSBlue Swirlfi
7036e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
7037e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
7038e78815a5SAndreas Färberfi
7039e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
7040e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7041e78815a5SAndreas Färberfi
70429bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
70439bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
70449bc5a719SAndreas Gustafssonfi
704597a847bcSbellard
7046cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
7047cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
7048cd4ec0b4SGerd Hoffmannfi
7049cd4ec0b4SGerd Hoffmann
70507b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
70517b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
70527b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
70537b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7054111a38b0SRobert Relyeafi
7055111a38b0SRobert Relyea
70562b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
70572b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7058b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7059b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
70602b2325ffSGerd Hoffmannfi
70612b2325ffSGerd Hoffmann
706269354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
706369354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7064cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7065cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
706669354a83SHans de Goedefi
706769354a83SHans de Goede
7068da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
7069da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
7070da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7071014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
7072014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7073014cb152SGerd Hoffmann  fi
707420ff075bSMichael Wallefi
707520ff075bSMichael Walle
7076d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
7077d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
7078d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7079d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7080d52c454aSMarc-André Lureaufi
7081d52c454aSMarc-André Lureau
7082d52c454aSMarc-André Lureau
70835a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
70845a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
70855a22ab71SYang Zhongfi
70865a22ab71SYang Zhong
708799f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
708899f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
708999f2dbd3SLiang Lifi
709099f2dbd3SLiang Li
7091607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
7092607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
7093607dacd0Sqiaonuohanfi
7094607dacd0Sqiaonuohan
7095607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
7096607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
7097607dacd0Sqiaonuohanfi
7098607dacd0Sqiaonuohan
70996b383c08SPeter Wuif test "$bzip2" = "yes" ; then
71006b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
71016b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
71026b383c08SPeter Wufi
71036b383c08SPeter Wu
710483bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
710583bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
710683bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
710783bc1f97SJulio Faraccofi
710883bc1f97SJulio Faracco
7109c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
7110d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
71116ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
71126ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7113c589b249SRonnie Sahlbergfi
7114c589b249SRonnie Sahlberg
71156542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
71164be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
71174be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
71186542aa9cSPeter Lievenfi
71196542aa9cSPeter Lieven
7120f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
7121f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
7122c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7123c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7124f794573eSEduardo Otubofi
7125f794573eSEduardo Otubo
712683fb7adfSbellard# XXX: suppress that
71277d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
71282358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
71297d3505c5Sbellardfi
71307d3505c5Sbellard
71314d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
71324d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
71334d9310f4SDaniel P. Berrangefi
71343556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
71353556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
71363556c233SPaolo Bonzinifi
7137f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
7138d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
71396ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
71406ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7141f27aaf4bSChristian Brunnerfi
714220ff6c80SAnthony Liguori
71437c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
714470c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
714570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
714670c60c08SStefan Hajnoczielse
714770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
714870c60c08SStefan Hajnoczifi
7149d0e2fce5SAneesh Kumar K.V
71507d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
71517d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
71527d992e4dSPeter Lievenfi
71537d992e4dSPeter Lieven
7154f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
7155f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
7156f0d92b56SLongpeng(Mike)fi
7157f0d92b56SLongpeng(Mike)
7158d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
7159d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7160d2042378SAneesh Kumar K.Vfi
7161d2042378SAneesh Kumar K.V
7162e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
7163e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7164e06a765eSHarsh Prateek Borafi
7165e06a765eSHarsh Prateek Bora
7166cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
7167cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
716806d71fa1SPeter Maydellfi
716906d71fa1SPeter Maydell
71703f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
71713f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
71723f4349dcSKevin Wolffi
71733f4349dcSKevin Wolf
7174d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
7175d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7176d83414e1SMarc-André Lureaufi
7177d83414e1SMarc-André Lureau
71788ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
71798ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
71808ab1bf12SLuiz Capitulinofi
71818ab1bf12SLuiz Capitulino
718276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
718376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
718476a347e1SRichard Hendersonfi
718576a347e1SRichard Henderson
7186f540166bSRichard Hendersonif test "$int128" = "yes" ; then
7187f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
7188f540166bSRichard Hendersonfi
7189f540166bSRichard Henderson
71907ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
71917ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
71927ebee43eSRichard Hendersonfi
71937ebee43eSRichard Henderson
7194e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
7195e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7196e6cd4bb5SRichard Hendersonfi
7197e6cd4bb5SRichard Henderson
7198df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
7199df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7200df79b996SRichard Hendersonfi
7201df79b996SRichard Henderson
7202db432672SRichard Hendersonif test "$vector16" = "yes" ; then
7203db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
7204db432672SRichard Hendersonfi
7205db432672SRichard Henderson
7206db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
7207db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7208db8aaae8SRichard Hendersonfi
7209db8aaae8SRichard Henderson
72101e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
72111e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
72121e6e9acaSRichard Hendersonfi
72131e6e9acaSRichard Henderson
7214eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
7215d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
72166ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
72176ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7218eb100396SBharata B Raofi
7219eb100396SBharata B Rao
7220d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
7221d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7222d85fa9ebSJeff Codyfi
7223d85fa9ebSJeff Cody
72240c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
72250c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
72260c14fb47SBharata B Raofi
72270c14fb47SBharata B Rao
7228df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
7229df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7230df3a429aSNiels de Vosfi
7231df3a429aSNiels de Vos
72327c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
72337c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
72347c815372SBharata B Raofi
72357c815372SBharata B Rao
7236e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7237e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7238e014dbe7SPrasanna Kumar Kaleverfi
7239e014dbe7SPrasanna Kumar Kalever
72400e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
72410e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
72420e3b891fSNiels de Vosfi
72430e3b891fSNiels de Vos
7244b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
7245b10d49d7SPino Toscano  echo "CONFIG_LIBSSH=m" >> $config_host_mak
7246b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7247b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
72480a12ec87SRichard W.M. Jonesfi
72490a12ec87SRichard W.M. Jones
7250ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
7251ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7252ed1701c6SDr. David Alan Gilbertfi
7253ed1701c6SDr. David Alan Gilbert
72543b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
72553cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
72563b8acc11SPaolo Bonzinifi
72573b8acc11SPaolo Bonzini
72585b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
72595b808275SLluís Vilanovaif have_backend "nop"; then
72606d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
726122890ab5SPrerna Saxenafi
72625b808275SLluís Vilanovaif have_backend "simple"; then
72636d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
72646d8a764eSLluís  # Set the appropriate trace file.
7265953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
72669410b56cSPrerna Saxenafi
7267ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7268ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
72696d8a764eSLluísfi
72705b808275SLluís Vilanovaif have_backend "ust"; then
72716d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
72726d8a764eSLluísfi
72735b808275SLluís Vilanovaif have_backend "dtrace"; then
72746d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
72756d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
72766d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
72776d8a764eSLluís  fi
7278c276b17dSDaniel P. Berrangefi
72795b808275SLluís Vilanovaif have_backend "ftrace"; then
7280781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7281781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7282781e9545SEiichi Tsukata  else
728321684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7284781e9545SEiichi Tsukata  fi
7285781e9545SEiichi Tsukatafi
72860a852417SPaul Durrantif have_backend "syslog"; then
72870a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
72880a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
72890a852417SPaul Durrant  else
72900a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
72910a852417SPaul Durrant  fi
72920a852417SPaul Durrantfi
72939410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
72949410b56cSPrerna Saxena
72952da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
72962da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7297392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
72982da776dbSMichael R. Hinesfi
72992da776dbSMichael R. Hines
730021ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
730121ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
730221ab34c9SMarcel Apfelbaumfi
730321ab34c9SMarcel Apfelbaum
7304575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7305575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7306575b22b1SLaurent Vivierfi
7307575b22b1SLaurent Vivier
7308ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7309ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7310ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7311ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7312ed279a06SKlim Kireevfi
7313ed279a06SKlim Kireev
7314a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7315a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7316a6b1d4c0SChanglong Xiefi
7317a6b1d4c0SChanglong Xie
73186a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
73196a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
73206a02c806SStefan Hajnoczifi
73216a02c806SStefan Hajnoczi
73224d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
73234d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
73244d04351fSChristopher Covingtonfi
73254d04351fSChristopher Covington
732649e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
732749e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
732849e00a18SAndreas Grapentinfi
732949e00a18SAndreas Grapentin
7330e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7331e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7332e674605fSTomáš Golembiovskýfi
7333db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
7334db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7335db1ed1abSRichard Hendersonfi
7336e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7337e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7338e0580342SKamil Rytarowskifi
7339e219c499SRichard Hendersonif test "$capstone" != "no" ; then
73408ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
73418ca80760SRichard Hendersonfi
7342ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7343ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7344ba59fb77SPaolo Bonzinifi
7345e0580342SKamil Rytarowski
73465c312079SDr. David Alan Gilbert# Hold two types of flag:
73475c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
73485c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7349479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
73505c312079SDr. David Alan Gilbert#                                     platform
7351479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
73525c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7353479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7354479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7355479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7356479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
73575c312079SDr. David Alan Gilbertfi
73585c312079SDr. David Alan Gilbert
7359da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
7360da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
7361da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
7362da92c3ffSAshish Mittalfi
7363da92c3ffSAshish Mittal
736417824406SJunyan Heif test "$libpmem" = "yes" ; then
736517824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
736617824406SJunyan Hefi
736717824406SJunyan He
73682f740136SJeff Codyif test "$bochs" = "yes" ; then
73692f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
73702f740136SJeff Codyfi
73712f740136SJeff Codyif test "$cloop" = "yes" ; then
73722f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
73732f740136SJeff Codyfi
73742f740136SJeff Codyif test "$dmg" = "yes" ; then
73752f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
73762f740136SJeff Codyfi
73772f740136SJeff Codyif test "$qcow1" = "yes" ; then
73782f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
73792f740136SJeff Codyfi
73802f740136SJeff Codyif test "$vdi" = "yes" ; then
73812f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
73822f740136SJeff Codyfi
73832f740136SJeff Codyif test "$vvfat" = "yes" ; then
73842f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
73852f740136SJeff Codyfi
73862f740136SJeff Codyif test "$qed" = "yes" ; then
73872f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
73882f740136SJeff Codyfi
73892f740136SJeff Codyif test "$parallels" = "yes" ; then
73902f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
73912f740136SJeff Codyfi
73922f740136SJeff Codyif test "$sheepdog" = "yes" ; then
73932f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
73942f740136SJeff Codyfi
73952f740136SJeff Cody
739640e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
739740e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
739840e8c6f4SAlex Bennée    LIBS="-ldl $LIBS"
739926fffe29SEmilio G. Cota    # Copy the export object list to the build dir
740026fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
740126fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
740226fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
740326fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
740426fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
740526fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
740626fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
740726fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
740826fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
740926fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
741026fffe29SEmilio G. Cota    else
741126fffe29SEmilio G. Cota	error_exit \
741226fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
741326fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
741426fffe29SEmilio G. Cota    fi
741540e8c6f4SAlex Bennéefi
741640e8c6f4SAlex Bennée
74175b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
74189edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
74195b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
74209edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
74215b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
74229edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7423e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
74249edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
742540d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
74269edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7427e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
7428c4f80543SAlistair Francis  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
74295b5e3037SPaolo Bonzinielse
74309edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
74315b5e3037SPaolo Bonzinifi
74329edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
74335b5e3037SPaolo Bonzini
743498ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
743598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7436804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7437804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
74381901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
74391901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
74401901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
744121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7442c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
7443406ab2f3SCleber Rosaecho "PYTHON2=$python2" >> $config_host_mak
7444804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7445a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7446a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
7447a31a8642SMichael S. Tsirkinfi
7448804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
744983f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
74503c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7451804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
745245d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7453cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
74545f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
74553dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7456804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7457804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
74589f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
74594852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
7460daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
74619fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7462e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
746346eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7464a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
746511cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7466f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7467e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7468e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
746980fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
74702944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
7471e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
7472e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7473e39f0062SPaolo Bonzinifi
7474e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
747546eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
74768a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
74776969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7478e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
747973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
74803e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7481409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7482804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
748317969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
748417969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7485957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
748690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
748790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
748894dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
74891d728c39SBlue Swirlif test "$gcov" = "yes" ; then
74901d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
74911d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
74921d728c39SBlue Swirlfi
7493804edf29SJuan Quintela
74943efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
74953efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
74963efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
74973efac6ebSTomáš Golembiovskýfi
74983efac6ebSTomáš Golembiovský
749905dfa22bSPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" ; then
750005dfa22bSPhilippe Mathieu-Daudé  echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
750105dfa22bSPhilippe Mathieu-Daudéfi
750205dfa22bSPhilippe Mathieu-Daudé
75036efd7517SPeter Maydell# use included Linux headers
75046efd7517SPeter Maydellif test "$linux" = "yes" ; then
7505a307beb6SAndreas Färber  mkdir -p linux-headers
75066efd7517SPeter Maydell  case "$cpu" in
7507c72b26ecSRichard Henderson  i386|x86_64|x32)
750808312a63SPeter Maydell    linux_arch=x86
75096efd7517SPeter Maydell    ;;
7510f8378accSRichard Henderson  ppc|ppc64|ppc64le)
751108312a63SPeter Maydell    linux_arch=powerpc
75126efd7517SPeter Maydell    ;;
75136efd7517SPeter Maydell  s390x)
751408312a63SPeter Maydell    linux_arch=s390
751508312a63SPeter Maydell    ;;
75161f080313SClaudio Fontana  aarch64)
75171f080313SClaudio Fontana    linux_arch=arm64
75181f080313SClaudio Fontana    ;;
7519222e7d11SSanjay Lal  mips64)
7520222e7d11SSanjay Lal    linux_arch=mips
7521222e7d11SSanjay Lal    ;;
752208312a63SPeter Maydell  *)
752308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
752408312a63SPeter Maydell    linux_arch="$cpu"
75256efd7517SPeter Maydell    ;;
75266efd7517SPeter Maydell  esac
752708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
752808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
752908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
753008312a63SPeter Maydell    fi
75316efd7517SPeter Maydellfi
75326efd7517SPeter Maydell
753397a847bcSbellardfor target in $target_list; do
753497a847bcSbellardtarget_dir="$target"
753525be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
753689138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
753752bf9771Stony.nguyen@bt.comtarget_aligned_only="no"
753852bf9771Stony.nguyen@bt.comcase "$target_name" in
753952bf9771Stony.nguyen@bt.com  alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
754052bf9771Stony.nguyen@bt.com  target_aligned_only="yes"
754152bf9771Stony.nguyen@bt.com  ;;
754252bf9771Stony.nguyen@bt.comesac
754397a847bcSbellardtarget_bigendian="no"
7544c1799a84SPaolo Bonzinicase "$target_name" in
7545a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
754652bf9771Stony.nguyen@bt.com  target_bigendian="yes"
7547ea2d6a39SJuan Quintela  ;;
7548ea2d6a39SJuan Quintelaesac
754997a847bcSbellardtarget_softmmu="no"
7550997344f3Sbellardtarget_user_only="no"
7551831b7825Sthstarget_linux_user="no"
755284778508Sblueswir1target_bsd_user="no"
75539e407a85Spbrookcase "$target" in
7554c1799a84SPaolo Bonzini  ${target_name}-softmmu)
75559e407a85Spbrook    target_softmmu="yes"
75569e407a85Spbrook    ;;
7557c1799a84SPaolo Bonzini  ${target_name}-linux-user)
75589e407a85Spbrook    target_user_only="yes"
75599e407a85Spbrook    target_linux_user="yes"
75609e407a85Spbrook    ;;
7561c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
756284778508Sblueswir1    target_user_only="yes"
756384778508Sblueswir1    target_bsd_user="yes"
756484778508Sblueswir1    ;;
75659e407a85Spbrook  *)
756676ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
75679e407a85Spbrook    exit 1
75689e407a85Spbrook    ;;
75699e407a85Spbrookesac
7570831b7825Sths
757197a847bcSbellardmkdir -p $target_dir
757225be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
757397a847bcSbellard
7574e5fe0c52Spbrookbflt="no"
7575ca759f9eSAlex Bennéemttcg="no"
757689138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
757756aebc89Spbrookgdb_xml_files=""
75787ba1e619Saliguori
7579c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
75806acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7581e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
7582e73aae67SJuan Quintela
7583c1799a84SPaolo Bonzinicase "$target_name" in
75842408a527Saurel32  i386)
75850a7fa00aSEmilio G. Cota    mttcg="yes"
75867b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
75872408a527Saurel32  ;;
75882408a527Saurel32  x86_64)
75896acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
75900a7fa00aSEmilio G. Cota    mttcg="yes"
75917b0f97baSDoug Gale	gdb_xml_files="i386-64bit.xml"
75922408a527Saurel32  ;;
75932408a527Saurel32  alpha)
75945ee4f3c2SRichard Henderson    mttcg="yes"
75952408a527Saurel32  ;;
75962408a527Saurel32  arm|armeb)
7597b498c8a0SJuan Quintela    TARGET_ARCH=arm
7598e5fe0c52Spbrook    bflt="yes"
7599ca759f9eSAlex Bennée    mttcg="yes"
760056aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
76012408a527Saurel32  ;;
7602722dd7beSMichael Weiser  aarch64|aarch64_be)
7603722dd7beSMichael Weiser    TARGET_ARCH=aarch64
76046a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
76056a49fa95SAlexander Graf    bflt="yes"
7606ca759f9eSAlex Bennée    mttcg="yes"
76078f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
76086a49fa95SAlexander Graf  ;;
76092408a527Saurel32  cris)
76102408a527Saurel32  ;;
761161766fe9SRichard Henderson  hppa)
76127b93dab5SRichard Henderson    mttcg="yes"
761361766fe9SRichard Henderson  ;;
7614613a22c9SMichael Walle  lm32)
7615613a22c9SMichael Walle  ;;
76162408a527Saurel32  m68k)
76170938cda5Saurel32    bflt="yes"
76185a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
76192408a527Saurel32  ;;
7620877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7621877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
762272b675caSEdgar E. Iglesias    bflt="yes"
7623be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
762472b675caSEdgar E. Iglesias  ;;
76252408a527Saurel32  mips|mipsel)
76260454728cSAleksandar Markovic    mttcg="yes"
7627b498c8a0SJuan Quintela    TARGET_ARCH=mips
762825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
76292408a527Saurel32  ;;
76302408a527Saurel32  mipsn32|mipsn32el)
76310454728cSAleksandar Markovic    mttcg="yes"
7632597e2cecSRichard Henderson    TARGET_ARCH=mips64
76336acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
763425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7635597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
76362408a527Saurel32  ;;
76372408a527Saurel32  mips64|mips64el)
76380454728cSAleksandar Markovic    mttcg="yes"
7639b498c8a0SJuan Quintela    TARGET_ARCH=mips64
76406acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
764125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
76422408a527Saurel32  ;;
7643d15a9c23SAnthony Green  moxie)
7644d15a9c23SAnthony Green  ;;
7645e671711cSMarek Vasut  nios2)
7646e671711cSMarek Vasut  ;;
76474a09d0bbSRichard Henderson  or1k)
7648e67db06eSJia Liu    TARGET_ARCH=openrisc
7649e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7650e67db06eSJia Liu  ;;
76512408a527Saurel32  ppc)
7652c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
76532408a527Saurel32  ;;
76542408a527Saurel32  ppc64)
76556acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7656e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7657f0b0685dSNikunj A Dadhania    mttcg=yes
76581438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
76592408a527Saurel32  ;;
76609c35126cSDoug Kwan  ppc64le)
76619c35126cSDoug Kwan    TARGET_ARCH=ppc64
76629c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
76639c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
7664f0b0685dSNikunj A Dadhania    mttcg=yes
76651438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
76669c35126cSDoug Kwan  ;;
76672408a527Saurel32  ppc64abi32)
7668b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
76696acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7670e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
767125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
76721438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
76732408a527Saurel32  ;;
767425fa194bSMichael Clark  riscv32)
767525fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
767625fa194bSMichael Clark    TARGET_ABI_DIR=riscv
767725fa194bSMichael Clark    mttcg=yes
7678ab9056ffSJonathan Behrens    gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
767925fa194bSMichael Clark  ;;
768025fa194bSMichael Clark  riscv64)
768125fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
768225fa194bSMichael Clark    TARGET_ABI_DIR=riscv
768325fa194bSMichael Clark    mttcg=yes
7684ab9056ffSJonathan Behrens    gdb_xml_files="riscv-64bit-cpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
768525fa194bSMichael Clark  ;;
76862408a527Saurel32  sh4|sh4eb)
7687b498c8a0SJuan Quintela    TARGET_ARCH=sh4
76884dbed897Spbrook    bflt="yes"
76892408a527Saurel32  ;;
76902408a527Saurel32  sparc)
76912408a527Saurel32  ;;
76922408a527Saurel32  sparc64)
76936acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
76942408a527Saurel32  ;;
76952408a527Saurel32  sparc32plus)
7696b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
76976acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7698e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
769925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
77002408a527Saurel32  ;;
770124e804ecSAlexander Graf  s390x)
770263685bc4SDavid Hildenbrand    mttcg=yes
770386158a2aSChristian 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"
770424e804ecSAlexander Graf  ;;
7705444e06b1SChen Gang  tilegx)
7706444e06b1SChen Gang  ;;
77075ecaa4edSPeter Crosthwaite  tricore)
77085ecaa4edSPeter Crosthwaite  ;;
7709d2fbca94SGuan Xuetao  unicore32)
7710d2fbca94SGuan Xuetao  ;;
7711cfa550c6SMax Filippov  xtensa|xtensaeb)
7712cfa550c6SMax Filippov    TARGET_ARCH=xtensa
771302e33e9fSMax Filippov    bflt="yes"
77149fb40342SMax Filippov    mttcg="yes"
7715cfa550c6SMax Filippov  ;;
77162408a527Saurel32  *)
771776ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
77182408a527Saurel32  ;;
77192408a527Saurel32esac
77205e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
77215e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
77225e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
77235e8861a0SPaolo Bonzinifi
77245e8861a0SPaolo Bonzini
77255e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
77265e8861a0SPaolo Bonzini
772799afc91dSDaniel P. Berrangeupper() {
772899afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
772999afc91dSDaniel P. Berrange}
773099afc91dSDaniel P. Berrange
773189138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
773225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7733c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
773425be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7735e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7736e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7737e6e91b9cSJuan Quintelafi
773825be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7739adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7740adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7741adfc3e91SStacey Sonfi
77423b6b7550SPaolo Bonzini
77433b6b7550SPaolo Bonziniif supported_xen_target $target; then
774425be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7745e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
7746eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7747eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7748eb6fda0fSAnthony PERARD    fi
7749e0e312f3SPaolo Bonzinielse
7750e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
7751432d268cSJun Nakajimafi
77523b6b7550SPaolo Bonziniif supported_kvm_target $target; then
775325be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
7754e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
7755e0e312f3SPaolo Bonzinielse
7756e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
7757c59249f9SJuan Quintelafi
77583b6b7550SPaolo Bonziniif supported_hax_target $target; then
7759b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7760b0cb0a66SVincent Palatinfi
7761c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7762c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7763c97d6d2cSSergio Andres Gomez Del Realfi
7764d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7765d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7766d661d9a4SJustin Terry (VM)fi
776752bf9771Stony.nguyen@bt.comif test "$target_aligned_only" = "yes" ; then
776852bf9771Stony.nguyen@bt.com  echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
776952bf9771Stony.nguyen@bt.comfi
7770de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
777125be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
777297a847bcSbellardfi
777397a847bcSbellardif test "$target_softmmu" = "yes" ; then
777425be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7775ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7776ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7777ca759f9eSAlex Bennée  fi
7778de83cd02Sbellardfi
7779997344f3Sbellardif test "$target_user_only" = "yes" ; then
778025be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7781a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7782997344f3Sbellardfi
7783831b7825Sthsif test "$target_linux_user" = "yes" ; then
778425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7785831b7825Sthsfi
778656aebc89Spbrooklist=""
778756aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
778856aebc89Spbrook  for x in $gdb_xml_files; do
778956aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
779056aebc89Spbrook  done
779125be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
77923d0f1517SJuan Quintelafi
7793de83cd02Sbellard
7794e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
779525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7796e5fe0c52Spbrookfi
779784778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
779825be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
779984778508Sblueswir1fi
78005b0753e0Sbellard
7801d75402b5SAlex Bennée
78024afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7803fa282484SJuan Quintela
78044afddb55SJuan Quintelacflags=""
7805fa282484SJuan Quintelaldflags=""
78069b8e111fSJuan Quintela
7807c765fcacSPeter Crosthwaitedisas_config() {
7808c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7809c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7810c765fcacSPeter Crosthwaite}
7811c765fcacSPeter Crosthwaite
781264656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
781364656024SJuan Quintela  case "$i" in
781464656024SJuan Quintela  alpha)
7815c765fcacSPeter Crosthwaite    disas_config "ALPHA"
781664656024SJuan Quintela  ;;
781782295d8aSRichard Henderson  aarch64)
781882295d8aSRichard Henderson    if test -n "${cxx}"; then
7819c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
782082295d8aSRichard Henderson    fi
782182295d8aSRichard Henderson  ;;
782264656024SJuan Quintela  arm)
7823c765fcacSPeter Crosthwaite    disas_config "ARM"
7824999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7825c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7826999b53ecSClaudio Fontana    fi
782764656024SJuan Quintela  ;;
782864656024SJuan Quintela  cris)
7829c765fcacSPeter Crosthwaite    disas_config "CRIS"
783064656024SJuan Quintela  ;;
7831429b31a2SRichard Henderson  hppa)
7832429b31a2SRichard Henderson    disas_config "HPPA"
7833429b31a2SRichard Henderson  ;;
7834c72b26ecSRichard Henderson  i386|x86_64|x32)
7835c765fcacSPeter Crosthwaite    disas_config "I386"
783664656024SJuan Quintela  ;;
783779368f49SMichael Walle  lm32)
7838c765fcacSPeter Crosthwaite    disas_config "LM32"
783979368f49SMichael Walle  ;;
784064656024SJuan Quintela  m68k)
7841c765fcacSPeter Crosthwaite    disas_config "M68K"
784264656024SJuan Quintela  ;;
7843877fdc12SEdgar E. Iglesias  microblaze*)
7844c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
784564656024SJuan Quintela  ;;
784664656024SJuan Quintela  mips*)
7847c765fcacSPeter Crosthwaite    disas_config "MIPS"
784889a955e8SAleksandar Markovic    if test -n "${cxx}"; then
784989a955e8SAleksandar Markovic      disas_config "NANOMIPS"
785089a955e8SAleksandar Markovic    fi
785164656024SJuan Quintela  ;;
7852d15a9c23SAnthony Green  moxie*)
7853c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7854d15a9c23SAnthony Green  ;;
7855e671711cSMarek Vasut  nios2)
7856e671711cSMarek Vasut    disas_config "NIOS2"
7857e671711cSMarek Vasut  ;;
78584a09d0bbSRichard Henderson  or1k)
7859c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7860e67db06eSJia Liu  ;;
786164656024SJuan Quintela  ppc*)
7862c765fcacSPeter Crosthwaite    disas_config "PPC"
786364656024SJuan Quintela  ;;
7864c4f80543SAlistair Francis  riscv*)
786525fa194bSMichael Clark    disas_config "RISCV"
786625fa194bSMichael Clark  ;;
786724e804ecSAlexander Graf  s390*)
7868c765fcacSPeter Crosthwaite    disas_config "S390"
786964656024SJuan Quintela  ;;
787064656024SJuan Quintela  sh4)
7871c765fcacSPeter Crosthwaite    disas_config "SH4"
787264656024SJuan Quintela  ;;
787364656024SJuan Quintela  sparc*)
7874c765fcacSPeter Crosthwaite    disas_config "SPARC"
787564656024SJuan Quintela  ;;
7876cfa550c6SMax Filippov  xtensa*)
7877c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7878cfa550c6SMax Filippov  ;;
787964656024SJuan Quintela  esac
788064656024SJuan Quinteladone
78819195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7882c765fcacSPeter Crosthwaite  disas_config "TCI"
78839195b2c2SStefan Weilfi
788464656024SJuan Quintela
78856ee7126fSJuan Quintelacase "$ARCH" in
78866ee7126fSJuan Quintelaalpha)
78876ee7126fSJuan Quintela  # Ensure there's only a single GP
78886ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
78896ee7126fSJuan Quintela;;
78906ee7126fSJuan Quintelaesac
78916ee7126fSJuan Quintela
7892d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
78930acf7dedSPhilippe Mathieu-Daudé  echo "TARGET_GPROF=y" >> $config_target_mak
7894d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7895d02c1db3SJuan Quintela    cflags="-p $cflags"
7896d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7897d02c1db3SJuan Quintela  fi
7898d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7899d02c1db3SJuan Quintela    ldflags="-p $ldflags"
790025be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7901d02c1db3SJuan Quintela  fi
7902d02c1db3SJuan Quintelafi
7903d02c1db3SJuan Quintela
7904e633a5c6SEric Blakeif test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
7905964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7906fa282484SJuan Quintelafi
7907fa282484SJuan Quintela
7908e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7909e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7910e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7911e9a3591fSChristian Borntraeger# header if
7912e9a3591fSChristian Borntraeger#  - we build on s390x
7913e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7914e9a3591fSChristian Borntraeger#  - KVM is enabled
7915e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7916e633a5c6SEric Blakeif test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
7917e633a5c6SEric Blake        test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
7918e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7919e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7920e9a3591fSChristian Borntraeger    fi
7921e9a3591fSChristian Borntraegerfi
7922e9a3591fSChristian Borntraeger
792325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
792425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7925fa282484SJuan Quintela
792697a847bcSbellarddone # for target in $targets
79277d13299dSbellard
7928d52c454aSMarc-André Lureauecho "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
7929d52c454aSMarc-André Lureauecho "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
7930d52c454aSMarc-André Lureau
7931e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
79323b8593eeSMarkus Armbruster  echo "config-host.h: dtc/all" >> $config_host_mak
7933a540f158SPeter Crosthwaitefi
7934e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
79353b8593eeSMarkus Armbruster  echo "config-host.h: capstone/all" >> $config_host_mak
7936e219c499SRichard Hendersonfi
7937e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7938e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7939e219c499SRichard Hendersonfi
7940a540f158SPeter Crosthwaite
7941a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7942a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7943a99d57bbSWanlong Gaofi
7944a99d57bbSWanlong Gao
7945fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7946fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7947fd0e6053SJohn Snowfi
7948fd0e6053SJohn Snow
7949e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
7950e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
7951e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
7952e29e5c6eSPeter Maydell# (these can be both files and directories).
7953e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
7954e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
7955e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
7956e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
7957e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
7958e29e5c6eSPeter Maydell# directory and symlink the directory instead.
79592038f8c8SPaolo BonziniDIRS="tests tests/tcg tests/tcg/lm32 tests/libqos tests/qapi-schema tests/qemu-iotests tests/vm"
7960fc281c80SEmanuele Giuseppe EspositoDIRS="$DIRS tests/fp tests/qgraph"
7961b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
7962744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
79632d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
79642038f8c8SPaolo BonziniLINKS="Makefile"
79652038f8c8SPaolo BonziniLINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
79662038f8c8SPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
7967671f760bSEmilio G. CotaLINKS="$LINKS tests/plugin/Makefile"
7968e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7969e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
7970e29e5c6eSPeter MaydellLINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7971e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
7972e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
797339950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
797439950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
79758f8fd9edSCleber RosaLINKS="$LINKS python"
7976753d11f2SRichard Hendersonfor bios_file in \
7977753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7978225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
7979753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7980753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7981e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7982753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
79834e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
798426ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
7985753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7986753d11f2SRichard Hendersondo
7987e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
79887ea78b74SJan Kiszkadone
7989d1807a4fSPaolo Bonzinimkdir -p $DIRS
7990e29e5c6eSPeter Maydellfor f in $LINKS ; do
7991cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7992f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7993f9245e10SPeter Maydell    fi
79947d13299dSbellarddone
79951ad2134fSPaul Brook
79962038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
79972038f8c8SPaolo Bonzini  export $i
79982038f8c8SPaolo Bonzinidone
79992038f8c8SPaolo Bonziniexport target_list source_path
80002038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
80012038f8c8SPaolo Bonzini
8002c34ebfdcSAnthony Liguori# temporary config to build submodules
80032d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
8004c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
800537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
8006c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8007cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
80085f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
8009c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
8010c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
80113dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
8012c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
8013a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
8014c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
80159f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
8016c34ebfdcSAnthony Liguoridone
8017c34ebfdcSAnthony Liguori
801876c7560aSMax Reitz# set up qemu-iotests in this build directory
801976c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
802076c7560aSMax Reitz
802176c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
802276c7560aSMax Reitzecho >> "$iotests_common_env"
802376c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
802476c7560aSMax Reitz
8025dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
8026dc655404SMichael S. Tsirkincat <<EOD >config.status
8027dc655404SMichael S. Tsirkin#!/bin/sh
8028dc655404SMichael S. Tsirkin# Generated by configure.
8029dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
8030dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
8031dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
8032dc655404SMichael S. TsirkinEOD
8033e811da7fSDaniel P. Berrangé
8034e811da7fSDaniel P. Berrangépreserve_env() {
8035e811da7fSDaniel P. Berrangé    envname=$1
8036e811da7fSDaniel P. Berrangé
8037e811da7fSDaniel P. Berrangé    eval envval=\$$envname
8038e811da7fSDaniel P. Berrangé
8039e811da7fSDaniel P. Berrangé    if test -n "$envval"
8040e811da7fSDaniel P. Berrangé    then
8041e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
8042e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
8043e811da7fSDaniel P. Berrangé    else
8044e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
8045e811da7fSDaniel P. Berrangé    fi
8046e811da7fSDaniel P. Berrangé}
8047e811da7fSDaniel P. Berrangé
8048e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
8049e811da7fSDaniel P. Berrangé# features/build target configure will detect
8050e811da7fSDaniel P. Berrangépreserve_env AR
8051e811da7fSDaniel P. Berrangépreserve_env AS
8052e811da7fSDaniel P. Berrangépreserve_env CC
8053e811da7fSDaniel P. Berrangépreserve_env CPP
8054e811da7fSDaniel P. Berrangépreserve_env CXX
8055e811da7fSDaniel P. Berrangépreserve_env INSTALL
8056e811da7fSDaniel P. Berrangépreserve_env LD
8057e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
8058e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
8059e811da7fSDaniel P. Berrangépreserve_env MAKE
8060e811da7fSDaniel P. Berrangépreserve_env NM
8061e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
8062e811da7fSDaniel P. Berrangépreserve_env PATH
8063e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
8064e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
8065e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
8066e811da7fSDaniel P. Berrangépreserve_env PYTHON
8067e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
8068e811da7fSDaniel P. Berrangépreserve_env SMBD
8069e811da7fSDaniel P. Berrangépreserve_env STRIP
8070e811da7fSDaniel P. Berrangépreserve_env WINDRES
8071e811da7fSDaniel P. Berrangé
8072dc655404SMichael S. Tsirkinprintf "exec" >>config.status
8073dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
8074cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
8075dc655404SMichael S. Tsirkinchmod +x config.status
8076dc655404SMichael S. Tsirkin
80778cd05ab6SPeter Maydellrm -r "$TMPDIR1"
8078