xref: /openbmc/qemu/configure (revision d339d766)
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"
337d13299dSbellard
34da1d85e3SGerd Hoffmannrm -f config.log
359ac81bbbSmalc
36b48e3611SPeter Maydell# Print a helpful header at the top of config.log
37b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
38979ae168SPeter Maydellprintf "# Configured with:" >> config.log
39979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
40979ae168SPeter Maydellecho >> config.log
41b48e3611SPeter Maydellecho "#" >> config.log
42b48e3611SPeter Maydell
43d880a3baSPaolo Bonziniprint_error() {
44d880a3baSPaolo Bonzini    (echo
4576ad07a4SPeter Maydell    echo "ERROR: $1"
4676ad07a4SPeter Maydell    while test -n "$2"; do
4776ad07a4SPeter Maydell        echo "       $2"
4876ad07a4SPeter Maydell        shift
4976ad07a4SPeter Maydell    done
50d880a3baSPaolo Bonzini    echo) >&2
51d880a3baSPaolo Bonzini}
52d880a3baSPaolo Bonzini
53d880a3baSPaolo Bonzinierror_exit() {
54d880a3baSPaolo Bonzini    print_error "$@"
5576ad07a4SPeter Maydell    exit 1
5676ad07a4SPeter Maydell}
5776ad07a4SPeter Maydell
589c83ffd8SPeter Maydelldo_compiler() {
599c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
609c83ffd8SPeter Maydell    # is compiler binary to execute.
619c83ffd8SPeter Maydell    local compiler="$1"
629c83ffd8SPeter Maydell    shift
638bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
648bbe05d7SIan Jackson        echo >>config.log "
658bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
668bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
678bbe05d7SIan Jackson    '; fi
689c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
699c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
708dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
718dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
728dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
738dc38a78SPeter Maydell    # obvious to developers.
748dc38a78SPeter Maydell    if test "$werror" != "yes"; then
758dc38a78SPeter Maydell        return 0
768dc38a78SPeter Maydell    fi
778dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
788dc38a78SPeter Maydell    case "$*" in
798dc38a78SPeter Maydell        *-Werror*)
808dc38a78SPeter Maydell           return 0
818dc38a78SPeter Maydell        ;;
828dc38a78SPeter Maydell    esac
839c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
849c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
8576ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
8676ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8776ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8876ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
898dc38a78SPeter Maydell}
908dc38a78SPeter Maydell
919c83ffd8SPeter Maydelldo_cc() {
929c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
939c83ffd8SPeter Maydell}
949c83ffd8SPeter Maydell
959c83ffd8SPeter Maydelldo_cxx() {
969c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
979c83ffd8SPeter Maydell}
989c83ffd8SPeter Maydell
999c83ffd8SPeter Maydellupdate_cxxflags() {
1009c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1019c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1029c83ffd8SPeter Maydell    # because they only make sense for C programs.
10311cde1c8SBruno Dominguez    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
10411cde1c8SBruno Dominguez
1059c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1069c83ffd8SPeter Maydell        case $arg in
1079c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1089c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1099c83ffd8SPeter Maydell                ;;
1107be41675SThomas Huth            -std=gnu99)
1117be41675SThomas Huth                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
1127be41675SThomas Huth                ;;
1139c83ffd8SPeter Maydell            *)
1149c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1159c83ffd8SPeter Maydell                ;;
1169c83ffd8SPeter Maydell        esac
1179c83ffd8SPeter Maydell    done
1189c83ffd8SPeter Maydell}
1199c83ffd8SPeter Maydell
12052166aa0SJuan Quintelacompile_object() {
121fd0e6053SJohn Snow  local_cflags="$1"
122fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
12352166aa0SJuan Quintela}
12452166aa0SJuan Quintela
12552166aa0SJuan Quintelacompile_prog() {
12652166aa0SJuan Quintela  local_cflags="$1"
12752166aa0SJuan Quintela  local_ldflags="$2"
1288dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
12952166aa0SJuan Quintela}
13052166aa0SJuan Quintela
13111568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
13211568d6dSPaolo Bonzinisymlink() {
13372b8b5a1SStefan Weil  rm -rf "$2"
134ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
13572b8b5a1SStefan Weil  ln -s "$1" "$2"
13611568d6dSPaolo Bonzini}
13711568d6dSPaolo Bonzini
1380dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1390dba6195SLoïc Minier# executable or a builtin)
1400dba6195SLoïc Minierhas() {
1410dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1420dba6195SLoïc Minier}
1430dba6195SLoïc Minier
1440dba6195SLoïc Minier# search for an executable in PATH
1450dba6195SLoïc Minierpath_of() {
1460dba6195SLoïc Minier    local_command="$1"
1470dba6195SLoïc Minier    local_ifs="$IFS"
1480dba6195SLoïc Minier    local_dir=""
1490dba6195SLoïc Minier
1500dba6195SLoïc Minier    # pathname has a dir component?
1510dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1520dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1530dba6195SLoïc Minier            echo "$local_command"
1540dba6195SLoïc Minier            return 0
1550dba6195SLoïc Minier        fi
1560dba6195SLoïc Minier    fi
1570dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1580dba6195SLoïc Minier        return 1
1590dba6195SLoïc Minier    fi
1600dba6195SLoïc Minier
1610dba6195SLoïc Minier    IFS=:
1620dba6195SLoïc Minier    for local_dir in $PATH; do
1630dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1640dba6195SLoïc Minier            echo "$local_dir/$local_command"
1650dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1660dba6195SLoïc Minier            return 0
1670dba6195SLoïc Minier        fi
1680dba6195SLoïc Minier    done
1690dba6195SLoïc Minier    # not found
1700dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1710dba6195SLoïc Minier    return 1
1720dba6195SLoïc Minier}
1730dba6195SLoïc Minier
1745b808275SLluís Vilanovahave_backend () {
1755b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1765b808275SLluís Vilanova}
1775b808275SLluís Vilanova
1783b6b7550SPaolo Bonziniglob() {
1793b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1803b6b7550SPaolo Bonzini}
1813b6b7550SPaolo Bonzini
1823b6b7550SPaolo Bonzinisupported_hax_target() {
1833b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1843b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1853b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1863b6b7550SPaolo Bonzini        i386|x86_64)
1873b6b7550SPaolo Bonzini            return 0
1883b6b7550SPaolo Bonzini        ;;
1893b6b7550SPaolo Bonzini    esac
1903b6b7550SPaolo Bonzini    return 1
1913b6b7550SPaolo Bonzini}
1923b6b7550SPaolo Bonzini
1933b6b7550SPaolo Bonzinisupported_kvm_target() {
1943b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1953b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1963b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1973b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1983b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
1993b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
2003b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
201a69dc537SThomas Huth        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | \
2023b6b7550SPaolo Bonzini        s390x:s390x)
2033b6b7550SPaolo Bonzini            return 0
2043b6b7550SPaolo Bonzini        ;;
2053b6b7550SPaolo Bonzini    esac
2063b6b7550SPaolo Bonzini    return 1
2073b6b7550SPaolo Bonzini}
2083b6b7550SPaolo Bonzini
2093b6b7550SPaolo Bonzinisupported_xen_target() {
2103b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2113b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
212b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
213b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
214b5ed2e11SPaolo Bonzini        i386|x86_64)
2153b6b7550SPaolo Bonzini            return 0
2163b6b7550SPaolo Bonzini        ;;
2173b6b7550SPaolo Bonzini    esac
2183b6b7550SPaolo Bonzini    return 1
2193b6b7550SPaolo Bonzini}
2203b6b7550SPaolo Bonzini
221c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
222c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
223c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
224c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
225c97d6d2cSSergio Andres Gomez Del Real        x86_64)
226c97d6d2cSSergio Andres Gomez Del Real            return 0
227c97d6d2cSSergio Andres Gomez Del Real        ;;
228c97d6d2cSSergio Andres Gomez Del Real    esac
229c97d6d2cSSergio Andres Gomez Del Real    return 1
230c97d6d2cSSergio Andres Gomez Del Real}
231c97d6d2cSSergio Andres Gomez Del Real
232d661d9a4SJustin Terry (VM)supported_whpx_target() {
233d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
234d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
235d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
236d661d9a4SJustin Terry (VM)        i386|x86_64)
237d661d9a4SJustin Terry (VM)            return 0
238d661d9a4SJustin Terry (VM)        ;;
239d661d9a4SJustin Terry (VM)    esac
240d661d9a4SJustin Terry (VM)    return 1
241d661d9a4SJustin Terry (VM)}
242d661d9a4SJustin Terry (VM)
243d880a3baSPaolo Bonzinisupported_target() {
244d880a3baSPaolo Bonzini    case "$1" in
245d880a3baSPaolo Bonzini        *-softmmu)
246d880a3baSPaolo Bonzini            ;;
247d880a3baSPaolo Bonzini        *-linux-user)
248d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
249d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
250d880a3baSPaolo Bonzini                return 1
251d880a3baSPaolo Bonzini            fi
252d880a3baSPaolo Bonzini            ;;
253d880a3baSPaolo Bonzini        *-bsd-user)
254d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
255d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
256d880a3baSPaolo Bonzini                return 1
257d880a3baSPaolo Bonzini            fi
258d880a3baSPaolo Bonzini            ;;
259d880a3baSPaolo Bonzini        *)
260d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
261d880a3baSPaolo Bonzini            return 1
262d880a3baSPaolo Bonzini            ;;
263d880a3baSPaolo Bonzini    esac
264b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
265b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
266b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
267b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
268c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
269d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
270b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
271b3f6ea7eSPaolo Bonzini    return 1
272d880a3baSPaolo Bonzini}
273d880a3baSPaolo Bonzini
274e9a3591fSChristian Borntraeger
275e9a3591fSChristian Borntraegerld_has() {
276e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
277e9a3591fSChristian Borntraeger}
278e9a3591fSChristian Borntraeger
2797d13299dSbellard# default parameters
28089138857SStefan Weilsource_path=$(dirname "$0")
2812ff6b91eSJuan Quintelacpu=""
282a31a8642SMichael S. Tsirkiniasl="iasl"
2831e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
28443ce4dfeSbellardstatic="no"
2857d13299dSbellardcross_prefix=""
2860c58ac1cSmalcaudio_drv_list=""
287b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
288b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
289e49d021eSPeter Maydellhost_cc="cc"
29073da375eSJuan Quintelalibs_softmmu=""
2913e2e0e6bSJuan Quintelalibs_tools=""
29267f86e8eSJuan Quintelaaudio_pt_int=""
293d5631638Smalcaudio_win_int=""
294957f1f99SMichael Rothlibs_qga=""
2955bc62e01SGerd Hoffmanndebug_info="yes"
29663678e17SSteven Noonanstack_protector=""
297ac0df51dSaliguori
29892712822SDaniel P. Berrangeif test -e "$source_path/.git"
29992712822SDaniel P. Berrangethen
300f62bbee5SDaniel P. Berrange    git_update=yes
30192712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
3023ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3033ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
30492712822SDaniel P. Berrangeelse
305f62bbee5SDaniel P. Berrange    git_update=no
306aef45d51SDaniel P. Berrange    git_submodules=""
3075c0ef67aSDaniel P. Berrangé
3085c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3095c0ef67aSDaniel P. Berrangé    then
3105c0ef67aSDaniel P. Berrangé        echo
3115c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3125c0ef67aSDaniel P. Berrangé        echo
3135c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3145c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3155c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3165c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3175c0ef67aSDaniel P. Berrangé        echo
3185c0ef67aSDaniel P. Berrangé        echo "  https://www.qemu.org/download/"
3195c0ef67aSDaniel P. Berrangé        echo
3205c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3215c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3225c0ef67aSDaniel P. Berrangé        echo
3235c0ef67aSDaniel P. Berrangé        exit 1
3245c0ef67aSDaniel P. Berrangé    fi
32592712822SDaniel P. Berrangefi
326cc84d63aSDaniel P. Berrangegit="git"
327ac0df51dSaliguori
328afb63ebdSStefan Weil# Don't accept a target_list environment variable.
329afb63ebdSStefan Weilunset target_list
330377529c0SPaolo Bonzini
331377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
332377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
333377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
334377529c0SPaolo Bonzini#              unless --disable-foo is given
335377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
336377529c0SPaolo Bonzini#              feature will searched for,
337377529c0SPaolo Bonzini#              if not found, configure exits with error
338377529c0SPaolo Bonzini#
339377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
340377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
341377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
342377529c0SPaolo Bonzini
343377529c0SPaolo Bonzinibluez=""
344377529c0SPaolo Bonzinibrlapi=""
345377529c0SPaolo Bonzinicurl=""
346377529c0SPaolo Bonzinicurses=""
347377529c0SPaolo Bonzinidocs=""
348377529c0SPaolo Bonzinifdt=""
34958952137SVincenzo Maffionenetmap="no"
350377529c0SPaolo Bonzinisdl=""
351ee8466d0SCole Robinsonsdlabi=""
352a442fe2fSDaniel P. Berrangésdl_image=""
353983eef5aSMeador Ingevirtfs=""
354fe8fc5aeSPaolo Bonzinimpath=""
355821601eaSJes Sorensenvnc="yes"
356377529c0SPaolo Bonzinisparse="no"
357377529c0SPaolo Bonzinivde=""
358377529c0SPaolo Bonzinivnc_sasl=""
359377529c0SPaolo Bonzinivnc_jpeg=""
360377529c0SPaolo Bonzinivnc_png=""
3616a021536SGerd Hoffmannxkbcommon=""
362377529c0SPaolo Bonzinixen=""
363d5b93ddfSAnthony PERARDxen_ctrl_version=""
364eb6fda0fSAnthony PERARDxen_pci_passthrough=""
365377529c0SPaolo Bonzinilinux_aio=""
36647e98658SCorey Bryantcap_ng=""
367377529c0SPaolo Bonziniattr=""
3684f26f2b6SAvi Kivitylibattr=""
369377529c0SPaolo Bonzinixfs=""
370b3f6ea7eSPaolo Bonzinitcg="yes"
371a40161cbSPaolo Bonzinimembarrier=""
372d41a75a2SBradvhost_net="no"
373042cea27SGongleivhost_crypto="no"
3745e9be92dSNicholas Bellingervhost_scsi="no"
375fc0b9b0eSStefan Hajnoczivhost_vsock="no"
376e6a74868SMarc-André Lureauvhost_user=""
377d41a75a2SBradkvm="no"
378b0cb0a66SVincent Palatinhax="no"
379c97d6d2cSSergio Andres Gomez Del Realhvf="no"
380d661d9a4SJustin Terry (VM)whpx="no"
3812da776dbSMichael R. Hinesrdma=""
38221ab34c9SMarcel Apfelbaumpvrdma=""
383377529c0SPaolo Bonzinigprof="no"
384377529c0SPaolo Bonzinidebug_tcg="no"
385377529c0SPaolo Bonzinidebug="no"
386247724cbSMarc-André Lureausanitizers="no"
387b553a042SJohn Snowfortify_source=""
388377529c0SPaolo Bonzinistrip_opt="yes"
3899195b2c2SStefan Weiltcg_interpreter="no"
390377529c0SPaolo Bonzinibigendian="no"
391377529c0SPaolo Bonzinimingw32="no"
3921d728c39SBlue Swirlgcov="no"
3931d728c39SBlue Swirlgcov_tool="gcov"
394377529c0SPaolo BonziniEXESUF=""
39517969268SFam ZhengDSOSUF=".so"
39617969268SFam ZhengLDFLAGS_SHARED="-shared"
39717969268SFam Zhengmodules="no"
398377529c0SPaolo Bonziniprefix="/usr/local"
399377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
400528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
4013d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
402850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
403377529c0SPaolo Bonzinibindir="\${prefix}/bin"
4043aa5d2beSAlon Levylibdir="\${prefix}/lib"
4058bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
4060f94d6daSAlon Levyincludedir="\${prefix}/include"
407377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
408785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
409377529c0SPaolo Bonziniconfsuffix="/qemu"
410377529c0SPaolo Bonzinislirp="yes"
411377529c0SPaolo Bonzinioss_lib=""
412377529c0SPaolo Bonzinibsd="no"
413377529c0SPaolo Bonzinilinux="no"
414377529c0SPaolo Bonzinisolaris="no"
415377529c0SPaolo Bonziniprofiler="no"
416377529c0SPaolo Bonzinicocoa="no"
417377529c0SPaolo Bonzinisoftmmu="yes"
418377529c0SPaolo Bonzinilinux_user="no"
419377529c0SPaolo Bonzinibsd_user="no"
420377529c0SPaolo Bonziniblobs="yes"
421377529c0SPaolo Bonzinipkgversion=""
42240d6444eSAvi Kivitypie=""
4233556c233SPaolo Bonziniqom_cast_debug="yes"
424baf86d6bSPaolo Bonzinitrace_backends="log"
425377529c0SPaolo Bonzinitrace_file="trace"
426377529c0SPaolo Bonzinispice=""
427377529c0SPaolo Bonzinirbd=""
4287b02f544SMarc-André Lureausmartcard=""
4292b2325ffSGerd Hoffmannlibusb=""
43069354a83SHans de Goedeusb_redir=""
431da076ffeSGerd Hoffmannopengl=""
432014cb152SGerd Hoffmannopengl_dmabuf="no"
4335dd89908SRichard Hendersoncpuid_h="no"
43486583a07SLiam Merwickavx2_opt=""
4351ece9905SAlon Levyzlib="yes"
4368ca80760SRichard Hendersoncapstone=""
437b25c9dffSStefan Weillzo=""
438b25c9dffSStefan Weilsnappy=""
4396b383c08SPeter Wubzip2=""
44083bc1f97SJulio Faraccolzfse=""
441e8ef31a3SMichael Tokarevguest_agent=""
442d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
44350cbebb9SMichael Rothguest_agent_ntddscsi="no"
4449dacf32dSYossi Hindinguest_agent_msi=""
445d9840e25STomoki Sekiyamavss_win32_sdk=""
446d9840e25STomoki Sekiyamawin_sdk="no"
4474b1c11fdSDaniel P. Berrangewant_tools="yes"
448c589b249SRonnie Sahlberglibiscsi=""
4496542aa9cSPeter Lievenlibnfs=""
450519175a2SAlex Barcelocoroutine=""
45170c60c08SStefan Hajnoczicoroutine_pool=""
4527d992e4dSPeter Lievendebug_stack_usage="no"
453f0d92b56SLongpeng(Mike)crypto_afalg="no"
454f794573eSEduardo Otuboseccomp=""
455eb100396SBharata B Raoglusterfs=""
456d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4570c14fb47SBharata B Raoglusterfs_discard="no"
458df3a429aSNiels de Vosglusterfs_fallocate="no"
4597c815372SBharata B Raoglusterfs_zerofill="no"
460a4ccabcfSAnthony Liguorigtk=""
461925a0400SGerd Hoffmanngtk_gl="no"
462a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
463ddbb0d09SDaniel P. Berrangegnutls=""
46491bfcdb0SDaniel P. Berrangenettle=""
46591bfcdb0SDaniel P. Berrangegcrypt=""
4661f923c70SLongpeng(Mike)gcrypt_hmac="no"
467bbbf9bfbSStefan Weilvte=""
4689d9e1521SGerd Hoffmannvirglrenderer=""
469e91c793cSCole Robinsontpm="yes"
4700a12ec87SRichard W.M. Joneslibssh2=""
471ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
472a99d57bbSWanlong Gaonuma=""
4732847b469SFam Zhengtcmalloc="no"
4747b01cb97SAlexandre Derumierjemalloc="no"
475a6b1d4c0SChanglong Xiereplication="yes"
476da92c3ffSAshish Mittalvxhs=""
4772f740136SJeff Codybochs="yes"
4782f740136SJeff Codycloop="yes"
4792f740136SJeff Codydmg="yes"
4802f740136SJeff Codyqcow1="yes"
4812f740136SJeff Codyvdi="yes"
4822f740136SJeff Codyvvfat="yes"
4832f740136SJeff Codyqed="yes"
4842f740136SJeff Codyparallels="yes"
4852f740136SJeff Codysheepdog="yes"
486ed279a06SKlim Kireevlibxml2=""
48751a12b51SAlex Bennéedocker="no"
488ba59fb77SPaolo Bonzinidebug_mutex="no"
48917824406SJunyan Helibpmem=""
4903efac6ebSTomáš Golembiovskýlibudev="no"
491377529c0SPaolo Bonzini
492d75402b5SAlex Bennée# cross compilers defaults, can be overridden with --cross-cc-ARCH
493d75402b5SAlex Bennéecross_cc_aarch64="aarch64-linux-gnu-gcc"
494d422b2bcSAlex Bennéecross_cc_aarch64_be="$cross_cc_aarch64"
495d422b2bcSAlex Bennéecross_cc_cflags_aarch64_be="-mbig-endian"
496d75402b5SAlex Bennéecross_cc_arm="arm-linux-gnueabihf-gcc"
497d422b2bcSAlex Bennéecross_cc_cflags_armeb="-mbig-endian"
498716a507cSAlex Bennéecross_cc_i386="i386-pc-linux-gnu-gcc"
499716a507cSAlex Bennéecross_cc_cflags_i386=""
500d75402b5SAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
501d422b2bcSAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
502d75402b5SAlex Bennée
503d75402b5SAlex Bennéeenabled_cross_compilers=""
504d75402b5SAlex Bennée
505898be3e0SPeter Maydellsupported_cpu="no"
506898be3e0SPeter Maydellsupported_os="no"
507fb59dabdSPeter Maydellbogus_os="no"
5085a22ab71SYang Zhongmalloc_trim=""
509898be3e0SPeter Maydell
510ac0df51dSaliguori# parse CC options first
511ac0df51dSaliguorifor opt do
51289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
513ac0df51dSaliguori  case "$opt" in
514ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
515ac0df51dSaliguori  ;;
5163d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
517ac0df51dSaliguori  ;;
51883f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
51983f73fceSTomoki Sekiyama  ;;
520ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
521ca4deeb1SPaolo Bonzini  ;;
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"
539d422b2bcSAlex Bennée  ;;
540d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
541d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
542d75402b5SAlex Bennée  ;;
543ac0df51dSaliguori  esac
544ac0df51dSaliguoridone
545ac0df51dSaliguori# OS specific
546ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
54793148aa5SStefan Weil# we can eliminate its usage altogether.
548ac0df51dSaliguori
549e49d021eSPeter Maydell# Preferred compiler:
550e49d021eSPeter Maydell#  ${CC} (if set)
551e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
552e49d021eSPeter Maydell#  system compiler
553e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
554e49d021eSPeter Maydell  cc="$host_cc"
555e49d021eSPeter Maydellelse
556b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
557e49d021eSPeter Maydellfi
558e49d021eSPeter Maydell
55983f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
56083f73fceSTomoki Sekiyama  cxx="c++"
56183f73fceSTomoki Sekiyamaelse
56283f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
56383f73fceSTomoki Sekiyamafi
56483f73fceSTomoki Sekiyama
565b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
566cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5675f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5683dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
569b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
570b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5719f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5724852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
573b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
574b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
57517884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
57617884d7bSSergei Trofimovichquery_pkg_config() {
57717884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
57817884d7bSSergei Trofimovich}
57917884d7bSSergei Trofimovichpkg_config=query_pkg_config
580b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
58147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
582ac0df51dSaliguori
58345d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
58445d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
58545d285abSPeter Maydell
586be17dc90SMichael S. Tsirkin# default flags for all hosts
5872d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5882d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5892d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5902d31515bSPeter Maydell# provides these semantics.)
5917be41675SThomas HuthQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
592f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
593c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
594be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5959edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5965bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5975bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
598be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5995bc62e01SGerd Hoffmannfi
600be17dc90SMichael S. Tsirkin
601ca4deeb1SPaolo Bonzini# make source path absolute
60289138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
603ca4deeb1SPaolo Bonzini
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
704fdf7ed96Smalc    cpu="ppc64"
705ac0df51dSaliguori  else
706fdf7ed96Smalc    cpu="ppc"
707fdf7ed96Smalc  fi
708afa05235SAurelien Jarnoelif check_define __mips__ ; then
709afa05235SAurelien Jarno  cpu="mips"
710d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
711d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
712d66ed0eaSAurelien Jarno    cpu="s390x"
713d66ed0eaSAurelien Jarno  else
714d66ed0eaSAurelien Jarno    cpu="s390"
715d66ed0eaSAurelien Jarno  fi
716c4f80543SAlistair Franciselif check_define __riscv ; then
717c4f80543SAlistair Francis  if check_define _LP64 ; then
718c4f80543SAlistair Francis    cpu="riscv64"
719c4f80543SAlistair Francis  else
720c4f80543SAlistair Francis    cpu="riscv32"
721c4f80543SAlistair Francis  fi
72221d89f84SPeter Maydellelif check_define __arm__ ; then
72321d89f84SPeter Maydell  cpu="arm"
7241f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7251f080313SClaudio Fontana  cpu="aarch64"
726fdf7ed96Smalcelse
72789138857SStefan Weil  cpu=$(uname -m)
728ac0df51dSaliguorifi
729ac0df51dSaliguori
730359bc95dSPeter MaydellARCH=
731359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
732359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7337d13299dSbellardcase "$cpu" in
734c4f80543SAlistair Francis  ppc|ppc64|s390|s390x|sparc64|x32|riscv32|riscv64)
735898be3e0SPeter Maydell    cpu="$cpu"
736898be3e0SPeter Maydell    supported_cpu="yes"
737d75402b5SAlex Bennée    eval "cross_cc_${cpu}=\$host_cc"
738898be3e0SPeter Maydell  ;;
7397d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
74097a847bcSbellard    cpu="i386"
741898be3e0SPeter Maydell    supported_cpu="yes"
742d75402b5SAlex Bennée    cross_cc_i386=$host_cc
7437d13299dSbellard  ;;
744aaa5fa14Saurel32  x86_64|amd64)
745aaa5fa14Saurel32    cpu="x86_64"
746898be3e0SPeter Maydell    supported_cpu="yes"
747d75402b5SAlex Bennée    cross_cc_x86_64=$host_cc
748aaa5fa14Saurel32  ;;
74921d89f84SPeter Maydell  armv*b|armv*l|arm)
75021d89f84SPeter Maydell    cpu="arm"
751898be3e0SPeter Maydell    supported_cpu="yes"
752d75402b5SAlex Bennée    cross_cc_arm=$host_cc
7537d13299dSbellard  ;;
7541f080313SClaudio Fontana  aarch64)
7551f080313SClaudio Fontana    cpu="aarch64"
756898be3e0SPeter Maydell    supported_cpu="yes"
757d75402b5SAlex Bennée    cross_cc_aarch64=$host_cc
7581f080313SClaudio Fontana  ;;
759afa05235SAurelien Jarno  mips*)
760afa05235SAurelien Jarno    cpu="mips"
761898be3e0SPeter Maydell    supported_cpu="yes"
762d75402b5SAlex Bennée    cross_cc_mips=$host_cc
763afa05235SAurelien Jarno  ;;
7643142255cSblueswir1  sparc|sun4[cdmuv])
765ae228531Sbellard    cpu="sparc"
7666499fd15SPeter Maydell    supported_cpu="yes"
767d75402b5SAlex Bennée    cross_cc_sparc=$host_cc
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"
7873cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
788307119e7SGerd Hoffmann  if check_include dsound.h; then
7893cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
790307119e7SGerd Hoffmann  else
791307119e7SGerd Hoffmann    audio_drv_list=""
792307119e7SGerd Hoffmann  fi
793898be3e0SPeter Maydell  supported_os="yes"
79467b915a5Sbellard;;
7955c40d2bdSthsGNU/kFreeBSD)
796a167ba50SAurelien Jarno  bsd="yes"
7976a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7980bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7995c40d2bdSths;;
8007d3505c5SbellardFreeBSD)
8017d3505c5Sbellard  bsd="yes"
8020db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8036a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8040bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
805f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
806f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
807a7764f15SEd Maste  # needed for kinfo_getproc
808a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
80958952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
810adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
811898be3e0SPeter Maydell  supported_os="yes"
8127d3505c5Sbellard;;
813c5e97233Sblueswir1DragonFly)
814c5e97233Sblueswir1  bsd="yes"
8150db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8166a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8170bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
818adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
819c5e97233Sblueswir1;;
8207d3505c5SbellardNetBSD)
8217d3505c5Sbellard  bsd="yes"
8220db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8236a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8240bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8258ef92a88Sblueswir1  oss_lib="-lossaudio"
826adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8273c2bdbc1SKamil Rytarowski  supported_os="yes"
8287d3505c5Sbellard;;
8297d3505c5SbellardOpenBSD)
8307d3505c5Sbellard  bsd="yes"
8310db4a067SPaolo Bonzini  make="${MAKE-gmake}"
832f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8330bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
834adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8350a773d55SBrad Smith  supported_os="yes"
8367d3505c5Sbellard;;
83783fb7adfSbellardDarwin)
83883fb7adfSbellard  bsd="yes"
83983fb7adfSbellard  darwin="yes"
840b0cb0a66SVincent Palatin  hax="yes"
841c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
84217969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8431b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
844a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
8450c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8461b0f9cc2Saliguori  fi
847fd677642Sths  cocoa="yes"
8486a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
84914382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8500c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8517973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
852a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
853a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
854a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
855adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
856898be3e0SPeter Maydell  supported_os="yes"
85783fb7adfSbellard;;
858ec530c81SbellardSunOS)
859ec530c81Sbellard  solaris="yes"
8600db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8610db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
862e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8636b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8646a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
8656b4d2ba1Sths  fi
866c2de5c91Smalc  audio_possible_drivers="oss sdl"
867d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
868d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
869d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
870d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
871a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
872560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
873560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
874560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
875ec530c81Sbellard;;
876179cf400SAndreas FärberHaiku)
877179cf400SAndreas Färber  haiku="yes"
878179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
879179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
880179cf400SAndreas Färber;;
881898be3e0SPeter MaydellLinux)
8826a485418SGerd Hoffmann  audio_drv_list="try-pa try-alsa try-sdl oss"
8830bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8845327cf48Sbellard  linux="yes"
885831b7825Sths  linux_user="yes"
886af2be207SJan Kiszka  kvm="yes"
887af2be207SJan Kiszka  vhost_net="yes"
888042cea27SGonglei  vhost_crypto="yes"
8895e9be92dSNicholas Bellinger  vhost_scsi="yes"
890fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
891e8d81a61SMao Zhongyi  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
892898be3e0SPeter Maydell  supported_os="yes"
8933efac6ebSTomáš Golembiovský  libudev="yes"
894898be3e0SPeter Maydell;;
8957d13299dSbellardesac
8967d13299dSbellard
8977d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
898b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
89984778508Sblueswir1    bsd_user="yes"
9007d3505c5Sbellard  fi
90108de3949SAndreas Färberfi
9027d3505c5Sbellard
9030db4a067SPaolo Bonzini: ${make=${MAKE-make}}
9040db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
90552510f8bSStefan Weil: ${python=${PYTHON-python}}
906e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9070db4a067SPaolo Bonzini
9083c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9093c4a4d0dSPeter Maydellif has clang; then
9103c4a4d0dSPeter Maydell  objcc=clang
9113c4a4d0dSPeter Maydellelse
9123c4a4d0dSPeter Maydell  objcc="$cc"
9133c4a4d0dSPeter Maydellfi
9143c4a4d0dSPeter Maydell
9153457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
9163457a3f8SJuan Quintela  EXESUF=".exe"
91717969268SFam Zheng  DSOSUF=".dll"
91878e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
91978e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
920f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
92193b25869SJohn Snow  write_c_skeleton;
922f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
923f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
924f7cf5d5bSStefan Weil  fi
925c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
926683035deSPaolo Bonzini  mandir="\${prefix}"
927528ae5b8SEduardo Habkost  datadir="\${prefix}"
928850da188SEduardo Habkost  qemu_docdir="\${prefix}"
929683035deSPaolo Bonzini  bindir="\${prefix}"
930683035deSPaolo Bonzini  sysconfdir="\${prefix}"
9315a699bbbSLaszlo Ersek  local_statedir=
932683035deSPaolo Bonzini  confsuffix=""
933105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9343457a3f8SJuan Quintelafi
9353457a3f8SJuan Quintela
936487fefdbSAnthony Liguoriwerror=""
93785aa5189Sbellard
9387d13299dSbellardfor opt do
93989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9407d13299dSbellard  case "$opt" in
9412efc3265Sbellard  --help|-h) show_help=yes
9422efc3265Sbellard  ;;
94399123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
94499123e13SMike Frysinger  ;;
945b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9467d13299dSbellard  ;;
947b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
94832ce6337Sbellard  ;;
949ca4deeb1SPaolo Bonzini  --source-path=*)
9507d13299dSbellard  ;;
951ac0df51dSaliguori  --cross-prefix=*)
9527d13299dSbellard  ;;
953ac0df51dSaliguori  --cc=*)
9547d13299dSbellard  ;;
955b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
95683469015Sbellard  ;;
95783f73fceSTomoki Sekiyama  --cxx=*)
95883f73fceSTomoki Sekiyama  ;;
959e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
960e007dbecSMichael S. Tsirkin  ;;
9613c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9623c4a4d0dSPeter Maydell  ;;
963b1a550a0Spbrook  --make=*) make="$optarg"
9647d13299dSbellard  ;;
9656a882643Spbrook  --install=*) install="$optarg"
9666a882643Spbrook  ;;
967c886edfbSBlue Swirl  --python=*) python="$optarg"
968c886edfbSBlue Swirl  ;;
9691d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9701d728c39SBlue Swirl  ;;
971e2d8830eSBrad  --smbd=*) smbd="$optarg"
972e2d8830eSBrad  ;;
973e2a2ed06SJuan Quintela  --extra-cflags=*)
9747d13299dSbellard  ;;
97511cde1c8SBruno Dominguez  --extra-cxxflags=*)
97611cde1c8SBruno Dominguez  ;;
977e2a2ed06SJuan Quintela  --extra-ldflags=*)
9787d13299dSbellard  ;;
9795bc62e01SGerd Hoffmann  --enable-debug-info)
9805bc62e01SGerd Hoffmann  ;;
9815bc62e01SGerd Hoffmann  --disable-debug-info)
9825bc62e01SGerd Hoffmann  ;;
983d75402b5SAlex Bennée  --cross-cc-*)
984d75402b5SAlex Bennée  ;;
98517969268SFam Zheng  --enable-modules)
98617969268SFam Zheng      modules="yes"
98717969268SFam Zheng  ;;
9883aa88b31SStefan Hajnoczi  --disable-modules)
9893aa88b31SStefan Hajnoczi      modules="no"
9903aa88b31SStefan Hajnoczi  ;;
9912ff6b91eSJuan Quintela  --cpu=*)
9927d13299dSbellard  ;;
993b1a550a0Spbrook  --target-list=*) target_list="$optarg"
994de83cd02Sbellard  ;;
9955b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9965b808275SLluís Vilanova  ;;
9975b808275SLluís Vilanova  # XXX: backwards compatibility
9985b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
99994a420b1SStefan Hajnoczi  ;;
100074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
10019410b56cSPrerna Saxena  ;;
10027d13299dSbellard  --enable-gprof) gprof="yes"
10037d13299dSbellard  ;;
10041d728c39SBlue Swirl  --enable-gcov) gcov="yes"
10051d728c39SBlue Swirl  ;;
100679427693SLoïc Minier  --static)
100779427693SLoïc Minier    static="yes"
100879427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
100917884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
101043ce4dfeSbellard  ;;
10110b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
10120b24e75fSPaolo Bonzini  ;;
10130b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
10140b24e75fSPaolo Bonzini  ;;
10153aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10163aa5d2beSAlon Levy  ;;
10178bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10188bf188aaSMichael Tokarev  ;;
10190f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10200f94d6daSAlon Levy  ;;
1021528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10220b24e75fSPaolo Bonzini  ;;
1023023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1024023d3d67SEduardo Habkost  ;;
1025850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10260b24e75fSPaolo Bonzini  ;;
1027ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
102807381cc1SAnthony Liguori  ;;
1029785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1030785c23aeSLuiz Capitulino  ;;
10313d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10323d5eecabSGerd Hoffmann  ;;
1033181ce1d0SOlaf Hering  --host=*|--build=*|\
1034181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1035785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1036023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1037023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1038023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1039023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1040023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1041023ddd74SMax Filippov    # lots of directory switches by default.
1042023ddd74SMax Filippov  ;;
104397a847bcSbellard  --disable-sdl) sdl="no"
104497a847bcSbellard  ;;
1045c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1046c4198157SJuan Quintela  ;;
104747c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
104847c03744SDave Airlie  ;;
1049a442fe2fSDaniel P. Berrangé  --disable-sdl-image) sdl_image="no"
1050a442fe2fSDaniel P. Berrangé  ;;
1051a442fe2fSDaniel P. Berrangé  --enable-sdl-image) sdl_image="yes"
1052a442fe2fSDaniel P. Berrangé  ;;
10533556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10543556c233SPaolo Bonzini  ;;
10553556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10563556c233SPaolo Bonzini  ;;
1057983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1058983eef5aSMeador Inge  ;;
1059983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1060983eef5aSMeador Inge  ;;
1061fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1062fe8fc5aeSPaolo Bonzini  ;;
1063fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1064fe8fc5aeSPaolo Bonzini  ;;
1065821601eaSJes Sorensen  --disable-vnc) vnc="no"
1066821601eaSJes Sorensen  ;;
1067821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1068821601eaSJes Sorensen  ;;
10692f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10702f6a1ab0Sblueswir1  ;;
10710c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10720c58ac1cSmalc  ;;
107389138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1074b64ec4e4SFam Zheng  ;;
107589138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1076eb852011SMarkus Armbruster  ;;
1077f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1078f8393946Saurel32  ;;
1079f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1080f8393946Saurel32  ;;
1081f3d08ee6SPaul Brook  --enable-debug)
1082f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1083f3d08ee6SPaul Brook      debug_tcg="yes"
10841fcc6d42SPeter Xu      debug_mutex="yes"
1085f3d08ee6SPaul Brook      debug="yes"
1086f3d08ee6SPaul Brook      strip_opt="no"
1087b553a042SJohn Snow      fortify_source="no"
1088f3d08ee6SPaul Brook  ;;
1089247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1090247724cbSMarc-André Lureau  ;;
1091247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1092247724cbSMarc-André Lureau  ;;
109303b4fe7dSaliguori  --enable-sparse) sparse="yes"
109403b4fe7dSaliguori  ;;
109503b4fe7dSaliguori  --disable-sparse) sparse="no"
109603b4fe7dSaliguori  ;;
10971625af87Saliguori  --disable-strip) strip_opt="no"
10981625af87Saliguori  ;;
10992f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
11002f9606b3Saliguori  ;;
1101ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1102ea784e3bSJuan Quintela  ;;
11032f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
11042f6f5c7aSCorentin Chary  ;;
11052f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
11062f6f5c7aSCorentin Chary  ;;
1107efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1108efe556adSCorentin Chary  ;;
1109efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1110efe556adSCorentin Chary  ;;
1111443f1376Sbellard  --disable-slirp) slirp="no"
1112c20709aaSbellard  ;;
1113e0e6c8c0Saliguori  --disable-vde) vde="no"
11148a16d273Sths  ;;
1115dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1116dfb278bdSJuan Quintela  ;;
111758952137SVincenzo Maffione  --disable-netmap) netmap="no"
111858952137SVincenzo Maffione  ;;
111958952137SVincenzo Maffione  --enable-netmap) netmap="yes"
112058952137SVincenzo Maffione  ;;
1121e37630caSaliguori  --disable-xen) xen="no"
1122e37630caSaliguori  ;;
1123fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1124fc321b4bSJuan Quintela  ;;
1125eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1126eb6fda0fSAnthony PERARD  ;;
1127eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1128eb6fda0fSAnthony PERARD  ;;
11292e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
11302e4d9fb1Saurel32  ;;
11314ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
11324ffcedb6SJuan Quintela  ;;
1133fb599c9aSbalrog  --disable-bluez) bluez="no"
1134fb599c9aSbalrog  ;;
1135a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1136a20a6f46SJuan Quintela  ;;
11377ba1e619Saliguori  --disable-kvm) kvm="no"
11387ba1e619Saliguori  ;;
1139b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1140b31a0277SJuan Quintela  ;;
1141b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1142180fb750Szhanghailiang  ;;
1143b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1144180fb750Szhanghailiang  ;;
1145c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1146c97d6d2cSSergio Andres Gomez Del Real  ;;
1147c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1148c97d6d2cSSergio Andres Gomez Del Real  ;;
1149d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1150d661d9a4SJustin Terry (VM)  ;;
1151d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1152d661d9a4SJustin Terry (VM)  ;;
11539195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11549195b2c2SStefan Weil  ;;
11559195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11569195b2c2SStefan Weil  ;;
115747e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
115847e98658SCorey Bryant  ;;
115947e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
116047e98658SCorey Bryant  ;;
1161b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1162b3f6ea7eSPaolo Bonzini  ;;
1163b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1164b3f6ea7eSPaolo Bonzini  ;;
11655a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11665a22ab71SYang Zhong  ;;
11675a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11685a22ab71SYang Zhong  ;;
1169cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1170cd4ec0b4SGerd Hoffmann  ;;
1171cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1172cd4ec0b4SGerd Hoffmann  ;;
1173c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1174c589b249SRonnie Sahlberg  ;;
1175c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1176c589b249SRonnie Sahlberg  ;;
11776542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11786542aa9cSPeter Lieven  ;;
11796542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11806542aa9cSPeter Lieven  ;;
118105c2a3e7Sbellard  --enable-profiler) profiler="yes"
118205c2a3e7Sbellard  ;;
118314821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
118414821030SPavel Borzenkov  ;;
1185c2de5c91Smalc  --enable-cocoa)
1186c2de5c91Smalc      cocoa="yes" ;
118789138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
11885b0753e0Sbellard  ;;
1189cad25d69Spbrook  --disable-system) softmmu="no"
11900a8e90f4Spbrook  ;;
1191cad25d69Spbrook  --enable-system) softmmu="yes"
11920a8e90f4Spbrook  ;;
11930953a80fSZachary Amsden  --disable-user)
11940953a80fSZachary Amsden      linux_user="no" ;
11950953a80fSZachary Amsden      bsd_user="no" ;
11960953a80fSZachary Amsden  ;;
11970953a80fSZachary Amsden  --enable-user) ;;
1198831b7825Sths  --disable-linux-user) linux_user="no"
11990a8e90f4Spbrook  ;;
1200831b7825Sths  --enable-linux-user) linux_user="yes"
1201831b7825Sths  ;;
120284778508Sblueswir1  --disable-bsd-user) bsd_user="no"
120384778508Sblueswir1  ;;
120484778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
120584778508Sblueswir1  ;;
120640d6444eSAvi Kivity  --enable-pie) pie="yes"
120734005a00SKirill A. Shutemov  ;;
120840d6444eSAvi Kivity  --disable-pie) pie="no"
120934005a00SKirill A. Shutemov  ;;
121085aa5189Sbellard  --enable-werror) werror="yes"
121185aa5189Sbellard  ;;
121285aa5189Sbellard  --disable-werror) werror="no"
121385aa5189Sbellard  ;;
121463678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
121563678e17SSteven Noonan  ;;
121663678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
121763678e17SSteven Noonan  ;;
12184d3b6f6eSbalrog  --disable-curses) curses="no"
12194d3b6f6eSbalrog  ;;
1220c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1221c584a6d0SJuan Quintela  ;;
1222769ce76dSAlexander Graf  --disable-curl) curl="no"
1223769ce76dSAlexander Graf  ;;
1224788c8196SJuan Quintela  --enable-curl) curl="yes"
1225788c8196SJuan Quintela  ;;
12262df87df7SJuan Quintela  --disable-fdt) fdt="no"
12272df87df7SJuan Quintela  ;;
12282df87df7SJuan Quintela  --enable-fdt) fdt="yes"
12292df87df7SJuan Quintela  ;;
12305c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12315c6c3a6cSChristoph Hellwig  ;;
12325c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12335c6c3a6cSChristoph Hellwig  ;;
1234758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1235758e8e38SVenkateswararao Jujjuri (JV)  ;;
1236758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1237758e8e38SVenkateswararao Jujjuri (JV)  ;;
1238a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1239a40161cbSPaolo Bonzini  ;;
1240a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1241a40161cbSPaolo Bonzini  ;;
124277755340Sths  --disable-blobs) blobs="no"
124377755340Sths  ;;
12447e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12454a19f1ecSpbrook  ;;
1246519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1247519175a2SAlex Barcelo  ;;
124870c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
124970c60c08SStefan Hajnoczi  ;;
125070c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
125170c60c08SStefan Hajnoczi  ;;
12527d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12537d992e4dSPeter Lieven  ;;
1254f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1255f0d92b56SLongpeng(Mike)  ;;
1256f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1257f0d92b56SLongpeng(Mike)  ;;
1258a25dba17SJuan Quintela  --disable-docs) docs="no"
125970ec5dc0SAnthony Liguori  ;;
1260a25dba17SJuan Quintela  --enable-docs) docs="yes"
126183a3ab8bSJuan Quintela  ;;
1262d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1263d5970055SMichael S. Tsirkin  ;;
1264d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1265d5970055SMichael S. Tsirkin  ;;
1266042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1267042cea27SGonglei  ;;
1268042cea27SGonglei  --enable-vhost-crypto)
1269042cea27SGonglei      vhost_crypto="yes"
1270042cea27SGonglei      if test "$mingw32" = "yes"; then
1271042cea27SGonglei          error_exit "vhost-crypto isn't available on win32"
1272042cea27SGonglei      fi
1273042cea27SGonglei  ;;
12745e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12755e9be92dSNicholas Bellinger  ;;
12765e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12775e9be92dSNicholas Bellinger  ;;
1278fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1279fc0b9b0eSStefan Hajnoczi  ;;
1280fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1281fc0b9b0eSStefan Hajnoczi  ;;
1282da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
128320ff075bSMichael Walle  ;;
1284da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
128520ff075bSMichael Walle  ;;
1286f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1287f27aaf4bSChristian Brunner  ;;
1288f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1289f27aaf4bSChristian Brunner  ;;
12908c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12918c84cf11SSergei Trofimovich  ;;
12928c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12938c84cf11SSergei Trofimovich  ;;
12947b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1295111a38b0SRobert Relyea  ;;
12967b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1297111a38b0SRobert Relyea  ;;
12982b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
12992b2325ffSGerd Hoffmann  ;;
13002b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
13012b2325ffSGerd Hoffmann  ;;
130269354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
130369354a83SHans de Goede  ;;
130469354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
130569354a83SHans de Goede  ;;
13061ece9905SAlon Levy  --disable-zlib-test) zlib="no"
13071ece9905SAlon Levy  ;;
1308b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1309b25c9dffSStefan Weil  ;;
1310607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1311607dacd0Sqiaonuohan  ;;
1312b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1313b25c9dffSStefan Weil  ;;
1314607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1315607dacd0Sqiaonuohan  ;;
13166b383c08SPeter Wu  --disable-bzip2) bzip2="no"
13176b383c08SPeter Wu  ;;
13186b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13196b383c08SPeter Wu  ;;
132083bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
132183bc1f97SJulio Faracco  ;;
132283bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
132383bc1f97SJulio Faracco  ;;
1324d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1325d138cee9SMichael Roth  ;;
1326d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1327d138cee9SMichael Roth  ;;
13289dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13299dacf32dSYossi Hindin  ;;
13309dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13319dacf32dSYossi Hindin  ;;
1332d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1333d9840e25STomoki Sekiyama  ;;
1334d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1335d9840e25STomoki Sekiyama  ;;
1336d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1337d9840e25STomoki Sekiyama  ;;
1338d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1339d9840e25STomoki Sekiyama  ;;
1340d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1341d9840e25STomoki Sekiyama  ;;
1342d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1343d9840e25STomoki Sekiyama  ;;
13444b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13454b1c11fdSDaniel P. Berrange  ;;
13464b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13474b1c11fdSDaniel P. Berrange  ;;
1348f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1349f794573eSEduardo Otubo  ;;
1350f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1351f794573eSEduardo Otubo  ;;
1352eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1353eb100396SBharata B Rao  ;;
135486583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
135586583a07SLiam Merwick  ;;
135686583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
135786583a07SLiam Merwick  ;;
1358eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1359eb100396SBharata B Rao  ;;
136052b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
136152b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1362583f6e7bSStefan Hajnoczi  ;;
1363cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1364cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1365cb6414dfSFam Zheng  ;;
1366315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1367315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1368315d3184SFam Zheng  ;;
1369a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1370a4ccabcfSAnthony Liguori  ;;
1371a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1372a4ccabcfSAnthony Liguori  ;;
1373a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1374a1c5e949SDaniel P. Berrange  ;;
1375ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1376ddbb0d09SDaniel P. Berrange  ;;
1377ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1378ddbb0d09SDaniel P. Berrange  ;;
137991bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
138091bfcdb0SDaniel P. Berrange  ;;
138191bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
138291bfcdb0SDaniel P. Berrange  ;;
138391bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
138491bfcdb0SDaniel P. Berrange  ;;
138591bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
138691bfcdb0SDaniel P. Berrange  ;;
13872da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13882da776dbSMichael R. Hines  ;;
13892da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13902da776dbSMichael R. Hines  ;;
139121ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
139221ab34c9SMarcel Apfelbaum  ;;
139321ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
139421ab34c9SMarcel Apfelbaum  ;;
1395bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1396bbbf9bfbSStefan Weil  ;;
1397bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1398bbbf9bfbSStefan Weil  ;;
13999d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14009d9e1521SGerd Hoffmann  ;;
14019d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
14029d9e1521SGerd Hoffmann  ;;
1403e91c793cSCole Robinson  --disable-tpm) tpm="no"
1404e91c793cSCole Robinson  ;;
1405ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1406ab214c29SStefan Berger  ;;
14070a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
14080a12ec87SRichard W.M. Jones  ;;
14090a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
14100a12ec87SRichard W.M. Jones  ;;
1411ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1412ed1701c6SDr. David Alan Gilbert  ;;
1413ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1414ed1701c6SDr. David Alan Gilbert  ;;
1415a99d57bbSWanlong Gao  --disable-numa) numa="no"
1416a99d57bbSWanlong Gao  ;;
1417a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1418a99d57bbSWanlong Gao  ;;
1419ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1420ed279a06SKlim Kireev  ;;
1421ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1422ed279a06SKlim Kireev  ;;
14232847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14242847b469SFam Zheng  ;;
14252847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14262847b469SFam Zheng  ;;
14277b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14287b01cb97SAlexandre Derumier  ;;
14297b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14307b01cb97SAlexandre Derumier  ;;
1431a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1432a6b1d4c0SChanglong Xie  ;;
1433a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1434a6b1d4c0SChanglong Xie  ;;
1435da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1436da92c3ffSAshish Mittal  ;;
1437da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1438da92c3ffSAshish Mittal  ;;
14392f740136SJeff Cody  --disable-bochs) bochs="no"
14402f740136SJeff Cody  ;;
14412f740136SJeff Cody  --enable-bochs) bochs="yes"
14422f740136SJeff Cody  ;;
14432f740136SJeff Cody  --disable-cloop) cloop="no"
14442f740136SJeff Cody  ;;
14452f740136SJeff Cody  --enable-cloop) cloop="yes"
14462f740136SJeff Cody  ;;
14472f740136SJeff Cody  --disable-dmg) dmg="no"
14482f740136SJeff Cody  ;;
14492f740136SJeff Cody  --enable-dmg) dmg="yes"
14502f740136SJeff Cody  ;;
14512f740136SJeff Cody  --disable-qcow1) qcow1="no"
14522f740136SJeff Cody  ;;
14532f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14542f740136SJeff Cody  ;;
14552f740136SJeff Cody  --disable-vdi) vdi="no"
14562f740136SJeff Cody  ;;
14572f740136SJeff Cody  --enable-vdi) vdi="yes"
14582f740136SJeff Cody  ;;
14592f740136SJeff Cody  --disable-vvfat) vvfat="no"
14602f740136SJeff Cody  ;;
14612f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14622f740136SJeff Cody  ;;
14632f740136SJeff Cody  --disable-qed) qed="no"
14642f740136SJeff Cody  ;;
14652f740136SJeff Cody  --enable-qed) qed="yes"
14662f740136SJeff Cody  ;;
14672f740136SJeff Cody  --disable-parallels) parallels="no"
14682f740136SJeff Cody  ;;
14692f740136SJeff Cody  --enable-parallels) parallels="yes"
14702f740136SJeff Cody  ;;
14712f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14722f740136SJeff Cody  ;;
14732f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14742f740136SJeff Cody  ;;
1475e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1476e6a74868SMarc-André Lureau  ;;
1477e6a74868SMarc-André Lureau  --enable-vhost-user)
1478e6a74868SMarc-André Lureau      vhost_user="yes"
1479e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1480e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1481e6a74868SMarc-André Lureau      fi
1482e6a74868SMarc-André Lureau  ;;
14838ca80760SRichard Henderson  --disable-capstone) capstone="no"
14848ca80760SRichard Henderson  ;;
14858ca80760SRichard Henderson  --enable-capstone) capstone="yes"
14868ca80760SRichard Henderson  ;;
1487e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1488e219c499SRichard Henderson  ;;
1489e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1490e219c499SRichard Henderson  ;;
1491cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1492cc84d63aSDaniel P. Berrange  ;;
1493f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1494f62bbee5SDaniel P. Berrange  ;;
1495f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1496f62bbee5SDaniel P. Berrange  ;;
1497ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1498ba59fb77SPaolo Bonzini  ;;
1499ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1500ba59fb77SPaolo Bonzini  ;;
150117824406SJunyan He  --enable-libpmem) libpmem=yes
150217824406SJunyan He  ;;
150317824406SJunyan He  --disable-libpmem) libpmem=no
150417824406SJunyan He  ;;
15052d2ad6d0SFam Zheng  *)
15062d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15072d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15082d2ad6d0SFam Zheng      exit 1
15097f1559c6Sbalrog  ;;
15107d13299dSbellard  esac
15117d13299dSbellarddone
15127d13299dSbellard
1513e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1514e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1515e6a74868SMarc-André Lureau        vhost_user="no"
1516e6a74868SMarc-André Lureau    else
1517e6a74868SMarc-André Lureau        vhost_user="yes"
1518e6a74868SMarc-André Lureau    fi
1519e6a74868SMarc-André Lureaufi
1520e6a74868SMarc-André Lureau
152140293e58Sbellardcase "$cpu" in
1522e3608d66SRichard Henderson    ppc)
1523e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1524e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
152513a5abe2SAlex Bennée           cross_cc_powerpc=$cc
152613a5abe2SAlex Bennée           cross_cc_cflags_powerpc=$CPU_CFLAGS
1527e3608d66SRichard Henderson           ;;
1528e3608d66SRichard Henderson    ppc64)
1529e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1530e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
153113a5abe2SAlex Bennée           cross_cc_ppc64=$cc
153213a5abe2SAlex Bennée           cross_cc_cflags_ppc64=$CPU_CFLAGS
1533e3608d66SRichard Henderson           ;;
15349b9c37c3SRichard Henderson    sparc)
1535f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1536f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
153713a5abe2SAlex Bennée           cross_cc_sparc=$cc
153813a5abe2SAlex Bennée           cross_cc_cflags_sparc=$CPU_CFLAGS
15393142255cSblueswir1           ;;
1540ed968ff1SJuan Quintela    sparc64)
154179f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1542f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
154313a5abe2SAlex Bennée           cross_cc_sparc64=$cc
154413a5abe2SAlex Bennée           cross_cc_cflags_sparc64=$CPU_CFLAGS
15453142255cSblueswir1           ;;
154676d83bdeSths    s390)
1547061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
154828d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
154913a5abe2SAlex Bennée           cross_cc_s390=$cc
155013a5abe2SAlex Bennée           cross_cc_cflags_s390=$CPU_CFLAGS
155128d7cc49SRichard Henderson           ;;
155228d7cc49SRichard Henderson    s390x)
1553061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
155428d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
155513a5abe2SAlex Bennée           cross_cc_s390x=$cc
155613a5abe2SAlex Bennée           cross_cc_cflags_s390x=$CPU_CFLAGS
155776d83bdeSths           ;;
155840293e58Sbellard    i386)
155979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
15600c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
1561716a507cSAlex Bennée           cross_cc_i386=$cc
1562716a507cSAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
156340293e58Sbellard           ;;
156440293e58Sbellard    x86_64)
15657ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15667ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
15677ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
15687ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
15690c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
1570716a507cSAlex Bennée           cross_cc_x86_64=$cc
1571716a507cSAlex Bennée           cross_cc_cflags_x86_64=$CPU_CFLAGS
1572379f6698SPaul Brook           ;;
1573c72b26ecSRichard Henderson    x32)
1574c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1575c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1576716a507cSAlex Bennée           cross_cc_i386=$cc
157713a5abe2SAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
1578c72b26ecSRichard Henderson           ;;
157930163d89SPeter Maydell    # No special flags required for other host CPUs
15803142255cSblueswir1esac
15813142255cSblueswir1
158279f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
158379f3b12fSPeter Crosthwaite
1584affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1585affc88ccSPeter Maydell# support, even if we're using TCI.
1586affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1587affc88ccSPeter Maydell  bsd_user="no"
1588affc88ccSPeter Maydell  linux_user="no"
1589affc88ccSPeter Maydellfi
1590affc88ccSPeter Maydell
159160e0df25SPeter Maydelldefault_target_list=""
159260e0df25SPeter Maydell
15936e92f823SPeter Maydellmak_wilds=""
15946e92f823SPeter Maydell
159560e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
15966e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
159760e0df25SPeter Maydellfi
159860e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
15996e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
160060e0df25SPeter Maydellfi
160160e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
16026e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
160360e0df25SPeter Maydellfi
160460e0df25SPeter Maydell
16056e92f823SPeter Maydellfor config in $mak_wilds; do
16066e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
16076e92f823SPeter Maydelldone
16086e92f823SPeter Maydell
1609c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
161064a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1611c53eeaf7SStefan Hajnoczi
1612af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1613af5db58eSpbrookcat << EOF
1614af5db58eSpbrook
1615af5db58eSpbrookUsage: configure [options]
1616af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1617af5db58eSpbrook
161808fb77edSStefan WeilStandard options:
161908fb77edSStefan Weil  --help                   print this message
162008fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
162108fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
162208fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
162308fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
162408fb77edSStefan Weil$(echo Available targets: $default_target_list | \
162508fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
162608fb77edSStefan Weil
162708fb77edSStefan WeilAdvanced options (experts only):
162808fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
162908fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
163008fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
163108fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
163208fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
163308fb77edSStefan Weil                           build time
163408fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
163508fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
163608fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
163711cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
163808fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1639d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1640d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
164108fb77edSStefan Weil  --make=MAKE              use specified make [$make]
164208fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
164308fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
164408fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1645db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
164608fb77edSStefan Weil  --static                 enable static build [$static]
164708fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
164808fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
164908fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
165008fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
165108fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1652db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
165308fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
165408fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
16553d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1656e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1657db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
165808fb77edSStefan Weil  --enable-debug           enable common debug build options
1659247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
166008fb77edSStefan Weil  --disable-strip          disable stripping binaries
166108fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
166263678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
166308fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
166408fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
166508fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
166608fb77edSStefan Weil  --block-drv-rw-whitelist=L
166708fb77edSStefan Weil                           set block driver read-write whitelist
166808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
166908fb77edSStefan Weil  --block-drv-ro-whitelist=L
167008fb77edSStefan Weil                           set block driver read-only whitelist
167108fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
16725b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1673c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
167408fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
167508fb77edSStefan Weil                           Default:trace-<pid>
1676c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1677c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
16785a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1679c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1680c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
168108fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
168233c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
168308fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
168408fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1685c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1686c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1687c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1688a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1689c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1690c12d66aaSLin Ma  --enable-profiler        profiler support
1691c12d66aaSLin Ma  --enable-debug-stack-usage
1692c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1693c23f23b9SMichael Tokarev
1694c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1695c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1696c23f23b9SMichael Tokarev
1697c23f23b9SMichael Tokarev  system          all system emulation targets
1698c23f23b9SMichael Tokarev  user            supported user emulation targets
1699c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1700c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1701c23f23b9SMichael Tokarev  docs            build documentation
1702c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1703c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1704c23f23b9SMichael Tokarev  pie             Position Independent Executables
1705c23f23b9SMichael Tokarev  modules         modules support
1706c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1707c23f23b9SMichael Tokarev  debug-info      debugging information
1708c23f23b9SMichael Tokarev  sparse          sparse checker
1709c23f23b9SMichael Tokarev
1710ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
171191bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
171291bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1713c23f23b9SMichael Tokarev  sdl             SDL UI
1714c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1715a442fe2fSDaniel P. Berrangé  sdl_image       SDL Image support for icons
1716c23f23b9SMichael Tokarev  gtk             gtk UI
1717c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1718c23f23b9SMichael Tokarev  curses          curses UI
1719c23f23b9SMichael Tokarev  vnc             VNC UI support
1720c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1721c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1722c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1723c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1724c23f23b9SMichael Tokarev  virtfs          VirtFS
1725fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1726c23f23b9SMichael Tokarev  xen             xen backend driver support
172770c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1728c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1729c23f23b9SMichael Tokarev  curl            curl connectivity
1730a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1731c23f23b9SMichael Tokarev  fdt             fdt device tree
1732c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1733c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1734b0cb0a66SVincent Palatin  hax             HAX acceleration support
1735c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1736d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
173721ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
173821ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1739c23f23b9SMichael Tokarev  vde             support for vde network
1740c23f23b9SMichael Tokarev  netmap          support for netmap network
1741c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1742c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1743c23f23b9SMichael Tokarev  attr            attr and xattr support
1744c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1745042cea27SGonglei  vhost-crypto    vhost-crypto acceleration support
1746c23f23b9SMichael Tokarev  spice           spice
1747c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1748c23f23b9SMichael Tokarev  libiscsi        iscsi support
1749c23f23b9SMichael Tokarev  libnfs          nfs support
17507b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1751c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1752ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1753c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1754c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1755c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1756c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1757c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
175883bc1f97SJulio Faracco  lzfse           support of lzfse compression library
175983bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
1760c23f23b9SMichael Tokarev  seccomp         seccomp support
1761c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1762c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1763c23f23b9SMichael Tokarev  tpm             TPM support
1764c23f23b9SMichael Tokarev  libssh2         ssh block device support
1765c23f23b9SMichael Tokarev  numa            libnuma support
1766ed279a06SKlim Kireev  libxml2         for Parallels image format
1767c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
17687b01cb97SAlexandre Derumier  jemalloc        jemalloc support
176986583a07SLiam Merwick  avx2            AVX2 optimization support
1770a6b1d4c0SChanglong Xie  replication     replication support
1771c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1772c12d66aaSLin Ma  opengl          opengl support
1773c12d66aaSLin Ma  virglrenderer   virgl rendering support
1774c12d66aaSLin Ma  xfsctl          xfsctl support
1775c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1776c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1777da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
17782f740136SJeff Cody  bochs           bochs image format support
17792f740136SJeff Cody  cloop           cloop image format support
17802f740136SJeff Cody  dmg             dmg image format support
17812f740136SJeff Cody  qcow1           qcow v1 image format support
17822f740136SJeff Cody  vdi             vdi image format support
17832f740136SJeff Cody  vvfat           vvfat image format support
17842f740136SJeff Cody  qed             qed image format support
17852f740136SJeff Cody  parallels       parallels image format support
17862f740136SJeff Cody  sheepdog        sheepdog block driver support
1787f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1788e6a74868SMarc-André Lureau  vhost-user      vhost-user support
17898ca80760SRichard Henderson  capstone        capstone disassembler support
1790ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
179117824406SJunyan He  libpmem         libpmem support
179208fb77edSStefan Weil
179308fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1794af5db58eSpbrookEOF
17952d2ad6d0SFam Zhengexit 0
1796af5db58eSpbrookfi
1797af5db58eSpbrook
1798c53eeaf7SStefan Hajnocziif ! has $python; then
1799c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1800c53eeaf7SStefan Hajnoczifi
1801c53eeaf7SStefan Hajnoczi
1802c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1803c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
18047f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
18057f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1806c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1807c53eeaf7SStefan Hajnoczifi
1808c53eeaf7SStefan Hajnoczi
1809755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1810755ee70fSCleber Rosapython_version=$($python -V 2>&1 | sed -e 's/Python\ //')
1811755ee70fSCleber Rosa
1812c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1813c53eeaf7SStefan Hajnoczipython="$python -B"
1814c53eeaf7SStefan Hajnoczi
18159aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
18169aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
18179aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
18189aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
18199aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
18209aae6e54SDaniel Henrique Barbozaif compile_object ; then
18219aae6e54SDaniel Henrique Barboza  : C compiler works ok
18229aae6e54SDaniel Henrique Barbozaelse
18239aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
18249aae6e54SDaniel Henrique Barbozafi
18259aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
18269aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
18279aae6e54SDaniel Henrique Barbozafi
18289aae6e54SDaniel Henrique Barboza
1829359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1830359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1831359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1832359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1833359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1834359bc95dSPeter Maydell    else
183576ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1836359bc95dSPeter Maydell    fi
1837359bc95dSPeter Maydellfi
1838359bc95dSPeter Maydell
18399c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
18409c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
18419c83ffd8SPeter Maydellif test -z "$werror" ; then
18429c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1843e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
18449c83ffd8SPeter Maydell        werror="yes"
18459c83ffd8SPeter Maydell    else
18469c83ffd8SPeter Maydell        werror="no"
18479c83ffd8SPeter Maydell    fi
18489c83ffd8SPeter Maydellfi
18499c83ffd8SPeter Maydell
1850fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1851fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1852fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1853fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1854fb59dabdSPeter Maydell    # host OS we should stop now.
1855951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1856fb59dabdSPeter Maydellfi
1857fb59dabdSPeter Maydell
1858efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1859efc6c070SThomas Huthcat > $TMPC << EOF
1860efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1861efc6c070SThomas Huth# ifdef __apple_build_version__
1862efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1863efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
1864efc6c070SThomas Huth#  endif
1865efc6c070SThomas Huth# else
1866efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1867efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
1868efc6c070SThomas Huth#  endif
1869efc6c070SThomas Huth# endif
1870efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1871efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1872efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
1873efc6c070SThomas Huth# endif
1874efc6c070SThomas Huth#else
1875efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1876efc6c070SThomas Huth#endif
1877efc6c070SThomas Huthint main (void) { return 0; }
1878efc6c070SThomas HuthEOF
1879efc6c070SThomas Huthif ! compile_prog "" "" ; then
1880efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1881efc6c070SThomas Huthfi
1882efc6c070SThomas Huth
18838d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
18848d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1885ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1886435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1887b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
188871429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
18890e39c4aaSGerd Hoffmanngcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
18906ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
18916ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
18926ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
18936ca026cbSPeter Maydell# so it's too error prone.
189493b25869SJohn Snow
189593b25869SJohn Snowcc_has_warning_flag() {
189693b25869SJohn Snow    write_c_skeleton;
189793b25869SJohn Snow
1898a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1899a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1900a1d29d6cSPeter Maydell    # warning options).
190193b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
190293b25869SJohn Snow    compile_prog "-Werror $optflag" ""
190393b25869SJohn Snow}
190493b25869SJohn Snow
190593b25869SJohn Snowfor flag in $gcc_flags; do
190693b25869SJohn Snow    if cc_has_warning_flag $flag ; then
19078d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19088d05095cSPaolo Bonzini    fi
19098d05095cSPaolo Bonzinidone
19108d05095cSPaolo Bonzini
191163678e17SSteven Noonanif test "$stack_protector" != "no"; then
1912fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1913fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1914fccd35a0SRodrigo Rebello{
1915fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1916fccd35a0SRodrigo Rebello    while (*c) {
1917fccd35a0SRodrigo Rebello        *p++ = *c++;
1918fccd35a0SRodrigo Rebello    }
1919fccd35a0SRodrigo Rebello    return 0;
1920fccd35a0SRodrigo Rebello}
1921fccd35a0SRodrigo RebelloEOF
192263678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
19233b463a3fSMiroslav Rezanina  sp_on=0
192463678e17SSteven Noonan  for flag in $gcc_flags; do
1925590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1926590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1927590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1928590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
192963678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19303b463a3fSMiroslav Rezanina      sp_on=1
193163678e17SSteven Noonan      break
193263678e17SSteven Noonan    fi
193363678e17SSteven Noonan  done
19343b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
19353b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
19363b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
19373b463a3fSMiroslav Rezanina    fi
19383b463a3fSMiroslav Rezanina  fi
193937746c5eSMarc-André Lureaufi
194037746c5eSMarc-André Lureau
194120bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
194220bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
194320bc94a2SPaolo Bonzinicat > $TMPC << EOF
194420bc94a2SPaolo Bonzinistruct {
194520bc94a2SPaolo Bonzini  int a[2];
194620bc94a2SPaolo Bonzini} x = {0};
194720bc94a2SPaolo BonziniEOF
194820bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
194920bc94a2SPaolo Bonzini  :
195020bc94a2SPaolo Bonzinielse
195120bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
195220bc94a2SPaolo Bonzinifi
195320bc94a2SPaolo Bonzini
1954d376e9deSThomas Huth# Static linking is not possible with modules or PIE
195540d6444eSAvi Kivityif test "$static" = "yes" ; then
1956aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1957aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1958aa0d1f44SPaolo Bonzini  fi
195940d6444eSAvi Kivity  if test "$pie" = "yes" ; then
196076ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
196140d6444eSAvi Kivity  else
196240d6444eSAvi Kivity    pie="no"
196340d6444eSAvi Kivity  fi
196440d6444eSAvi Kivityfi
196540d6444eSAvi Kivity
1966768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1967768b7855SEmilio G. Cota  cat > $TMPC << EOF
1968768b7855SEmilio G. Cotastatic __thread int tls_var;
1969768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1970768b7855SEmilio G. CotaEOF
1971768b7855SEmilio G. Cota
1972768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1973768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1974768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1975768b7855SEmilio G. Cotafi
1976768b7855SEmilio G. Cota
197740d6444eSAvi Kivityif test "$pie" = ""; then
197840d6444eSAvi Kivity  case "$cpu-$targetos" in
1979c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
198040d6444eSAvi Kivity      ;;
198140d6444eSAvi Kivity    *)
198240d6444eSAvi Kivity      pie="no"
198340d6444eSAvi Kivity      ;;
198440d6444eSAvi Kivity  esac
198540d6444eSAvi Kivityfi
198640d6444eSAvi Kivity
198740d6444eSAvi Kivityif test "$pie" != "no" ; then
198840d6444eSAvi Kivity  cat > $TMPC << EOF
198921d4a791SAvi Kivity
199021d4a791SAvi Kivity#ifdef __linux__
199121d4a791SAvi Kivity#  define THREAD __thread
199221d4a791SAvi Kivity#else
199321d4a791SAvi Kivity#  define THREAD
199421d4a791SAvi Kivity#endif
199521d4a791SAvi Kivity
199621d4a791SAvi Kivitystatic THREAD int tls_var;
199721d4a791SAvi Kivity
199821d4a791SAvi Kivityint main(void) { return tls_var; }
199921d4a791SAvi Kivity
200040d6444eSAvi KivityEOF
200140d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
200240d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
200340d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
200440d6444eSAvi Kivity    pie="yes"
200540d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
200640d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
200740d6444eSAvi Kivity    fi
200840d6444eSAvi Kivity  else
200940d6444eSAvi Kivity    if test "$pie" = "yes"; then
201076ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
201140d6444eSAvi Kivity    else
201240d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
201340d6444eSAvi Kivity      pie="no"
201440d6444eSAvi Kivity    fi
201540d6444eSAvi Kivity  fi
201646eef33bSBrad
2017e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
201846eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
201946eef33bSBrad    LDFLAGS_NOPIE="-nopie"
202046eef33bSBrad  fi
202140d6444eSAvi Kivityfi
202240d6444eSAvi Kivity
202309dada40SPaolo Bonzini##########################################
202409dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
202509dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
202609dada40SPaolo Bonzini# specification is necessary
202709dada40SPaolo Bonzini
202809dada40SPaolo Bonziniif test "$cpu" = "i386"; then
202909dada40SPaolo Bonzini  cat > $TMPC << EOF
203009dada40SPaolo Bonzinistatic int sfaa(int *ptr)
203109dada40SPaolo Bonzini{
203209dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
203309dada40SPaolo Bonzini}
203409dada40SPaolo Bonzini
203509dada40SPaolo Bonziniint main(void)
203609dada40SPaolo Bonzini{
203709dada40SPaolo Bonzini  int val = 42;
20381405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
203909dada40SPaolo Bonzini  sfaa(&val);
204009dada40SPaolo Bonzini  return val;
204109dada40SPaolo Bonzini}
204209dada40SPaolo BonziniEOF
204309dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
204409dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
204509dada40SPaolo Bonzini  fi
204609dada40SPaolo Bonzinifi
204709dada40SPaolo Bonzini
204809dada40SPaolo Bonzini#########################################
2049ec530c81Sbellard# Solaris specific configure tool chain decisions
205009dada40SPaolo Bonzini
2051ec530c81Sbellardif test "$solaris" = "yes" ; then
20526792aa11SLoïc Minier  if has $install; then
20536792aa11SLoïc Minier    :
20546792aa11SLoïc Minier  else
205576ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
205676ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
205776ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2058ec530c81Sbellard  fi
205989138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
206076ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
206176ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
206276ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2063ec530c81Sbellard  fi
20646792aa11SLoïc Minier  if has ar; then
20656792aa11SLoïc Minier    :
20666792aa11SLoïc Minier  else
2067ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
206876ad07a4SPeter Maydell      error_exit "No path includes ar" \
206976ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2070ec530c81Sbellard    fi
207176ad07a4SPeter Maydell    error_exit "No path includes ar"
2072ec530c81Sbellard  fi
2073ec530c81Sbellardfi
2074ec530c81Sbellard
2075afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2076d880a3baSPaolo Bonzini    for target in $default_target_list; do
2077d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2078d880a3baSPaolo Bonzini            target_list="$target_list $target"
2079d880a3baSPaolo Bonzini    done
2080d880a3baSPaolo Bonzini    target_list="${target_list# }"
2081121afa9eSAnthony Liguorielse
208289138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2083d880a3baSPaolo Bonzini    for target in $target_list; do
208425b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
208525b48338SPeter Maydell        # friendly error message than if we let it fall through.
208625b48338SPeter Maydell        case " $default_target_list " in
208725b48338SPeter Maydell            *" $target "*)
208825b48338SPeter Maydell                ;;
208925b48338SPeter Maydell            *)
209025b48338SPeter Maydell                error_exit "Unknown target name '$target'"
209125b48338SPeter Maydell                ;;
209225b48338SPeter Maydell        esac
2093d880a3baSPaolo Bonzini        supported_target $target || exit 1
209425b48338SPeter Maydell    done
2095d880a3baSPaolo Bonzinifi
209625b48338SPeter Maydell
2097f55fe278SPaolo Bonzini# see if system emulation was really requested
2098f55fe278SPaolo Bonzinicase " $target_list " in
2099f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2100f55fe278SPaolo Bonzini  ;;
2101f55fe278SPaolo Bonzini  *) softmmu=no
2102f55fe278SPaolo Bonzini  ;;
2103f55fe278SPaolo Bonziniesac
21045327cf48Sbellard
2105249247c9SJuan Quintelafeature_not_found() {
2106249247c9SJuan Quintela  feature=$1
210721684af0SStewart Smith  remedy=$2
2108249247c9SJuan Quintela
210976ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
211021684af0SStewart Smith      "configure was not able to find it." \
211121684af0SStewart Smith      "$remedy"
2112249247c9SJuan Quintela}
2113249247c9SJuan Quintela
21147d13299dSbellard# ---
21157d13299dSbellard# big/little endian test
21167d13299dSbellardcat > $TMPC << EOF
211761cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
211861cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
211961cc919fSMike Frysingerextern int foo(short *, short *);
212061cc919fSMike Frysingerint main(int argc, char *argv[]) {
212161cc919fSMike Frysinger    return foo(big_endian, little_endian);
21227d13299dSbellard}
21237d13299dSbellardEOF
21247d13299dSbellard
212561cc919fSMike Frysingerif compile_object ; then
212612f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
212761cc919fSMike Frysinger        bigendian="yes"
212812f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
212961cc919fSMike Frysinger        bigendian="no"
21307d13299dSbellard    else
21317d13299dSbellard        echo big/little test failed
21327d13299dSbellard    fi
21337d13299dSbellardelse
213461cc919fSMike Frysinger    echo big/little test failed
21357d13299dSbellardfi
21367d13299dSbellard
2137b0a47e79SJuan Quintela##########################################
2138a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2139a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2140a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2141a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2142a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2143a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2144a30878e7SPeter Maydell    fi
2145a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2146a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2147a30878e7SPeter Maydell    fi
2148a30878e7SPeter Maydell    gtk=no
2149a30878e7SPeter Maydell    sdl=no
2150a30878e7SPeter Maydellfi
2151a30878e7SPeter Maydell
21526b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
21536b39b063SEric Blakecat > $TMPC << EOF
21546b39b063SEric Blake#include <stdint.h>
21556b39b063SEric Blake#include <stdio.h>
21566b39b063SEric Blakeint main(int argc, char *argv[]) {
21576b39b063SEric Blake    return printf("%zu", SIZE_MAX);
21586b39b063SEric Blake}
21596b39b063SEric BlakeEOF
21606b39b063SEric Blakehave_broken_size_max=no
21616b39b063SEric Blakeif ! compile_object -Werror ; then
21626b39b063SEric Blake    have_broken_size_max=yes
21636b39b063SEric Blakefi
21646b39b063SEric Blake
2165a30878e7SPeter Maydell##########################################
2166015a33bdSGonglei# L2TPV3 probe
2167015a33bdSGonglei
2168015a33bdSGongleicat > $TMPC <<EOF
2169015a33bdSGonglei#include <sys/socket.h>
2170bff6cb72SMichael Tokarev#include <linux/ip.h>
2171015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2172015a33bdSGongleiEOF
2173015a33bdSGongleiif compile_prog "" "" ; then
2174015a33bdSGonglei  l2tpv3=yes
2175015a33bdSGongleielse
2176015a33bdSGonglei  l2tpv3=no
2177015a33bdSGongleifi
2178015a33bdSGonglei
2179015a33bdSGonglei##########################################
21804d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
21814d9310f4SDaniel P. Berrange
21824d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
21834d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
21844d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
21854d9310f4SDaniel P. Berrange    #
21864d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
21874d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
21884d9310f4SDaniel P. Berrange    #
21894d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
21904d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
21914d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
21924d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
21934d9310f4SDaniel P. Berrange    # that for you.
21944d9310f4SDaniel P. Berrange    #
21954d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
21964d9310f4SDaniel P. Berrange    # are not in fact redundant.
21974d9310f4SDaniel P. Berrangecat > $TMPC << EOF
21984d9310f4SDaniel P. Berrange#include <unistd.h>
21994d9310f4SDaniel P. Berrange#include <time.h>
22004d9310f4SDaniel P. Berrange#undef localtime_r
22014d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
22024d9310f4SDaniel P. BerrangeEOF
22034d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
22044d9310f4SDaniel P. Berrange        localtime_r="yes"
22054d9310f4SDaniel P. Berrange    else
22064d9310f4SDaniel P. Berrange        localtime_r="no"
22074d9310f4SDaniel P. Berrange    fi
22084d9310f4SDaniel P. Berrangefi
22094d9310f4SDaniel P. Berrange
22104d9310f4SDaniel P. Berrange##########################################
2211779ab5e3SStefan Weil# pkg-config probe
2212779ab5e3SStefan Weil
2213779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
221476ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2215779ab5e3SStefan Weilfi
2216779ab5e3SStefan Weil
2217779ab5e3SStefan Weil##########################################
2218b0a47e79SJuan Quintela# NPTL probe
2219b0a47e79SJuan Quintela
222024cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2221bd0c5661Spbrook  cat > $TMPC <<EOF
2222bd0c5661Spbrook#include <sched.h>
222330813ceaSpbrook#include <linux/futex.h>
2224182eacc0SStefan Weilint main(void) {
2225bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2226bd0c5661Spbrook#error bork
2227bd0c5661Spbrook#endif
2228182eacc0SStefan Weil  return 0;
2229bd0c5661Spbrook}
2230bd0c5661SpbrookEOF
223124cb36a6SPeter Maydell  if ! compile_object ; then
223221684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2233b0a47e79SJuan Quintela  fi
2234bd0c5661Spbrookfi
2235bd0c5661Spbrook
2236ac62922eSbalrog##########################################
2237607dacd0Sqiaonuohan# lzo check
2238607dacd0Sqiaonuohan
2239607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2240607dacd0Sqiaonuohan    cat > $TMPC << EOF
2241607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2242607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2243607dacd0SqiaonuohanEOF
2244607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2245607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2246b25c9dffSStefan Weil        lzo="yes"
2247b25c9dffSStefan Weil    else
2248b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2249b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2250b25c9dffSStefan Weil        fi
2251b25c9dffSStefan Weil        lzo="no"
2252b25c9dffSStefan Weil    fi
2253607dacd0Sqiaonuohanfi
2254607dacd0Sqiaonuohan
2255607dacd0Sqiaonuohan##########################################
2256607dacd0Sqiaonuohan# snappy check
2257607dacd0Sqiaonuohan
2258607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2259607dacd0Sqiaonuohan    cat > $TMPC << EOF
2260607dacd0Sqiaonuohan#include <snappy-c.h>
2261607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2262607dacd0SqiaonuohanEOF
2263607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2264607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2265b25c9dffSStefan Weil        snappy="yes"
2266b25c9dffSStefan Weil    else
2267b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2268b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2269b25c9dffSStefan Weil        fi
2270b25c9dffSStefan Weil        snappy="no"
2271b25c9dffSStefan Weil    fi
2272607dacd0Sqiaonuohanfi
2273607dacd0Sqiaonuohan
2274607dacd0Sqiaonuohan##########################################
22756b383c08SPeter Wu# bzip2 check
22766b383c08SPeter Wu
22776b383c08SPeter Wuif test "$bzip2" != "no" ; then
22786b383c08SPeter Wu    cat > $TMPC << EOF
22796b383c08SPeter Wu#include <bzlib.h>
22806b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
22816b383c08SPeter WuEOF
22826b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
22836b383c08SPeter Wu        bzip2="yes"
22846b383c08SPeter Wu    else
22856b383c08SPeter Wu        if test "$bzip2" = "yes"; then
22866b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
22876b383c08SPeter Wu        fi
22886b383c08SPeter Wu        bzip2="no"
22896b383c08SPeter Wu    fi
22906b383c08SPeter Wufi
22916b383c08SPeter Wu
22926b383c08SPeter Wu##########################################
229383bc1f97SJulio Faracco# lzfse check
229483bc1f97SJulio Faracco
229583bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
229683bc1f97SJulio Faracco    cat > $TMPC << EOF
229783bc1f97SJulio Faracco#include <lzfse.h>
229883bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
229983bc1f97SJulio FaraccoEOF
230083bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
230183bc1f97SJulio Faracco        lzfse="yes"
230283bc1f97SJulio Faracco    else
230383bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
230483bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
230583bc1f97SJulio Faracco        fi
230683bc1f97SJulio Faracco        lzfse="no"
230783bc1f97SJulio Faracco    fi
230883bc1f97SJulio Faraccofi
230983bc1f97SJulio Faracco
231083bc1f97SJulio Faracco##########################################
2311f794573eSEduardo Otubo# libseccomp check
2312f794573eSEduardo Otubo
2313d0699bd3SMarc-André Lureaulibseccomp_minver="2.2.0"
2314f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2315693e5910SAndrew Jones    case "$cpu" in
2316d0699bd3SMarc-André Lureau    i386|x86_64|mips)
23175ce43972SJames Hogan        ;;
2318693e5910SAndrew Jones    arm|aarch64)
2319693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2320693e5910SAndrew Jones        ;;
23213aa35fcfSThomas Huth    ppc|ppc64|s390x)
23223e684455SMichael Strosaker        libseccomp_minver="2.3.0"
23233e684455SMichael Strosaker        ;;
2324693e5910SAndrew Jones    *)
2325693e5910SAndrew Jones        libseccomp_minver=""
2326693e5910SAndrew Jones        ;;
2327693e5910SAndrew Jones    esac
2328693e5910SAndrew Jones
2329693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2330693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2331c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2332c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2333f794573eSEduardo Otubo        seccomp="yes"
2334f794573eSEduardo Otubo    else
2335f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2336693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2337693e5910SAndrew Jones                feature_not_found "libseccomp" \
2338693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2339693e5910SAndrew Jones            else
2340693e5910SAndrew Jones                feature_not_found "libseccomp" \
2341693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2342693e5910SAndrew Jones            fi
2343896848f0SEduardo Otubo        fi
2344e84d5956SYann E. MORIN        seccomp="no"
2345f794573eSEduardo Otubo    fi
2346f794573eSEduardo Otubofi
2347f794573eSEduardo Otubo##########################################
2348e37630caSaliguori# xen probe
2349e37630caSaliguori
2350fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2351c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2352c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2353c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2354c1cdd9d5SJuergen Gross
2355c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2356c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2357c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2358c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2359c1cdd9d5SJuergen Gross    xen=yes
2360c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2361c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
236258ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
236358ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
236458ea9a7aSAnthony PERARD    fi
2365c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2366c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2367c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2368c1cdd9d5SJuergen Gross  else
2369c1cdd9d5SJuergen Gross
2370b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2371d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2372d5b93ddfSAnthony PERARD
237350ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
237450ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
237550ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
237650ced5b3SStefan Weil
237750ced5b3SStefan Weil    # Xen (any)
237850ced5b3SStefan Weil    cat > $TMPC <<EOF
237950ced5b3SStefan Weil#include <xenctrl.h>
238050ced5b3SStefan Weilint main(void) {
238150ced5b3SStefan Weil  return 0;
238250ced5b3SStefan Weil}
238350ced5b3SStefan WeilEOF
238450ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
238550ced5b3SStefan Weil      # Xen not found
238650ced5b3SStefan Weil      if test "$xen" = "yes" ; then
238721684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
238850ced5b3SStefan Weil      fi
238950ced5b3SStefan Weil      xen=no
239050ced5b3SStefan Weil
2391d5b93ddfSAnthony PERARD    # Xen unstable
239269deef08SPeter Maydell    elif
239369deef08SPeter Maydell        cat > $TMPC <<EOF &&
23942cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
23952cbf8903SRoss Lagerwall#define __XEN_TOOLS__
23962cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2397d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
23982cbf8903SRoss Lagerwallint main(void) {
23992cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2400d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
24012cbf8903SRoss Lagerwall
24022cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
24032cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
24042cbf8903SRoss Lagerwall
2405d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2406d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2407d3c49ebbSPaul Durrant
24082cbf8903SRoss Lagerwall  return 0;
24092cbf8903SRoss Lagerwall}
24102cbf8903SRoss LagerwallEOF
24112cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24122cbf8903SRoss Lagerwall      then
24132cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24142cbf8903SRoss Lagerwall      xen_ctrl_version=41100
24152cbf8903SRoss Lagerwall      xen=yes
24162cbf8903SRoss Lagerwall    elif
24172cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
24185ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
24195ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
242058ea9a7aSAnthony PERARD#include <xentoolcore.h>
24215ba3d756SIgor Druzhininint main(void) {
24225ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
24235ba3d756SIgor Druzhinin
24245ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
24255ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
242658ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
24275ba3d756SIgor Druzhinin
24285ba3d756SIgor Druzhinin  return 0;
24295ba3d756SIgor Druzhinin}
24305ba3d756SIgor DruzhininEOF
243158ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24325ba3d756SIgor Druzhinin      then
243358ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24345ba3d756SIgor Druzhinin      xen_ctrl_version=41000
24355ba3d756SIgor Druzhinin      xen=yes
24365ba3d756SIgor Druzhinin    elif
24375ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2438da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2439da8090ccSPaul Durrant#define __XEN_TOOLS__
2440da8090ccSPaul Durrant#include <xendevicemodel.h>
2441da8090ccSPaul Durrantint main(void) {
2442da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2443da8090ccSPaul Durrant
2444da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2445da8090ccSPaul Durrant  xendevicemodel_close(xd);
2446da8090ccSPaul Durrant
2447da8090ccSPaul Durrant  return 0;
2448da8090ccSPaul Durrant}
2449da8090ccSPaul DurrantEOF
2450da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2451da8090ccSPaul Durrant      then
2452da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2453f1167ee6SJuergen Gross      xen_ctrl_version=40900
2454da8090ccSPaul Durrant      xen=yes
2455da8090ccSPaul Durrant    elif
2456da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
24575eeb39c2SIan Campbell/*
24585eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
24595eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2460b6eb9b45SPaulina Szubarczyk *
2461b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2462b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2463b6eb9b45SPaulina Szubarczyk */
2464b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2465b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2466b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2467b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2468b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2469b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2470b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2471b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2472b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2473b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2474b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2475b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2476b6eb9b45SPaulina Szubarczyk#endif
2477b6eb9b45SPaulina Szubarczykint main(void) {
2478b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2479b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2480b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2481b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2482b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2483b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2484b6eb9b45SPaulina Szubarczyk
2485b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2486b6eb9b45SPaulina Szubarczyk
2487b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2488b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2489b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2490b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2491b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2492b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2493b6eb9b45SPaulina Szubarczyk
2494b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2495b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2496b6eb9b45SPaulina Szubarczyk
2497b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2498b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2499b6eb9b45SPaulina Szubarczyk
2500b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2501b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2502b6eb9b45SPaulina Szubarczyk
2503b6eb9b45SPaulina Szubarczyk  return 0;
2504b6eb9b45SPaulina Szubarczyk}
2505b6eb9b45SPaulina SzubarczykEOF
2506b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2507b6eb9b45SPaulina Szubarczyk      then
2508f1167ee6SJuergen Gross      xen_ctrl_version=40800
2509b6eb9b45SPaulina Szubarczyk      xen=yes
2510b6eb9b45SPaulina Szubarczyk    elif
2511b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2512b6eb9b45SPaulina Szubarczyk/*
2513b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2514b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
25155eeb39c2SIan Campbell */
25165eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
25175eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
25185eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25195eeb39c2SIan Campbell#include <xenctrl.h>
25205eeb39c2SIan Campbell#include <xenstore.h>
25215eeb39c2SIan Campbell#include <xenevtchn.h>
25225eeb39c2SIan Campbell#include <xengnttab.h>
25235eeb39c2SIan Campbell#include <xenforeignmemory.h>
25245eeb39c2SIan Campbell#include <stdint.h>
25255eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
25265eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
25275eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
25285eeb39c2SIan Campbell#endif
25295eeb39c2SIan Campbellint main(void) {
25305eeb39c2SIan Campbell  xc_interface *xc = NULL;
25315eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
25325eeb39c2SIan Campbell  xenevtchn_handle *xe;
25335eeb39c2SIan Campbell  xengnttab_handle *xg;
25345eeb39c2SIan Campbell  xen_domain_handle_t handle;
25355eeb39c2SIan Campbell
25365eeb39c2SIan Campbell  xs_daemon_open();
25375eeb39c2SIan Campbell
25385eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
25395eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
25405eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25415eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25425eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
25435eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
25445eeb39c2SIan Campbell
25455eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
25465eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
25475eeb39c2SIan Campbell
25485eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
25495eeb39c2SIan Campbell  xenevtchn_fd(xe);
25505eeb39c2SIan Campbell
25515eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
25525eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
25535eeb39c2SIan Campbell
25545eeb39c2SIan Campbell  return 0;
25555eeb39c2SIan Campbell}
25565eeb39c2SIan CampbellEOF
25575eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
25585eeb39c2SIan Campbell      then
2559f1167ee6SJuergen Gross      xen_ctrl_version=40701
25605eeb39c2SIan Campbell      xen=yes
25615eeb39c2SIan Campbell    elif
25625eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2563e37630caSaliguori#include <xenctrl.h>
2564cdadde39SRoger Pau Monne#include <stdint.h>
2565cdadde39SRoger Pau Monneint main(void) {
2566cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2567cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2568cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2569cdadde39SRoger Pau Monne  return 0;
2570cdadde39SRoger Pau Monne}
2571cdadde39SRoger Pau MonneEOF
2572cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2573cdadde39SRoger Pau Monne      then
2574f1167ee6SJuergen Gross      xen_ctrl_version=40700
2575cdadde39SRoger Pau Monne      xen=yes
2576cdadde39SRoger Pau Monne
2577cdadde39SRoger Pau Monne    # Xen 4.6
2578cdadde39SRoger Pau Monne    elif
2579cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2580cdadde39SRoger Pau Monne#include <xenctrl.h>
2581e108a3c1SAnthony PERARD#include <xenstore.h>
2582d5b93ddfSAnthony PERARD#include <stdint.h>
2583d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2584d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2585d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2586d5b93ddfSAnthony PERARD#endif
2587d5b93ddfSAnthony PERARDint main(void) {
2588d5b93ddfSAnthony PERARD  xc_interface *xc;
2589d5b93ddfSAnthony PERARD  xs_daemon_open();
2590d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2591d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2592d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2593b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25948688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2595d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
259620a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2597d8b441a3SJan Beulich  return 0;
2598d8b441a3SJan Beulich}
2599d8b441a3SJan BeulichEOF
2600d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2601d8b441a3SJan Beulich      then
2602f1167ee6SJuergen Gross      xen_ctrl_version=40600
2603d8b441a3SJan Beulich      xen=yes
2604d8b441a3SJan Beulich
2605d8b441a3SJan Beulich    # Xen 4.5
2606d8b441a3SJan Beulich    elif
2607d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2608d8b441a3SJan Beulich#include <xenctrl.h>
2609d8b441a3SJan Beulich#include <xenstore.h>
2610d8b441a3SJan Beulich#include <stdint.h>
2611d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2612d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2613d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2614d8b441a3SJan Beulich#endif
2615d8b441a3SJan Beulichint main(void) {
2616d8b441a3SJan Beulich  xc_interface *xc;
2617d8b441a3SJan Beulich  xs_daemon_open();
2618d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2619d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2620d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2621d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2622d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26233996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
26243996e85cSPaul Durrant  return 0;
26253996e85cSPaul Durrant}
26263996e85cSPaul DurrantEOF
26273996e85cSPaul Durrant        compile_prog "" "$xen_libs"
26283996e85cSPaul Durrant      then
2629f1167ee6SJuergen Gross      xen_ctrl_version=40500
26303996e85cSPaul Durrant      xen=yes
26313996e85cSPaul Durrant
26323996e85cSPaul Durrant    elif
26333996e85cSPaul Durrant        cat > $TMPC <<EOF &&
26343996e85cSPaul Durrant#include <xenctrl.h>
26353996e85cSPaul Durrant#include <xenstore.h>
26363996e85cSPaul Durrant#include <stdint.h>
26373996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
26383996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
26393996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
26403996e85cSPaul Durrant#endif
26413996e85cSPaul Durrantint main(void) {
26423996e85cSPaul Durrant  xc_interface *xc;
26433996e85cSPaul Durrant  xs_daemon_open();
26443996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
26453996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26463996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
26473996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26483996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26498688e065SStefano Stabellini  return 0;
26508688e065SStefano Stabellini}
26518688e065SStefano StabelliniEOF
26528688e065SStefano Stabellini        compile_prog "" "$xen_libs"
265369deef08SPeter Maydell      then
2654f1167ee6SJuergen Gross      xen_ctrl_version=40200
26558688e065SStefano Stabellini      xen=yes
26568688e065SStefano Stabellini
2657e37630caSaliguori    else
2658fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2659edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2660edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2661fc321b4bSJuan Quintela      fi
2662fc321b4bSJuan Quintela      xen=no
2663e37630caSaliguori    fi
2664d5b93ddfSAnthony PERARD
2665d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2666f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
26675eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
26685eeb39c2SIan Campbell      fi
2669d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2670d5b93ddfSAnthony PERARD    fi
2671e37630caSaliguori  fi
2672c1cdd9d5SJuergen Grossfi
2673e37630caSaliguori
2674eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2675edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2676eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2677eb6fda0fSAnthony PERARD  else
2678eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
267976ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
268076ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2681eb6fda0fSAnthony PERARD    fi
2682eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2683eb6fda0fSAnthony PERARD  fi
2684eb6fda0fSAnthony PERARDfi
2685eb6fda0fSAnthony PERARD
2686e37630caSaliguori##########################################
2687d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2688d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2689327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2690d661d9a4SJustin Terry (VM)        whpx="yes"
2691d661d9a4SJustin Terry (VM)    else
2692d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
269353537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2694d661d9a4SJustin Terry (VM)        fi
2695d661d9a4SJustin Terry (VM)        whpx="no"
2696d661d9a4SJustin Terry (VM)    fi
2697d661d9a4SJustin Terry (VM)fi
2698d661d9a4SJustin Terry (VM)
2699d661d9a4SJustin Terry (VM)##########################################
2700dfffc653SJuan Quintela# Sparse probe
2701dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
27020dba6195SLoïc Minier  if has cgcc; then
2703dfffc653SJuan Quintela    sparse=yes
2704dfffc653SJuan Quintela  else
2705dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
270621684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2707dfffc653SJuan Quintela    fi
2708dfffc653SJuan Quintela    sparse=no
2709dfffc653SJuan Quintela  fi
2710dfffc653SJuan Quintelafi
2711dfffc653SJuan Quintela
2712dfffc653SJuan Quintela##########################################
2713f676c67eSJeremy White# X11 probe
2714f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
27158781595bSGerd Hoffmann    have_x11=yes
271689138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
271789138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2718f676c67eSJeremy Whitefi
2719f676c67eSJeremy White
2720f676c67eSJeremy White##########################################
2721a4ccabcfSAnthony Liguori# GTK probe
2722a4ccabcfSAnthony Liguori
27235a464e6cSPeter Xuif test "$gtk" != "no"; then
272489d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
272589d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
272658296cb6SDaniel P. Berrangé    gtkversion="3.14.0"
2727bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
272889138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
272989138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
273089138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
27310a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
27328781595bSGerd Hoffmann            need_x11=yes
2733f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2734f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
27350a337ed0SGerd Hoffmann        fi
2736bbbf9bfbSStefan Weil        gtk="yes"
2737bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
27385fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2739bbbf9bfbSStefan Weil    else
2740bbbf9bfbSStefan Weil        gtk="no"
2741bbbf9bfbSStefan Weil    fi
2742bbbf9bfbSStefan Weilfi
2743bbbf9bfbSStefan Weil
2744ddbb0d09SDaniel P. Berrange
2745ddbb0d09SDaniel P. Berrange##########################################
2746ddbb0d09SDaniel P. Berrange# GNUTLS probe
2747ddbb0d09SDaniel P. Berrange
2748ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2749a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
275089138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
275189138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2752ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2753ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2754ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2755ddbb0d09SDaniel P. Berrange        gnutls="yes"
2756ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2757a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2758ddbb0d09SDaniel P. Berrange    else
2759ddbb0d09SDaniel P. Berrange        gnutls="no"
2760ddbb0d09SDaniel P. Berrange    fi
2761ddbb0d09SDaniel P. Berrangefi
2762ddbb0d09SDaniel P. Berrange
276391bfcdb0SDaniel P. Berrange
276491bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
276591bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2766a0722409SDaniel P. Berrangé# explicitly
276791bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
276891bfcdb0SDaniel P. Berrangethen
2769a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
277091bfcdb0SDaniel P. Berrange    then
277191bfcdb0SDaniel P. Berrange        gcrypt="no"
277291bfcdb0SDaniel P. Berrange    fi
277391bfcdb0SDaniel P. Berrangefi
277491bfcdb0SDaniel P. Berrange
277591bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
277691bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2777a0722409SDaniel P. Berrangé# explicitly
277891bfcdb0SDaniel P. Berrangeif test -z "$nettle"
277991bfcdb0SDaniel P. Berrangethen
2780a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
278191bfcdb0SDaniel P. Berrange    then
278291bfcdb0SDaniel P. Berrange        nettle="no"
278391bfcdb0SDaniel P. Berrange    fi
278491bfcdb0SDaniel P. Berrangefi
278591bfcdb0SDaniel P. Berrange
2786dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
278791bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
278891bfcdb0SDaniel P. Berrange    then
278991bfcdb0SDaniel P. Berrange	return 1
279091bfcdb0SDaniel P. Berrange    fi
279191bfcdb0SDaniel P. Berrange
279291bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
279391bfcdb0SDaniel P. Berrange    then
279489138857SStefan Weil	host=$(libgcrypt-config --host)
279591bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
279691bfcdb0SDaniel P. Berrange	then
279791bfcdb0SDaniel P. Berrange	    return 1
279891bfcdb0SDaniel P. Berrange	fi
279991bfcdb0SDaniel P. Berrange    fi
280091bfcdb0SDaniel P. Berrange
2801dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2802dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2803dea7a64eSDaniel P. Berrangé
2804dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2805dea7a64eSDaniel P. Berrangé    then
2806dea7a64eSDaniel P. Berrangé       return 1
2807dea7a64eSDaniel P. Berrangé    fi
2808dea7a64eSDaniel P. Berrangé
280991bfcdb0SDaniel P. Berrange    return 0
281091bfcdb0SDaniel P. Berrange}
281191bfcdb0SDaniel P. Berrange
2812a0722409SDaniel P. Berrangé
2813a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
281464dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2815a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2816a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2817a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2818a0722409SDaniel P. Berrangé        libs_softmmu="$nettle_libs $libs_softmmu"
2819a0722409SDaniel P. Berrangé        libs_tools="$nettle_libs $libs_tools"
2820a0722409SDaniel P. Berrangé        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2821a0722409SDaniel P. Berrangé        nettle="yes"
2822a0722409SDaniel P. Berrangé
2823a0722409SDaniel P. Berrangé        if test -z "$gcrypt"; then
2824a0722409SDaniel P. Berrangé           gcrypt="no"
2825a0722409SDaniel P. Berrangé        fi
2826a0722409SDaniel P. Berrangé    else
2827a0722409SDaniel P. Berrangé        if test "$nettle" = "yes"; then
282864dd2f3bSDaniel P. Berrangé            feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2829a0722409SDaniel P. Berrangé        else
2830a0722409SDaniel P. Berrangé            nettle="no"
2831a0722409SDaniel P. Berrangé        fi
2832a0722409SDaniel P. Berrangé    fi
2833a0722409SDaniel P. Berrangéfi
2834a0722409SDaniel P. Berrangé
283591bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2836dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
283789138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
283889138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
283991bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
284091bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
284191bfcdb0SDaniel P. Berrange        # turn breaks static builds...
284291bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
284391bfcdb0SDaniel P. Berrange        then
284491bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
284591bfcdb0SDaniel P. Berrange        fi
284662893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
284762893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
284862893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
284991bfcdb0SDaniel P. Berrange        gcrypt="yes"
28501f923c70SLongpeng(Mike)
28511f923c70SLongpeng(Mike)        cat > $TMPC << EOF
28521f923c70SLongpeng(Mike)#include <gcrypt.h>
28531f923c70SLongpeng(Mike)int main(void) {
28541f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
28551f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
28561f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
28571f923c70SLongpeng(Mike)  return 0;
28581f923c70SLongpeng(Mike)}
28591f923c70SLongpeng(Mike)EOF
28601f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
28611f923c70SLongpeng(Mike)            gcrypt_hmac=yes
28621f923c70SLongpeng(Mike)        fi
286362893b67SDaniel P. Berrange    else
286491bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
2865dea7a64eSDaniel P. Berrangé            feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
286691bfcdb0SDaniel P. Berrange        else
286791bfcdb0SDaniel P. Berrange            gcrypt="no"
286891bfcdb0SDaniel P. Berrange        fi
286962893b67SDaniel P. Berrange    fi
287062893b67SDaniel P. Berrangefi
287162893b67SDaniel P. Berrange
2872ddbb0d09SDaniel P. Berrange
287391bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
287491bfcdb0SDaniel P. Berrangethen
287591bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
287691bfcdb0SDaniel P. Berrangefi
2877ed754746SDaniel P. Berrange
28789a2fd434SDaniel P. Berrange##########################################
28799a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
28809a2fd434SDaniel P. Berrange
28819a2fd434SDaniel P. Berrangetasn1=yes
288290246037SDaniel P. Berrangetasn1_cflags=""
288390246037SDaniel P. Berrangetasn1_libs=""
28849a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
288589138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
288689138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
28879a2fd434SDaniel P. Berrangeelse
28889a2fd434SDaniel P. Berrange    tasn1=no
28899a2fd434SDaniel P. Berrangefi
28909a2fd434SDaniel P. Berrange
2891ed754746SDaniel P. Berrange
2892bbbf9bfbSStefan Weil##########################################
2893559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2894559607eaSDaniel P. Berrange
2895559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2896559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2897559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2898559607eaSDaniel P. Berrangefi
2899559607eaSDaniel P. Berrange
2900559607eaSDaniel P. Berrange##########################################
2901bbbf9bfbSStefan Weil# VTE probe
2902bbbf9bfbSStefan Weil
2903bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2904c6feff9eSCole Robinson    vteminversion="0.32.0"
2905c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
2906c6feff9eSCole Robinson      vtepackage="vte-2.91"
2907c6feff9eSCole Robinson    else
2908528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
2909c6feff9eSCole Robinson    fi
2910c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
291189138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
291289138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
291389138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2914bbbf9bfbSStefan Weil        vte="yes"
2915bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
2916c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
29179e04c683SStefan Weil    else
2918bbbf9bfbSStefan Weil        vte="no"
2919a4ccabcfSAnthony Liguori    fi
2920a4ccabcfSAnthony Liguorifi
2921a4ccabcfSAnthony Liguori
2922a4ccabcfSAnthony Liguori##########################################
292311d9f695Sbellard# SDL probe
292411d9f695Sbellard
29253ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
29263ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
292747c03744SDave Airlie
2928c6093a05SPeter Xusdl_probe ()
2929c6093a05SPeter Xu{
2930c6093a05SPeter Xu  sdl_too_old=no
2931ee8466d0SCole Robinson  if test "$sdlabi" = ""; then
29328f4ea9cdSGerd Hoffmann      if $pkg_config --exists "sdl2"; then
2933ee8466d0SCole Robinson          sdlabi=2.0
29348f4ea9cdSGerd Hoffmann      elif $pkg_config --exists "sdl"; then
2935ee8466d0SCole Robinson          sdlabi=1.2
29368f4ea9cdSGerd Hoffmann      else
29378f4ea9cdSGerd Hoffmann          sdlabi=2.0
2938ee8466d0SCole Robinson      fi
2939ee8466d0SCole Robinson  fi
2940ee8466d0SCole Robinson
294147c03744SDave Airlie  if test $sdlabi = "2.0"; then
294247c03744SDave Airlie      sdl_config=$sdl2_config
294347c03744SDave Airlie      sdlname=sdl2
294447c03744SDave Airlie      sdlconfigname=sdl2_config
2945e07047cfSCole Robinson  elif test $sdlabi = "1.2"; then
294647c03744SDave Airlie      sdlname=sdl
294747c03744SDave Airlie      sdlconfigname=sdl_config
2948e07047cfSCole Robinson  else
2949e07047cfSCole Robinson      error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
29503ec87ffeSPaolo Bonzini  fi
29513ec87ffeSPaolo Bonzini
295289138857SStefan Weil  if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
295347c03744SDave Airlie    sdl_config=$sdlconfigname
295447c03744SDave Airlie  fi
295547c03744SDave Airlie
295647c03744SDave Airlie  if $pkg_config $sdlname --exists; then
295747c03744SDave Airlie    sdlconfig="$pkg_config $sdlname"
295889138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
29593ec87ffeSPaolo Bonzini  elif has ${sdl_config}; then
29603ec87ffeSPaolo Bonzini    sdlconfig="$sdl_config"
296189138857SStefan Weil    sdlversion=$($sdlconfig --version)
2962a0dfd8a4SLoïc Minier  else
2963a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
29648f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
2965a0dfd8a4SLoïc Minier    fi
2966a0dfd8a4SLoïc Minier    sdl=no
2967c6093a05SPeter Xu    # no need to do the rest
2968c6093a05SPeter Xu    return
29699316f803SPaolo Bonzini  fi
297029e5badaSScott Wood  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
29713ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
29723ec87ffeSPaolo Bonzini  fi
297311d9f695Sbellard
297411d9f695Sbellard  cat > $TMPC << EOF
297511d9f695Sbellard#include <SDL.h>
297611d9f695Sbellard#undef main /* We don't want SDL to override our main() */
297711d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
297811d9f695SbellardEOF
297989138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
29802ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
298174f42e18STeLeMan  if test "$static" = "yes" ; then
29825f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
29835f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
29845f37e6d4SThomas Huth    else
298589138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
29865f37e6d4SThomas Huth    fi
298774f42e18STeLeMan  else
298889138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
298974f42e18STeLeMan  fi
299052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
299189138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
299211d9f695Sbellard      sdl_too_old=yes
299311d9f695Sbellard    else
299411d9f695Sbellard      sdl=yes
299511d9f695Sbellard    fi
29967c1f25b4Sbellard
299767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
29981ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
299967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
300089138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
300189138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
300211d9f695Sbellard      fi
300352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
30041ac88f28SJuan Quintela	:
30051ac88f28SJuan Quintela      else
30061ac88f28SJuan Quintela        sdl=no
30077c1f25b4Sbellard      fi
30087c1f25b4Sbellard    fi # static link
3009c4198157SJuan Quintela  else # sdl not found
3010c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
301121684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
3012c4198157SJuan Quintela    fi
3013c4198157SJuan Quintela    sdl=no
30147c1f25b4Sbellard  fi # sdl compile test
3015c6093a05SPeter Xu}
3016c6093a05SPeter Xu
3017a442fe2fSDaniel P. Berrangésdl_image_probe ()
3018a442fe2fSDaniel P. Berrangé{
3019a442fe2fSDaniel P. Berrangé    if test "$sdl_image" != "no" ; then
3020a442fe2fSDaniel P. Berrangé        if $pkg_config SDL2_image --exists; then
3021a442fe2fSDaniel P. Berrangé            if test "$static" = "yes"; then
3022a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3023a442fe2fSDaniel P. Berrangé            else
3024a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3025a442fe2fSDaniel P. Berrangé            fi
3026a442fe2fSDaniel P. Berrangé            sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3027a442fe2fSDaniel P. Berrangé            sdl_image=yes
3028a442fe2fSDaniel P. Berrangé
3029a442fe2fSDaniel P. Berrangé            sdl_cflags="$sdl_cflags $sdl_image_cflags"
3030a442fe2fSDaniel P. Berrangé            sdl_libs="$sdl_libs $sdl_image_libs"
3031a442fe2fSDaniel P. Berrangé        else
3032a442fe2fSDaniel P. Berrangé            if test "$sdl_image" = "yes" ; then
3033a442fe2fSDaniel P. Berrangé                feature_not_found "sdl_image" "Install SDL Image devel"
3034a442fe2fSDaniel P. Berrangé            else
3035a442fe2fSDaniel P. Berrangé                sdl_image=no
3036a442fe2fSDaniel P. Berrangé            fi
3037a442fe2fSDaniel P. Berrangé        fi
3038a442fe2fSDaniel P. Berrangé    fi
3039a442fe2fSDaniel P. Berrangé}
3040a442fe2fSDaniel P. Berrangé
3041c6093a05SPeter Xuif test "$sdl" != "no" ; then
3042c6093a05SPeter Xu  sdl_probe
3043fd677642Sthsfi
304411d9f695Sbellard
30455368a422Saliguoriif test "$sdl" = "yes" ; then
3046a442fe2fSDaniel P. Berrangé  sdl_image_probe
3047a442fe2fSDaniel P. Berrangéelse
3048a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes"; then
3049a442fe2fSDaniel P. Berrangé    echo "warning: SDL Image requested, but SDL is not available, disabling"
3050a442fe2fSDaniel P. Berrangé  fi
3051a442fe2fSDaniel P. Berrangé  sdl_image=no
3052a442fe2fSDaniel P. Berrangéfi
3053a442fe2fSDaniel P. Berrangé
3054a442fe2fSDaniel P. Berrangéif test "$sdl" = "yes" ; then
30555368a422Saliguori  cat > $TMPC <<EOF
30565368a422Saliguori#include <SDL.h>
30575368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
30585368a422Saliguori#include <X11/XKBlib.h>
30595368a422Saliguori#else
30605368a422Saliguori#error No x11 support
30615368a422Saliguori#endif
30625368a422Saliguoriint main(void) { return 0; }
30635368a422SaliguoriEOF
3064f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
30658781595bSGerd Hoffmann    need_x11=yes
3066f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3067f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
30685368a422Saliguori  fi
30695368a422Saliguorifi
30705368a422Saliguori
30718f28f3fbSths##########################################
30722da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
30732da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
30742da776dbSMichael R. Hines  cat > $TMPC <<EOF
30752da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
30762da776dbSMichael R. Hinesint main(void) { return 0; }
30772da776dbSMichael R. HinesEOF
3078ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
30792da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
30802da776dbSMichael R. Hines    rdma="yes"
3081ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
30822da776dbSMichael R. Hines  else
30832da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
30842da776dbSMichael R. Hines        error_exit \
3085ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
30862da776dbSMichael R. Hines            " Your options:" \
3087ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
30882da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
30892da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
30902da776dbSMichael R. Hines    fi
30912da776dbSMichael R. Hines    rdma="no"
30922da776dbSMichael R. Hines  fi
30932da776dbSMichael R. Hinesfi
30942da776dbSMichael R. Hines
309521ab34c9SMarcel Apfelbaum##########################################
309621ab34c9SMarcel Apfelbaum# PVRDMA detection
309721ab34c9SMarcel Apfelbaum
309821ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
309921ab34c9SMarcel Apfelbaum#include <sys/mman.h>
310021ab34c9SMarcel Apfelbaum
310121ab34c9SMarcel Apfelbaumint
310221ab34c9SMarcel Apfelbaummain(void)
310321ab34c9SMarcel Apfelbaum{
310421ab34c9SMarcel Apfelbaum    char buf = 0;
310521ab34c9SMarcel Apfelbaum    void *addr = &buf;
310621ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
310721ab34c9SMarcel Apfelbaum
310821ab34c9SMarcel Apfelbaum    return 0;
310921ab34c9SMarcel Apfelbaum}
311021ab34c9SMarcel ApfelbaumEOF
311121ab34c9SMarcel Apfelbaum
311221ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
311321ab34c9SMarcel Apfelbaum    case "$pvrdma" in
311421ab34c9SMarcel Apfelbaum    "")
311521ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
311621ab34c9SMarcel Apfelbaum            pvrdma="yes"
311721ab34c9SMarcel Apfelbaum        else
311821ab34c9SMarcel Apfelbaum            pvrdma="no"
311921ab34c9SMarcel Apfelbaum        fi
312021ab34c9SMarcel Apfelbaum        ;;
312121ab34c9SMarcel Apfelbaum    "yes")
312221ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
312321ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
312421ab34c9SMarcel Apfelbaum        fi
312521ab34c9SMarcel Apfelbaum        pvrdma="yes"
312621ab34c9SMarcel Apfelbaum        ;;
312721ab34c9SMarcel Apfelbaum    "no")
312821ab34c9SMarcel Apfelbaum        pvrdma="no"
312921ab34c9SMarcel Apfelbaum        ;;
313021ab34c9SMarcel Apfelbaum    esac
313121ab34c9SMarcel Apfelbaumelse
313221ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
313321ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
313421ab34c9SMarcel Apfelbaum    fi
313521ab34c9SMarcel Apfelbaum    pvrdma="no"
313621ab34c9SMarcel Apfelbaumfi
313795c6bff3SBenoît Canet
313895c6bff3SBenoît Canet##########################################
31392f9606b3Saliguori# VNC SASL detection
3140821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
31412f9606b3Saliguori  cat > $TMPC <<EOF
31422f9606b3Saliguori#include <sasl/sasl.h>
31432f9606b3Saliguori#include <stdio.h>
31442f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
31452f9606b3SaliguoriEOF
31462f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
31472f9606b3Saliguori  vnc_sasl_cflags=""
31482f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
314952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3150ea784e3bSJuan Quintela    vnc_sasl=yes
3151fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3152ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
31532f9606b3Saliguori  else
3154ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
315521684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3156ea784e3bSJuan Quintela    fi
3157ea784e3bSJuan Quintela    vnc_sasl=no
31582f9606b3Saliguori  fi
31592f9606b3Saliguorifi
31602f9606b3Saliguori
31612f9606b3Saliguori##########################################
31622f6f5c7aSCorentin Chary# VNC JPEG detection
3163821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
31642f6f5c7aSCorentin Charycat > $TMPC <<EOF
31652f6f5c7aSCorentin Chary#include <stdio.h>
31662f6f5c7aSCorentin Chary#include <jpeglib.h>
31672f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
31682f6f5c7aSCorentin CharyEOF
31692f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
31702f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
31712f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
31722f6f5c7aSCorentin Chary    vnc_jpeg=yes
31732f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3174ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
31752f6f5c7aSCorentin Chary  else
31762f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
317721684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
31782f6f5c7aSCorentin Chary    fi
31792f6f5c7aSCorentin Chary    vnc_jpeg=no
31802f6f5c7aSCorentin Chary  fi
31812f6f5c7aSCorentin Charyfi
31822f6f5c7aSCorentin Chary
31832f6f5c7aSCorentin Chary##########################################
3184efe556adSCorentin Chary# VNC PNG detection
3185821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
3186efe556adSCorentin Charycat > $TMPC <<EOF
3187efe556adSCorentin Chary//#include <stdio.h>
3188efe556adSCorentin Chary#include <png.h>
3189832ce9c2SScott Wood#include <stddef.h>
3190efe556adSCorentin Charyint main(void) {
3191efe556adSCorentin Chary    png_structp png_ptr;
3192efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
31937edc3fedSPeter Maydell    return png_ptr != 0;
3194efe556adSCorentin Chary}
3195efe556adSCorentin CharyEOF
319665d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
319789138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
319889138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
31999af8025eSBrad  else
3200efe556adSCorentin Chary    vnc_png_cflags=""
3201efe556adSCorentin Chary    vnc_png_libs="-lpng"
32029af8025eSBrad  fi
3203efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3204efe556adSCorentin Chary    vnc_png=yes
3205efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
32069af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3207efe556adSCorentin Chary  else
3208efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
320921684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3210efe556adSCorentin Chary    fi
3211efe556adSCorentin Chary    vnc_png=no
3212efe556adSCorentin Chary  fi
3213efe556adSCorentin Charyfi
3214efe556adSCorentin Chary
3215efe556adSCorentin Chary##########################################
32166a021536SGerd Hoffmann# xkbcommon probe
32176a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
32186a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
32196a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
32206a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
32216a021536SGerd Hoffmann    xkbcommon=yes
32226a021536SGerd Hoffmann  else
32236a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
32246a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
32256a021536SGerd Hoffmann    fi
32266a021536SGerd Hoffmann    xkbcommon=no
32276a021536SGerd Hoffmann  fi
32286a021536SGerd Hoffmannfi
32296a021536SGerd Hoffmann
32306a021536SGerd Hoffmann##########################################
323176655d6dSaliguori# fnmatch() probe, used for ACL routines
323276655d6dSaliguorifnmatch="no"
323376655d6dSaliguoricat > $TMPC << EOF
323476655d6dSaliguori#include <fnmatch.h>
323576655d6dSaliguoriint main(void)
323676655d6dSaliguori{
323776655d6dSaliguori    fnmatch("foo", "foo", 0);
323876655d6dSaliguori    return 0;
323976655d6dSaliguori}
324076655d6dSaliguoriEOF
324152166aa0SJuan Quintelaif compile_prog "" "" ; then
324276655d6dSaliguori   fnmatch="yes"
324376655d6dSaliguorifi
324476655d6dSaliguori
324576655d6dSaliguori##########################################
3246c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3247dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3248dce512deSChristoph Hellwig  cat > $TMPC << EOF
3249ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3250dce512deSChristoph Hellwig#include <xfs/xfs.h>
3251dce512deSChristoph Hellwigint main(void)
3252dce512deSChristoph Hellwig{
3253dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3254dce512deSChristoph Hellwig    return 0;
3255dce512deSChristoph Hellwig}
3256dce512deSChristoph HellwigEOF
3257dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3258dce512deSChristoph Hellwig    xfs="yes"
3259dce512deSChristoph Hellwig  else
3260dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
326121684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3262dce512deSChristoph Hellwig    fi
3263dce512deSChristoph Hellwig    xfs=no
3264dce512deSChristoph Hellwig  fi
3265dce512deSChristoph Hellwigfi
3266dce512deSChristoph Hellwig
3267dce512deSChristoph Hellwig##########################################
32688a16d273Sths# vde libraries probe
3269dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
32704baae0acSJuan Quintela  vde_libs="-lvdeplug"
32718a16d273Sths  cat > $TMPC << EOF
32728a16d273Sths#include <libvdeplug.h>
32734a7f0e06Spbrookint main(void)
32744a7f0e06Spbrook{
32754a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3276fea08e08SPeter Maydell    char s[] = "";
3277fea08e08SPeter Maydell    vde_open(s, s, &a);
32784a7f0e06Spbrook    return 0;
32794a7f0e06Spbrook}
32808a16d273SthsEOF
328152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
32824baae0acSJuan Quintela    vde=yes
3283dfb278bdSJuan Quintela  else
3284dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
328521684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3286dfb278bdSJuan Quintela    fi
3287dfb278bdSJuan Quintela    vde=no
32888a16d273Sths  fi
32898a16d273Sthsfi
32908a16d273Sths
32918a16d273Sths##########################################
32920a985b37SVincenzo Maffione# netmap support probe
32930a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
32940a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
32950a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
32960a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
32970a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
329858952137SVincenzo Maffioneif test "$netmap" != "no" ; then
329958952137SVincenzo Maffione  cat > $TMPC << EOF
330058952137SVincenzo Maffione#include <inttypes.h>
330158952137SVincenzo Maffione#include <net/if.h>
330258952137SVincenzo Maffione#include <net/netmap.h>
330358952137SVincenzo Maffione#include <net/netmap_user.h>
33040a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
33050a985b37SVincenzo Maffione#error
33060a985b37SVincenzo Maffione#endif
330758952137SVincenzo Maffioneint main(void) { return 0; }
330858952137SVincenzo MaffioneEOF
330958952137SVincenzo Maffione  if compile_prog "" "" ; then
331058952137SVincenzo Maffione    netmap=yes
331158952137SVincenzo Maffione  else
331258952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
331358952137SVincenzo Maffione      feature_not_found "netmap"
331458952137SVincenzo Maffione    fi
331558952137SVincenzo Maffione    netmap=no
331658952137SVincenzo Maffione  fi
331758952137SVincenzo Maffionefi
331858952137SVincenzo Maffione
331958952137SVincenzo Maffione##########################################
332047e98658SCorey Bryant# libcap-ng library probe
332147e98658SCorey Bryantif test "$cap_ng" != "no" ; then
332247e98658SCorey Bryant  cap_libs="-lcap-ng"
332347e98658SCorey Bryant  cat > $TMPC << EOF
332447e98658SCorey Bryant#include <cap-ng.h>
332547e98658SCorey Bryantint main(void)
332647e98658SCorey Bryant{
332747e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
332847e98658SCorey Bryant    return 0;
332947e98658SCorey Bryant}
333047e98658SCorey BryantEOF
333147e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
333247e98658SCorey Bryant    cap_ng=yes
333347e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
333447e98658SCorey Bryant  else
333547e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
333621684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
333747e98658SCorey Bryant    fi
333847e98658SCorey Bryant    cap_ng=no
333947e98658SCorey Bryant  fi
334047e98658SCorey Bryantfi
334147e98658SCorey Bryant
334247e98658SCorey Bryant##########################################
3343c2de5c91Smalc# Sound support libraries probe
33448f28f3fbSths
334589138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3346c2de5c91Smalcfor drv in $audio_drv_list; do
3347c2de5c91Smalc    case $drv in
3348e42975a1SGerd Hoffmann    alsa | try-alsa)
3349c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3350c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3351e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3352e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3353e42975a1SGerd Hoffmann        fi
3354e42975a1SGerd Hoffmann    else
3355e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3356e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3357c80a867fSGerd Hoffmann        else
3358c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3359c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3360c80a867fSGerd Hoffmann        fi
3361e42975a1SGerd Hoffmann    fi
3362c2de5c91Smalc    ;;
3363c2de5c91Smalc
3364e42975a1SGerd Hoffmann    pa | try-pa)
3365c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3366c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
336767f86e8eSJuan Quintela        audio_pt_int="yes"
3368e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3369e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3370e42975a1SGerd Hoffmann        fi
3371e42975a1SGerd Hoffmann    else
3372e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3373e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3374c80a867fSGerd Hoffmann        else
3375c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3376c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3377c80a867fSGerd Hoffmann        fi
3378e42975a1SGerd Hoffmann    fi
3379b8e59f18Smalc    ;;
3380b8e59f18Smalc
3381373967b2SGerd Hoffmann    sdl)
3382373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3383373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3384373967b2SGerd Hoffmann    fi
3385373967b2SGerd Hoffmann    ;;
3386373967b2SGerd Hoffmann
3387e42975a1SGerd Hoffmann    try-sdl)
3388e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3389e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3390e42975a1SGerd Hoffmann    else
3391e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3392e42975a1SGerd Hoffmann    fi
3393e42975a1SGerd Hoffmann    ;;
3394e42975a1SGerd Hoffmann
3395997e690aSJuan Quintela    coreaudio)
3396b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3397997e690aSJuan Quintela    ;;
3398997e690aSJuan Quintela
3399a4bf6780SJuan Quintela    dsound)
3400b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3401d5631638Smalc      audio_win_int="yes"
3402a4bf6780SJuan Quintela    ;;
3403a4bf6780SJuan Quintela
3404a4bf6780SJuan Quintela    oss)
3405b1149911SFam Zheng      oss_libs="$oss_lib"
3406a4bf6780SJuan Quintela    ;;
3407a4bf6780SJuan Quintela
3408373967b2SGerd Hoffmann    wav)
3409373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
34102f6a1ab0Sblueswir1    ;;
34112f6a1ab0Sblueswir1
3412e4c63a6aSmalc    *)
34131c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
341476ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
341576ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3416e4c63a6aSmalc    }
3417e4c63a6aSmalc    ;;
3418c2de5c91Smalc    esac
3419c2de5c91Smalcdone
34208f28f3fbSths
34214d3b6f6eSbalrog##########################################
34222e4d9fb1Saurel32# BrlAPI probe
34232e4d9fb1Saurel32
34244ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3425eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
34262e4d9fb1Saurel32  cat > $TMPC << EOF
34272e4d9fb1Saurel32#include <brlapi.h>
3428832ce9c2SScott Wood#include <stddef.h>
34292e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
34302e4d9fb1Saurel32EOF
343152166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
34322e4d9fb1Saurel32    brlapi=yes
34334ffcedb6SJuan Quintela  else
34344ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
343521684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
34364ffcedb6SJuan Quintela    fi
34374ffcedb6SJuan Quintela    brlapi=no
3438eb82284fSJuan Quintela  fi
3439eb82284fSJuan Quintelafi
34402e4d9fb1Saurel32
34412e4d9fb1Saurel32##########################################
34424d3b6f6eSbalrog# curses probe
3443a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3444e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
34458ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
34468ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3447e095e2f3SStefan Weil  else
34487c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
34498ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3450e095e2f3SStefan Weil  fi
3451c584a6d0SJuan Quintela  curses_found=no
34524d3b6f6eSbalrog  cat > $TMPC << EOF
34538ddc5bf9SSamuel Thibault#include <locale.h>
34544d3b6f6eSbalrog#include <curses.h>
34558ddc5bf9SSamuel Thibault#include <wchar.h>
3456ef9a2524SStefan Weilint main(void) {
34578ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
34588ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3459ef9a2524SStefan Weil  resize_term(0, 0);
34608ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
34618ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
34627c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3463271f37abSKamil Rytarowski  return 0;
3464ef9a2524SStefan Weil}
34654d3b6f6eSbalrogEOF
3466ecbe251fSVadim Evard  IFS=:
34678ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3468b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3469b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
34707c703002SSamuel Thibault    IFS=:
34718ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3472ecbe251fSVadim Evard      unset IFS
34738ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3474c584a6d0SJuan Quintela        curses_found=yes
34754f78ef9aSJuan Quintela        break
34764d3b6f6eSbalrog      fi
34774f78ef9aSJuan Quintela    done
34787c703002SSamuel Thibault    if test "$curses_found" = yes ; then
34797c703002SSamuel Thibault      break
34807c703002SSamuel Thibault    fi
34818ddc5bf9SSamuel Thibault  done
3482ecbe251fSVadim Evard  unset IFS
3483c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3484c584a6d0SJuan Quintela    curses=yes
3485c584a6d0SJuan Quintela  else
3486c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
348721684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3488c584a6d0SJuan Quintela    fi
3489c584a6d0SJuan Quintela    curses=no
3490c584a6d0SJuan Quintela  fi
34914f78ef9aSJuan Quintelafi
34924d3b6f6eSbalrog
3493414f0dabSblueswir1##########################################
3494769ce76dSAlexander Graf# curl probe
3495a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
349665d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3497a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
34984e2b0658SPaolo Bonzini  else
34994e2b0658SPaolo Bonzini    curlconfig=curl-config
35004e2b0658SPaolo Bonzini  fi
3501769ce76dSAlexander Graf  cat > $TMPC << EOF
3502769ce76dSAlexander Graf#include <curl/curl.h>
35030b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3504769ce76dSAlexander GrafEOF
350589138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
350689138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3507b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3508769ce76dSAlexander Graf    curl=yes
3509788c8196SJuan Quintela  else
3510788c8196SJuan Quintela    if test "$curl" = "yes" ; then
351121684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3512788c8196SJuan Quintela    fi
3513788c8196SJuan Quintela    curl=no
3514769ce76dSAlexander Graf  fi
3515769ce76dSAlexander Graffi # test "$curl"
3516769ce76dSAlexander Graf
3517769ce76dSAlexander Graf##########################################
3518fb599c9aSbalrog# bluez support probe
3519a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3520e820e3f4Sbalrog  cat > $TMPC << EOF
3521e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3522e820e3f4Sbalrogint main(void) { return bt_error(0); }
3523e820e3f4SbalrogEOF
352489138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
352589138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
352652166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3527a20a6f46SJuan Quintela    bluez=yes
3528e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3529e820e3f4Sbalrog  else
3530a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
353121684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3532a20a6f46SJuan Quintela    fi
3533e820e3f4Sbalrog    bluez="no"
3534e820e3f4Sbalrog  fi
3535fb599c9aSbalrogfi
3536fb599c9aSbalrog
3537fb599c9aSbalrog##########################################
3538e18df141SAnthony Liguori# glib support probe
3539a52d28afSPaolo Bonzini
3540e7b3af81SDaniel P. Berrangéglib_req_ver=2.40
3541aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3542aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3543a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3544aa0d1f44SPaolo Bonzinifi
3545e26110cfSFam Zheng
35464eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
35474eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
35484eaf7202SSameeh Jubran
35494eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
35504eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
35514eaf7202SSameeh Jubranfi
35524eaf7202SSameeh Jubran
3553aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3554e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
355589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
355689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
35574a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
355814015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3559957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3560e18df141SAnthony Liguori    else
3561e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3562e26110cfSFam Zheng    fi
3563e26110cfSFam Zhengdone
3564e26110cfSFam Zheng
3565977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3566977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3567977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3568977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3569977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3570977a82abSDaniel P. Berrange#include <glib.h>
3571977a82abSDaniel P. Berrange#include <unistd.h>
3572977a82abSDaniel P. Berrange
3573977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3574977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3575977a82abSDaniel P. Berrange
3576977a82abSDaniel P. Berrangeint main(void) {
3577977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3578977a82abSDaniel P. Berrange   return 0;
3579977a82abSDaniel P. Berrange}
3580977a82abSDaniel P. BerrangeEOF
3581977a82abSDaniel P. Berrange
35825919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3583977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3584977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3585977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3586977a82abSDaniel P. Berrange	       "build target"
3587977a82abSDaniel P. Berrangefi
3588977a82abSDaniel P. Berrange
3589bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3590bbbf2e04SJohn Snowcat > $TMPC << EOF
3591bbbf2e04SJohn Snow#include <glib.h>
3592bbbf2e04SJohn Snowint main(void) { return 0; }
3593bbbf2e04SJohn SnowEOF
3594bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3595bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3596bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3597bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3598bbbf2e04SJohn Snow    fi
3599bbbf2e04SJohn Snowfi
3600bbbf2e04SJohn Snow
36016a1f42bdSStefan Weil#########################################
36026a1f42bdSStefan Weil# zlib check
36036a1f42bdSStefan Weil
36046a1f42bdSStefan Weilif test "$zlib" != "no" ; then
36056a1f42bdSStefan Weil    if $pkg_config --exists zlib; then
36066a1f42bdSStefan Weil        zlib_cflags=$($pkg_config --cflags zlib)
36076a1f42bdSStefan Weil        zlib_libs=$($pkg_config --libs zlib)
36086a1f42bdSStefan Weil        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
36096a1f42bdSStefan Weil        LIBS="$zlib_libs $LIBS"
36106a1f42bdSStefan Weil    else
36116a1f42bdSStefan Weil        cat > $TMPC << EOF
36126a1f42bdSStefan Weil#include <zlib.h>
36136a1f42bdSStefan Weilint main(void) { zlibVersion(); return 0; }
36146a1f42bdSStefan WeilEOF
36156a1f42bdSStefan Weil        if compile_prog "" "-lz" ; then
36166a1f42bdSStefan Weil            LIBS="$LIBS -lz"
36176a1f42bdSStefan Weil        else
36186a1f42bdSStefan Weil            error_exit "zlib check failed" \
36196a1f42bdSStefan Weil                "Make sure to have the zlib libs and headers installed."
36206a1f42bdSStefan Weil        fi
36216a1f42bdSStefan Weil    fi
36226a1f42bdSStefan Weilfi
36236a1f42bdSStefan Weil
3624e26110cfSFam Zheng##########################################
3625e26110cfSFam Zheng# SHA command probe for modules
3626e26110cfSFam Zhengif test "$modules" = yes; then
3627e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3628e26110cfSFam Zheng    for c in $shacmd_probe; do
36298ccefb91SFam Zheng        if has $c; then
3630e26110cfSFam Zheng            shacmd="$c"
3631e26110cfSFam Zheng            break
3632e26110cfSFam Zheng        fi
3633e26110cfSFam Zheng    done
3634e26110cfSFam Zheng    if test "$shacmd" = ""; then
3635e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3636e26110cfSFam Zheng    fi
3637e18df141SAnthony Liguorifi
3638e18df141SAnthony Liguori
3639e18df141SAnthony Liguori##########################################
3640e2134eb9SGerd Hoffmann# pixman support probe
3641e2134eb9SGerd Hoffmann
364274880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
364374880fe2SRobert Schiele  pixman_cflags=
364474880fe2SRobert Schiele  pixman_libs=
364535c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
364689138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
364789138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3648e2134eb9SGerd Hoffmannelse
3649c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3650c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3651e2134eb9SGerd Hoffmannfi
3652e2134eb9SGerd Hoffmann
3653e2134eb9SGerd Hoffmann##########################################
3654fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3655fe8fc5aeSPaolo Bonzini
3656fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
36571b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3658fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3659fe8fc5aeSPaolo Bonzini#include <libudev.h>
3660fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3661fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3662fe8fc5aeSPaolo Bonziniint logsink;
3663b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3664b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3665b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3666b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3667b3f1c8c4SPaolo Bonzinistruct udev *udev;
3668b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3669b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3670b3f1c8c4SPaolo Bonzini
3671fe8fc5aeSPaolo Bonziniint main(void) {
3672b3f1c8c4SPaolo Bonzini    udev = udev_new();
3673b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3674fe8fc5aeSPaolo Bonzini    return 0;
3675fe8fc5aeSPaolo Bonzini}
3676fe8fc5aeSPaolo BonziniEOF
3677fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3678fe8fc5aeSPaolo Bonzini    mpathpersist=yes
36791b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
36801b0578f5SMurilo Opsfelder Araujo  else
36811b0578f5SMurilo Opsfelder Araujo    # probe for the old API
36821b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
36831b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
36841b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
36851b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
36861b0578f5SMurilo Opsfelder Araujoint logsink;
36871b0578f5SMurilo Opsfelder Araujoint main(void) {
36881b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
36891b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
36901b0578f5SMurilo Opsfelder Araujo    return 0;
36911b0578f5SMurilo Opsfelder Araujo}
36921b0578f5SMurilo Opsfelder AraujoEOF
36931b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
36941b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
36951b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3696fe8fc5aeSPaolo Bonzini    else
3697fe8fc5aeSPaolo Bonzini      mpathpersist=no
3698fe8fc5aeSPaolo Bonzini    fi
36991b0578f5SMurilo Opsfelder Araujo  fi
3700fe8fc5aeSPaolo Bonzinielse
3701fe8fc5aeSPaolo Bonzini  mpathpersist=no
3702fe8fc5aeSPaolo Bonzinifi
3703fe8fc5aeSPaolo Bonzini
3704fe8fc5aeSPaolo Bonzini##########################################
370517bff52bSM. Mohan Kumar# libcap probe
370617bff52bSM. Mohan Kumar
370717bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
370817bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
370917bff52bSM. Mohan Kumar#include <stdio.h>
371017bff52bSM. Mohan Kumar#include <sys/capability.h>
3711cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
371217bff52bSM. Mohan KumarEOF
371317bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
371417bff52bSM. Mohan Kumar    cap=yes
371517bff52bSM. Mohan Kumar  else
371617bff52bSM. Mohan Kumar    cap=no
371717bff52bSM. Mohan Kumar  fi
371817bff52bSM. Mohan Kumarfi
371917bff52bSM. Mohan Kumar
372017bff52bSM. Mohan Kumar##########################################
3721e5d355d1Saliguori# pthread probe
37224b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
37233c529d93Saliguori
3724e5d355d1Saliguoripthread=no
3725414f0dabSblueswir1cat > $TMPC << EOF
37263c529d93Saliguori#include <pthread.h>
37277a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
37287a42bbe4SStefan Weilint main(void) {
37297a42bbe4SStefan Weil  pthread_t thread;
37307a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
37317a42bbe4SStefan Weil  return 0;
37327a42bbe4SStefan Weil}
3733414f0dabSblueswir1EOF
3734bd00d539SAndreas Färberif compile_prog "" "" ; then
3735bd00d539SAndreas Färber  pthread=yes
3736bd00d539SAndreas Färberelse
3737de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
373852166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3739e5d355d1Saliguori      pthread=yes
3740e3c56761SPeter Portante      found=no
3741e3c56761SPeter Portante      for lib_entry in $LIBS; do
3742e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3743e3c56761SPeter Portante          found=yes
3744e3c56761SPeter Portante          break
3745e3c56761SPeter Portante        fi
3746e3c56761SPeter Portante      done
3747e3c56761SPeter Portante      if test "$found" = "no"; then
37485572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
374914ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3750e3c56761SPeter Portante      fi
3751409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3752de65fe0fSSebastian Herbszt      break
3753414f0dabSblueswir1    fi
3754de65fe0fSSebastian Herbszt  done
3755bd00d539SAndreas Färberfi
3756414f0dabSblueswir1
37574617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
375876ad07a4SPeter Maydell  error_exit "pthread check failed" \
375976ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3760e5d355d1Saliguorifi
3761e5d355d1Saliguori
3762479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3763479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
37645c312079SDr. David Alan Gilbertcat > $TMPC << EOF
37655c312079SDr. David Alan Gilbert#include <pthread.h>
37665c312079SDr. David Alan Gilbert
37675c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
37685c312079SDr. David Alan Gilbertint main(void)
37695c312079SDr. David Alan Gilbert{
37705c312079SDr. David Alan Gilbert    pthread_t thread;
37715c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
37725c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
37735c312079SDr. David Alan Gilbert    return 0;
37745c312079SDr. David Alan Gilbert}
37755c312079SDr. David Alan GilbertEOF
37765c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3777479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3778479a5747SRoman Bolshakovfi
3779479a5747SRoman Bolshakov
3780479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3781479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3782479a5747SRoman Bolshakovcat > $TMPC << EOF
3783479a5747SRoman Bolshakov#include <pthread.h>
3784479a5747SRoman Bolshakov
3785479a5747SRoman Bolshakovstatic void *f(void *p) { pthread_setname_np("QEMU"); }
3786479a5747SRoman Bolshakovint main(void)
3787479a5747SRoman Bolshakov{
3788479a5747SRoman Bolshakov    pthread_t thread;
3789479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3790479a5747SRoman Bolshakov    return 0;
3791479a5747SRoman Bolshakov}
3792479a5747SRoman BolshakovEOF
3793479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3794479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
37955c312079SDr. David Alan Gilbertfi
37965c312079SDr. David Alan Gilbert
3797bf9298b9Saliguori##########################################
3798f27aaf4bSChristian Brunner# rbd probe
3799f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3800f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3801f27aaf4bSChristian Brunner#include <stdio.h>
3802ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3803f27aaf4bSChristian Brunnerint main(void) {
3804ad32e9c0SJosh Durgin    rados_t cluster;
3805ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3806f27aaf4bSChristian Brunner    return 0;
3807f27aaf4bSChristian Brunner}
3808f27aaf4bSChristian BrunnerEOF
3809ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3810f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3811f27aaf4bSChristian Brunner    rbd=yes
3812f27aaf4bSChristian Brunner  else
3813f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
381421684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3815f27aaf4bSChristian Brunner    fi
3816f27aaf4bSChristian Brunner    rbd=no
3817f27aaf4bSChristian Brunner  fi
3818f27aaf4bSChristian Brunnerfi
3819f27aaf4bSChristian Brunner
3820f27aaf4bSChristian Brunner##########################################
38210a12ec87SRichard W.M. Jones# libssh2 probe
38224fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
38230a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
382465d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
382589138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
382689138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
38270a12ec87SRichard W.M. Jones    libssh2=yes
38280a12ec87SRichard W.M. Jones  else
38290a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
38304fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
38310a12ec87SRichard W.M. Jones    fi
38320a12ec87SRichard W.M. Jones    libssh2=no
38330a12ec87SRichard W.M. Jones  fi
38340a12ec87SRichard W.M. Jonesfi
38350a12ec87SRichard W.M. Jones
38360a12ec87SRichard W.M. Jones##########################################
38379a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
38389a2d462eSRichard W.M. Jones
38399a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
38409a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
38419a2d462eSRichard W.M. Jones#include <stdio.h>
38429a2d462eSRichard W.M. Jones#include <libssh2.h>
38439a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
38449a2d462eSRichard W.M. Jonesint main(void) {
38459a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
38469a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
38479a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
38489a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
38499a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
38509a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
38519a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
38529a2d462eSRichard W.M. Jones    return 0;
38539a2d462eSRichard W.M. Jones}
38549a2d462eSRichard W.M. JonesEOF
38559a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
38569a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
38579a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
38589a2d462eSRichard W.M. Jones  fi
38599a2d462eSRichard W.M. Jonesfi
38609a2d462eSRichard W.M. Jones
38619a2d462eSRichard W.M. Jones##########################################
38625c6c3a6cSChristoph Hellwig# linux-aio probe
38635c6c3a6cSChristoph Hellwig
38645c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
38655c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
38665c6c3a6cSChristoph Hellwig#include <libaio.h>
38675c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3868832ce9c2SScott Wood#include <stddef.h>
38695c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
38705c6c3a6cSChristoph HellwigEOF
38715c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
38725c6c3a6cSChristoph Hellwig    linux_aio=yes
38735c6c3a6cSChristoph Hellwig  else
38745c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
387521684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
38765c6c3a6cSChristoph Hellwig    fi
38773cfcae3cSLuiz Capitulino    linux_aio=no
38785c6c3a6cSChristoph Hellwig  fi
38795c6c3a6cSChristoph Hellwigfi
38805c6c3a6cSChristoph Hellwig
38815c6c3a6cSChristoph Hellwig##########################################
38823b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
38833b8acc11SPaolo Bonzini
38843b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
38853b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
38863b8acc11SPaolo Bonzinielse
38873b8acc11SPaolo Bonzini  tpm_passthrough=no
38883b8acc11SPaolo Bonzinifi
38893b8acc11SPaolo Bonzini
3890f4ede81eSAmarnath Valluri# TPM emulator is for all posix systems
3891f4ede81eSAmarnath Valluriif test "$mingw32" != "yes"; then
3892f4ede81eSAmarnath Valluri  tpm_emulator=$tpm
3893f4ede81eSAmarnath Vallurielse
3894f4ede81eSAmarnath Valluri  tpm_emulator=no
3895f4ede81eSAmarnath Vallurifi
38963b8acc11SPaolo Bonzini##########################################
3897758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3898758e8e38SVenkateswararao Jujjuri (JV)
3899758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3900758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3901758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3902758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3903f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3904f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3905f2338fb4SPavel Borzenkov#else
39064f26f2b6SAvi Kivity#include <sys/xattr.h>
3907f2338fb4SPavel Borzenkov#endif
3908758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3909758e8e38SVenkateswararao Jujjuri (JV)EOF
39104f26f2b6SAvi Kivity  if compile_prog "" "" ; then
39114f26f2b6SAvi Kivity    attr=yes
39124f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3913f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3914758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3915758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
39164f26f2b6SAvi Kivity    libattr=yes
3917758e8e38SVenkateswararao Jujjuri (JV)  else
3918758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
391921684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3920758e8e38SVenkateswararao Jujjuri (JV)    fi
3921758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3922758e8e38SVenkateswararao Jujjuri (JV)  fi
3923758e8e38SVenkateswararao Jujjuri (JV)fi
3924758e8e38SVenkateswararao Jujjuri (JV)
3925758e8e38SVenkateswararao Jujjuri (JV)##########################################
3926bf9298b9Saliguori# iovec probe
3927bf9298b9Saliguoricat > $TMPC <<EOF
3928db34f0b3Sblueswir1#include <sys/types.h>
3929bf9298b9Saliguori#include <sys/uio.h>
3930db34f0b3Sblueswir1#include <unistd.h>
3931f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3932bf9298b9SaliguoriEOF
3933bf9298b9Saliguoriiovec=no
393452166aa0SJuan Quintelaif compile_prog "" "" ; then
3935bf9298b9Saliguori  iovec=yes
3936bf9298b9Saliguorifi
3937bf9298b9Saliguori
3938f652e6afSaurel32##########################################
3939ceb42de8Saliguori# preadv probe
3940ceb42de8Saliguoricat > $TMPC <<EOF
3941ceb42de8Saliguori#include <sys/types.h>
3942ceb42de8Saliguori#include <sys/uio.h>
3943ceb42de8Saliguori#include <unistd.h>
3944c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3945ceb42de8SaliguoriEOF
3946ceb42de8Saliguoripreadv=no
394752166aa0SJuan Quintelaif compile_prog "" "" ; then
3948ceb42de8Saliguori  preadv=yes
3949ceb42de8Saliguorifi
3950ceb42de8Saliguori
3951ceb42de8Saliguori##########################################
3952f652e6afSaurel32# fdt probe
3953e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3954e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3955e169e1e1SPeter Maydellfdt_required=no
3956e169e1e1SPeter Maydellfor target in $target_list; do
3957e169e1e1SPeter Maydell  case $target in
3958a666409fSKONRAD Frederic    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3959e169e1e1SPeter Maydell      fdt_required=yes
3960e169e1e1SPeter Maydell    ;;
3961e169e1e1SPeter Maydell  esac
3962e169e1e1SPeter Maydelldone
3963e169e1e1SPeter Maydell
3964e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3965e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3966e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3967e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3968e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3969e169e1e1SPeter Maydell  fi
3970e169e1e1SPeter Maydell  fdt=yes
3971e169e1e1SPeter Maydellfi
3972e169e1e1SPeter Maydell
39732df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3974b41af4baSJuan Quintela  fdt_libs="-lfdt"
397596ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
39766e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3977f652e6afSaurel32  cat > $TMPC << EOF
397831ce0adbSThomas Huth#include <libfdt.h>
397996ce6545SPeter Crosthwaite#include <libfdt_env.h>
3980fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
3981f652e6afSaurel32EOF
398252166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3983a540f158SPeter Crosthwaite    # system DTC is good - use it
3984e3971d61SPhilippe Mathieu-Daudé    fdt=system
3985aef45d51SDaniel P. Berrange  else
3986aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3987aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3988aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3989aef45d51SDaniel P. Berrange      fi
3990aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3991e3971d61SPhilippe Mathieu-Daudé          fdt=git
3992a540f158SPeter Crosthwaite          mkdir -p dtc
3993cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3994a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3995a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
39962df87df7SJuan Quintela          fi
3997a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
39988a99e9a3SPhilippe Mathieu-Daudé          fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
39998a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4000a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4001aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4002aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4003aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4004a540f158SPeter Crosthwaite      else
4005a540f158SPeter Crosthwaite          # don't have and don't want
4006de3a354aSMichael Walle          fdt_libs=
40072df87df7SJuan Quintela          fdt=no
4008f652e6afSaurel32      fi
4009f652e6afSaurel32  fi
4010aef45d51SDaniel P. Berrangefi
4011f652e6afSaurel32
4012a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
4013a540f158SPeter Crosthwaite
401420ff075bSMichael Walle##########################################
4015fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4016b1546f32SGerd Hoffmann
4017da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
40184939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
40195f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
40205f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
40215f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4022da076ffeSGerd Hoffmann    opengl=yes
4023925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4024925a0400SGerd Hoffmann        gtk_gl="yes"
4025925a0400SGerd Hoffmann    fi
4026cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
402720ff075bSMichael Walle  else
4028da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4029dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
403020ff075bSMichael Walle    fi
4031f676c67eSJeremy White    opengl_cflags=""
4032da076ffeSGerd Hoffmann    opengl_libs=""
4033da076ffeSGerd Hoffmann    opengl=no
403420ff075bSMichael Walle  fi
403520ff075bSMichael Wallefi
403620ff075bSMichael Walle
4037014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4038014cb152SGerd Hoffmann  cat > $TMPC << EOF
4039014cb152SGerd Hoffmann#include <epoxy/egl.h>
4040014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4041014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4042014cb152SGerd Hoffmann#endif
4043014cb152SGerd Hoffmannint main(void) { return 0; }
4044014cb152SGerd HoffmannEOF
4045014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4046014cb152SGerd Hoffmann    opengl_dmabuf=yes
4047014cb152SGerd Hoffmann  fi
4048014cb152SGerd Hoffmannfi
4049c9a12e75SChrysostomos Nanakos
4050ed279a06SKlim Kireev##########################################
4051ed279a06SKlim Kireev# libxml2 probe
4052ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4053ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4054ed279a06SKlim Kireev        libxml2="yes"
4055ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4056ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4057ed279a06SKlim Kireev    else
4058ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4059ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4060ed279a06SKlim Kireev        fi
4061ed279a06SKlim Kireev        libxml2="no"
4062ed279a06SKlim Kireev    fi
4063ed279a06SKlim Kireevfi
4064c9a12e75SChrysostomos Nanakos
4065eb100396SBharata B Rao##########################################
4066eb100396SBharata B Rao# glusterfs probe
4067eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
406865d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4069e01bee08SBharata B Rao    glusterfs="yes"
407089138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
407189138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4072d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4073d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4074d85fa9ebSJeff Cody    fi
407565d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
40760c14fb47SBharata B Rao      glusterfs_discard="yes"
40770c14fb47SBharata B Rao    fi
40787c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4079df3a429aSNiels de Vos      glusterfs_fallocate="yes"
40807c815372SBharata B Rao      glusterfs_zerofill="yes"
40817c815372SBharata B Rao    fi
4082eb100396SBharata B Rao  else
4083eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
40848efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
40858efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4086eb100396SBharata B Rao    fi
4087e01bee08SBharata B Rao    glusterfs="no"
4088eb100396SBharata B Rao  fi
4089eb100396SBharata B Raofi
4090eb100396SBharata B Rao
409139386ac7Saurel32# Check for inotify functions when we are building linux-user
40923b3f24adSaurel32# emulator.  This is done because older glibc versions don't
40933b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
40943b3f24adSaurel32# don't provide them even if kernel supports them.
40953b3f24adSaurel32#
40963b3f24adSaurel32inotify=no
40973b3f24adSaurel32cat > $TMPC << EOF
40983b3f24adSaurel32#include <sys/inotify.h>
40993b3f24adSaurel32
41003b3f24adSaurel32int
41013b3f24adSaurel32main(void)
41023b3f24adSaurel32{
41033b3f24adSaurel32	/* try to start inotify */
41048690e420Saurel32	return inotify_init();
41053b3f24adSaurel32}
41063b3f24adSaurel32EOF
410752166aa0SJuan Quintelaif compile_prog "" "" ; then
41083b3f24adSaurel32  inotify=yes
41093b3f24adSaurel32fi
41103b3f24adSaurel32
4111c05c7a73SRiku Voipioinotify1=no
4112c05c7a73SRiku Voipiocat > $TMPC << EOF
4113c05c7a73SRiku Voipio#include <sys/inotify.h>
4114c05c7a73SRiku Voipio
4115c05c7a73SRiku Voipioint
4116c05c7a73SRiku Voipiomain(void)
4117c05c7a73SRiku Voipio{
4118c05c7a73SRiku Voipio    /* try to start inotify */
4119c05c7a73SRiku Voipio    return inotify_init1(0);
4120c05c7a73SRiku Voipio}
4121c05c7a73SRiku VoipioEOF
4122c05c7a73SRiku Voipioif compile_prog "" "" ; then
4123c05c7a73SRiku Voipio  inotify1=yes
4124c05c7a73SRiku Voipiofi
4125c05c7a73SRiku Voipio
4126099d6b0fSRiku Voipio# check if pipe2 is there
4127099d6b0fSRiku Voipiopipe2=no
4128099d6b0fSRiku Voipiocat > $TMPC << EOF
4129099d6b0fSRiku Voipio#include <unistd.h>
4130099d6b0fSRiku Voipio#include <fcntl.h>
4131099d6b0fSRiku Voipio
4132099d6b0fSRiku Voipioint main(void)
4133099d6b0fSRiku Voipio{
4134099d6b0fSRiku Voipio    int pipefd[2];
41359bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4136099d6b0fSRiku Voipio}
4137099d6b0fSRiku VoipioEOF
413852166aa0SJuan Quintelaif compile_prog "" "" ; then
4139099d6b0fSRiku Voipio  pipe2=yes
4140099d6b0fSRiku Voipiofi
4141099d6b0fSRiku Voipio
414240ff6d7eSKevin Wolf# check if accept4 is there
414340ff6d7eSKevin Wolfaccept4=no
414440ff6d7eSKevin Wolfcat > $TMPC << EOF
414540ff6d7eSKevin Wolf#include <sys/socket.h>
414640ff6d7eSKevin Wolf#include <stddef.h>
414740ff6d7eSKevin Wolf
414840ff6d7eSKevin Wolfint main(void)
414940ff6d7eSKevin Wolf{
415040ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
415140ff6d7eSKevin Wolf    return 0;
415240ff6d7eSKevin Wolf}
415340ff6d7eSKevin WolfEOF
415440ff6d7eSKevin Wolfif compile_prog "" "" ; then
415540ff6d7eSKevin Wolf  accept4=yes
415640ff6d7eSKevin Wolffi
415740ff6d7eSKevin Wolf
41583ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
41593ce34dfbSvibisreenivasansplice=no
41603ce34dfbSvibisreenivasancat > $TMPC << EOF
41613ce34dfbSvibisreenivasan#include <unistd.h>
41623ce34dfbSvibisreenivasan#include <fcntl.h>
41633ce34dfbSvibisreenivasan#include <limits.h>
41643ce34dfbSvibisreenivasan
41653ce34dfbSvibisreenivasanint main(void)
41663ce34dfbSvibisreenivasan{
416766ea0f22SStefan Weil    int len, fd = 0;
41683ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
41693ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
41703ce34dfbSvibisreenivasan    return 0;
41713ce34dfbSvibisreenivasan}
41723ce34dfbSvibisreenivasanEOF
417352166aa0SJuan Quintelaif compile_prog "" "" ; then
41743ce34dfbSvibisreenivasan  splice=yes
41753ce34dfbSvibisreenivasanfi
41763ce34dfbSvibisreenivasan
4177dcc38d1cSMarcelo Tosatti##########################################
4178a99d57bbSWanlong Gao# libnuma probe
4179a99d57bbSWanlong Gao
4180a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4181a99d57bbSWanlong Gao  cat > $TMPC << EOF
4182a99d57bbSWanlong Gao#include <numa.h>
4183a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4184a99d57bbSWanlong GaoEOF
4185a99d57bbSWanlong Gao
4186a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4187a99d57bbSWanlong Gao    numa=yes
4188a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4189a99d57bbSWanlong Gao  else
4190a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4191a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4192a99d57bbSWanlong Gao    fi
4193a99d57bbSWanlong Gao    numa=no
4194a99d57bbSWanlong Gao  fi
4195a99d57bbSWanlong Gaofi
4196a99d57bbSWanlong Gao
41977b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
41987b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
41997b01cb97SAlexandre Derumier    exit 1
42007b01cb97SAlexandre Derumierfi
42017b01cb97SAlexandre Derumier
42025a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
42035a22ab71SYang Zhong# do not support it.
42045a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
42055a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
42065a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
42075a22ab71SYang Zhong    fi
42085a22ab71SYang Zhong    malloc_trim="no"
42095a22ab71SYang Zhongfi
42105a22ab71SYang Zhong
42115a22ab71SYang Zhong#######################################
42125a22ab71SYang Zhong# malloc_trim
42135a22ab71SYang Zhong
42145a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
42155a22ab71SYang Zhong    cat > $TMPC << EOF
42165a22ab71SYang Zhong#include <malloc.h>
42175a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
42185a22ab71SYang ZhongEOF
42195a22ab71SYang Zhong    if compile_prog "" "" ; then
42205a22ab71SYang Zhong        malloc_trim="yes"
42215a22ab71SYang Zhong    else
42225a22ab71SYang Zhong        malloc_trim="no"
42235a22ab71SYang Zhong    fi
42245a22ab71SYang Zhongfi
42255a22ab71SYang Zhong
4226a99d57bbSWanlong Gao##########################################
42272847b469SFam Zheng# tcmalloc probe
42282847b469SFam Zheng
42292847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
42302847b469SFam Zheng  cat > $TMPC << EOF
42312847b469SFam Zheng#include <stdlib.h>
42322847b469SFam Zhengint main(void) { malloc(1); return 0; }
42332847b469SFam ZhengEOF
42342847b469SFam Zheng
42352847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
42362847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
42372847b469SFam Zheng  else
42382847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
42392847b469SFam Zheng  fi
42402847b469SFam Zhengfi
42412847b469SFam Zheng
42422847b469SFam Zheng##########################################
42437b01cb97SAlexandre Derumier# jemalloc probe
42447b01cb97SAlexandre Derumier
42457b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
42467b01cb97SAlexandre Derumier  cat > $TMPC << EOF
42477b01cb97SAlexandre Derumier#include <stdlib.h>
42487b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
42497b01cb97SAlexandre DerumierEOF
42507b01cb97SAlexandre Derumier
42517b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
42527b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
42537b01cb97SAlexandre Derumier  else
42547b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
42557b01cb97SAlexandre Derumier  fi
42567b01cb97SAlexandre Derumierfi
42577b01cb97SAlexandre Derumier
42587b01cb97SAlexandre Derumier##########################################
4259dcc38d1cSMarcelo Tosatti# signalfd probe
4260dcc38d1cSMarcelo Tosattisignalfd="no"
4261dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4262dcc38d1cSMarcelo Tosatti#include <unistd.h>
4263dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4264dcc38d1cSMarcelo Tosatti#include <signal.h>
4265dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4266dcc38d1cSMarcelo TosattiEOF
4267dcc38d1cSMarcelo Tosatti
4268dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4269dcc38d1cSMarcelo Tosatti  signalfd=yes
4270dcc38d1cSMarcelo Tosattifi
4271dcc38d1cSMarcelo Tosatti
4272*d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4273*d339d766SRichard W.M. Jonesoptreset="no"
4274*d339d766SRichard W.M. Jonescat > $TMPC << EOF
4275*d339d766SRichard W.M. Jones#include <getopt.h>
4276*d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4277*d339d766SRichard W.M. JonesEOF
4278*d339d766SRichard W.M. Jones
4279*d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4280*d339d766SRichard W.M. Jones  optreset=yes
4281*d339d766SRichard W.M. Jonesfi
4282*d339d766SRichard W.M. Jones
4283c2882b96SRiku Voipio# check if eventfd is supported
4284c2882b96SRiku Voipioeventfd=no
4285c2882b96SRiku Voipiocat > $TMPC << EOF
4286c2882b96SRiku Voipio#include <sys/eventfd.h>
4287c2882b96SRiku Voipio
4288c2882b96SRiku Voipioint main(void)
4289c2882b96SRiku Voipio{
429055cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4291c2882b96SRiku Voipio}
4292c2882b96SRiku VoipioEOF
4293c2882b96SRiku Voipioif compile_prog "" "" ; then
4294c2882b96SRiku Voipio  eventfd=yes
4295c2882b96SRiku Voipiofi
4296c2882b96SRiku Voipio
4297751bcc39SMarc-André Lureau# check if memfd is supported
4298751bcc39SMarc-André Lureaumemfd=no
4299751bcc39SMarc-André Lureaucat > $TMPC << EOF
430075e5b70eSPaolo Bonzini#include <sys/mman.h>
4301751bcc39SMarc-André Lureau
4302751bcc39SMarc-André Lureauint main(void)
4303751bcc39SMarc-André Lureau{
4304751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4305751bcc39SMarc-André Lureau}
4306751bcc39SMarc-André LureauEOF
4307751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4308751bcc39SMarc-André Lureau  memfd=yes
4309751bcc39SMarc-André Lureaufi
4310751bcc39SMarc-André Lureau
4311955727d2SCortland Tölva# check for usbfs
4312955727d2SCortland Tölvahave_usbfs=no
4313955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
4314955727d2SCortland Tölva  if check_include linux/usbdevice_fs.h; then
4315955727d2SCortland Tölva    have_usbfs=yes
4316955727d2SCortland Tölva  fi
4317955727d2SCortland Tölva  have_usbfs=yes
4318955727d2SCortland Tölvafi
4319751bcc39SMarc-André Lureau
4320d0927938SUlrich Hecht# check for fallocate
4321d0927938SUlrich Hechtfallocate=no
4322d0927938SUlrich Hechtcat > $TMPC << EOF
4323d0927938SUlrich Hecht#include <fcntl.h>
4324d0927938SUlrich Hecht
4325d0927938SUlrich Hechtint main(void)
4326d0927938SUlrich Hecht{
4327d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4328d0927938SUlrich Hecht    return 0;
4329d0927938SUlrich Hecht}
4330d0927938SUlrich HechtEOF
43318fb03151SPeter Maydellif compile_prog "" "" ; then
4332d0927938SUlrich Hecht  fallocate=yes
4333d0927938SUlrich Hechtfi
4334d0927938SUlrich Hecht
43353d4fa43eSKusanagi Kouichi# check for fallocate hole punching
43363d4fa43eSKusanagi Kouichifallocate_punch_hole=no
43373d4fa43eSKusanagi Kouichicat > $TMPC << EOF
43383d4fa43eSKusanagi Kouichi#include <fcntl.h>
43393d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
43403d4fa43eSKusanagi Kouichi
43413d4fa43eSKusanagi Kouichiint main(void)
43423d4fa43eSKusanagi Kouichi{
43433d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
43443d4fa43eSKusanagi Kouichi    return 0;
43453d4fa43eSKusanagi Kouichi}
43463d4fa43eSKusanagi KouichiEOF
43473d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
43483d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
43493d4fa43eSKusanagi Kouichifi
43503d4fa43eSKusanagi Kouichi
4351b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4352b953f075SDenis V. Lunevfallocate_zero_range=no
4353b953f075SDenis V. Lunevcat > $TMPC << EOF
4354b953f075SDenis V. Lunev#include <fcntl.h>
4355b953f075SDenis V. Lunev#include <linux/falloc.h>
4356b953f075SDenis V. Lunev
4357b953f075SDenis V. Lunevint main(void)
4358b953f075SDenis V. Lunev{
4359b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4360b953f075SDenis V. Lunev    return 0;
4361b953f075SDenis V. Lunev}
4362b953f075SDenis V. LunevEOF
4363b953f075SDenis V. Lunevif compile_prog "" "" ; then
4364b953f075SDenis V. Lunev  fallocate_zero_range=yes
4365b953f075SDenis V. Lunevfi
4366b953f075SDenis V. Lunev
4367ed911435SKevin Wolf# check for posix_fallocate
4368ed911435SKevin Wolfposix_fallocate=no
4369ed911435SKevin Wolfcat > $TMPC << EOF
4370ed911435SKevin Wolf#include <fcntl.h>
4371ed911435SKevin Wolf
4372ed911435SKevin Wolfint main(void)
4373ed911435SKevin Wolf{
4374ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4375ed911435SKevin Wolf    return 0;
4376ed911435SKevin Wolf}
4377ed911435SKevin WolfEOF
4378ed911435SKevin Wolfif compile_prog "" "" ; then
4379ed911435SKevin Wolf    posix_fallocate=yes
4380ed911435SKevin Wolffi
4381ed911435SKevin Wolf
4382c727f47dSPeter Maydell# check for sync_file_range
4383c727f47dSPeter Maydellsync_file_range=no
4384c727f47dSPeter Maydellcat > $TMPC << EOF
4385c727f47dSPeter Maydell#include <fcntl.h>
4386c727f47dSPeter Maydell
4387c727f47dSPeter Maydellint main(void)
4388c727f47dSPeter Maydell{
4389c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4390c727f47dSPeter Maydell    return 0;
4391c727f47dSPeter Maydell}
4392c727f47dSPeter MaydellEOF
43938fb03151SPeter Maydellif compile_prog "" "" ; then
4394c727f47dSPeter Maydell  sync_file_range=yes
4395c727f47dSPeter Maydellfi
4396c727f47dSPeter Maydell
4397dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4398dace20dcSPeter Maydellfiemap=no
4399dace20dcSPeter Maydellcat > $TMPC << EOF
4400dace20dcSPeter Maydell#include <sys/ioctl.h>
4401dace20dcSPeter Maydell#include <linux/fs.h>
4402dace20dcSPeter Maydell#include <linux/fiemap.h>
4403dace20dcSPeter Maydell
4404dace20dcSPeter Maydellint main(void)
4405dace20dcSPeter Maydell{
4406dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4407dace20dcSPeter Maydell    return 0;
4408dace20dcSPeter Maydell}
4409dace20dcSPeter MaydellEOF
44108fb03151SPeter Maydellif compile_prog "" "" ; then
4411dace20dcSPeter Maydell  fiemap=yes
4412dace20dcSPeter Maydellfi
4413dace20dcSPeter Maydell
4414d0927938SUlrich Hecht# check for dup3
4415d0927938SUlrich Hechtdup3=no
4416d0927938SUlrich Hechtcat > $TMPC << EOF
4417d0927938SUlrich Hecht#include <unistd.h>
4418d0927938SUlrich Hecht
4419d0927938SUlrich Hechtint main(void)
4420d0927938SUlrich Hecht{
4421d0927938SUlrich Hecht    dup3(0, 0, 0);
4422d0927938SUlrich Hecht    return 0;
4423d0927938SUlrich Hecht}
4424d0927938SUlrich HechtEOF
442578f5d726SJan Kiszkaif compile_prog "" "" ; then
4426d0927938SUlrich Hecht  dup3=yes
4427d0927938SUlrich Hechtfi
4428d0927938SUlrich Hecht
44294e0c6529SAlex Bligh# check for ppoll support
44304e0c6529SAlex Blighppoll=no
44314e0c6529SAlex Blighcat > $TMPC << EOF
44324e0c6529SAlex Bligh#include <poll.h>
44334e0c6529SAlex Bligh
44344e0c6529SAlex Blighint main(void)
44354e0c6529SAlex Bligh{
44364e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
44374e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
44384e0c6529SAlex Bligh    return 0;
44394e0c6529SAlex Bligh}
44404e0c6529SAlex BlighEOF
44414e0c6529SAlex Blighif compile_prog "" "" ; then
44424e0c6529SAlex Bligh  ppoll=yes
44434e0c6529SAlex Blighfi
44444e0c6529SAlex Bligh
4445cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4446cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4447cd758dd0SAlex Blighcat > $TMPC << EOF
4448cd758dd0SAlex Bligh#include <sys/prctl.h>
4449cd758dd0SAlex Bligh
4450cd758dd0SAlex Blighint main(void)
4451cd758dd0SAlex Bligh{
4452cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4453cd758dd0SAlex Bligh    return 0;
4454cd758dd0SAlex Bligh}
4455cd758dd0SAlex BlighEOF
4456cd758dd0SAlex Blighif compile_prog "" "" ; then
4457cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4458cd758dd0SAlex Blighfi
4459cd758dd0SAlex Bligh
44603b6edd16SPeter Maydell# check for epoll support
44613b6edd16SPeter Maydellepoll=no
44623b6edd16SPeter Maydellcat > $TMPC << EOF
44633b6edd16SPeter Maydell#include <sys/epoll.h>
44643b6edd16SPeter Maydell
44653b6edd16SPeter Maydellint main(void)
44663b6edd16SPeter Maydell{
44673b6edd16SPeter Maydell    epoll_create(0);
44683b6edd16SPeter Maydell    return 0;
44693b6edd16SPeter Maydell}
44703b6edd16SPeter MaydellEOF
44718fb03151SPeter Maydellif compile_prog "" "" ; then
44723b6edd16SPeter Maydell  epoll=yes
44733b6edd16SPeter Maydellfi
44743b6edd16SPeter Maydell
4475227f0214SPeter Maydell# epoll_create1 is a later addition
4476227f0214SPeter Maydell# so we must check separately for its presence
44773b6edd16SPeter Maydellepoll_create1=no
44783b6edd16SPeter Maydellcat > $TMPC << EOF
44793b6edd16SPeter Maydell#include <sys/epoll.h>
44803b6edd16SPeter Maydell
44813b6edd16SPeter Maydellint main(void)
44823b6edd16SPeter Maydell{
448319e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
448419e83f6bSPeter Maydell     * a function being called. This is necessary so that on
448519e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
448619e83f6bSPeter Maydell     * the library but not declared in the header file we will
448719e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
448819e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
448919e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
449019e83f6bSPeter Maydell     */
4491c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
44923b6edd16SPeter Maydell}
44933b6edd16SPeter MaydellEOF
44948fb03151SPeter Maydellif compile_prog "" "" ; then
44953b6edd16SPeter Maydell  epoll_create1=yes
44963b6edd16SPeter Maydellfi
44973b6edd16SPeter Maydell
4498a8fd1abaSPeter Maydell# check for sendfile support
4499a8fd1abaSPeter Maydellsendfile=no
4500a8fd1abaSPeter Maydellcat > $TMPC << EOF
4501a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4502a8fd1abaSPeter Maydell
4503a8fd1abaSPeter Maydellint main(void)
4504a8fd1abaSPeter Maydell{
4505a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4506a8fd1abaSPeter Maydell}
4507a8fd1abaSPeter MaydellEOF
4508a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4509a8fd1abaSPeter Maydell  sendfile=yes
4510a8fd1abaSPeter Maydellfi
4511a8fd1abaSPeter Maydell
451251834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
451351834341SRiku Voipiotimerfd=no
451451834341SRiku Voipiocat > $TMPC << EOF
451551834341SRiku Voipio#include <sys/timerfd.h>
451651834341SRiku Voipio
451751834341SRiku Voipioint main(void)
451851834341SRiku Voipio{
451951834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
452051834341SRiku Voipio}
452151834341SRiku VoipioEOF
452251834341SRiku Voipioif compile_prog "" "" ; then
452351834341SRiku Voipio  timerfd=yes
452451834341SRiku Voipiofi
452551834341SRiku Voipio
45269af5c906SRiku Voipio# check for setns and unshare support
45279af5c906SRiku Voipiosetns=no
45289af5c906SRiku Voipiocat > $TMPC << EOF
45299af5c906SRiku Voipio#include <sched.h>
45309af5c906SRiku Voipio
45319af5c906SRiku Voipioint main(void)
45329af5c906SRiku Voipio{
45339af5c906SRiku Voipio    int ret;
45349af5c906SRiku Voipio    ret = setns(0, 0);
45359af5c906SRiku Voipio    ret = unshare(0);
45369af5c906SRiku Voipio    return ret;
45379af5c906SRiku Voipio}
45389af5c906SRiku VoipioEOF
45399af5c906SRiku Voipioif compile_prog "" "" ; then
45409af5c906SRiku Voipio  setns=yes
45419af5c906SRiku Voipiofi
45429af5c906SRiku Voipio
454338860a03SAleksandar Markovic# clock_adjtime probe
454438860a03SAleksandar Markovicclock_adjtime=no
454538860a03SAleksandar Markoviccat > $TMPC <<EOF
454638860a03SAleksandar Markovic#include <time.h>
454738860a03SAleksandar Markovic
454838860a03SAleksandar Markovicint main(void)
454938860a03SAleksandar Markovic{
455038860a03SAleksandar Markovic    return clock_adjtime(0, 0);
455138860a03SAleksandar Markovic}
455238860a03SAleksandar MarkovicEOF
455338860a03SAleksandar Markovicclock_adjtime=no
455438860a03SAleksandar Markovicif compile_prog "" "" ; then
455538860a03SAleksandar Markovic  clock_adjtime=yes
455638860a03SAleksandar Markovicfi
455738860a03SAleksandar Markovic
45585a03cd00SAleksandar Markovic# syncfs probe
45595a03cd00SAleksandar Markovicsyncfs=no
45605a03cd00SAleksandar Markoviccat > $TMPC <<EOF
45615a03cd00SAleksandar Markovic#include <unistd.h>
45625a03cd00SAleksandar Markovic
45635a03cd00SAleksandar Markovicint main(void)
45645a03cd00SAleksandar Markovic{
45655a03cd00SAleksandar Markovic    return syncfs(0);
45665a03cd00SAleksandar Markovic}
45675a03cd00SAleksandar MarkovicEOF
45685a03cd00SAleksandar Markovicsyncfs=no
45695a03cd00SAleksandar Markovicif compile_prog "" "" ; then
45705a03cd00SAleksandar Markovic  syncfs=yes
45715a03cd00SAleksandar Markovicfi
45725a03cd00SAleksandar Markovic
4573cc8ae6deSpbrook# Check if tools are available to build documentation.
4574a25dba17SJuan Quintelaif test "$docs" != "no" ; then
457501668d98SStefan Weil  if has makeinfo && has pod2man; then
4576a25dba17SJuan Quintela    docs=yes
457783a3ab8bSJuan Quintela  else
4578a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
457921684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
458083a3ab8bSJuan Quintela    fi
4581a25dba17SJuan Quintela    docs=no
458283a3ab8bSJuan Quintela  fi
4583cc8ae6deSpbrookfi
4584cc8ae6deSpbrook
4585f514f41cSStefan Weil# Search for bswap_32 function
45866ae9a1f4SJuan Quintelabyteswap_h=no
45876ae9a1f4SJuan Quintelacat > $TMPC << EOF
45886ae9a1f4SJuan Quintela#include <byteswap.h>
45896ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
45906ae9a1f4SJuan QuintelaEOF
459152166aa0SJuan Quintelaif compile_prog "" "" ; then
45926ae9a1f4SJuan Quintela  byteswap_h=yes
45936ae9a1f4SJuan Quintelafi
45946ae9a1f4SJuan Quintela
459575f13596SStefan Weil# Search for bswap32 function
45966ae9a1f4SJuan Quintelabswap_h=no
45976ae9a1f4SJuan Quintelacat > $TMPC << EOF
45986ae9a1f4SJuan Quintela#include <sys/endian.h>
45996ae9a1f4SJuan Quintela#include <sys/types.h>
46006ae9a1f4SJuan Quintela#include <machine/bswap.h>
46016ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
46026ae9a1f4SJuan QuintelaEOF
460352166aa0SJuan Quintelaif compile_prog "" "" ; then
46046ae9a1f4SJuan Quintela  bswap_h=yes
46056ae9a1f4SJuan Quintelafi
46066ae9a1f4SJuan Quintela
4607da93a1fdSaliguori##########################################
4608e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4609c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4610e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
46113c33ea96SPaolo Bonzini    libiscsi="yes"
4612ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4613ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4614c589b249SRonnie Sahlberg  else
4615c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4616e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4617c589b249SRonnie Sahlberg    fi
4618c589b249SRonnie Sahlberg    libiscsi="no"
4619c589b249SRonnie Sahlberg  fi
4620c589b249SRonnie Sahlbergfi
4621c589b249SRonnie Sahlberg
4622c589b249SRonnie Sahlberg##########################################
46238bacde8dSNatanael Copa# Do we need libm
46248bacde8dSNatanael Copacat > $TMPC << EOF
46258bacde8dSNatanael Copa#include <math.h>
4626f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
46278bacde8dSNatanael CopaEOF
46288bacde8dSNatanael Copaif compile_prog "" "" ; then
46298bacde8dSNatanael Copa  :
46308bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
46318bacde8dSNatanael Copa  LIBS="-lm $LIBS"
46328bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
46338bacde8dSNatanael Copaelse
463476ad07a4SPeter Maydell  error_exit "libm check failed"
46358bacde8dSNatanael Copafi
46368bacde8dSNatanael Copa
46378bacde8dSNatanael Copa##########################################
4638da93a1fdSaliguori# Do we need librt
46398bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
46408bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
46418bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
46428bacde8dSNatanael Copa# function in addition.
4643da93a1fdSaliguoricat > $TMPC <<EOF
4644da93a1fdSaliguori#include <signal.h>
4645da93a1fdSaliguori#include <time.h>
46468bacde8dSNatanael Copaint main(void) {
46478bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
46488bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
46498bacde8dSNatanael Copa}
4650da93a1fdSaliguoriEOF
4651da93a1fdSaliguori
465252166aa0SJuan Quintelaif compile_prog "" "" ; then
465307ffa4bdSJuan Quintela  :
46548bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
465518e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
465618e588b1SRick Liu  LIBS="$LIBS -lrt"
465718e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4658da93a1fdSaliguorifi
4659da93a1fdSaliguori
466031ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
466178723752SPeter Maydell        "$haiku" != "yes" ; then
46626362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
46636362a53fSJuan Quintelafi
46646362a53fSJuan Quintela
4665de5071c5SBlue Swirl##########################################
4666cd4ec0b4SGerd Hoffmann# spice probe
4667cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4668cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4669cd4ec0b4SGerd Hoffmann#include <spice.h>
4670cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4671cd4ec0b4SGerd HoffmannEOF
4672710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4673710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
46741b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
467565d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4676cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4677cd4ec0b4SGerd Hoffmann    spice="yes"
4678cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4679cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
46802e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
46812e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4682cd4ec0b4SGerd Hoffmann  else
4683cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
46848efc9363SHu Tao      feature_not_found "spice" \
46851b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4686cd4ec0b4SGerd Hoffmann    fi
4687cd4ec0b4SGerd Hoffmann    spice="no"
4688cd4ec0b4SGerd Hoffmann  fi
4689cd4ec0b4SGerd Hoffmannfi
4690cd4ec0b4SGerd Hoffmann
46917b02f544SMarc-André Lureau# check for smartcard support
46927b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
46930f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
46947b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
46957b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
46967b02f544SMarc-André Lureau        smartcard="yes"
4697111a38b0SRobert Relyea    else
46987b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
46997b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4700111a38b0SRobert Relyea        fi
47017b02f544SMarc-André Lureau        smartcard="no"
4702111a38b0SRobert Relyea    fi
4703111a38b0SRobert Relyeafi
4704111a38b0SRobert Relyea
47052b2325ffSGerd Hoffmann# check for libusb
47062b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
470765d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
47082b2325ffSGerd Hoffmann        libusb="yes"
4709ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4710ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
47112b2325ffSGerd Hoffmann    else
47122b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
47138efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
47142b2325ffSGerd Hoffmann        fi
47152b2325ffSGerd Hoffmann        libusb="no"
47162b2325ffSGerd Hoffmann    fi
47172b2325ffSGerd Hoffmannfi
47182b2325ffSGerd Hoffmann
471969354a83SHans de Goede# check for usbredirparser for usb network redirection support
472069354a83SHans de Goedeif test "$usb_redir" != "no" ; then
472165d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
472269354a83SHans de Goede        usb_redir="yes"
4723ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4724ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
472569354a83SHans de Goede    else
472669354a83SHans de Goede        if test "$usb_redir" = "yes"; then
472721684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
472869354a83SHans de Goede        fi
472969354a83SHans de Goede        usb_redir="no"
473069354a83SHans de Goede    fi
473169354a83SHans de Goedefi
473269354a83SHans de Goede
4733cd4ec0b4SGerd Hoffmann##########################################
4734d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4735d9840e25STomoki Sekiyama
4736d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4737d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4738690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4739d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4740d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4741690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4742d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4743d9840e25STomoki Sekiyama	  ;;
4744690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4745d9840e25STomoki Sekiyama  esac
4746d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4747d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4748d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4749d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4750d9840e25STomoki SekiyamaEOF
4751d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4752d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4753d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4754315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4755f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4756d9840e25STomoki Sekiyama  else
4757d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4758d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4759d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4760d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4761d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4762d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4763d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4764d9840e25STomoki Sekiyama    fi
4765d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4766d9840e25STomoki Sekiyama  fi
4767d9840e25STomoki Sekiyamafi
4768d9840e25STomoki Sekiyama
4769d9840e25STomoki Sekiyama##########################################
4770d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4771d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4772d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4773d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4774d9840e25STomoki Sekiyama
4775d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4776d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4777d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4778d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4779d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4780d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4781d9840e25STomoki Sekiyama    else
4782d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4783d9840e25STomoki Sekiyama    fi
4784d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4785d9840e25STomoki Sekiyama    win_sdk=""
4786d9840e25STomoki Sekiyama  fi
4787d9840e25STomoki Sekiyamafi
4788d9840e25STomoki Sekiyama
4789d9840e25STomoki Sekiyama##########################################
479050cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
479150cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
479250cbebb9SMichael Roth  cat > $TMPC << EOF
479350cbebb9SMichael Roth#include <windows.h>
479450cbebb9SMichael Roth#include <ntddscsi.h>
479550cbebb9SMichael Rothint main(void) {
479650cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
479750cbebb9SMichael Roth#error Missing required ioctl definitions
479850cbebb9SMichael Roth#endif
479950cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
480050cbebb9SMichael Roth  return addr.Lun;
480150cbebb9SMichael Roth}
480250cbebb9SMichael RothEOF
480350cbebb9SMichael Roth  if compile_prog "" "" ; then
480450cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4805c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
480650cbebb9SMichael Roth  fi
480750cbebb9SMichael Rothfi
480850cbebb9SMichael Roth
480950cbebb9SMichael Roth##########################################
48109d9e1521SGerd Hoffmann# virgl renderer probe
48119d9e1521SGerd Hoffmann
48129d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
48139d9e1521SGerd Hoffmann  cat > $TMPC << EOF
48149d9e1521SGerd Hoffmann#include <virglrenderer.h>
48159d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
48169d9e1521SGerd HoffmannEOF
48179d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
48189d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
481947479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
48209d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
48219d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
48229d9e1521SGerd Hoffmann    virglrenderer="yes"
48239d9e1521SGerd Hoffmann  else
48249d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
48259d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
48269d9e1521SGerd Hoffmann    fi
48279d9e1521SGerd Hoffmann    virglrenderer="no"
48289d9e1521SGerd Hoffmann  fi
48299d9e1521SGerd Hoffmannfi
48309d9e1521SGerd Hoffmann
48319d9e1521SGerd Hoffmann##########################################
48328ca80760SRichard Henderson# capstone
48338ca80760SRichard Henderson
4834e219c499SRichard Hendersoncase "$capstone" in
4835e219c499SRichard Henderson  "" | yes)
48368ca80760SRichard Henderson    if $pkg_config capstone; then
4837e219c499SRichard Henderson      capstone=system
4838123ac0bbSAlexey Kardashevskiy    elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
4839e219c499SRichard Henderson      capstone=git
4840e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4841e219c499SRichard Henderson      capstone=internal
4842e219c499SRichard Henderson    elif test -z "$capstone" ; then
4843e219c499SRichard Henderson      capstone=no
4844e219c499SRichard Henderson    else
4845e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4846e219c499SRichard Henderson    fi
4847e219c499SRichard Henderson    ;;
4848e219c499SRichard Henderson
4849e219c499SRichard Henderson  system)
4850e219c499SRichard Henderson    if ! $pkg_config capstone; then
4851e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4852e219c499SRichard Henderson    fi
4853e219c499SRichard Henderson    ;;
4854e219c499SRichard Hendersonesac
4855e219c499SRichard Henderson
4856e219c499SRichard Hendersoncase "$capstone" in
4857e219c499SRichard Henderson  git | internal)
4858e219c499SRichard Henderson    if test "$capstone" = git; then
4859e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4860e219c499SRichard Henderson    fi
4861e219c499SRichard Henderson    mkdir -p capstone
4862e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4863e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4864e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4865e219c499SRichard Henderson    else
4866e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4867e219c499SRichard Henderson    fi
4868e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4869e219c499SRichard Henderson    ;;
4870e219c499SRichard Henderson
4871e219c499SRichard Henderson  system)
48728ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
48738ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4874e219c499SRichard Henderson    ;;
4875e219c499SRichard Henderson
4876e219c499SRichard Henderson  no)
4877e219c499SRichard Henderson    ;;
4878e219c499SRichard Henderson  *)
4879e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4880e219c499SRichard Henderson    ;;
4881e219c499SRichard Hendersonesac
48828ca80760SRichard Henderson
48838ca80760SRichard Henderson##########################################
48845f6b9e8fSBlue Swirl# check if we have fdatasync
48855f6b9e8fSBlue Swirl
48865f6b9e8fSBlue Swirlfdatasync=no
48875f6b9e8fSBlue Swirlcat > $TMPC << EOF
48885f6b9e8fSBlue Swirl#include <unistd.h>
4889d1722a27SAlexandre Raymondint main(void) {
4890d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4891d1722a27SAlexandre Raymondreturn fdatasync(0);
4892d1722a27SAlexandre Raymond#else
4893e172fe11SStefan Weil#error Not supported
4894d1722a27SAlexandre Raymond#endif
4895d1722a27SAlexandre Raymond}
48965f6b9e8fSBlue SwirlEOF
48975f6b9e8fSBlue Swirlif compile_prog "" "" ; then
48985f6b9e8fSBlue Swirl    fdatasync=yes
48995f6b9e8fSBlue Swirlfi
49005f6b9e8fSBlue Swirl
490194a420b1SStefan Hajnoczi##########################################
4902e78815a5SAndreas Färber# check if we have madvise
4903e78815a5SAndreas Färber
4904e78815a5SAndreas Färbermadvise=no
4905e78815a5SAndreas Färbercat > $TMPC << EOF
4906e78815a5SAndreas Färber#include <sys/types.h>
4907e78815a5SAndreas Färber#include <sys/mman.h>
4908832ce9c2SScott Wood#include <stddef.h>
4909e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4910e78815a5SAndreas FärberEOF
4911e78815a5SAndreas Färberif compile_prog "" "" ; then
4912e78815a5SAndreas Färber    madvise=yes
4913e78815a5SAndreas Färberfi
4914e78815a5SAndreas Färber
4915e78815a5SAndreas Färber##########################################
4916e78815a5SAndreas Färber# check if we have posix_madvise
4917e78815a5SAndreas Färber
4918e78815a5SAndreas Färberposix_madvise=no
4919e78815a5SAndreas Färbercat > $TMPC << EOF
4920e78815a5SAndreas Färber#include <sys/mman.h>
4921832ce9c2SScott Wood#include <stddef.h>
4922e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4923e78815a5SAndreas FärberEOF
4924e78815a5SAndreas Färberif compile_prog "" "" ; then
4925e78815a5SAndreas Färber    posix_madvise=yes
4926e78815a5SAndreas Färberfi
4927e78815a5SAndreas Färber
4928e78815a5SAndreas Färber##########################################
49299bc5a719SAndreas Gustafsson# check if we have posix_memalign()
49309bc5a719SAndreas Gustafsson
49319bc5a719SAndreas Gustafssonposix_memalign=no
49329bc5a719SAndreas Gustafssoncat > $TMPC << EOF
49339bc5a719SAndreas Gustafsson#include <stdlib.h>
49349bc5a719SAndreas Gustafssonint main(void) {
49359bc5a719SAndreas Gustafsson    void *p;
49369bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
49379bc5a719SAndreas Gustafsson}
49389bc5a719SAndreas GustafssonEOF
49399bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
49409bc5a719SAndreas Gustafsson    posix_memalign=yes
49419bc5a719SAndreas Gustafssonfi
49429bc5a719SAndreas Gustafsson
49439bc5a719SAndreas Gustafsson##########################################
49440a852417SPaul Durrant# check if we have posix_syslog
49450a852417SPaul Durrant
49460a852417SPaul Durrantposix_syslog=no
49470a852417SPaul Durrantcat > $TMPC << EOF
49480a852417SPaul Durrant#include <syslog.h>
49490a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
49500a852417SPaul DurrantEOF
49510a852417SPaul Durrantif compile_prog "" "" ; then
49520a852417SPaul Durrant    posix_syslog=yes
49530a852417SPaul Durrantfi
49540a852417SPaul Durrant
49550a852417SPaul Durrant##########################################
4956401bc051SPeter Maydell# check if we have sem_timedwait
4957401bc051SPeter Maydell
4958401bc051SPeter Maydellsem_timedwait=no
4959401bc051SPeter Maydellcat > $TMPC << EOF
4960401bc051SPeter Maydell#include <semaphore.h>
4961401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4962401bc051SPeter MaydellEOF
4963401bc051SPeter Maydellif compile_prog "" "" ; then
4964401bc051SPeter Maydell    sem_timedwait=yes
4965401bc051SPeter Maydellfi
4966401bc051SPeter Maydell
4967401bc051SPeter Maydell##########################################
49685c99fa37SKeno Fischer# check if we have strchrnul
49695c99fa37SKeno Fischer
49705c99fa37SKeno Fischerstrchrnul=no
49715c99fa37SKeno Fischercat > $TMPC << EOF
49725c99fa37SKeno Fischer#include <string.h>
49735c99fa37SKeno Fischerint main(void);
49745c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
49755c99fa37SKeno Fischerchar *haystack = (char*)&main;
49765c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
49775c99fa37SKeno FischerEOF
49785c99fa37SKeno Fischerif compile_prog "" "" ; then
49795c99fa37SKeno Fischer    strchrnul=yes
49805c99fa37SKeno Fischerfi
49815c99fa37SKeno Fischer
49825c99fa37SKeno Fischer##########################################
498394a420b1SStefan Hajnoczi# check if trace backend exists
498494a420b1SStefan Hajnoczi
49855b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
498694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
49875b808275SLluís Vilanova  error_exit "invalid trace backends" \
49885b808275SLluís Vilanova      "Please choose supported trace backends."
498994a420b1SStefan Hajnoczifi
499094a420b1SStefan Hajnoczi
49917e24e92aSStefan Hajnoczi##########################################
49927e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
49935b808275SLluís Vilanovaif have_backend "ust"; then
49947e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4995bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
49967e24e92aSStefan Hajnocziint main(void) { return 0; }
49977e24e92aSStefan HajnocziEOF
4998c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4999bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
500089138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
50017e24e92aSStefan Hajnoczi    else
5002c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5003bf15f63cSMohamad Gebai    fi
5004bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
500589138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5006bf15f63cSMohamad Gebai    else
5007bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5008bf15f63cSMohamad Gebai    fi
5009bf15f63cSMohamad Gebai
5010bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5011bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5012bf15f63cSMohamad Gebai  else
5013bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
50147e24e92aSStefan Hajnoczi  fi
50157e24e92aSStefan Hajnoczifi
5016b3d08c02SDaniel P. Berrange
5017b3d08c02SDaniel P. Berrange##########################################
5018b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
50195b808275SLluís Vilanovaif have_backend "dtrace"; then
5020b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
502176ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5022b3d08c02SDaniel P. Berrange  fi
5023c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5024c276b17dSDaniel P. Berrange  if has 'stap' ; then
5025c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5026c276b17dSDaniel P. Berrange  fi
5027b3d08c02SDaniel P. Berrangefi
5028b3d08c02SDaniel P. Berrange
50297e24e92aSStefan Hajnoczi##########################################
5030519175a2SAlex Barcelo# check and set a backend for coroutine
5031d0e2fce5SAneesh Kumar K.V
50327c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
503333c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
503433c53c54SDaniel P. Berrange# specific one.
50357c2acc70SPeter Maydell
50367c2acc70SPeter Maydellucontext_works=no
5037d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5038d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5039d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5040cdf84806SPeter Maydell#ifdef __stub_makecontext
5041cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5042cdf84806SPeter Maydell#endif
504375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5044d0e2fce5SAneesh Kumar K.VEOF
5045d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
50467c2acc70SPeter Maydell    ucontext_works=yes
5047d0e2fce5SAneesh Kumar K.V  fi
5048519175a2SAlex Barcelofi
50497c2acc70SPeter Maydell
50507c2acc70SPeter Maydellif test "$coroutine" = ""; then
50517c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
50527c2acc70SPeter Maydell    coroutine=win32
50537c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
50547c2acc70SPeter Maydell    coroutine=ucontext
5055519175a2SAlex Barcelo  else
50567c2acc70SPeter Maydell    coroutine=sigaltstack
50577c2acc70SPeter Maydell  fi
50587c2acc70SPeter Maydellelse
50597c2acc70SPeter Maydell  case $coroutine in
50607c2acc70SPeter Maydell  windows)
50617c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
50627c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
50637c2acc70SPeter Maydell    fi
50647c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
50657c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
50667c2acc70SPeter Maydell    coroutine=win32
50677c2acc70SPeter Maydell    ;;
50687c2acc70SPeter Maydell  ucontext)
50697c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
50707c2acc70SPeter Maydell      feature_not_found "ucontext"
50717c2acc70SPeter Maydell    fi
50727c2acc70SPeter Maydell    ;;
507333c53c54SDaniel P. Berrange  sigaltstack)
50747c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
50757c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
50767c2acc70SPeter Maydell    fi
50777c2acc70SPeter Maydell    ;;
50787c2acc70SPeter Maydell  *)
507976ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
50807c2acc70SPeter Maydell    ;;
50817c2acc70SPeter Maydell  esac
5082d0e2fce5SAneesh Kumar K.Vfi
5083d0e2fce5SAneesh Kumar K.V
508470c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
508570c60c08SStefan Hajnoczi  coroutine_pool=yes
508670c60c08SStefan Hajnoczifi
508770c60c08SStefan Hajnoczi
50887d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
50897d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
50907d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
50917d992e4dSPeter Lieven    coroutine_pool=no
50927d992e4dSPeter Lieven  fi
50937d992e4dSPeter Lievenfi
50947d992e4dSPeter Lieven
50957d992e4dSPeter Lieven
5096d0e2fce5SAneesh Kumar K.V##########################################
5097d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5098d2042378SAneesh Kumar K.V
50994e1797f9SStefan Weilopen_by_handle_at=no
5100d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5101d2042378SAneesh Kumar K.V#include <fcntl.h>
5102acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5103acc55ba8SStefan Weil# error missing definition
5104acc55ba8SStefan Weil#else
510575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5106acc55ba8SStefan Weil#endif
5107d2042378SAneesh Kumar K.VEOF
5108d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5109d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5110d2042378SAneesh Kumar K.Vfi
5111d2042378SAneesh Kumar K.V
5112e06a765eSHarsh Prateek Bora########################################
5113e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5114e06a765eSHarsh Prateek Bora
5115e06a765eSHarsh Prateek Boralinux_magic_h=no
5116e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5117e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5118e06a765eSHarsh Prateek Boraint main(void) {
511975cafad7SStefan Weil  return 0;
5120e06a765eSHarsh Prateek Bora}
5121e06a765eSHarsh Prateek BoraEOF
5122e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5123e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5124e06a765eSHarsh Prateek Borafi
5125e06a765eSHarsh Prateek Bora
51268ab1bf12SLuiz Capitulino########################################
5127c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
5128c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
5129c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
5130c95e3080SKevin Wolf# only a warning.
5131c95e3080SKevin Wolf#
5132c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
5133c95e3080SKevin Wolf# the build doesn't fail anyway.
5134c95e3080SKevin Wolf
513506d71fa1SPeter Maydellpragma_disable_unused_but_set=no
513606d71fa1SPeter Maydellcat > $TMPC << EOF
5137e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
5138c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5139e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
5140c95e3080SKevin Wolf
514106d71fa1SPeter Maydellint main(void) {
514206d71fa1SPeter Maydell    return 0;
514306d71fa1SPeter Maydell}
514406d71fa1SPeter MaydellEOF
514506d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
5146cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
5147c95e3080SKevin Wolfelse
5148c95e3080SKevin Wolf    werror=no
514906d71fa1SPeter Maydellfi
515006d71fa1SPeter Maydell
515106d71fa1SPeter Maydell########################################
5152541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
51533f4349dcSKevin Wolf
51543f4349dcSKevin Wolfvalgrind_h=no
51553f4349dcSKevin Wolfcat > $TMPC << EOF
51563f4349dcSKevin Wolf#include <valgrind/valgrind.h>
51573f4349dcSKevin Wolfint main(void) {
51583f4349dcSKevin Wolf  return 0;
51593f4349dcSKevin Wolf}
51603f4349dcSKevin WolfEOF
51613f4349dcSKevin Wolfif compile_prog "" "" ; then
51623f4349dcSKevin Wolf    valgrind_h=yes
51633f4349dcSKevin Wolffi
51643f4349dcSKevin Wolf
51653f4349dcSKevin Wolf########################################
51668ab1bf12SLuiz Capitulino# check if environ is declared
51678ab1bf12SLuiz Capitulino
51688ab1bf12SLuiz Capitulinohas_environ=no
51698ab1bf12SLuiz Capitulinocat > $TMPC << EOF
51708ab1bf12SLuiz Capitulino#include <unistd.h>
51718ab1bf12SLuiz Capitulinoint main(void) {
5172c075a723SBlue Swirl    environ = 0;
51738ab1bf12SLuiz Capitulino    return 0;
51748ab1bf12SLuiz Capitulino}
51758ab1bf12SLuiz CapitulinoEOF
51768ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
51778ab1bf12SLuiz Capitulino    has_environ=yes
51788ab1bf12SLuiz Capitulinofi
51798ab1bf12SLuiz Capitulino
518076a347e1SRichard Henderson########################################
518176a347e1SRichard Henderson# check if cpuid.h is usable.
518276a347e1SRichard Henderson
518376a347e1SRichard Hendersoncat > $TMPC << EOF
518476a347e1SRichard Henderson#include <cpuid.h>
518576a347e1SRichard Hendersonint main(void) {
5186774d566cSPeter Maydell    unsigned a, b, c, d;
5187774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5188774d566cSPeter Maydell
5189774d566cSPeter Maydell    if (max >= 1) {
5190774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5191774d566cSPeter Maydell    }
5192774d566cSPeter Maydell
5193774d566cSPeter Maydell    if (max >= 7) {
5194774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5195774d566cSPeter Maydell    }
5196774d566cSPeter Maydell
519776a347e1SRichard Henderson    return 0;
519876a347e1SRichard Henderson}
519976a347e1SRichard HendersonEOF
520076a347e1SRichard Hendersonif compile_prog "" "" ; then
520176a347e1SRichard Henderson    cpuid_h=yes
520276a347e1SRichard Hendersonfi
520376a347e1SRichard Henderson
52045dd89908SRichard Henderson##########################################
52055dd89908SRichard Henderson# avx2 optimization requirement check
52065dd89908SRichard Henderson#
52075dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
52085dd89908SRichard Henderson# since we won't be able to select the new routines.
52095dd89908SRichard Henderson
521086583a07SLiam Merwickif test "$cpuid_h" = "yes" -a "$avx2_opt" != "no"; then
52115dd89908SRichard Henderson  cat > $TMPC << EOF
52125dd89908SRichard Henderson#pragma GCC push_options
52135dd89908SRichard Henderson#pragma GCC target("avx2")
52145dd89908SRichard Henderson#include <cpuid.h>
52155dd89908SRichard Henderson#include <immintrin.h>
52165dd89908SRichard Hendersonstatic int bar(void *a) {
52175dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
52185dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
52195dd89908SRichard Henderson}
52205dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
52215dd89908SRichard HendersonEOF
52225dd89908SRichard Henderson  if compile_object "" ; then
52235dd89908SRichard Henderson    avx2_opt="yes"
522486583a07SLiam Merwick  else
522586583a07SLiam Merwick    avx2_opt="no"
52265dd89908SRichard Henderson  fi
52275dd89908SRichard Hendersonfi
52285dd89908SRichard Henderson
5229f540166bSRichard Henderson########################################
5230f540166bSRichard Henderson# check if __[u]int128_t is usable.
5231f540166bSRichard Henderson
5232f540166bSRichard Hendersonint128=no
5233f540166bSRichard Hendersoncat > $TMPC << EOF
5234f540166bSRichard Henderson__int128_t a;
5235f540166bSRichard Henderson__uint128_t b;
5236f540166bSRichard Hendersonint main (void) {
5237f540166bSRichard Henderson  a = a + b;
5238f540166bSRichard Henderson  b = a * b;
5239464e3671SPeter Maydell  a = a * a;
5240f540166bSRichard Henderson  return 0;
5241f540166bSRichard Henderson}
5242f540166bSRichard HendersonEOF
5243f540166bSRichard Hendersonif compile_prog "" "" ; then
5244f540166bSRichard Henderson    int128=yes
5245f540166bSRichard Hendersonfi
524676a347e1SRichard Henderson
52477ebee43eSRichard Henderson#########################################
52487ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
52497ebee43eSRichard Henderson
52507ebee43eSRichard Hendersonatomic128=no
52517ebee43eSRichard Hendersonif test "$int128" = "yes"; then
52527ebee43eSRichard Henderson  cat > $TMPC << EOF
52537ebee43eSRichard Hendersonint main(void)
52547ebee43eSRichard Henderson{
52557ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
52567ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
52577ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
52587ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
52597ebee43eSRichard Henderson  return 0;
52607ebee43eSRichard Henderson}
52617ebee43eSRichard HendersonEOF
52627ebee43eSRichard Henderson  if compile_prog "" "" ; then
52637ebee43eSRichard Henderson    atomic128=yes
52647ebee43eSRichard Henderson  fi
52657ebee43eSRichard Hendersonfi
52667ebee43eSRichard Henderson
5267e6cd4bb5SRichard Hendersoncmpxchg128=no
5268e6cd4bb5SRichard Hendersonif test "$int128" = yes -a "$atomic128" = no; then
5269e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5270e6cd4bb5SRichard Hendersonint main(void)
5271e6cd4bb5SRichard Henderson{
5272e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5273e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5274e6cd4bb5SRichard Henderson  return 0;
5275e6cd4bb5SRichard Henderson}
5276e6cd4bb5SRichard HendersonEOF
5277e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5278e6cd4bb5SRichard Henderson    cmpxchg128=yes
5279e6cd4bb5SRichard Henderson  fi
5280e6cd4bb5SRichard Hendersonfi
5281e6cd4bb5SRichard Henderson
5282df79b996SRichard Henderson#########################################
5283df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5284df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5285df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5286df79b996SRichard Henderson
5287df79b996SRichard Hendersoncat > $TMPC << EOF
5288df79b996SRichard Henderson#include <stdint.h>
5289df79b996SRichard Hendersonint main(void)
5290df79b996SRichard Henderson{
5291df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5292df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5293df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5294df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5295df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5296df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5297df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5298df79b996SRichard Henderson#else
5299df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5300df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5301df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5302df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5303df79b996SRichard Henderson#endif
5304df79b996SRichard Henderson  return 0;
5305df79b996SRichard Henderson}
5306df79b996SRichard HendersonEOF
5307df79b996SRichard Hendersonif compile_prog "" "" ; then
5308df79b996SRichard Henderson  atomic64=yes
5309df79b996SRichard Hendersonfi
5310df79b996SRichard Henderson
53111e6e9acaSRichard Henderson########################################
5312db432672SRichard Henderson# See if 16-byte vector operations are supported.
5313db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5314db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5315db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5316db432672SRichard Henderson
5317db432672SRichard Hendersoncat > $TMPC << EOF
5318db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5319db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5320db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5321db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5322db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5323db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5324db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5325db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5326db432672SRichard Hendersonstatic U1 a1, b1;
5327db432672SRichard Hendersonstatic U2 a2, b2;
5328db432672SRichard Hendersonstatic U4 a4, b4;
5329db432672SRichard Hendersonstatic U8 a8, b8;
5330db432672SRichard Hendersonstatic S1 c1;
5331db432672SRichard Hendersonstatic S2 c2;
5332db432672SRichard Hendersonstatic S4 c4;
5333db432672SRichard Hendersonstatic S8 c8;
5334db432672SRichard Hendersonstatic int i;
533574912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
533674912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
533774912f6dSLaurent Vivier{
533874912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
533974912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
534074912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
534174912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
534274912f6dSLaurent Vivier}
5343db432672SRichard Hendersonint main(void)
5344db432672SRichard Henderson{
5345db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5346db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5347db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5348db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5349db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5350db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5351db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5352db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5353db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5354db432672SRichard Henderson  return 0;
5355db432672SRichard Henderson}
5356db432672SRichard HendersonEOF
5357db432672SRichard Henderson
5358db432672SRichard Hendersonvector16=no
5359db432672SRichard Hendersonif compile_prog "" "" ; then
5360db432672SRichard Henderson  vector16=yes
5361db432672SRichard Hendersonfi
5362db432672SRichard Henderson
5363db432672SRichard Henderson########################################
53641e6e9acaSRichard Henderson# check if getauxval is available.
53651e6e9acaSRichard Henderson
53661e6e9acaSRichard Hendersongetauxval=no
53671e6e9acaSRichard Hendersoncat > $TMPC << EOF
53681e6e9acaSRichard Henderson#include <sys/auxv.h>
53691e6e9acaSRichard Hendersonint main(void) {
53701e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
53711e6e9acaSRichard Henderson}
53721e6e9acaSRichard HendersonEOF
53731e6e9acaSRichard Hendersonif compile_prog "" "" ; then
53741e6e9acaSRichard Henderson    getauxval=yes
53751e6e9acaSRichard Hendersonfi
53761e6e9acaSRichard Henderson
5377fd0e6053SJohn Snow########################################
5378fd0e6053SJohn Snow# check if ccache is interfering with
5379fd0e6053SJohn Snow# semantic analysis of macros
5380fd0e6053SJohn Snow
53815e4dfd3dSJohn Snowunset CCACHE_CPP2
5382fd0e6053SJohn Snowccache_cpp2=no
5383fd0e6053SJohn Snowcat > $TMPC << EOF
5384fd0e6053SJohn Snowstatic const int Z = 1;
5385fd0e6053SJohn Snow#define fn() ({ Z; })
5386fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5387fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5388fd0e6053SJohn Snow#define ID(X) (X)
5389fd0e6053SJohn Snowint main(int argc, char *argv[])
5390fd0e6053SJohn Snow{
5391fd0e6053SJohn Snow    int x = 0, y = 0;
5392fd0e6053SJohn Snow    x = ID(x);
5393fd0e6053SJohn Snow    x = fn();
5394fd0e6053SJohn Snow    fn();
5395fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5396fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5397fd0e6053SJohn Snow    return 0;
5398fd0e6053SJohn Snow}
5399fd0e6053SJohn SnowEOF
5400fd0e6053SJohn Snow
5401fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5402fd0e6053SJohn Snow    ccache_cpp2=yes
5403fd0e6053SJohn Snowfi
5404fd0e6053SJohn Snow
5405b553a042SJohn Snow#################################################
5406b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5407b553a042SJohn Snow
5408b553a042SJohn Snowif test "$fortify_source" != "no"; then
5409b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5410b553a042SJohn Snow    fortify_source="no";
5411e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5412cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5413b553a042SJohn Snow    fortify_source="no";
5414b553a042SJohn Snow  else
5415b553a042SJohn Snow    fortify_source="yes"
5416b553a042SJohn Snow  fi
5417b553a042SJohn Snowfi
5418b553a042SJohn Snow
54191efad060SFam Zheng###############################################
54201efad060SFam Zheng# Check if copy_file_range is provided by glibc
54211efad060SFam Zhenghave_copy_file_range=no
54221efad060SFam Zhengcat > $TMPC << EOF
54231efad060SFam Zheng#include <unistd.h>
54241efad060SFam Zhengint main(void) {
54251efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
54261efad060SFam Zheng  return 0;
54271efad060SFam Zheng}
54281efad060SFam ZhengEOF
54291efad060SFam Zhengif compile_prog "" "" ; then
54301efad060SFam Zheng    have_copy_file_range=yes
54311efad060SFam Zhengfi
54321efad060SFam Zheng
5433d2042378SAneesh Kumar K.V##########################################
5434277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5435277abf15SJan Vesely
5436277abf15SJan Veselyhave_fsxattr=no
5437277abf15SJan Veselycat > $TMPC << EOF
5438277abf15SJan Vesely#include <linux/fs.h>
5439277abf15SJan Veselystruct fsxattr foo;
5440277abf15SJan Veselyint main(void) {
5441277abf15SJan Vesely  return 0;
5442277abf15SJan Vesely}
5443277abf15SJan VeselyEOF
5444277abf15SJan Veselyif compile_prog "" "" ; then
5445277abf15SJan Vesely    have_fsxattr=yes
5446277abf15SJan Veselyfi
5447277abf15SJan Vesely
5448b66e10e4SPeter Maydell##########################################
5449a40161cbSPaolo Bonzini# check for usable membarrier system call
5450a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5451a40161cbSPaolo Bonzini    have_membarrier=no
5452a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5453a40161cbSPaolo Bonzini        have_membarrier=yes
5454a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5455a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5456a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5457a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5458a40161cbSPaolo Bonzini    #include <unistd.h>
5459a40161cbSPaolo Bonzini    #include <stdlib.h>
5460a40161cbSPaolo Bonzini    int main(void) {
5461a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5462a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5463a40161cbSPaolo Bonzini	exit(0);
5464a40161cbSPaolo Bonzini    }
5465a40161cbSPaolo BonziniEOF
5466a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5467a40161cbSPaolo Bonzini            have_membarrier=yes
5468a40161cbSPaolo Bonzini        fi
5469a40161cbSPaolo Bonzini    fi
5470a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5471a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5472a40161cbSPaolo Bonzini    fi
5473a40161cbSPaolo Bonzinielse
5474a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5475a40161cbSPaolo Bonzini    # work on Wine.
5476a40161cbSPaolo Bonzini    membarrier=no
5477a40161cbSPaolo Bonzinifi
5478a40161cbSPaolo Bonzini
5479a40161cbSPaolo Bonzini##########################################
5480b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5481575b22b1SLaurent Vivierhave_rtnetlink=no
5482575b22b1SLaurent Viviercat > $TMPC << EOF
5483575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5484575b22b1SLaurent Vivierint main(void) {
5485575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5486575b22b1SLaurent Vivier}
5487575b22b1SLaurent VivierEOF
5488575b22b1SLaurent Vivierif compile_prog "" "" ; then
5489575b22b1SLaurent Vivier    have_rtnetlink=yes
5490575b22b1SLaurent Vivierfi
5491575b22b1SLaurent Vivier
54926a02c806SStefan Hajnoczi##########################################
54936a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
54946a02c806SStefan Hajnoczihave_af_vsock=no
54956a02c806SStefan Hajnoczicat > $TMPC << EOF
54966a02c806SStefan Hajnoczi#include <errno.h>
54976a02c806SStefan Hajnoczi#include <sys/types.h>
54986a02c806SStefan Hajnoczi#include <sys/socket.h>
54996a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
55006a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
55016a02c806SStefan Hajnoczi#endif
55026a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
55036a02c806SStefan Hajnocziint main(void) {
55046a02c806SStefan Hajnoczi    int sock, ret;
55056a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
55066a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
55076a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
55086a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
55096a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
55106a02c806SStefan Hajnoczi        return 0;
55116a02c806SStefan Hajnoczi    }
55126a02c806SStefan Hajnoczi    return -1;
55136a02c806SStefan Hajnoczi}
55146a02c806SStefan HajnocziEOF
55156a02c806SStefan Hajnocziif compile_prog "" "" ; then
55166a02c806SStefan Hajnoczi    have_af_vsock=yes
55176a02c806SStefan Hajnoczifi
55186a02c806SStefan Hajnoczi
5519f0d92b56SLongpeng(Mike)##########################################
5520f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5521f0d92b56SLongpeng(Mike)hava_afalg=no
5522f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5523f0d92b56SLongpeng(Mike)#include <errno.h>
5524f0d92b56SLongpeng(Mike)#include <sys/types.h>
5525f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5526f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5527f0d92b56SLongpeng(Mike)int main(void) {
5528f0d92b56SLongpeng(Mike)    int sock;
5529f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5530f0d92b56SLongpeng(Mike)    return sock;
5531f0d92b56SLongpeng(Mike)}
5532f0d92b56SLongpeng(Mike)EOF
5533f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5534f0d92b56SLongpeng(Mike)    have_afalg=yes
5535f0d92b56SLongpeng(Mike)fi
5536f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5537f0d92b56SLongpeng(Mike)then
5538f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5539f0d92b56SLongpeng(Mike)    then
5540f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5541f0d92b56SLongpeng(Mike)    fi
5542f0d92b56SLongpeng(Mike)fi
5543f0d92b56SLongpeng(Mike)
5544f0d92b56SLongpeng(Mike)
55456969ec6cSJames Clarke#################################################
5546c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5547d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5548c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5549c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5550c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5551c97d6d2cSSergio Andres Gomez Del RealEOF
5552c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5553c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5554c97d6d2cSSergio Andres Gomez Del Real  else
5555c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5556c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5557c97d6d2cSSergio Andres Gomez Del Real  fi
5558c97d6d2cSSergio Andres Gomez Del Realfi
5559c97d6d2cSSergio Andres Gomez Del Real
5560c97d6d2cSSergio Andres Gomez Del Real#################################################
55616969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
55626969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
55636969ec6cSJames Clarke# given. It does no harm to give it on other
55646969ec6cSJames Clarke# platforms too.
55656969ec6cSJames Clarke
55666969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
55676969ec6cSJames Clarke#       contains -Wmissing-prototypes
55686969ec6cSJames Clarkecat > $TMPC << EOF
55696969ec6cSJames Clarkeextern int foo(void);
55706969ec6cSJames Clarkeint foo(void) { return 0; }
55716969ec6cSJames ClarkeEOF
55726969ec6cSJames Clarkeif ! compile_object ""; then
55736969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
55746969ec6cSJames Clarkefi
55757ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
55767ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
55777ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
55787ecf44a5SPaolo Bonzini    break
55797ecf44a5SPaolo Bonzini  fi
55807ecf44a5SPaolo Bonzinidone
55817ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
55827ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
55836969ec6cSJames Clarkefi
55846969ec6cSJames Clarke
5585277abf15SJan Vesely##########################################
55864d04351fSChristopher Covington# check for sysmacros.h
55874d04351fSChristopher Covington
55884d04351fSChristopher Covingtonhave_sysmacros=no
55894d04351fSChristopher Covingtoncat > $TMPC << EOF
55904d04351fSChristopher Covington#include <sys/sysmacros.h>
55914d04351fSChristopher Covingtonint main(void) {
55924d04351fSChristopher Covington    return makedev(0, 0);
55934d04351fSChristopher Covington}
55944d04351fSChristopher CovingtonEOF
55954d04351fSChristopher Covingtonif compile_prog "" "" ; then
55964d04351fSChristopher Covington    have_sysmacros=yes
55974d04351fSChristopher Covingtonfi
55984d04351fSChristopher Covington
55994d04351fSChristopher Covington##########################################
5600da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5601da92c3ffSAshish Mittal# Check if libvxhs is installed
5602da92c3ffSAshish Mittal
5603da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5604da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5605da92c3ffSAshish Mittal#include <stdint.h>
5606da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5607da92c3ffSAshish Mittal
5608da92c3ffSAshish Mittalvoid *vxhs_callback;
5609da92c3ffSAshish Mittal
5610da92c3ffSAshish Mittalint main(void) {
5611da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5612da92c3ffSAshish Mittal    return 0;
5613da92c3ffSAshish Mittal}
5614da92c3ffSAshish MittalEOF
5615da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5616da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5617da92c3ffSAshish Mittal    vxhs=yes
5618da92c3ffSAshish Mittal  else
5619da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5620da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5621da92c3ffSAshish Mittal    fi
5622da92c3ffSAshish Mittal    vxhs=no
5623da92c3ffSAshish Mittal  fi
5624da92c3ffSAshish Mittalfi
5625da92c3ffSAshish Mittal
5626da92c3ffSAshish Mittal##########################################
562749e00a18SAndreas Grapentin# check for _Static_assert()
562849e00a18SAndreas Grapentin
562949e00a18SAndreas Grapentinhave_static_assert=no
563049e00a18SAndreas Grapentincat > $TMPC << EOF
563149e00a18SAndreas Grapentin_Static_assert(1, "success");
563249e00a18SAndreas Grapentinint main(void) {
563349e00a18SAndreas Grapentin    return 0;
563449e00a18SAndreas Grapentin}
563549e00a18SAndreas GrapentinEOF
563649e00a18SAndreas Grapentinif compile_prog "" "" ; then
563749e00a18SAndreas Grapentin    have_static_assert=yes
563849e00a18SAndreas Grapentinfi
563949e00a18SAndreas Grapentin
564049e00a18SAndreas Grapentin##########################################
5641e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5642e674605fSTomáš Golembiovský
5643e674605fSTomáš Golembiovskýhave_utmpx=no
5644e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5645e674605fSTomáš Golembiovský#include <utmpx.h>
5646e674605fSTomáš Golembiovskýstruct utmpx user_info;
5647e674605fSTomáš Golembiovskýint main(void) {
5648e674605fSTomáš Golembiovský    return 0;
5649e674605fSTomáš Golembiovský}
5650e674605fSTomáš GolembiovskýEOF
5651e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5652e674605fSTomáš Golembiovský    have_utmpx=yes
5653e674605fSTomáš Golembiovskýfi
5654e674605fSTomáš Golembiovský
5655e674605fSTomáš Golembiovský##########################################
5656247724cbSMarc-André Lureau# checks for sanitizers
5657247724cbSMarc-André Lureau
5658247724cbSMarc-André Lureauhave_asan=no
5659247724cbSMarc-André Lureauhave_ubsan=no
5660d83414e1SMarc-André Lureauhave_asan_iface_h=no
5661d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5662247724cbSMarc-André Lureau
5663247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5664b9f44da2SMarc-André Lureau  write_c_skeleton
5665247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5666247724cbSMarc-André Lureau      have_asan=yes
5667247724cbSMarc-André Lureau  fi
5668b9f44da2SMarc-André Lureau
5669b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5670b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5671b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5672b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5673b9f44da2SMarc-André Lureau#include <stdlib.h>
5674b9f44da2SMarc-André Lureauint main(void) {
5675b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5676b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5677b9f44da2SMarc-André Lureau}
5678b9f44da2SMarc-André LureauEOF
5679247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5680247724cbSMarc-André Lureau      have_ubsan=yes
5681247724cbSMarc-André Lureau  fi
5682d83414e1SMarc-André Lureau
5683d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5684d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5685d83414e1SMarc-André Lureau  fi
5686d83414e1SMarc-André Lureau
5687d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5688d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5689d83414e1SMarc-André Lureauint main(void) {
5690d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5691d83414e1SMarc-André Lureau  return 0;
5692d83414e1SMarc-André Lureau}
5693d83414e1SMarc-André LureauEOF
5694d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5695d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5696d83414e1SMarc-André Lureau  fi
5697247724cbSMarc-André Lureaufi
5698247724cbSMarc-André Lureau
5699247724cbSMarc-André Lureau##########################################
570051a12b51SAlex Bennée# Docker and cross-compiler support
570151a12b51SAlex Bennée#
570251a12b51SAlex Bennée# This is specifically for building test
570351a12b51SAlex Bennée# cases for foreign architectures, not
570451a12b51SAlex Bennée# cross-compiling QEMU itself.
570551a12b51SAlex Bennée
570651a12b51SAlex Bennéeif has "docker"; then
570751a12b51SAlex Bennée    docker=$($python $source_path/tests/docker/docker.py probe)
570851a12b51SAlex Bennéefi
570951a12b51SAlex Bennée
571051a12b51SAlex Bennée##########################################
571117824406SJunyan He# check for libpmem
571217824406SJunyan He
571317824406SJunyan Heif test "$libpmem" != "no"; then
571417824406SJunyan He	if $pkg_config --exists "libpmem"; then
571517824406SJunyan He		libpmem="yes"
571617824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
571717824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
571817824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
571917824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
572017824406SJunyan He	else
572117824406SJunyan He		if test "$libpmem" = "yes" ; then
572217824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
572317824406SJunyan He		fi
572417824406SJunyan He		libpmem="no"
572517824406SJunyan He	fi
572617824406SJunyan Hefi
572717824406SJunyan He
572817824406SJunyan He##########################################
5729e86ecd4bSJuan Quintela# End of CC checks
5730e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5731e86ecd4bSJuan Quintela
5732d83414e1SMarc-André Lureauwrite_c_skeleton
5733d83414e1SMarc-André Lureau
57341d728c39SBlue Swirlif test "$gcov" = "yes" ; then
57351d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
57361d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5737b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5738e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
573948e56d50SPaolo Bonzinielif test "$debug" = "no"; then
5740ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5741e86ecd4bSJuan Quintelafi
5742a316e378SJuan Quintela
5743247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5744247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
5745d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5746d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5747d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5748d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5749d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5750d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5751d83414e1SMarc-André Lureau  fi
5752247724cbSMarc-André Lureaufi
5753247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5754247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
5755247724cbSMarc-André Lureaufi
5756247724cbSMarc-André Lureau
57576542aa9cSPeter Lieven##########################################
57586542aa9cSPeter Lieven# Do we have libnfs
57596542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5760b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
57616542aa9cSPeter Lieven    libnfs="yes"
57626542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
57636542aa9cSPeter Lieven  else
57646542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
57658efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
57666542aa9cSPeter Lieven    fi
57676542aa9cSPeter Lieven    libnfs="no"
57686542aa9cSPeter Lieven  fi
57696542aa9cSPeter Lievenfi
57701d728c39SBlue Swirl
57713efac6ebSTomáš Golembiovský##########################################
57723efac6ebSTomáš Golembiovský# Do we have libudev
57733efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
57743efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
57753efac6ebSTomáš Golembiovský    libudev="yes"
57763efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
57773efac6ebSTomáš Golembiovský  else
57783efac6ebSTomáš Golembiovský    libudev="no"
57793efac6ebSTomáš Golembiovský  fi
57803efac6ebSTomáš Golembiovskýfi
57813efac6ebSTomáš Golembiovský
57826ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
57836ca026cbSPeter Maydellif test "$werror" = "yes"; then
57846ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
57856ca026cbSPeter Maydellfi
57866ca026cbSPeter Maydell
5787e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5788e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
57891156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5790e86ecd4bSJuan Quintela    fi
5791e86ecd4bSJuan Quintelafi
5792e86ecd4bSJuan Quintela
579394dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
579494dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
579594dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
579694dd53c5SGerd Hoffmannelse
579794dd53c5SGerd Hoffmann    POD2MAN="pod2man"
579894dd53c5SGerd Hoffmannfi
579994dd53c5SGerd Hoffmann
5800952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5801952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5802952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5803e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5804952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5805952afb71SBlue Swirl        fi
5806952afb71SBlue Swirl    done
5807952afb71SBlue Swirlfi
5808952afb71SBlue Swirl
580910ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5810e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5811528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5812834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
5813a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
581467ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
58155a67135aSbellard
5816e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5817e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5818e0580342SKamil Rytarowski  ivshmem=yes
5819e0580342SKamil Rytarowskifi
5820e0580342SKamil Rytarowski
58214b1c11fdSDaniel P. Berrangetools=""
58224b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
582372d277a7SGerd Hoffmann  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
58244b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
58254b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5826b1449edbSKamil Rytarowski  fi
5827b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5828a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
58294b1c11fdSDaniel P. Berrange  fi
58303fa2d384SViktor Prutyanov  if [ "$posix" = "yes" ] && [ "$curl" = "yes" ]; then
58313fa2d384SViktor Prutyanov    tools="elf2dmp $tools"
58323fa2d384SViktor Prutyanov  fi
58334b1c11fdSDaniel P. Berrangefi
58344b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5835b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5836b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5837983eef5aSMeador Inge      virtfs=yes
583817bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5839983eef5aSMeador Inge    else
5840983eef5aSMeador Inge      if test "$virtfs" = yes; then
5841b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5842983eef5aSMeador Inge      fi
584317500370SAndreas Färber      virtfs=no
5844983eef5aSMeador Inge    fi
5845fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5846fe8fc5aeSPaolo Bonzini      mpath=yes
5847fe8fc5aeSPaolo Bonzini    else
5848fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5849fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5850fe8fc5aeSPaolo Bonzini      fi
5851fe8fc5aeSPaolo Bonzini      mpath=no
5852fe8fc5aeSPaolo Bonzini    fi
5853b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5854b855f8d1SPaolo Bonzini  else
5855b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5856b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5857b855f8d1SPaolo Bonzini    fi
5858b855f8d1SPaolo Bonzini    virtfs=no
5859fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5860fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5861fe8fc5aeSPaolo Bonzini    fi
5862fe8fc5aeSPaolo Bonzini    mpath=no
586317bff52bSM. Mohan Kumar  fi
58646a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
58656a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
58666a021536SGerd Hoffmann  fi
5867ff69fd8cSLaurent Vivierfi
58689d6bc27bSMichael Roth
58699d6bc27bSMichael Roth# Probe for guest agent support/options
58709d6bc27bSMichael Roth
5871e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5872b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5873fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5874e8ef31a3SMichael Tokarev      guest_agent=yes
5875e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5876e8ef31a3SMichael Tokarev      guest_agent=no
5877e8ef31a3SMichael Tokarev  else
5878e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5879ca35f780SPaolo Bonzini  fi
58804b1c11fdSDaniel P. Berrangefi
5881ca35f780SPaolo Bonzini
58829d6bc27bSMichael Roth# Guest agent Window MSI  package
58839d6bc27bSMichael Roth
58849d6bc27bSMichael Rothif test "$guest_agent" != yes; then
58859d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
58869d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
58879d6bc27bSMichael Roth  fi
58889d6bc27bSMichael Roth  guest_agent_msi=no
58899d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
58909d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
58919d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
58929d6bc27bSMichael Roth  fi
58939d6bc27bSMichael Roth  guest_agent_msi=no
58949d6bc27bSMichael Rothelif ! has wixl; then
58959d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
58969d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
58979d6bc27bSMichael Roth  fi
58989d6bc27bSMichael Roth  guest_agent_msi=no
58991a34904eSMichael Rothelse
59001a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
59011a34904eSMichael Roth  # disabled explicitly
59021a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
59031a34904eSMichael Roth    guest_agent_msi=yes
59041a34904eSMichael Roth  fi
59059d6bc27bSMichael Rothfi
59069d6bc27bSMichael Roth
59071a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
59089d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
59099d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
59109d6bc27bSMichael Roth  fi
59119d6bc27bSMichael Roth
59129d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
59139d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
59149d6bc27bSMichael Roth  fi
59159d6bc27bSMichael Roth
59169d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
59179d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
59189d6bc27bSMichael Roth  fi
59199d6bc27bSMichael Roth
59209d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
592189138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
59229d6bc27bSMichael Roth  fi
59239d6bc27bSMichael Roth
592489138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
59259d6bc27bSMichael Roth
59269d6bc27bSMichael Roth  case "$cpu" in
59279d6bc27bSMichael Roth  x86_64)
59289d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
59299d6bc27bSMichael Roth    ;;
59309d6bc27bSMichael Roth  i386)
59319d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
59329d6bc27bSMichael Roth    ;;
59339d6bc27bSMichael Roth  *)
59349d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
59359d6bc27bSMichael Roth    ;;
59369d6bc27bSMichael Roth  esac
59379d6bc27bSMichael Rothfi
59389d6bc27bSMichael Roth
5939ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5940ca35f780SPaolo Bonziniroms=
5941ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5942ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5943ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5944e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5945c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5946c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5947c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5948e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5949e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5950ca35f780SPaolo Bonzini            roms="optionrom"
5951e57218b6SPeter Maydell            break
5952e57218b6SPeter Maydell        fi
5953e57218b6SPeter Maydell    done
5954ca35f780SPaolo Bonzinifi
5955d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
595639ac8455SDavid Gibson  roms="$roms spapr-rtas"
595739ac8455SDavid Gibsonfi
5958ca35f780SPaolo Bonzini
59592e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
59609933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
59612e33c3f8SThomas Huth  write_c_skeleton
59622e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
59639933c305SChristian Borntraeger    roms="$roms s390-ccw"
59649933c305SChristian Borntraeger  fi
59652e33c3f8SThomas Huthfi
59669933c305SChristian Borntraeger
5967964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
596892fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5969964c6fa1SRichard Henderson  textseg_addr=
5970964c6fa1SRichard Henderson  case "$cpu" in
5971479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5972479eb121SRichard Henderson      # ??? Rationale for choosing this address
5973964c6fa1SRichard Henderson      textseg_addr=0x60000000
5974964c6fa1SRichard Henderson      ;;
5975964c6fa1SRichard Henderson    mips)
5976479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5977479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5978479eb121SRichard Henderson      textseg_addr=0x60000000
5979964c6fa1SRichard Henderson      ;;
5980964c6fa1SRichard Henderson  esac
5981964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5982964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5983964c6fa1SRichard Henderson    int main(void) { return 0; }
5984964c6fa1SRichard HendersonEOF
5985964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5986964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5987964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5988964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5989964c6fa1SRichard Henderson      # at least.
599092fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
599192fe2ba8SPeter Maydell        error_exit \
599292fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
599392fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
599492fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
599592fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
599692fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
599792fe2ba8SPeter Maydell            "--disable-user option to configure."
599892fe2ba8SPeter Maydell      fi
599992fe2ba8SPeter Maydell
6000964c6fa1SRichard Henderson      $ld --verbose | sed \
6001964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
6002964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
6003964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
6004964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
6005964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
6006964c6fa1SRichard Henderson    fi
6007964c6fa1SRichard Henderson  fi
6008964c6fa1SRichard Hendersonfi
6009964c6fa1SRichard Henderson
601011cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
601111cde1c8SBruno 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.
601211cde1c8SBruno Dominguezif has $cxx; then
601311cde1c8SBruno Dominguez    cat > $TMPC <<EOF
601411cde1c8SBruno Dominguezint c_function(void);
601511cde1c8SBruno Dominguezint main(void) { return c_function(); }
601611cde1c8SBruno DominguezEOF
601711cde1c8SBruno Dominguez
601811cde1c8SBruno Dominguez    compile_object
601911cde1c8SBruno Dominguez
602011cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
602111cde1c8SBruno Dominguezextern "C" {
602211cde1c8SBruno Dominguez   int c_function(void);
602311cde1c8SBruno Dominguez}
602411cde1c8SBruno Dominguezint c_function(void) { return 42; }
602511cde1c8SBruno DominguezEOF
602611cde1c8SBruno Dominguez
602711cde1c8SBruno Dominguez    update_cxxflags
602811cde1c8SBruno Dominguez
602911cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
603011cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
603111cde1c8SBruno Dominguez        :
603211cde1c8SBruno Dominguez    else
603311cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
603411cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
603511cde1c8SBruno Dominguez        cxx=
603611cde1c8SBruno Dominguez    fi
603711cde1c8SBruno Dominguezelse
603811cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
603911cde1c8SBruno Dominguez    cxx=
604011cde1c8SBruno Dominguezfi
604111cde1c8SBruno Dominguez
604202d34f62SCole Robinsonecho_version() {
604302d34f62SCole Robinson    if test "$1" = "yes" ; then
604402d34f62SCole Robinson        echo "($2)"
604502d34f62SCole Robinson    fi
604602d34f62SCole Robinson}
604702d34f62SCole Robinson
604850e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
604950e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
60508a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
605150e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
60525ca9388aSGerd Hoffmann
60537d13299dSbellardecho "Install prefix    $prefix"
605489138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
60553d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
605689138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
605789138857SStefan Weilecho "library directory $(eval echo $libdir)"
605889138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
605989138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
606089138857SStefan Weilecho "include directory $(eval echo $includedir)"
606189138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
606211d9f695Sbellardif test "$mingw32" = "no" ; then
606389138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
606489138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
606543ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
60665a699bbbSLaszlo Ersekelse
60675a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
6068d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
606911d9f695Sbellardfi
60705a67135aSbellardecho "Source path       $source_path"
6071cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
6072aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
60737d13299dSbellardecho "C compiler        $cc"
607483469015Sbellardecho "Host C compiler   $host_cc"
607583f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
60763c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
607745d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
60780c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
6079a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
60800c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
60818a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
60827d13299dSbellardecho "make              $make"
60836a882643Spbrookecho "install           $install"
6084755ee70fSCleber Rosaecho "python            $python ($python_version)"
6085e2d8830eSBradif test "$slirp" = "yes" ; then
6086e2d8830eSBrad    echo "smbd              $smbd"
6087e2d8830eSBradfi
608817969268SFam Zhengecho "module support    $modules"
6089a98fd896Sbellardecho "host CPU          $cpu"
6090de83cd02Sbellardecho "host big endian   $bigendian"
609197a847bcSbellardecho "target list       $target_list"
60927d13299dSbellardecho "gprof enabled     $gprof"
609303b4fe7dSaliguoriecho "sparse enabled    $sparse"
60941625af87Saliguoriecho "strip binaries    $strip_opt"
609505c2a3e7Sbellardecho "profiler          $profiler"
609643ce4dfeSbellardecho "static build      $static"
60975b0753e0Sbellardif test "$darwin" = "yes" ; then
60985b0753e0Sbellard    echo "Cocoa support     $cocoa"
60995b0753e0Sbellardfi
610089138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
6101a442fe2fSDaniel P. Berrangéecho "SDL image support $sdl_image"
610289138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
6103925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
610489138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
6105a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
6106ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
610791bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
610889138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
61099a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
61104d3b6f6eSbalrogecho "curses support    $curses"
611147479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6112769ce76dSAlexander Grafecho "curl support      $curl"
611367b915a5Sbellardecho "mingw32 support   $mingw32"
61140c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
6115b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
6116b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
6117983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
6118fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
6119821601eaSJes Sorensenecho "VNC support       $vnc"
6120821601eaSJes Sorensenif test "$vnc" = "yes" ; then
61212f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
61222f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
6123efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
6124821601eaSJes Sorensenfi
61253142255cSblueswir1if test -n "$sparc_cpu"; then
61263142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
61273142255cSblueswir1fi
6128e37630caSaliguoriecho "xen support       $xen"
61293996e85cSPaul Durrantif test "$xen" = "yes" ; then
61303996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
61313996e85cSPaul Durrantfi
61322e4d9fb1Saurel32echo "brlapi support    $brlapi"
6133a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
6134a25dba17SJuan Quintelaecho "Documentation     $docs"
613540d6444eSAvi Kivityecho "PIE               $pie"
61368a16d273Sthsecho "vde support       $vde"
613758952137SVincenzo Maffioneecho "netmap support    $netmap"
61385c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
6139758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
614077755340Sthsecho "Install blobs     $blobs"
6141b31a0277SJuan Quintelaecho "KVM support       $kvm"
6142b0cb0a66SVincent Palatinecho "HAX support       $hax"
6143c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
6144d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
6145b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
6146b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
6147b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
61489195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
6149b3f6ea7eSPaolo Bonzinifi
61505a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
6151b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
615221ab34c9SMarcel Apfelbaumecho "PVRDMA support    $pvrdma"
6153f652e6afSaurel32echo "fdt support       $fdt"
6154a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
6155ceb42de8Saliguoriecho "preadv support    $preadv"
61565f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
6157e78815a5SAndreas Färberecho "madvise           $madvise"
6158e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
61599bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
616047e98658SCorey Bryantecho "libcap-ng support $cap_ng"
6161d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
6162042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
61635e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
6164fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
6165e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
61665b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
6167713572a7SMarc-André Lureauif have_backend "simple"; then
61689410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
6169e00e36fbSStefan Weilfi
617089138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6171f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
6172dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
61737b02f544SMarc-André Lureauecho "smartcard support $smartcard"
61742b2325ffSGerd Hoffmannecho "libusb            $libusb"
617569354a83SHans de Goedeecho "usb net redir     $usb_redir"
6176da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
6177014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
6178c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
61796542aa9cSPeter Lievenecho "libnfs support    $libnfs"
6180d138cee9SMichael Rothecho "build guest agent $guest_agent"
6181d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
618250cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
61834c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
6184f794573eSEduardo Otuboecho "seccomp support   $seccomp"
61857c2acc70SPeter Maydellecho "coroutine backend $coroutine"
618670c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
61877d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
6188ba59fb77SPaolo Bonziniecho "mutex debugging   $debug_mutex"
6189f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
6190eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
61911d728c39SBlue Swirlecho "gcov              $gcov_tool"
61921d728c39SBlue Swirlecho "gcov enabled      $gcov"
6193ab214c29SStefan Bergerecho "TPM support       $tpm"
61940a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
61953b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
6196f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
61973556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
6198ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
6199607dacd0Sqiaonuohanecho "lzo support       $lzo"
6200607dacd0Sqiaonuohanecho "snappy support    $snappy"
62016b383c08SPeter Wuecho "bzip2 support     $bzip2"
620283bc1f97SJulio Faraccoecho "lzfse support     $lzfse"
6203a99d57bbSWanlong Gaoecho "NUMA host support $numa"
6204ed279a06SKlim Kireevecho "libxml2           $libxml2"
62052847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
62067b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
620799f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
6208a6b1d4c0SChanglong Xieecho "replication support $replication"
6209da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
62102f740136SJeff Codyecho "bochs support     $bochs"
62112f740136SJeff Codyecho "cloop support     $cloop"
62122f740136SJeff Codyecho "dmg support       $dmg"
62132f740136SJeff Codyecho "qcow v1 support   $qcow1"
62142f740136SJeff Codyecho "vdi support       $vdi"
62152f740136SJeff Codyecho "vvfat support     $vvfat"
62162f740136SJeff Codyecho "qed support       $qed"
62172f740136SJeff Codyecho "parallels support $parallels"
62182f740136SJeff Codyecho "sheepdog support  $sheepdog"
62198ca80760SRichard Hendersonecho "capstone          $capstone"
622051a12b51SAlex Bennéeecho "docker            $docker"
622117824406SJunyan Heecho "libpmem support   $libpmem"
62223efac6ebSTomáš Golembiovskýecho "libudev           $libudev"
622367b915a5Sbellard
62241ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
622524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
6226e8cd23deSbellardfi
622797a847bcSbellard
6228e52c6ba3SDaniel P. Berrangeif test "$sdlabi" = "1.2"; then
6229e52c6ba3SDaniel P. Berrange    echo
6230e52c6ba3SDaniel P. Berrange    echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
6231e52c6ba3SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using SDL 2.0"
6232e52c6ba3SDaniel P. Berrangefi
6233e52c6ba3SDaniel P. Berrange
6234898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
6235898be3e0SPeter Maydell    echo
6236898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6237898be3e0SPeter Maydell    echo
6238898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
6239898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
6240898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6241898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6242898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6243898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6244898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6245898be3e0SPeter Maydellfi
6246898be3e0SPeter Maydell
6247898be3e0SPeter Maydellif test "$supported_os" = "no"; then
6248898be3e0SPeter Maydell    echo
6249898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6250898be3e0SPeter Maydell    echo
6251c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
6252c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
6253898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6254898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6255898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6256898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6257898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6258898be3e0SPeter Maydellfi
6259898be3e0SPeter Maydell
626098ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
626197a847bcSbellard
6262dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6263dbd99ae3SStefan Weil
626498ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
626598ec69acSJuan Quintelaecho >> $config_host_mak
626698ec69acSJuan Quintela
6267e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
626899d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
626999d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
62703aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
62718bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
62720f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
627399d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
627499d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
627522d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
62769afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
62773d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
62789afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6279e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
62805a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6281785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
62825a699bbbSLaszlo Ersekfi
6283f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6284834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6285a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
628667ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6287f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6288cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6289aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6290f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6291804edf29SJuan Quintela
629298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6293727e5283SPaolo Bonzini
6294f8393946Saurel32if test "$debug_tcg" = "yes" ; then
62952358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6296f8393946Saurel32fi
62971625af87Saliguoriif test "$strip_opt" = "yes" ; then
629852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
62991625af87Saliguorifi
63007d13299dSbellardif test "$bigendian" = "yes" ; then
6301e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
630297a847bcSbellardfi
630367b915a5Sbellardif test "$mingw32" = "yes" ; then
630498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
630589138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
63069fe6de94SBlue Swirl  version_major=${rc_version%%.*}
63079fe6de94SBlue Swirl  rc_version=${rc_version#*.}
63089fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
63099fe6de94SBlue Swirl  rc_version=${rc_version#*.}
63109fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
63119fe6de94SBlue Swirl  version_micro=0
63129fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
63139fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6314d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6315d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6316f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6317d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6318d9840e25STomoki Sekiyama  fi
631950cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
632076dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
632150cbebb9SMichael Roth  fi
63221a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
63239dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
63249dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
63259dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
63269dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
63279dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
63289dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
63299dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
63309dacf32dSYossi Hindin  fi
6331210fa556Spbrookelse
633235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6333210fa556Spbrookfi
6334128ab2ffSblueswir1
6335dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6336dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6337dffcb71cSMark McLoughlinfi
6338dffcb71cSMark McLoughlin
633983fb7adfSbellardif test "$darwin" = "yes" ; then
634098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
634183fb7adfSbellardfi
6342b29fe3edSmalc
6343ec530c81Sbellardif test "$solaris" = "yes" ; then
634498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6345ec530c81Sbellardfi
6346179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6347179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6348179cf400SAndreas Färberfi
634997a847bcSbellardif test "$static" = "yes" ; then
635098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
635197a847bcSbellardfi
63521ba16968SStefan Weilif test "$profiler" = "yes" ; then
63532358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
635405c2a3e7Sbellardfi
6355c20709aaSbellardif test "$slirp" = "yes" ; then
635698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6357e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6358c20709aaSbellardfi
63598a16d273Sthsif test "$vde" = "yes" ; then
636098ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6361e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
63628a16d273Sthsfi
636358952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
636458952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
636558952137SVincenzo Maffionefi
6366015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6367015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6368015a33bdSGongleifi
636947e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
637047e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
637147e98658SCorey Bryantfi
63722358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
63730c58ac1cSmalcfor drv in $audio_drv_list; do
63741ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6375ce3dc033SGerd Hoffmann    case "$drv" in
6376051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6377ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6378ce3dc033SGerd Hoffmann	*)
6379ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6380ce3dc033SGerd Hoffmann    esac
63810c58ac1cSmalcdone
6382b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6383b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6384b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6385b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6386b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
638767f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
638867f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
638967f86e8eSJuan Quintelafi
6390d5631638Smalcif test "$audio_win_int" = "yes" ; then
6391d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6392d5631638Smalcfi
6393b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6394b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6395821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6396821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6397821601eaSJes Sorensenfi
63982f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
639998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
64002f9606b3Saliguorifi
6401821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
64022f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
64032f6f5c7aSCorentin Charyfi
6404821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6405efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6406efe556adSCorentin Charyfi
64076a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
64086a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
64096a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
64106a021536SGerd Hoffmannfi
641176655d6dSaliguoriif test "$fnmatch" = "yes" ; then
64122358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
641376655d6dSaliguorifi
6414dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6415dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6416dce512deSChristoph Hellwigfi
641789138857SStefan Weilqemu_version=$(head $source_path/VERSION)
641898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
64192358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
642098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
64212b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6422a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
642398ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6424cc8ae6deSpbrookfi
642517969268SFam Zhengif test "$modules" = "yes"; then
6426e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6427e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
642889138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
642917969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
643017969268SFam Zhengfi
64318781595bSGerd Hoffmannif test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
64328781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
64338781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
64348781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
64358781595bSGerd Hoffmannfi
64361ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
643796400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
6438a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
64398ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
64408ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6441a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes" ; then
6442a442fe2fSDaniel P. Berrangé      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
6443a442fe2fSDaniel P. Berrangé  fi
644449ecc3faSbellardfi
644549ecc3faSbellardif test "$cocoa" = "yes" ; then
644698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
644749ecc3faSbellardfi
64484d3b6f6eSbalrogif test "$curses" = "yes" ; then
64492373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
64502373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
64512373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6452ab4e5602SJan Kiszkafi
6453099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
64542358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6455099d6b0fSRiku Voipiofi
645640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
645740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
645840ff6d7eSKevin Wolffi
64593ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
64602358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
64613ce34dfbSvibisreenivasanfi
6462c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6463c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6464c2882b96SRiku Voipiofi
6465751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6466751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6467751bcc39SMarc-André Lureaufi
6468955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6469955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6470955727d2SCortland Tölvafi
6471d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6472d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6473d0927938SUlrich Hechtfi
64743d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
64753d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
64763d4fa43eSKusanagi Kouichifi
6477b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6478b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6479b953f075SDenis V. Lunevfi
6480ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6481ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6482ed911435SKevin Wolffi
6483c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6484c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6485c727f47dSPeter Maydellfi
6486dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6487dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6488dace20dcSPeter Maydellfi
6489d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6490d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6491d0927938SUlrich Hechtfi
64924e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
64934e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
64944e0c6529SAlex Blighfi
6495cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6496cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6497cd758dd0SAlex Blighfi
64983b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
64993b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
65003b6edd16SPeter Maydellfi
65013b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
65023b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
65033b6edd16SPeter Maydellfi
6504a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6505a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6506a8fd1abaSPeter Maydellfi
650751834341SRiku Voipioif test "$timerfd" = "yes" ; then
650851834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
650951834341SRiku Voipiofi
65109af5c906SRiku Voipioif test "$setns" = "yes" ; then
65119af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
65129af5c906SRiku Voipiofi
651338860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
651438860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
651538860a03SAleksandar Markovicfi
65165a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
65175a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
65185a03cd00SAleksandar Markovicfi
65193b3f24adSaurel32if test "$inotify" = "yes" ; then
65202358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
65213b3f24adSaurel32fi
6522c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6523c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6524c05c7a73SRiku Voipiofi
6525401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6526401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6527401bc051SPeter Maydellfi
65285c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
65295c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
65305c99fa37SKeno Fischerfi
65316ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
65326ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
65336ae9a1f4SJuan Quintelafi
65346ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
65356ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
65366ae9a1f4SJuan Quintelafi
6537769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6538d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6539b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
65406ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6541769ce76dSAlexander Graffi
65422e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
654398ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
65448eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
65452e4d9fb1Saurel32fi
6546fb599c9aSbalrogif test "$bluez" = "yes" ; then
654798ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
6548ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6549fb599c9aSbalrogfi
6550a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6551e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6552a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6553014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6554925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6555925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6556925a0400SGerd Hoffmann  fi
6557bbbf9bfbSStefan Weilfi
6558a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6559ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6560ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6561ddbb0d09SDaniel P. Berrangefi
656291bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
656391bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
65641f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
65651f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
65661f923c70SLongpeng(Mike)  fi
656762893b67SDaniel P. Berrangefi
656891bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
656991bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6570becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6571ed754746SDaniel P. Berrangefi
65729a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
65739a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
65749a2fd434SDaniel P. Berrangefi
6575559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6576559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6577559607eaSDaniel P. Berrangefi
65786b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
65796b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
65806b39b063SEric Blakefi
6581277abf15SJan Vesely
6582277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6583277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6584277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6585277abf15SJan Vesely# if this macro is set.
6586277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6587277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6588277abf15SJan Veselyfi
65891efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
65901efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
65911efad060SFam Zhengfi
6592bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6593bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6594a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6595e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6596a4ccabcfSAnthony Liguorifi
65979d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
65989d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
65999d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
66009d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
66019d9e1521SGerd Hoffmannfi
6602e37630caSaliguoriif test "$xen" = "yes" ; then
66036dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6604d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6605e37630caSaliguorifi
66065c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
66075c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
66085c6c3a6cSChristoph Hellwigfi
6609758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6610758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6611758e8e38SVenkateswararao Jujjuri (JV)fi
66124f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
66134f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
66144f26f2b6SAvi Kivityfi
6615983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6616758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6617758e8e38SVenkateswararao Jujjuri (JV)fi
6618fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6619fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
66201b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
66211b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
66221b0578f5SMurilo Opsfelder Araujo  fi
6623fe8fc5aeSPaolo Bonzinifi
66245e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
66255e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
66265e9be92dSNicholas Bellingerfi
6627e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
662803ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
662903ce5744SNikolay Nikolaevfi
6630042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6631042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6632042cea27SGongleifi
6633fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6634fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6635fc0b9b0eSStefan Hajnoczifi
6636e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6637e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6638e6a74868SMarc-André Lureaufi
663977755340Sthsif test "$blobs" = "yes" ; then
664098ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
664177755340Sthsfi
6642bf9298b9Saliguoriif test "$iovec" = "yes" ; then
66432358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6644bf9298b9Saliguorifi
6645ceb42de8Saliguoriif test "$preadv" = "yes" ; then
66462358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6647ceb42de8Saliguorifi
6648e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
66493f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6650f652e6afSaurel32fi
6651a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6652a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6653a40161cbSPaolo Bonzinifi
6654dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6655dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6656dcc38d1cSMarcelo Tosattifi
6657*d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
6658*d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
6659*d339d766SRichard W.M. Jonesfi
6660b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6661b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
66629195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
66639195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
66649195b2c2SStefan Weil  fi
6665b3f6ea7eSPaolo Bonzinifi
66665f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
66675f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
66685f6b9e8fSBlue Swirlfi
6669e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6670e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6671e78815a5SAndreas Färberfi
6672e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6673e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6674e78815a5SAndreas Färberfi
66759bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
66769bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
66779bc5a719SAndreas Gustafssonfi
667897a847bcSbellard
6679cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6680cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6681cd4ec0b4SGerd Hoffmannfi
6682cd4ec0b4SGerd Hoffmann
66837b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
66847b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
66857b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
66867b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6687111a38b0SRobert Relyeafi
6688111a38b0SRobert Relyea
66892b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
66902b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6691b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6692b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
66932b2325ffSGerd Hoffmannfi
66942b2325ffSGerd Hoffmann
669569354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
669669354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6697cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6698cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
669969354a83SHans de Goedefi
670069354a83SHans de Goede
6701da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6702da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6703da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6704014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6705014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6706014cb152SGerd Hoffmann  fi
670720ff075bSMichael Wallefi
670820ff075bSMichael Walle
67095a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
67105a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
67115a22ab71SYang Zhongfi
67125a22ab71SYang Zhong
671399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
671499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
671599f2dbd3SLiang Lifi
671699f2dbd3SLiang Li
6717607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6718607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6719607dacd0Sqiaonuohanfi
6720607dacd0Sqiaonuohan
6721607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6722607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6723607dacd0Sqiaonuohanfi
6724607dacd0Sqiaonuohan
67256b383c08SPeter Wuif test "$bzip2" = "yes" ; then
67266b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
67276b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
67286b383c08SPeter Wufi
67296b383c08SPeter Wu
673083bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
673183bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
673283bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
673383bc1f97SJulio Faraccofi
673483bc1f97SJulio Faracco
6735c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6736d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
67376ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
67386ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6739c589b249SRonnie Sahlbergfi
6740c589b249SRonnie Sahlberg
67416542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
67424be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
67434be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
67446542aa9cSPeter Lievenfi
67456542aa9cSPeter Lieven
6746f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6747f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6748c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6749c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6750f794573eSEduardo Otubofi
6751f794573eSEduardo Otubo
675283fb7adfSbellard# XXX: suppress that
67537d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
67542358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
67557d3505c5Sbellardfi
67567d3505c5Sbellard
67574d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
67584d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
67594d9310f4SDaniel P. Berrangefi
67603556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
67613556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
67623556c233SPaolo Bonzinifi
6763f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6764d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
67656ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
67666ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6767f27aaf4bSChristian Brunnerfi
676820ff6c80SAnthony Liguori
67697c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
677070c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
677170c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
677270c60c08SStefan Hajnoczielse
677370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
677470c60c08SStefan Hajnoczifi
6775d0e2fce5SAneesh Kumar K.V
67767d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
67777d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
67787d992e4dSPeter Lievenfi
67797d992e4dSPeter Lieven
6780f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6781f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6782f0d92b56SLongpeng(Mike)fi
6783f0d92b56SLongpeng(Mike)
6784d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6785d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6786d2042378SAneesh Kumar K.Vfi
6787d2042378SAneesh Kumar K.V
6788e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6789e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6790e06a765eSHarsh Prateek Borafi
6791e06a765eSHarsh Prateek Bora
6792cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6793cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
679406d71fa1SPeter Maydellfi
679506d71fa1SPeter Maydell
67963f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
67973f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
67983f4349dcSKevin Wolffi
67993f4349dcSKevin Wolf
6800d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
6801d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6802d83414e1SMarc-André Lureaufi
6803d83414e1SMarc-André Lureau
68048ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
68058ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
68068ab1bf12SLuiz Capitulinofi
68078ab1bf12SLuiz Capitulino
680876a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
680976a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
681076a347e1SRichard Hendersonfi
681176a347e1SRichard Henderson
6812f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6813f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6814f540166bSRichard Hendersonfi
6815f540166bSRichard Henderson
68167ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
68177ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
68187ebee43eSRichard Hendersonfi
68197ebee43eSRichard Henderson
6820e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
6821e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
6822e6cd4bb5SRichard Hendersonfi
6823e6cd4bb5SRichard Henderson
6824df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6825df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6826df79b996SRichard Hendersonfi
6827df79b996SRichard Henderson
6828db432672SRichard Hendersonif test "$vector16" = "yes" ; then
6829db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
6830db432672SRichard Hendersonfi
6831db432672SRichard Henderson
68321e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
68331e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
68341e6e9acaSRichard Hendersonfi
68351e6e9acaSRichard Henderson
6836eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6837d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
68386ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
68396ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6840eb100396SBharata B Raofi
6841eb100396SBharata B Rao
6842d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6843d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6844d85fa9ebSJeff Codyfi
6845d85fa9ebSJeff Cody
68460c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
68470c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
68480c14fb47SBharata B Raofi
68490c14fb47SBharata B Rao
6850df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6851df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6852df3a429aSNiels de Vosfi
6853df3a429aSNiels de Vos
68547c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
68557c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
68567c815372SBharata B Raofi
68577c815372SBharata B Rao
68580a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6859d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
68606ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
68616ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
68620a12ec87SRichard W.M. Jonesfi
68630a12ec87SRichard W.M. Jones
6864ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6865ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6866ed1701c6SDr. David Alan Gilbertfi
6867ed1701c6SDr. David Alan Gilbert
68683b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
68693b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6870f4ede81eSAmarnath Valluri  # TPM passthrough support?
68713b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
68723b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
68733b8acc11SPaolo Bonzini  fi
6874f4ede81eSAmarnath Valluri  # TPM emulator support?
6875f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6876f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6877f4ede81eSAmarnath Valluri  fi
68783b8acc11SPaolo Bonzinifi
68793b8acc11SPaolo Bonzini
68805b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
68815b808275SLluís Vilanovaif have_backend "nop"; then
68826d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
688322890ab5SPrerna Saxenafi
68845b808275SLluís Vilanovaif have_backend "simple"; then
68856d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
68866d8a764eSLluís  # Set the appropriate trace file.
6887953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
68889410b56cSPrerna Saxenafi
6889ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6890ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
68916d8a764eSLluísfi
68925b808275SLluís Vilanovaif have_backend "ust"; then
68936d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
68946d8a764eSLluísfi
68955b808275SLluís Vilanovaif have_backend "dtrace"; then
68966d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
68976d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
68986d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
68996d8a764eSLluís  fi
6900c276b17dSDaniel P. Berrangefi
69015b808275SLluís Vilanovaif have_backend "ftrace"; then
6902781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6903781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6904781e9545SEiichi Tsukata  else
690521684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6906781e9545SEiichi Tsukata  fi
6907781e9545SEiichi Tsukatafi
69080a852417SPaul Durrantif have_backend "syslog"; then
69090a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
69100a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
69110a852417SPaul Durrant  else
69120a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
69130a852417SPaul Durrant  fi
69140a852417SPaul Durrantfi
69159410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
69169410b56cSPrerna Saxena
69172da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
69182da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6919392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
69202da776dbSMichael R. Hinesfi
69212da776dbSMichael R. Hines
692221ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
692321ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
692421ab34c9SMarcel Apfelbaumfi
692521ab34c9SMarcel Apfelbaum
6926575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6927575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6928575b22b1SLaurent Vivierfi
6929575b22b1SLaurent Vivier
6930ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6931ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6932ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6933ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6934ed279a06SKlim Kireevfi
6935ed279a06SKlim Kireev
6936a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6937a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6938a6b1d4c0SChanglong Xiefi
6939a6b1d4c0SChanglong Xie
69406a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
69416a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
69426a02c806SStefan Hajnoczifi
69436a02c806SStefan Hajnoczi
69444d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
69454d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
69464d04351fSChristopher Covingtonfi
69474d04351fSChristopher Covington
694849e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
694949e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
695049e00a18SAndreas Grapentinfi
695149e00a18SAndreas Grapentin
6952e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6953e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6954e674605fSTomáš Golembiovskýfi
6955e674605fSTomáš Golembiovský
6956e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6957e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6958e0580342SKamil Rytarowskifi
6959e219c499SRichard Hendersonif test "$capstone" != "no" ; then
69608ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
69618ca80760SRichard Hendersonfi
6962ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
6963ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6964ba59fb77SPaolo Bonzinifi
6965e0580342SKamil Rytarowski
69665c312079SDr. David Alan Gilbert# Hold two types of flag:
69675c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
69685c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
6969479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
69705c312079SDr. David Alan Gilbert#                                     platform
6971479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
69725c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6973479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
6974479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
6975479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6976479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
69775c312079SDr. David Alan Gilbertfi
69785c312079SDr. David Alan Gilbert
6979da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6980da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6981da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6982da92c3ffSAshish Mittalfi
6983da92c3ffSAshish Mittal
698417824406SJunyan Heif test "$libpmem" = "yes" ; then
698517824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
698617824406SJunyan Hefi
698717824406SJunyan He
69882f740136SJeff Codyif test "$bochs" = "yes" ; then
69892f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
69902f740136SJeff Codyfi
69912f740136SJeff Codyif test "$cloop" = "yes" ; then
69922f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
69932f740136SJeff Codyfi
69942f740136SJeff Codyif test "$dmg" = "yes" ; then
69952f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
69962f740136SJeff Codyfi
69972f740136SJeff Codyif test "$qcow1" = "yes" ; then
69982f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
69992f740136SJeff Codyfi
70002f740136SJeff Codyif test "$vdi" = "yes" ; then
70012f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
70022f740136SJeff Codyfi
70032f740136SJeff Codyif test "$vvfat" = "yes" ; then
70042f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
70052f740136SJeff Codyfi
70062f740136SJeff Codyif test "$qed" = "yes" ; then
70072f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
70082f740136SJeff Codyfi
70092f740136SJeff Codyif test "$parallels" = "yes" ; then
70102f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
70112f740136SJeff Codyfi
70122f740136SJeff Codyif test "$sheepdog" = "yes" ; then
70132f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
70142f740136SJeff Codyfi
70152f740136SJeff Cody
70165b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
70179edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
70185b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
70199edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
70205b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
70219edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7022c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
70239edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
702440d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
70259edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7026c4f80543SAlistair Franciselif test "$ARCH" = "riscv32" -o "$ARCH" = "riscv64" ; then
7027c4f80543SAlistair Francis  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
70285b5e3037SPaolo Bonzinielse
70299edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
70305b5e3037SPaolo Bonzinifi
70319edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
70325b5e3037SPaolo Bonzini
703398ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
703498ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7035804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7036804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
70371901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
70381901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
70391901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
704021655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7041c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
7042755ee70fSCleber Rosaecho "PYTHON_VERSION=$python_version" >> $config_host_mak
7043804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7044a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7045a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
7046a31a8642SMichael S. Tsirkinfi
7047804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
704883f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
70493c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7050804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
705145d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7052cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
70535f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
70543dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7055804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7056804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
70579f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
70584852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
70599fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7060e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
706146eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7062a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
706311cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7064f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7065e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7066e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
706780fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
70682944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
7069e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
7070e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7071e39f0062SPaolo Bonzinifi
707242da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
707342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
707442da6041SGerd Hoffmannelse
707542da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
707642da6041SGerd Hoffmannfi
7077e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
707846eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
70798a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
70806969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7081e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
708273da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
70833e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7084409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7085804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
708617969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
708717969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7088957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
708990246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
709090246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
709194dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
70921d728c39SBlue Swirlif test "$gcov" = "yes" ; then
70931d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
70941d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
70951d728c39SBlue Swirlfi
7096804edf29SJuan Quintela
709751a12b51SAlex Bennéeif test "$docker" != "no"; then
709851a12b51SAlex Bennée    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
709951a12b51SAlex Bennéefi
710051a12b51SAlex Bennée
71013efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
71023efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
71033efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
71043efac6ebSTomáš Golembiovskýfi
71053efac6ebSTomáš Golembiovský
71066efd7517SPeter Maydell# use included Linux headers
71076efd7517SPeter Maydellif test "$linux" = "yes" ; then
7108a307beb6SAndreas Färber  mkdir -p linux-headers
71096efd7517SPeter Maydell  case "$cpu" in
7110c72b26ecSRichard Henderson  i386|x86_64|x32)
711108312a63SPeter Maydell    linux_arch=x86
71126efd7517SPeter Maydell    ;;
7113a69dc537SThomas Huth  ppc|ppc64)
711408312a63SPeter Maydell    linux_arch=powerpc
71156efd7517SPeter Maydell    ;;
71166efd7517SPeter Maydell  s390x)
711708312a63SPeter Maydell    linux_arch=s390
711808312a63SPeter Maydell    ;;
71191f080313SClaudio Fontana  aarch64)
71201f080313SClaudio Fontana    linux_arch=arm64
71211f080313SClaudio Fontana    ;;
7122222e7d11SSanjay Lal  mips64)
7123222e7d11SSanjay Lal    linux_arch=mips
7124222e7d11SSanjay Lal    ;;
712508312a63SPeter Maydell  *)
712608312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
712708312a63SPeter Maydell    linux_arch="$cpu"
71286efd7517SPeter Maydell    ;;
71296efd7517SPeter Maydell  esac
713008312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
713108312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
713208312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
713308312a63SPeter Maydell    fi
71346efd7517SPeter Maydellfi
71356efd7517SPeter Maydell
713697a847bcSbellardfor target in $target_list; do
713797a847bcSbellardtarget_dir="$target"
713825be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
713989138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
714097a847bcSbellardtarget_bigendian="no"
71411f3d3c8fSJuan Quintela
7142c1799a84SPaolo Bonzinicase "$target_name" in
7143a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7144ea2d6a39SJuan Quintela  target_bigendian=yes
7145ea2d6a39SJuan Quintela  ;;
7146ea2d6a39SJuan Quintelaesac
714797a847bcSbellardtarget_softmmu="no"
7148997344f3Sbellardtarget_user_only="no"
7149831b7825Sthstarget_linux_user="no"
715084778508Sblueswir1target_bsd_user="no"
71519e407a85Spbrookcase "$target" in
7152c1799a84SPaolo Bonzini  ${target_name}-softmmu)
71539e407a85Spbrook    target_softmmu="yes"
71549e407a85Spbrook    ;;
7155c1799a84SPaolo Bonzini  ${target_name}-linux-user)
71569e407a85Spbrook    target_user_only="yes"
71579e407a85Spbrook    target_linux_user="yes"
71589e407a85Spbrook    ;;
7159c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
716084778508Sblueswir1    target_user_only="yes"
716184778508Sblueswir1    target_bsd_user="yes"
716284778508Sblueswir1    ;;
71639e407a85Spbrook  *)
716476ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
71659e407a85Spbrook    exit 1
71669e407a85Spbrook    ;;
71679e407a85Spbrookesac
7168831b7825Sths
7169d75402b5SAlex Bennéetarget_compiler=""
7170d75402b5SAlex Bennéetarget_compiler_static=""
7171716a507cSAlex Bennéetarget_compiler_cflags=""
7172d75402b5SAlex Bennée
717397a847bcSbellardmkdir -p $target_dir
717425be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
717597a847bcSbellard
7176e5fe0c52Spbrookbflt="no"
7177ca759f9eSAlex Bennéemttcg="no"
717889138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
717956aebc89Spbrookgdb_xml_files=""
71807ba1e619Saliguori
7181c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
71826acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7183e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
7184e73aae67SJuan Quintela
7185c1799a84SPaolo Bonzinicase "$target_name" in
71862408a527Saurel32  i386)
71870a7fa00aSEmilio G. Cota    mttcg="yes"
7188b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
7189d75402b5SAlex Bennée    target_compiler=$cross_cc_i386
7190716a507cSAlex Bennée    target_compiler_cflags=$cross_cc_ccflags_i386
71912408a527Saurel32  ;;
71922408a527Saurel32  x86_64)
71936acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
71940a7fa00aSEmilio G. Cota    mttcg="yes"
7195b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
7196d75402b5SAlex Bennée    target_compiler=$cross_cc_x86_64
71972408a527Saurel32  ;;
71982408a527Saurel32  alpha)
71995ee4f3c2SRichard Henderson    mttcg="yes"
7200d75402b5SAlex Bennée    target_compiler=$cross_cc_alpha
72012408a527Saurel32  ;;
72022408a527Saurel32  arm|armeb)
7203b498c8a0SJuan Quintela    TARGET_ARCH=arm
7204e5fe0c52Spbrook    bflt="yes"
7205ca759f9eSAlex Bennée    mttcg="yes"
720656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7207d75402b5SAlex Bennée    target_compiler=$cross_cc_arm
7208d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
72092408a527Saurel32  ;;
7210722dd7beSMichael Weiser  aarch64|aarch64_be)
7211722dd7beSMichael Weiser    TARGET_ARCH=aarch64
72126a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
72136a49fa95SAlexander Graf    bflt="yes"
7214ca759f9eSAlex Bennée    mttcg="yes"
72158f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7216d75402b5SAlex Bennée    target_compiler=$cross_cc_aarch64
7217d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
72186a49fa95SAlexander Graf  ;;
72192408a527Saurel32  cris)
7220d75402b5SAlex Bennée    target_compiler=$cross_cc_cris
72212408a527Saurel32  ;;
722261766fe9SRichard Henderson  hppa)
72237b93dab5SRichard Henderson    mttcg="yes"
7224d75402b5SAlex Bennée    target_compiler=$cross_cc_hppa
722561766fe9SRichard Henderson  ;;
7226613a22c9SMichael Walle  lm32)
7227d75402b5SAlex Bennée    target_compiler=$cross_cc_lm32
7228613a22c9SMichael Walle  ;;
72292408a527Saurel32  m68k)
72300938cda5Saurel32    bflt="yes"
72315a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7232d75402b5SAlex Bennée    target_compiler=$cross_cc_m68k
72332408a527Saurel32  ;;
7234877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7235877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
723672b675caSEdgar E. Iglesias    bflt="yes"
7237be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
7238d75402b5SAlex Bennée    target_compiler=$cross_cc_microblaze
723972b675caSEdgar E. Iglesias  ;;
72402408a527Saurel32  mips|mipsel)
7241b498c8a0SJuan Quintela    TARGET_ARCH=mips
7242d75402b5SAlex Bennée    target_compiler=$cross_cc_mips
724325be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
72442408a527Saurel32  ;;
72452408a527Saurel32  mipsn32|mipsn32el)
7246597e2cecSRichard Henderson    TARGET_ARCH=mips64
72476acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7248d75402b5SAlex Bennée    target_compiler=$cross_cc_mipsn32
724925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7250597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
72512408a527Saurel32  ;;
72522408a527Saurel32  mips64|mips64el)
7253b498c8a0SJuan Quintela    TARGET_ARCH=mips64
72546acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7255d75402b5SAlex Bennée    target_compiler=$cross_cc_mips64
725625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
72572408a527Saurel32  ;;
7258d15a9c23SAnthony Green  moxie)
7259d75402b5SAlex Bennée    target_compiler=$cross_cc_moxie
7260d15a9c23SAnthony Green  ;;
7261e671711cSMarek Vasut  nios2)
7262d75402b5SAlex Bennée    target_compiler=$cross_cc_nios2
7263e671711cSMarek Vasut  ;;
72644a09d0bbSRichard Henderson  or1k)
7265d75402b5SAlex Bennée    target_compiler=$cross_cc_or1k
7266e67db06eSJia Liu    TARGET_ARCH=openrisc
7267e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7268e67db06eSJia Liu  ;;
72692408a527Saurel32  ppc)
7270c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7271d75402b5SAlex Bennée    target_compiler=$cross_cc_powerpc
72722408a527Saurel32  ;;
72732408a527Saurel32  ppc64)
72746acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7275e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7276f0b0685dSNikunj A Dadhania    mttcg=yes
72771438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7278d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64
72792408a527Saurel32  ;;
72809c35126cSDoug Kwan  ppc64le)
72819c35126cSDoug Kwan    TARGET_ARCH=ppc64
72829c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
72839c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
7284f0b0685dSNikunj A Dadhania    mttcg=yes
72851438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7286d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64le
72879c35126cSDoug Kwan  ;;
72882408a527Saurel32  ppc64abi32)
7289b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
72906acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7291e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
729225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
72931438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7294d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64abi32
72952408a527Saurel32  ;;
729625fa194bSMichael Clark  riscv32)
729725fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
729825fa194bSMichael Clark    TARGET_ABI_DIR=riscv
729925fa194bSMichael Clark    mttcg=yes
7300d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv32
730125fa194bSMichael Clark  ;;
730225fa194bSMichael Clark  riscv64)
730325fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
730425fa194bSMichael Clark    TARGET_ABI_DIR=riscv
730525fa194bSMichael Clark    mttcg=yes
7306d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv64
730725fa194bSMichael Clark  ;;
73082408a527Saurel32  sh4|sh4eb)
7309b498c8a0SJuan Quintela    TARGET_ARCH=sh4
73104dbed897Spbrook    bflt="yes"
7311d75402b5SAlex Bennée    target_compiler=$cross_cc_sh4
73122408a527Saurel32  ;;
73132408a527Saurel32  sparc)
7314d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc
73152408a527Saurel32  ;;
73162408a527Saurel32  sparc64)
73176acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7318d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc64
73192408a527Saurel32  ;;
73202408a527Saurel32  sparc32plus)
7321b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
73226acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7323e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7324d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc32plus
732525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
73262408a527Saurel32  ;;
732724e804ecSAlexander Graf  s390x)
732863685bc4SDavid Hildenbrand    mttcg=yes
732986158a2aSChristian 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"
7330d75402b5SAlex Bennée    target_compiler=$cross_cc_s390x
733124e804ecSAlexander Graf  ;;
7332444e06b1SChen Gang  tilegx)
7333d75402b5SAlex Bennée    target_compiler=$cross_cc_tilegx
7334444e06b1SChen Gang  ;;
73355ecaa4edSPeter Crosthwaite  tricore)
7336d75402b5SAlex Bennée    target_compiler=$cross_cc_tricore
73375ecaa4edSPeter Crosthwaite  ;;
7338d2fbca94SGuan Xuetao  unicore32)
7339d75402b5SAlex Bennée    target_compiler=$cross_cc_unicore32
7340d2fbca94SGuan Xuetao  ;;
7341cfa550c6SMax Filippov  xtensa|xtensaeb)
7342cfa550c6SMax Filippov    TARGET_ARCH=xtensa
734302e33e9fSMax Filippov    bflt="yes"
73449fb40342SMax Filippov    mttcg="yes"
7345d75402b5SAlex Bennée    target_compiler=$cross_cc_xtensa
7346cfa550c6SMax Filippov  ;;
73472408a527Saurel32  *)
734876ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
73492408a527Saurel32  ;;
73502408a527Saurel32esac
73515e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
73525e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
73535e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
73545e8861a0SPaolo Bonzinifi
73555e8861a0SPaolo Bonzini
7356d75402b5SAlex Bennée# Do we have a cross compiler for this target?
7357d75402b5SAlex Bennéeif has $target_compiler; then
7358d75402b5SAlex Bennée
7359d75402b5SAlex Bennée    write_c_skeleton
7360d75402b5SAlex Bennée
7361716a507cSAlex Bennée    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7362d75402b5SAlex Bennée        # For host systems we might get away with building without -static
7363716a507cSAlex Bennée        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7364d75402b5SAlex Bennée            target_compiler=""
7365d75402b5SAlex Bennée        else
7366d75402b5SAlex Bennée            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7367d75402b5SAlex Bennée            target_compiler_static="n"
7368d75402b5SAlex Bennée        fi
7369d75402b5SAlex Bennée    else
7370d75402b5SAlex Bennée        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7371d75402b5SAlex Bennée        target_compiler_static="y"
7372d75402b5SAlex Bennée    fi
7373d75402b5SAlex Bennéeelse
7374d75402b5SAlex Bennée    target_compiler=""
7375d75402b5SAlex Bennéefi
7376d75402b5SAlex Bennée
73775e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
73785e8861a0SPaolo Bonzini
737999afc91dSDaniel P. Berrangeupper() {
738099afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
738199afc91dSDaniel P. Berrange}
738299afc91dSDaniel P. Berrange
738389138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
738425be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7385c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
738625be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7387e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7388e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7389e6e91b9cSJuan Quintelafi
739025be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7391adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7392adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7393adfc3e91SStacey Sonfi
73943b6b7550SPaolo Bonzini
73953b6b7550SPaolo Bonziniif supported_xen_target $target; then
739625be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7397eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7398eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7399eb6fda0fSAnthony PERARD    fi
7400432d268cSJun Nakajimafi
74013b6b7550SPaolo Bonziniif supported_kvm_target $target; then
740225be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
74031ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
7404d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7405e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
7406e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7407e6a74868SMarc-André Lureau        fi
7408d5970055SMichael S. Tsirkin    fi
7409c59249f9SJuan Quintelafi
74103b6b7550SPaolo Bonziniif supported_hax_target $target; then
7411b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7412b0cb0a66SVincent Palatinfi
7413c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7414c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7415c97d6d2cSSergio Andres Gomez Del Realfi
7416d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7417d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7418d661d9a4SJustin Terry (VM)fi
7419de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
742025be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
742197a847bcSbellardfi
742297a847bcSbellardif test "$target_softmmu" = "yes" ; then
742325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7424ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7425ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7426ca759f9eSAlex Bennée  fi
7427de83cd02Sbellardfi
7428997344f3Sbellardif test "$target_user_only" = "yes" ; then
742925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7430a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7431997344f3Sbellardfi
7432831b7825Sthsif test "$target_linux_user" = "yes" ; then
743325be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7434831b7825Sthsfi
743556aebc89Spbrooklist=""
743656aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
743756aebc89Spbrook  for x in $gdb_xml_files; do
743856aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
743956aebc89Spbrook  done
744025be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
74413d0f1517SJuan Quintelafi
7442de83cd02Sbellard
7443e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
744425be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7445e5fe0c52Spbrookfi
744684778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
744725be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
744884778508Sblueswir1fi
74495b0753e0Sbellard
7450d75402b5SAlex Bennéeif test -n "$target_compiler"; then
7451d75402b5SAlex Bennée  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7452d75402b5SAlex Bennée
7453d75402b5SAlex Bennée  if test -n "$target_compiler_static"; then
7454d75402b5SAlex Bennée      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7455d75402b5SAlex Bennée  fi
7456716a507cSAlex Bennée
7457716a507cSAlex Bennée  if test -n "$target_compiler_cflags"; then
7458716a507cSAlex Bennée      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7459d75402b5SAlex Bennée  fi
7460716a507cSAlex Bennéefi
7461716a507cSAlex Bennée
7462d75402b5SAlex Bennée
74634afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7464fa282484SJuan Quintela
74654afddb55SJuan Quintelacflags=""
7466fa282484SJuan Quintelaldflags=""
74679b8e111fSJuan Quintela
7468c765fcacSPeter Crosthwaitedisas_config() {
7469c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7470c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7471c765fcacSPeter Crosthwaite}
7472c765fcacSPeter Crosthwaite
747364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
747464656024SJuan Quintela  case "$i" in
747564656024SJuan Quintela  alpha)
7476c765fcacSPeter Crosthwaite    disas_config "ALPHA"
747764656024SJuan Quintela  ;;
747882295d8aSRichard Henderson  aarch64)
747982295d8aSRichard Henderson    if test -n "${cxx}"; then
7480c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
748182295d8aSRichard Henderson    fi
748282295d8aSRichard Henderson  ;;
748364656024SJuan Quintela  arm)
7484c765fcacSPeter Crosthwaite    disas_config "ARM"
7485999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7486c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7487999b53ecSClaudio Fontana    fi
748864656024SJuan Quintela  ;;
748964656024SJuan Quintela  cris)
7490c765fcacSPeter Crosthwaite    disas_config "CRIS"
749164656024SJuan Quintela  ;;
7492429b31a2SRichard Henderson  hppa)
7493429b31a2SRichard Henderson    disas_config "HPPA"
7494429b31a2SRichard Henderson  ;;
7495c72b26ecSRichard Henderson  i386|x86_64|x32)
7496c765fcacSPeter Crosthwaite    disas_config "I386"
749764656024SJuan Quintela  ;;
749879368f49SMichael Walle  lm32)
7499c765fcacSPeter Crosthwaite    disas_config "LM32"
750079368f49SMichael Walle  ;;
750164656024SJuan Quintela  m68k)
7502c765fcacSPeter Crosthwaite    disas_config "M68K"
750364656024SJuan Quintela  ;;
7504877fdc12SEdgar E. Iglesias  microblaze*)
7505c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
750664656024SJuan Quintela  ;;
750764656024SJuan Quintela  mips*)
7508c765fcacSPeter Crosthwaite    disas_config "MIPS"
750989a955e8SAleksandar Markovic    if test -n "${cxx}"; then
751089a955e8SAleksandar Markovic      disas_config "NANOMIPS"
751189a955e8SAleksandar Markovic    fi
751264656024SJuan Quintela  ;;
7513d15a9c23SAnthony Green  moxie*)
7514c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7515d15a9c23SAnthony Green  ;;
7516e671711cSMarek Vasut  nios2)
7517e671711cSMarek Vasut    disas_config "NIOS2"
7518e671711cSMarek Vasut  ;;
75194a09d0bbSRichard Henderson  or1k)
7520c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7521e67db06eSJia Liu  ;;
752264656024SJuan Quintela  ppc*)
7523c765fcacSPeter Crosthwaite    disas_config "PPC"
752464656024SJuan Quintela  ;;
7525c4f80543SAlistair Francis  riscv*)
752625fa194bSMichael Clark    disas_config "RISCV"
752725fa194bSMichael Clark  ;;
752824e804ecSAlexander Graf  s390*)
7529c765fcacSPeter Crosthwaite    disas_config "S390"
753064656024SJuan Quintela  ;;
753164656024SJuan Quintela  sh4)
7532c765fcacSPeter Crosthwaite    disas_config "SH4"
753364656024SJuan Quintela  ;;
753464656024SJuan Quintela  sparc*)
7535c765fcacSPeter Crosthwaite    disas_config "SPARC"
753664656024SJuan Quintela  ;;
7537cfa550c6SMax Filippov  xtensa*)
7538c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7539cfa550c6SMax Filippov  ;;
754064656024SJuan Quintela  esac
754164656024SJuan Quinteladone
75429195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7543c765fcacSPeter Crosthwaite  disas_config "TCI"
75449195b2c2SStefan Weilfi
754564656024SJuan Quintela
75466ee7126fSJuan Quintelacase "$ARCH" in
75476ee7126fSJuan Quintelaalpha)
75486ee7126fSJuan Quintela  # Ensure there's only a single GP
75496ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
75506ee7126fSJuan Quintela;;
75516ee7126fSJuan Quintelaesac
75526ee7126fSJuan Quintela
7553d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
75540acf7dedSPhilippe Mathieu-Daudé  echo "TARGET_GPROF=y" >> $config_target_mak
7555d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7556d02c1db3SJuan Quintela    cflags="-p $cflags"
7557d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7558d02c1db3SJuan Quintela  fi
7559d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7560d02c1db3SJuan Quintela    ldflags="-p $ldflags"
756125be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7562d02c1db3SJuan Quintela  fi
7563d02c1db3SJuan Quintelafi
7564d02c1db3SJuan Quintela
75659b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
7566964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7567fa282484SJuan Quintelafi
7568fa282484SJuan Quintela
7569e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7570e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7571e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7572e9a3591fSChristian Borntraeger# header if
7573e9a3591fSChristian Borntraeger#  - we build on s390x
7574e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7575e9a3591fSChristian Borntraeger#  - KVM is enabled
7576e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7577e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7578e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7579e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7580e9a3591fSChristian Borntraeger    fi
7581e9a3591fSChristian Borntraegerfi
7582e9a3591fSChristian Borntraeger
758325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
758425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7585fa282484SJuan Quintela
758697a847bcSbellarddone # for target in $targets
75877d13299dSbellard
7588d75402b5SAlex Bennéeif test -n "$enabled_cross_compilers"; then
7589d75402b5SAlex Bennée    echo
7590d75402b5SAlex Bennée    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7591d75402b5SAlex Bennéefi
7592d75402b5SAlex Bennée
7593e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
7594a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
7595a540f158SPeter Crosthwaitefi
7596e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7597e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
7598e219c499SRichard Hendersonfi
7599e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7600e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7601e219c499SRichard Hendersonfi
7602a540f158SPeter Crosthwaite
7603a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7604a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7605a99d57bbSWanlong Gaofi
7606a99d57bbSWanlong Gao
7607fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7608fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7609fd0e6053SJohn Snowfi
7610fd0e6053SJohn Snow
7611e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
7612e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
7613e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
7614e29e5c6eSPeter Maydell# (these can be both files and directories).
7615e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
7616e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
7617e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
7618e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
7619e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
7620e29e5c6eSPeter Maydell# directory and symlink the directory instead.
7621b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
76223ac1f813SEmilio G. CotaDIRS="$DIRS tests/fp"
7623b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
76249933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
76252d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
7626e29e5c6eSPeter MaydellLINKS="Makefile tests/tcg/Makefile qdict-test-data.txt"
7627e29e5c6eSPeter MaydellLINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7628e29e5c6eSPeter MaydellLINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7629e29e5c6eSPeter MaydellLINKS="$LINKS tests/fp/Makefile"
7630e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7631e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/spapr-rtas/Makefile"
7632e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
7633e29e5c6eSPeter MaydellLINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7634e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
7635e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
763639950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
763739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
7638753d11f2SRichard Hendersonfor bios_file in \
7639753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7640225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
76415acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
7642753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7643753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7644e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7645753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
76464e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
7647753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7648753d11f2SRichard Hendersondo
7649e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
76507ea78b74SJan Kiszkadone
7651d1807a4fSPaolo Bonzinimkdir -p $DIRS
7652e29e5c6eSPeter Maydellfor f in $LINKS ; do
7653cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7654f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7655f9245e10SPeter Maydell    fi
76567d13299dSbellarddone
76571ad2134fSPaul Brook
7658c34ebfdcSAnthony Liguori# temporary config to build submodules
76592d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
7660c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
766137116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7662c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7663cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
76645f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7665c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7666c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
76673dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7668c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7669a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7670c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
76719f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7672c34ebfdcSAnthony Liguoridone
7673c34ebfdcSAnthony Liguori
767476c7560aSMax Reitz# set up qemu-iotests in this build directory
767576c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
767676c7560aSMax Reitz
767776c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
767876c7560aSMax Reitzecho >> "$iotests_common_env"
767976c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
768076c7560aSMax Reitz
7681dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7682dc655404SMichael S. Tsirkincat <<EOD >config.status
7683dc655404SMichael S. Tsirkin#!/bin/sh
7684dc655404SMichael S. Tsirkin# Generated by configure.
7685dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7686dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7687dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7688dc655404SMichael S. TsirkinEOD
7689e811da7fSDaniel P. Berrangé
7690e811da7fSDaniel P. Berrangépreserve_env() {
7691e811da7fSDaniel P. Berrangé    envname=$1
7692e811da7fSDaniel P. Berrangé
7693e811da7fSDaniel P. Berrangé    eval envval=\$$envname
7694e811da7fSDaniel P. Berrangé
7695e811da7fSDaniel P. Berrangé    if test -n "$envval"
7696e811da7fSDaniel P. Berrangé    then
7697e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
7698e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
7699e811da7fSDaniel P. Berrangé    else
7700e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
7701e811da7fSDaniel P. Berrangé    fi
7702e811da7fSDaniel P. Berrangé}
7703e811da7fSDaniel P. Berrangé
7704e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
7705e811da7fSDaniel P. Berrangé# features/build target configure will detect
7706e811da7fSDaniel P. Berrangépreserve_env AR
7707e811da7fSDaniel P. Berrangépreserve_env AS
7708e811da7fSDaniel P. Berrangépreserve_env CC
7709e811da7fSDaniel P. Berrangépreserve_env CPP
7710e811da7fSDaniel P. Berrangépreserve_env CXX
7711e811da7fSDaniel P. Berrangépreserve_env INSTALL
7712e811da7fSDaniel P. Berrangépreserve_env LD
7713e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
7714e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
7715e811da7fSDaniel P. Berrangépreserve_env MAKE
7716e811da7fSDaniel P. Berrangépreserve_env NM
7717e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
7718e811da7fSDaniel P. Berrangépreserve_env PATH
7719e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
7720e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
7721e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
7722e811da7fSDaniel P. Berrangépreserve_env PYTHON
7723e811da7fSDaniel P. Berrangépreserve_env SDL_CONFIG
7724e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
7725e811da7fSDaniel P. Berrangépreserve_env SMBD
7726e811da7fSDaniel P. Berrangépreserve_env STRIP
7727e811da7fSDaniel P. Berrangépreserve_env WINDRES
7728e811da7fSDaniel P. Berrangé
7729dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7730dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
7731cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7732dc655404SMichael S. Tsirkinchmod +x config.status
7733dc655404SMichael S. Tsirkin
77348cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7735