xref: /openbmc/qemu/configure (revision 1f773d9d)
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=""
351a442fe2fSDaniel P. Berrangésdl_image=""
352983eef5aSMeador Ingevirtfs=""
353fe8fc5aeSPaolo Bonzinimpath=""
354821601eaSJes Sorensenvnc="yes"
355377529c0SPaolo Bonzinisparse="no"
356377529c0SPaolo Bonzinivde=""
357377529c0SPaolo Bonzinivnc_sasl=""
358377529c0SPaolo Bonzinivnc_jpeg=""
359377529c0SPaolo Bonzinivnc_png=""
3606a021536SGerd Hoffmannxkbcommon=""
361377529c0SPaolo Bonzinixen=""
362d5b93ddfSAnthony PERARDxen_ctrl_version=""
363eb6fda0fSAnthony PERARDxen_pci_passthrough=""
364377529c0SPaolo Bonzinilinux_aio=""
36547e98658SCorey Bryantcap_ng=""
366377529c0SPaolo Bonziniattr=""
3674f26f2b6SAvi Kivitylibattr=""
368377529c0SPaolo Bonzinixfs=""
369b3f6ea7eSPaolo Bonzinitcg="yes"
370a40161cbSPaolo Bonzinimembarrier=""
371299e6f19SPaolo Bonzinivhost_net=""
372299e6f19SPaolo Bonzinivhost_crypto=""
373299e6f19SPaolo Bonzinivhost_scsi=""
374299e6f19SPaolo Bonzinivhost_vsock=""
375e6a74868SMarc-André Lureauvhost_user=""
376d41a75a2SBradkvm="no"
377b0cb0a66SVincent Palatinhax="no"
378c97d6d2cSSergio Andres Gomez Del Realhvf="no"
379d661d9a4SJustin Terry (VM)whpx="no"
3802da776dbSMichael R. Hinesrdma=""
38121ab34c9SMarcel Apfelbaumpvrdma=""
382377529c0SPaolo Bonzinigprof="no"
383377529c0SPaolo Bonzinidebug_tcg="no"
384377529c0SPaolo Bonzinidebug="no"
385247724cbSMarc-André Lureausanitizers="no"
386b553a042SJohn Snowfortify_source=""
387377529c0SPaolo Bonzinistrip_opt="yes"
3889195b2c2SStefan Weiltcg_interpreter="no"
389377529c0SPaolo Bonzinibigendian="no"
390377529c0SPaolo Bonzinimingw32="no"
3911d728c39SBlue Swirlgcov="no"
3921d728c39SBlue Swirlgcov_tool="gcov"
393377529c0SPaolo BonziniEXESUF=""
39417969268SFam ZhengDSOSUF=".so"
39517969268SFam ZhengLDFLAGS_SHARED="-shared"
39617969268SFam Zhengmodules="no"
397377529c0SPaolo Bonziniprefix="/usr/local"
398377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
399528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
4003d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
401850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
402377529c0SPaolo Bonzinibindir="\${prefix}/bin"
4033aa5d2beSAlon Levylibdir="\${prefix}/lib"
4048bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
4050f94d6daSAlon Levyincludedir="\${prefix}/include"
406377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
407785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
408377529c0SPaolo Bonziniconfsuffix="/qemu"
409675b9b53SMarc-André Lureauslirp=""
410377529c0SPaolo Bonzinioss_lib=""
411377529c0SPaolo Bonzinibsd="no"
412377529c0SPaolo Bonzinilinux="no"
413377529c0SPaolo Bonzinisolaris="no"
414377529c0SPaolo Bonziniprofiler="no"
415377529c0SPaolo Bonzinicocoa="no"
416377529c0SPaolo Bonzinisoftmmu="yes"
417377529c0SPaolo Bonzinilinux_user="no"
418377529c0SPaolo Bonzinibsd_user="no"
419377529c0SPaolo Bonziniblobs="yes"
420377529c0SPaolo Bonzinipkgversion=""
42140d6444eSAvi Kivitypie=""
4223556c233SPaolo Bonziniqom_cast_debug="yes"
423baf86d6bSPaolo Bonzinitrace_backends="log"
424377529c0SPaolo Bonzinitrace_file="trace"
425377529c0SPaolo Bonzinispice=""
426377529c0SPaolo Bonzinirbd=""
4277b02f544SMarc-André Lureausmartcard=""
4282b2325ffSGerd Hoffmannlibusb=""
42969354a83SHans de Goedeusb_redir=""
430da076ffeSGerd Hoffmannopengl=""
431014cb152SGerd Hoffmannopengl_dmabuf="no"
4325dd89908SRichard Hendersoncpuid_h="no"
43386583a07SLiam Merwickavx2_opt=""
4341ece9905SAlon Levyzlib="yes"
4358ca80760SRichard Hendersoncapstone=""
436b25c9dffSStefan Weillzo=""
437b25c9dffSStefan Weilsnappy=""
4386b383c08SPeter Wubzip2=""
43983bc1f97SJulio Faraccolzfse=""
440e8ef31a3SMichael Tokarevguest_agent=""
441d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
44250cbebb9SMichael Rothguest_agent_ntddscsi="no"
4439dacf32dSYossi Hindinguest_agent_msi=""
444d9840e25STomoki Sekiyamavss_win32_sdk=""
445d9840e25STomoki Sekiyamawin_sdk="no"
4464b1c11fdSDaniel P. Berrangewant_tools="yes"
447c589b249SRonnie Sahlberglibiscsi=""
4486542aa9cSPeter Lievenlibnfs=""
449519175a2SAlex Barcelocoroutine=""
45070c60c08SStefan Hajnoczicoroutine_pool=""
4517d992e4dSPeter Lievendebug_stack_usage="no"
452f0d92b56SLongpeng(Mike)crypto_afalg="no"
453f794573eSEduardo Otuboseccomp=""
454eb100396SBharata B Raoglusterfs=""
455d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4560c14fb47SBharata B Raoglusterfs_discard="no"
457df3a429aSNiels de Vosglusterfs_fallocate="no"
4587c815372SBharata B Raoglusterfs_zerofill="no"
459a4ccabcfSAnthony Liguorigtk=""
460925a0400SGerd Hoffmanngtk_gl="no"
461a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
462ddbb0d09SDaniel P. Berrangegnutls=""
46391bfcdb0SDaniel P. Berrangenettle=""
46491bfcdb0SDaniel P. Berrangegcrypt=""
4651f923c70SLongpeng(Mike)gcrypt_hmac="no"
4668953caf3SDaniel P. Berrangeauth_pam=""
467bbbf9bfbSStefan Weilvte=""
4689d9e1521SGerd Hoffmannvirglrenderer=""
4697aaa6a16SPaolo Bonzinitpm=""
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=""
490f3494749SPaolo Bonzinidefault_devices="yes"
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
58047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
581ac0df51dSaliguori
58245d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
58345d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
58445d285abSPeter Maydell
585be17dc90SMichael S. Tsirkin# default flags for all hosts
5862d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5872d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5882d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5892d31515bSPeter Maydell# provides these semantics.)
5907be41675SThomas HuthQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
591f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
592c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
593be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5949edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5955bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5965bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
597be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5985bc62e01SGerd Hoffmannfi
599be17dc90SMichael S. Tsirkin
600ca4deeb1SPaolo Bonzini# make source path absolute
60189138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
602ca4deeb1SPaolo Bonzini
603cab00a5aSMichael S. Tsirkin# running configure in the source tree?
604cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
605cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
606cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
607cab00a5aSMichael S. Tsirkinelse
608cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
609cab00a5aSMichael S. Tsirkinfi
610cab00a5aSMichael S. Tsirkin
611ac0df51dSaliguoricheck_define() {
612ac0df51dSaliguoricat > $TMPC <<EOF
613ac0df51dSaliguori#if !defined($1)
614fd786e1aSPeter Maydell#error $1 not defined
615ac0df51dSaliguori#endif
616ac0df51dSaliguoriint main(void) { return 0; }
617ac0df51dSaliguoriEOF
61852166aa0SJuan Quintela  compile_object
619ac0df51dSaliguori}
620ac0df51dSaliguori
621307119e7SGerd Hoffmanncheck_include() {
622307119e7SGerd Hoffmanncat > $TMPC <<EOF
623307119e7SGerd Hoffmann#include <$1>
624307119e7SGerd Hoffmannint main(void) { return 0; }
625307119e7SGerd HoffmannEOF
626307119e7SGerd Hoffmann  compile_object
627307119e7SGerd Hoffmann}
628307119e7SGerd Hoffmann
62993b25869SJohn Snowwrite_c_skeleton() {
63093b25869SJohn Snow    cat > $TMPC <<EOF
63193b25869SJohn Snowint main(void) { return 0; }
63293b25869SJohn SnowEOF
63393b25869SJohn Snow}
63493b25869SJohn Snow
635bbea4050SPeter Maydellif check_define __linux__ ; then
636bbea4050SPeter Maydell  targetos="Linux"
637bbea4050SPeter Maydellelif check_define _WIN32 ; then
638bbea4050SPeter Maydell  targetos='MINGW32'
639bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
640bbea4050SPeter Maydell  targetos='OpenBSD'
641bbea4050SPeter Maydellelif check_define __sun__ ; then
642bbea4050SPeter Maydell  targetos='SunOS'
643bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
644bbea4050SPeter Maydell  targetos='Haiku'
645951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
646951fedfcSPeter Maydell  targetos='FreeBSD'
647951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
648951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
649951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
650951fedfcSPeter Maydell  targetos='DragonFly'
651951fedfcSPeter Maydellelif check_define __NetBSD__; then
652951fedfcSPeter Maydell  targetos='NetBSD'
653951fedfcSPeter Maydellelif check_define __APPLE__; then
654951fedfcSPeter Maydell  targetos='Darwin'
655bbea4050SPeter Maydellelse
656951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
657951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
658951fedfcSPeter Maydell  # be the result of a missing compiler.
659951fedfcSPeter Maydell  targetos='bogus'
660951fedfcSPeter Maydell  bogus_os='yes'
661bbea4050SPeter Maydellfi
662bbea4050SPeter Maydell
663bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
664bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
665bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
666bbea4050SPeter Maydell# the correct CPU with the --cpu option.
667bbea4050SPeter Maydellcase $targetos in
668bbea4050SPeter MaydellDarwin)
669bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
670bbea4050SPeter Maydell  # run 64-bit userspace code.
671bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
672bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
673bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
674bbea4050SPeter Maydell    cpu="x86_64"
675bbea4050SPeter Maydell  fi
676bbea4050SPeter Maydell  ;;
677bbea4050SPeter MaydellSunOS)
67889138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
679bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
680bbea4050SPeter Maydell    cpu="x86_64"
681bbea4050SPeter Maydell  fi
682bbea4050SPeter Maydellesac
683bbea4050SPeter Maydell
6842ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6852ff6b91eSJuan Quintela  # command line argument
6862ff6b91eSJuan Quintela  :
6872ff6b91eSJuan Quintelaelif check_define __i386__ ; then
688ac0df51dSaliguori  cpu="i386"
689ac0df51dSaliguorielif check_define __x86_64__ ; then
690c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
691c72b26ecSRichard Henderson    cpu="x32"
692c72b26ecSRichard Henderson  else
693ac0df51dSaliguori    cpu="x86_64"
694c72b26ecSRichard Henderson  fi
6953aa9bd6cSblueswir1elif check_define __sparc__ ; then
6963aa9bd6cSblueswir1  if check_define __arch64__ ; then
6973aa9bd6cSblueswir1    cpu="sparc64"
6983aa9bd6cSblueswir1  else
6993aa9bd6cSblueswir1    cpu="sparc"
7003aa9bd6cSblueswir1  fi
701fdf7ed96Smalcelif check_define _ARCH_PPC ; then
702fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
703fdf7ed96Smalc    cpu="ppc64"
704ac0df51dSaliguori  else
705fdf7ed96Smalc    cpu="ppc"
706fdf7ed96Smalc  fi
707afa05235SAurelien Jarnoelif check_define __mips__ ; then
708afa05235SAurelien Jarno  cpu="mips"
709d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
710d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
711d66ed0eaSAurelien Jarno    cpu="s390x"
712d66ed0eaSAurelien Jarno  else
713d66ed0eaSAurelien Jarno    cpu="s390"
714d66ed0eaSAurelien Jarno  fi
715c4f80543SAlistair Franciselif check_define __riscv ; then
716c4f80543SAlistair Francis  if check_define _LP64 ; then
717c4f80543SAlistair Francis    cpu="riscv64"
718c4f80543SAlistair Francis  else
719c4f80543SAlistair Francis    cpu="riscv32"
720c4f80543SAlistair Francis  fi
72121d89f84SPeter Maydellelif check_define __arm__ ; then
72221d89f84SPeter Maydell  cpu="arm"
7231f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7241f080313SClaudio Fontana  cpu="aarch64"
725fdf7ed96Smalcelse
72689138857SStefan Weil  cpu=$(uname -m)
727ac0df51dSaliguorifi
728ac0df51dSaliguori
729359bc95dSPeter MaydellARCH=
730359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
731359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7327d13299dSbellardcase "$cpu" in
733c4f80543SAlistair Francis  ppc|ppc64|s390|s390x|sparc64|x32|riscv32|riscv64)
734898be3e0SPeter Maydell    cpu="$cpu"
735898be3e0SPeter Maydell    supported_cpu="yes"
736d75402b5SAlex Bennée    eval "cross_cc_${cpu}=\$host_cc"
737898be3e0SPeter Maydell  ;;
7387d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
73997a847bcSbellard    cpu="i386"
740898be3e0SPeter Maydell    supported_cpu="yes"
741d75402b5SAlex Bennée    cross_cc_i386=$host_cc
7427d13299dSbellard  ;;
743aaa5fa14Saurel32  x86_64|amd64)
744aaa5fa14Saurel32    cpu="x86_64"
745898be3e0SPeter Maydell    supported_cpu="yes"
746d75402b5SAlex Bennée    cross_cc_x86_64=$host_cc
747aaa5fa14Saurel32  ;;
74821d89f84SPeter Maydell  armv*b|armv*l|arm)
74921d89f84SPeter Maydell    cpu="arm"
750898be3e0SPeter Maydell    supported_cpu="yes"
751d75402b5SAlex Bennée    cross_cc_arm=$host_cc
7527d13299dSbellard  ;;
7531f080313SClaudio Fontana  aarch64)
7541f080313SClaudio Fontana    cpu="aarch64"
755898be3e0SPeter Maydell    supported_cpu="yes"
756d75402b5SAlex Bennée    cross_cc_aarch64=$host_cc
7571f080313SClaudio Fontana  ;;
758afa05235SAurelien Jarno  mips*)
759afa05235SAurelien Jarno    cpu="mips"
760898be3e0SPeter Maydell    supported_cpu="yes"
761d75402b5SAlex Bennée    cross_cc_mips=$host_cc
762afa05235SAurelien Jarno  ;;
7633142255cSblueswir1  sparc|sun4[cdmuv])
764ae228531Sbellard    cpu="sparc"
7656499fd15SPeter Maydell    supported_cpu="yes"
766d75402b5SAlex Bennée    cross_cc_sparc=$host_cc
767ae228531Sbellard  ;;
7687d13299dSbellard  *)
769359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
770359bc95dSPeter Maydell    ARCH=unknown
7717d13299dSbellard  ;;
7727d13299dSbellardesac
773359bc95dSPeter Maydellif test -z "$ARCH"; then
774359bc95dSPeter Maydell  ARCH="$cpu"
775359bc95dSPeter Maydellfi
776e2d52ad3SJuan Quintela
7777d13299dSbellard# OS specific
7780dbfc675SJuan Quintela
779adfc3e91SStacey Son# host *BSD for user mode
780adfc3e91SStacey SonHOST_VARIANT_DIR=""
781adfc3e91SStacey Son
7827d13299dSbellardcase $targetos in
78367b915a5SbellardMINGW32*)
78467b915a5Sbellard  mingw32="yes"
785b0cb0a66SVincent Palatin  hax="yes"
786299e6f19SPaolo Bonzini  vhost_user="no"
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"
822604a5b99SKamil Rytarowski  hax="yes"
8230db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8246a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8250bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8268ef92a88Sblueswir1  oss_lib="-lossaudio"
827adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8283c2bdbc1SKamil Rytarowski  supported_os="yes"
8297d3505c5Sbellard;;
8307d3505c5SbellardOpenBSD)
8317d3505c5Sbellard  bsd="yes"
8320db4a067SPaolo Bonzini  make="${MAKE-gmake}"
833f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8340bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
835adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8360a773d55SBrad Smith  supported_os="yes"
8377d3505c5Sbellard;;
83883fb7adfSbellardDarwin)
83983fb7adfSbellard  bsd="yes"
84083fb7adfSbellard  darwin="yes"
841b0cb0a66SVincent Palatin  hax="yes"
842c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
84317969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8441b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
845a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
8460c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8471b0f9cc2Saliguori  fi
848fd677642Sths  cocoa="yes"
8496a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
85014382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8510c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8527973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
853a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
854a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
855a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
856adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
857898be3e0SPeter Maydell  supported_os="yes"
85883fb7adfSbellard;;
859ec530c81SbellardSunOS)
860ec530c81Sbellard  solaris="yes"
8610db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8620db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
863e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8646b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8656a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
8666b4d2ba1Sths  fi
867c2de5c91Smalc  audio_possible_drivers="oss sdl"
868d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
869d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
870d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
871d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
872a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
873560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
874560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
875560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
876ec530c81Sbellard;;
877179cf400SAndreas FärberHaiku)
878179cf400SAndreas Färber  haiku="yes"
879179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
880179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
881179cf400SAndreas Färber;;
882898be3e0SPeter MaydellLinux)
8837183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
8840bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8855327cf48Sbellard  linux="yes"
886831b7825Sths  linux_user="yes"
887af2be207SJan Kiszka  kvm="yes"
888e8d81a61SMao Zhongyi  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
889898be3e0SPeter Maydell  supported_os="yes"
8903efac6ebSTomáš Golembiovský  libudev="yes"
891898be3e0SPeter Maydell;;
8927d13299dSbellardesac
8937d13299dSbellard
8947d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
895b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
89684778508Sblueswir1    bsd_user="yes"
8977d3505c5Sbellard  fi
89808de3949SAndreas Färberfi
8997d3505c5Sbellard
9000db4a067SPaolo Bonzini: ${make=${MAKE-make}}
9010db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
90252510f8bSStefan Weil: ${python=${PYTHON-python}}
903e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9040db4a067SPaolo Bonzini
9053c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9063c4a4d0dSPeter Maydellif has clang; then
9073c4a4d0dSPeter Maydell  objcc=clang
9083c4a4d0dSPeter Maydellelse
9093c4a4d0dSPeter Maydell  objcc="$cc"
9103c4a4d0dSPeter Maydellfi
9113c4a4d0dSPeter Maydell
9123457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
9133457a3f8SJuan Quintela  EXESUF=".exe"
91417969268SFam Zheng  DSOSUF=".dll"
91578e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
91678e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
917f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
91893b25869SJohn Snow  write_c_skeleton;
919f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
920f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
921f7cf5d5bSStefan Weil  fi
922c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
923683035deSPaolo Bonzini  mandir="\${prefix}"
924528ae5b8SEduardo Habkost  datadir="\${prefix}"
925850da188SEduardo Habkost  qemu_docdir="\${prefix}"
926683035deSPaolo Bonzini  bindir="\${prefix}"
927683035deSPaolo Bonzini  sysconfdir="\${prefix}"
9285a699bbbSLaszlo Ersek  local_statedir=
929683035deSPaolo Bonzini  confsuffix=""
930105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9313457a3f8SJuan Quintelafi
9323457a3f8SJuan Quintela
933487fefdbSAnthony Liguoriwerror=""
93485aa5189Sbellard
9357d13299dSbellardfor opt do
93689138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9377d13299dSbellard  case "$opt" in
9382efc3265Sbellard  --help|-h) show_help=yes
9392efc3265Sbellard  ;;
94099123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
94199123e13SMike Frysinger  ;;
942b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9437d13299dSbellard  ;;
944b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
94532ce6337Sbellard  ;;
946ca4deeb1SPaolo Bonzini  --source-path=*)
9477d13299dSbellard  ;;
948ac0df51dSaliguori  --cross-prefix=*)
9497d13299dSbellard  ;;
950ac0df51dSaliguori  --cc=*)
9517d13299dSbellard  ;;
952b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
95383469015Sbellard  ;;
95483f73fceSTomoki Sekiyama  --cxx=*)
95583f73fceSTomoki Sekiyama  ;;
956e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
957e007dbecSMichael S. Tsirkin  ;;
9583c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9593c4a4d0dSPeter Maydell  ;;
960b1a550a0Spbrook  --make=*) make="$optarg"
9617d13299dSbellard  ;;
9626a882643Spbrook  --install=*) install="$optarg"
9636a882643Spbrook  ;;
964c886edfbSBlue Swirl  --python=*) python="$optarg"
965c886edfbSBlue Swirl  ;;
9661d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9671d728c39SBlue Swirl  ;;
968e2d8830eSBrad  --smbd=*) smbd="$optarg"
969e2d8830eSBrad  ;;
970e2a2ed06SJuan Quintela  --extra-cflags=*)
9717d13299dSbellard  ;;
97211cde1c8SBruno Dominguez  --extra-cxxflags=*)
97311cde1c8SBruno Dominguez  ;;
974e2a2ed06SJuan Quintela  --extra-ldflags=*)
9757d13299dSbellard  ;;
9765bc62e01SGerd Hoffmann  --enable-debug-info)
9775bc62e01SGerd Hoffmann  ;;
9785bc62e01SGerd Hoffmann  --disable-debug-info)
9795bc62e01SGerd Hoffmann  ;;
980d75402b5SAlex Bennée  --cross-cc-*)
981d75402b5SAlex Bennée  ;;
98217969268SFam Zheng  --enable-modules)
98317969268SFam Zheng      modules="yes"
98417969268SFam Zheng  ;;
9853aa88b31SStefan Hajnoczi  --disable-modules)
9863aa88b31SStefan Hajnoczi      modules="no"
9873aa88b31SStefan Hajnoczi  ;;
9882ff6b91eSJuan Quintela  --cpu=*)
9897d13299dSbellard  ;;
990b1a550a0Spbrook  --target-list=*) target_list="$optarg"
991de83cd02Sbellard  ;;
9925b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9935b808275SLluís Vilanova  ;;
9945b808275SLluís Vilanova  # XXX: backwards compatibility
9955b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
99694a420b1SStefan Hajnoczi  ;;
99774242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9989410b56cSPrerna Saxena  ;;
999f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1000f3494749SPaolo Bonzini  ;;
1001f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1002f3494749SPaolo Bonzini  ;;
10037d13299dSbellard  --enable-gprof) gprof="yes"
10047d13299dSbellard  ;;
10051d728c39SBlue Swirl  --enable-gcov) gcov="yes"
10061d728c39SBlue Swirl  ;;
100779427693SLoïc Minier  --static)
100879427693SLoïc Minier    static="yes"
100979427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
101017884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
101143ce4dfeSbellard  ;;
10120b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
10130b24e75fSPaolo Bonzini  ;;
10140b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
10150b24e75fSPaolo Bonzini  ;;
10163aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10173aa5d2beSAlon Levy  ;;
10188bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10198bf188aaSMichael Tokarev  ;;
10200f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10210f94d6daSAlon Levy  ;;
1022528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10230b24e75fSPaolo Bonzini  ;;
1024023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1025023d3d67SEduardo Habkost  ;;
1026850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10270b24e75fSPaolo Bonzini  ;;
1028ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
102907381cc1SAnthony Liguori  ;;
1030785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1031785c23aeSLuiz Capitulino  ;;
10323d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10333d5eecabSGerd Hoffmann  ;;
1034181ce1d0SOlaf Hering  --host=*|--build=*|\
1035181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1036785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1037023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1038023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1039023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1040023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1041023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1042023ddd74SMax Filippov    # lots of directory switches by default.
1043023ddd74SMax Filippov  ;;
104497a847bcSbellard  --disable-sdl) sdl="no"
104597a847bcSbellard  ;;
1046c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1047c4198157SJuan Quintela  ;;
1048a442fe2fSDaniel P. Berrangé  --disable-sdl-image) sdl_image="no"
1049a442fe2fSDaniel P. Berrangé  ;;
1050a442fe2fSDaniel P. Berrangé  --enable-sdl-image) sdl_image="yes"
1051a442fe2fSDaniel P. Berrangé  ;;
10523556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10533556c233SPaolo Bonzini  ;;
10543556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10553556c233SPaolo Bonzini  ;;
1056983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1057983eef5aSMeador Inge  ;;
1058983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1059983eef5aSMeador Inge  ;;
1060fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1061fe8fc5aeSPaolo Bonzini  ;;
1062fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1063fe8fc5aeSPaolo Bonzini  ;;
1064821601eaSJes Sorensen  --disable-vnc) vnc="no"
1065821601eaSJes Sorensen  ;;
1066821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1067821601eaSJes Sorensen  ;;
10682f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10692f6a1ab0Sblueswir1  ;;
10700c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10710c58ac1cSmalc  ;;
107289138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1073b64ec4e4SFam Zheng  ;;
107489138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1075eb852011SMarkus Armbruster  ;;
1076f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1077f8393946Saurel32  ;;
1078f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1079f8393946Saurel32  ;;
1080f3d08ee6SPaul Brook  --enable-debug)
1081f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1082f3d08ee6SPaul Brook      debug_tcg="yes"
10831fcc6d42SPeter Xu      debug_mutex="yes"
1084f3d08ee6SPaul Brook      debug="yes"
1085f3d08ee6SPaul Brook      strip_opt="no"
1086b553a042SJohn Snow      fortify_source="no"
1087f3d08ee6SPaul Brook  ;;
1088247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1089247724cbSMarc-André Lureau  ;;
1090247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1091247724cbSMarc-André Lureau  ;;
109203b4fe7dSaliguori  --enable-sparse) sparse="yes"
109303b4fe7dSaliguori  ;;
109403b4fe7dSaliguori  --disable-sparse) sparse="no"
109503b4fe7dSaliguori  ;;
10961625af87Saliguori  --disable-strip) strip_opt="no"
10971625af87Saliguori  ;;
10982f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
10992f9606b3Saliguori  ;;
1100ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1101ea784e3bSJuan Quintela  ;;
11022f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
11032f6f5c7aSCorentin Chary  ;;
11042f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
11052f6f5c7aSCorentin Chary  ;;
1106efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1107efe556adSCorentin Chary  ;;
1108efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1109efe556adSCorentin Chary  ;;
1110443f1376Sbellard  --disable-slirp) slirp="no"
1111c20709aaSbellard  ;;
1112675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1113675b9b53SMarc-André Lureau  ;;
1114e0e6c8c0Saliguori  --disable-vde) vde="no"
11158a16d273Sths  ;;
1116dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1117dfb278bdSJuan Quintela  ;;
111858952137SVincenzo Maffione  --disable-netmap) netmap="no"
111958952137SVincenzo Maffione  ;;
112058952137SVincenzo Maffione  --enable-netmap) netmap="yes"
112158952137SVincenzo Maffione  ;;
1122e37630caSaliguori  --disable-xen) xen="no"
1123e37630caSaliguori  ;;
1124fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1125fc321b4bSJuan Quintela  ;;
1126eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1127eb6fda0fSAnthony PERARD  ;;
1128eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1129eb6fda0fSAnthony PERARD  ;;
11302e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
11312e4d9fb1Saurel32  ;;
11324ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
11334ffcedb6SJuan Quintela  ;;
1134fb599c9aSbalrog  --disable-bluez) bluez="no"
1135fb599c9aSbalrog  ;;
1136a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1137a20a6f46SJuan Quintela  ;;
11387ba1e619Saliguori  --disable-kvm) kvm="no"
11397ba1e619Saliguori  ;;
1140b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1141b31a0277SJuan Quintela  ;;
1142b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1143180fb750Szhanghailiang  ;;
1144b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1145180fb750Szhanghailiang  ;;
1146c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1147c97d6d2cSSergio Andres Gomez Del Real  ;;
1148c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1149c97d6d2cSSergio Andres Gomez Del Real  ;;
1150d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1151d661d9a4SJustin Terry (VM)  ;;
1152d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1153d661d9a4SJustin Terry (VM)  ;;
11549195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11559195b2c2SStefan Weil  ;;
11569195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11579195b2c2SStefan Weil  ;;
115847e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
115947e98658SCorey Bryant  ;;
116047e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
116147e98658SCorey Bryant  ;;
1162b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1163b3f6ea7eSPaolo Bonzini  ;;
1164b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1165b3f6ea7eSPaolo Bonzini  ;;
11665a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11675a22ab71SYang Zhong  ;;
11685a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11695a22ab71SYang Zhong  ;;
1170cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1171cd4ec0b4SGerd Hoffmann  ;;
1172cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1173cd4ec0b4SGerd Hoffmann  ;;
1174c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1175c589b249SRonnie Sahlberg  ;;
1176c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1177c589b249SRonnie Sahlberg  ;;
11786542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11796542aa9cSPeter Lieven  ;;
11806542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11816542aa9cSPeter Lieven  ;;
118205c2a3e7Sbellard  --enable-profiler) profiler="yes"
118305c2a3e7Sbellard  ;;
118414821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
118514821030SPavel Borzenkov  ;;
1186c2de5c91Smalc  --enable-cocoa)
1187c2de5c91Smalc      cocoa="yes" ;
118889138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
11895b0753e0Sbellard  ;;
1190cad25d69Spbrook  --disable-system) softmmu="no"
11910a8e90f4Spbrook  ;;
1192cad25d69Spbrook  --enable-system) softmmu="yes"
11930a8e90f4Spbrook  ;;
11940953a80fSZachary Amsden  --disable-user)
11950953a80fSZachary Amsden      linux_user="no" ;
11960953a80fSZachary Amsden      bsd_user="no" ;
11970953a80fSZachary Amsden  ;;
11980953a80fSZachary Amsden  --enable-user) ;;
1199831b7825Sths  --disable-linux-user) linux_user="no"
12000a8e90f4Spbrook  ;;
1201831b7825Sths  --enable-linux-user) linux_user="yes"
1202831b7825Sths  ;;
120384778508Sblueswir1  --disable-bsd-user) bsd_user="no"
120484778508Sblueswir1  ;;
120584778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
120684778508Sblueswir1  ;;
120740d6444eSAvi Kivity  --enable-pie) pie="yes"
120834005a00SKirill A. Shutemov  ;;
120940d6444eSAvi Kivity  --disable-pie) pie="no"
121034005a00SKirill A. Shutemov  ;;
121185aa5189Sbellard  --enable-werror) werror="yes"
121285aa5189Sbellard  ;;
121385aa5189Sbellard  --disable-werror) werror="no"
121485aa5189Sbellard  ;;
121563678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
121663678e17SSteven Noonan  ;;
121763678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
121863678e17SSteven Noonan  ;;
12194d3b6f6eSbalrog  --disable-curses) curses="no"
12204d3b6f6eSbalrog  ;;
1221c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1222c584a6d0SJuan Quintela  ;;
1223769ce76dSAlexander Graf  --disable-curl) curl="no"
1224769ce76dSAlexander Graf  ;;
1225788c8196SJuan Quintela  --enable-curl) curl="yes"
1226788c8196SJuan Quintela  ;;
12272df87df7SJuan Quintela  --disable-fdt) fdt="no"
12282df87df7SJuan Quintela  ;;
12292df87df7SJuan Quintela  --enable-fdt) fdt="yes"
12302df87df7SJuan Quintela  ;;
12315c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12325c6c3a6cSChristoph Hellwig  ;;
12335c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12345c6c3a6cSChristoph Hellwig  ;;
1235758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1236758e8e38SVenkateswararao Jujjuri (JV)  ;;
1237758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1238758e8e38SVenkateswararao Jujjuri (JV)  ;;
1239a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1240a40161cbSPaolo Bonzini  ;;
1241a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1242a40161cbSPaolo Bonzini  ;;
124377755340Sths  --disable-blobs) blobs="no"
124477755340Sths  ;;
12457e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12464a19f1ecSpbrook  ;;
1247519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1248519175a2SAlex Barcelo  ;;
124970c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
125070c60c08SStefan Hajnoczi  ;;
125170c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
125270c60c08SStefan Hajnoczi  ;;
12537d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12547d992e4dSPeter Lieven  ;;
1255f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1256f0d92b56SLongpeng(Mike)  ;;
1257f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1258f0d92b56SLongpeng(Mike)  ;;
1259a25dba17SJuan Quintela  --disable-docs) docs="no"
126070ec5dc0SAnthony Liguori  ;;
1261a25dba17SJuan Quintela  --enable-docs) docs="yes"
126283a3ab8bSJuan Quintela  ;;
1263d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1264d5970055SMichael S. Tsirkin  ;;
1265d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1266d5970055SMichael S. Tsirkin  ;;
1267042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1268042cea27SGonglei  ;;
1269299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1270042cea27SGonglei  ;;
12715e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12725e9be92dSNicholas Bellinger  ;;
12735e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12745e9be92dSNicholas Bellinger  ;;
1275fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1276fc0b9b0eSStefan Hajnoczi  ;;
1277fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1278fc0b9b0eSStefan Hajnoczi  ;;
1279da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
128020ff075bSMichael Walle  ;;
1281da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
128220ff075bSMichael Walle  ;;
1283f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1284f27aaf4bSChristian Brunner  ;;
1285f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1286f27aaf4bSChristian Brunner  ;;
12878c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12888c84cf11SSergei Trofimovich  ;;
12898c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12908c84cf11SSergei Trofimovich  ;;
12917b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1292111a38b0SRobert Relyea  ;;
12937b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1294111a38b0SRobert Relyea  ;;
12952b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
12962b2325ffSGerd Hoffmann  ;;
12972b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
12982b2325ffSGerd Hoffmann  ;;
129969354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
130069354a83SHans de Goede  ;;
130169354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
130269354a83SHans de Goede  ;;
13031ece9905SAlon Levy  --disable-zlib-test) zlib="no"
13041ece9905SAlon Levy  ;;
1305b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1306b25c9dffSStefan Weil  ;;
1307607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1308607dacd0Sqiaonuohan  ;;
1309b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1310b25c9dffSStefan Weil  ;;
1311607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1312607dacd0Sqiaonuohan  ;;
13136b383c08SPeter Wu  --disable-bzip2) bzip2="no"
13146b383c08SPeter Wu  ;;
13156b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13166b383c08SPeter Wu  ;;
131783bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
131883bc1f97SJulio Faracco  ;;
131983bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
132083bc1f97SJulio Faracco  ;;
1321d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1322d138cee9SMichael Roth  ;;
1323d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1324d138cee9SMichael Roth  ;;
13259dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13269dacf32dSYossi Hindin  ;;
13279dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13289dacf32dSYossi Hindin  ;;
1329d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1330d9840e25STomoki Sekiyama  ;;
1331d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1332d9840e25STomoki Sekiyama  ;;
1333d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1334d9840e25STomoki Sekiyama  ;;
1335d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1336d9840e25STomoki Sekiyama  ;;
1337d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1338d9840e25STomoki Sekiyama  ;;
1339d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1340d9840e25STomoki Sekiyama  ;;
13414b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13424b1c11fdSDaniel P. Berrange  ;;
13434b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13444b1c11fdSDaniel P. Berrange  ;;
1345f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1346f794573eSEduardo Otubo  ;;
1347f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1348f794573eSEduardo Otubo  ;;
1349eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1350eb100396SBharata B Rao  ;;
135186583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
135286583a07SLiam Merwick  ;;
135386583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
135486583a07SLiam Merwick  ;;
1355eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1356eb100396SBharata B Rao  ;;
135752b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
135852b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1359583f6e7bSStefan Hajnoczi  ;;
1360cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1361cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1362cb6414dfSFam Zheng  ;;
1363315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1364315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1365315d3184SFam Zheng  ;;
1366a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1367a4ccabcfSAnthony Liguori  ;;
1368a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1369a4ccabcfSAnthony Liguori  ;;
1370a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1371a1c5e949SDaniel P. Berrange  ;;
1372ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1373ddbb0d09SDaniel P. Berrange  ;;
1374ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1375ddbb0d09SDaniel P. Berrange  ;;
137691bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
137791bfcdb0SDaniel P. Berrange  ;;
137891bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
137991bfcdb0SDaniel P. Berrange  ;;
138091bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
138191bfcdb0SDaniel P. Berrange  ;;
138291bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
138391bfcdb0SDaniel P. Berrange  ;;
13848953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
13858953caf3SDaniel P. Berrange  ;;
13868953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
13878953caf3SDaniel P. Berrange  ;;
13882da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13892da776dbSMichael R. Hines  ;;
13902da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13912da776dbSMichael R. Hines  ;;
139221ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
139321ab34c9SMarcel Apfelbaum  ;;
139421ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
139521ab34c9SMarcel Apfelbaum  ;;
1396bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1397bbbf9bfbSStefan Weil  ;;
1398bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1399bbbf9bfbSStefan Weil  ;;
14009d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14019d9e1521SGerd Hoffmann  ;;
14029d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
14039d9e1521SGerd Hoffmann  ;;
1404e91c793cSCole Robinson  --disable-tpm) tpm="no"
1405e91c793cSCole Robinson  ;;
1406ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1407ab214c29SStefan Berger  ;;
14080a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
14090a12ec87SRichard W.M. Jones  ;;
14100a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
14110a12ec87SRichard W.M. Jones  ;;
1412ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1413ed1701c6SDr. David Alan Gilbert  ;;
1414ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1415ed1701c6SDr. David Alan Gilbert  ;;
1416a99d57bbSWanlong Gao  --disable-numa) numa="no"
1417a99d57bbSWanlong Gao  ;;
1418a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1419a99d57bbSWanlong Gao  ;;
1420ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1421ed279a06SKlim Kireev  ;;
1422ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1423ed279a06SKlim Kireev  ;;
14242847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14252847b469SFam Zheng  ;;
14262847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14272847b469SFam Zheng  ;;
14287b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14297b01cb97SAlexandre Derumier  ;;
14307b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14317b01cb97SAlexandre Derumier  ;;
1432a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1433a6b1d4c0SChanglong Xie  ;;
1434a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1435a6b1d4c0SChanglong Xie  ;;
1436da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1437da92c3ffSAshish Mittal  ;;
1438da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1439da92c3ffSAshish Mittal  ;;
14402f740136SJeff Cody  --disable-bochs) bochs="no"
14412f740136SJeff Cody  ;;
14422f740136SJeff Cody  --enable-bochs) bochs="yes"
14432f740136SJeff Cody  ;;
14442f740136SJeff Cody  --disable-cloop) cloop="no"
14452f740136SJeff Cody  ;;
14462f740136SJeff Cody  --enable-cloop) cloop="yes"
14472f740136SJeff Cody  ;;
14482f740136SJeff Cody  --disable-dmg) dmg="no"
14492f740136SJeff Cody  ;;
14502f740136SJeff Cody  --enable-dmg) dmg="yes"
14512f740136SJeff Cody  ;;
14522f740136SJeff Cody  --disable-qcow1) qcow1="no"
14532f740136SJeff Cody  ;;
14542f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14552f740136SJeff Cody  ;;
14562f740136SJeff Cody  --disable-vdi) vdi="no"
14572f740136SJeff Cody  ;;
14582f740136SJeff Cody  --enable-vdi) vdi="yes"
14592f740136SJeff Cody  ;;
14602f740136SJeff Cody  --disable-vvfat) vvfat="no"
14612f740136SJeff Cody  ;;
14622f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14632f740136SJeff Cody  ;;
14642f740136SJeff Cody  --disable-qed) qed="no"
14652f740136SJeff Cody  ;;
14662f740136SJeff Cody  --enable-qed) qed="yes"
14672f740136SJeff Cody  ;;
14682f740136SJeff Cody  --disable-parallels) parallels="no"
14692f740136SJeff Cody  ;;
14702f740136SJeff Cody  --enable-parallels) parallels="yes"
14712f740136SJeff Cody  ;;
14722f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14732f740136SJeff Cody  ;;
14742f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14752f740136SJeff Cody  ;;
1476e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1477e6a74868SMarc-André Lureau  ;;
1478299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1479299e6f19SPaolo Bonzini  ;;
1480299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1481299e6f19SPaolo Bonzini  ;;
1482299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1483e6a74868SMarc-André Lureau  ;;
14848ca80760SRichard Henderson  --disable-capstone) capstone="no"
14858ca80760SRichard Henderson  ;;
14868ca80760SRichard Henderson  --enable-capstone) capstone="yes"
14878ca80760SRichard Henderson  ;;
1488e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1489e219c499SRichard Henderson  ;;
1490e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1491e219c499SRichard Henderson  ;;
1492cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1493cc84d63aSDaniel P. Berrange  ;;
1494f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1495f62bbee5SDaniel P. Berrange  ;;
1496f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1497f62bbee5SDaniel P. Berrange  ;;
1498ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1499ba59fb77SPaolo Bonzini  ;;
1500ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1501ba59fb77SPaolo Bonzini  ;;
150217824406SJunyan He  --enable-libpmem) libpmem=yes
150317824406SJunyan He  ;;
150417824406SJunyan He  --disable-libpmem) libpmem=no
150517824406SJunyan He  ;;
15062d2ad6d0SFam Zheng  *)
15072d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15082d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15092d2ad6d0SFam Zheng      exit 1
15107f1559c6Sbalrog  ;;
15117d13299dSbellard  esac
15127d13299dSbellarddone
15137d13299dSbellard
151440293e58Sbellardcase "$cpu" in
1515e3608d66SRichard Henderson    ppc)
1516e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1517e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
151813a5abe2SAlex Bennée           cross_cc_powerpc=$cc
151913a5abe2SAlex Bennée           cross_cc_cflags_powerpc=$CPU_CFLAGS
1520e3608d66SRichard Henderson           ;;
1521e3608d66SRichard Henderson    ppc64)
1522e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1523e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
152413a5abe2SAlex Bennée           cross_cc_ppc64=$cc
152513a5abe2SAlex Bennée           cross_cc_cflags_ppc64=$CPU_CFLAGS
1526e3608d66SRichard Henderson           ;;
15279b9c37c3SRichard Henderson    sparc)
1528f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1529f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
153013a5abe2SAlex Bennée           cross_cc_sparc=$cc
153113a5abe2SAlex Bennée           cross_cc_cflags_sparc=$CPU_CFLAGS
15323142255cSblueswir1           ;;
1533ed968ff1SJuan Quintela    sparc64)
153479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1535f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
153613a5abe2SAlex Bennée           cross_cc_sparc64=$cc
153713a5abe2SAlex Bennée           cross_cc_cflags_sparc64=$CPU_CFLAGS
15383142255cSblueswir1           ;;
153976d83bdeSths    s390)
1540061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
154128d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
154213a5abe2SAlex Bennée           cross_cc_s390=$cc
154313a5abe2SAlex Bennée           cross_cc_cflags_s390=$CPU_CFLAGS
154428d7cc49SRichard Henderson           ;;
154528d7cc49SRichard Henderson    s390x)
1546061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
154728d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
154813a5abe2SAlex Bennée           cross_cc_s390x=$cc
154913a5abe2SAlex Bennée           cross_cc_cflags_s390x=$CPU_CFLAGS
155076d83bdeSths           ;;
155140293e58Sbellard    i386)
155279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
15530c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
1554716a507cSAlex Bennée           cross_cc_i386=$cc
1555716a507cSAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
155640293e58Sbellard           ;;
155740293e58Sbellard    x86_64)
15587ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15597ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
15607ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
15617ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
15620c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
1563716a507cSAlex Bennée           cross_cc_x86_64=$cc
1564716a507cSAlex Bennée           cross_cc_cflags_x86_64=$CPU_CFLAGS
1565379f6698SPaul Brook           ;;
1566c72b26ecSRichard Henderson    x32)
1567c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1568c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1569716a507cSAlex Bennée           cross_cc_i386=$cc
157013a5abe2SAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
1571c72b26ecSRichard Henderson           ;;
157230163d89SPeter Maydell    # No special flags required for other host CPUs
15733142255cSblueswir1esac
15743142255cSblueswir1
157579f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
157679f3b12fSPeter Crosthwaite
1577affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1578affc88ccSPeter Maydell# support, even if we're using TCI.
1579affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1580affc88ccSPeter Maydell  bsd_user="no"
1581affc88ccSPeter Maydell  linux_user="no"
1582affc88ccSPeter Maydellfi
1583affc88ccSPeter Maydell
158460e0df25SPeter Maydelldefault_target_list=""
158560e0df25SPeter Maydell
15866e92f823SPeter Maydellmak_wilds=""
15876e92f823SPeter Maydell
158860e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
15896e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
159060e0df25SPeter Maydellfi
159160e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
15926e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
159360e0df25SPeter Maydellfi
159460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
15956e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
159660e0df25SPeter Maydellfi
159760e0df25SPeter Maydell
15986e92f823SPeter Maydellfor config in $mak_wilds; do
15996e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
16006e92f823SPeter Maydelldone
16016e92f823SPeter Maydell
1602c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
160364a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1604c53eeaf7SStefan Hajnoczi
1605af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1606af5db58eSpbrookcat << EOF
1607af5db58eSpbrook
1608af5db58eSpbrookUsage: configure [options]
1609af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1610af5db58eSpbrook
161108fb77edSStefan WeilStandard options:
161208fb77edSStefan Weil  --help                   print this message
161308fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
161408fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
161508fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
161608fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
161708fb77edSStefan Weil$(echo Available targets: $default_target_list | \
161808fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
161908fb77edSStefan Weil
162008fb77edSStefan WeilAdvanced options (experts only):
162108fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
162208fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
162308fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
162408fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
162508fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
162608fb77edSStefan Weil                           build time
162708fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
162808fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
162908fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
163011cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
163108fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1632d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1633d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
163408fb77edSStefan Weil  --make=MAKE              use specified make [$make]
163508fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
163608fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
163708fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1638db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
163908fb77edSStefan Weil  --static                 enable static build [$static]
164008fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
164108fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
164208fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
164308fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
164408fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1645db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
164608fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
164708fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
16483d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1649e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1650db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
165108fb77edSStefan Weil  --enable-debug           enable common debug build options
1652247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
165308fb77edSStefan Weil  --disable-strip          disable stripping binaries
165408fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
165563678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
165608fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
165708fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
165808fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
165908fb77edSStefan Weil  --block-drv-rw-whitelist=L
166008fb77edSStefan Weil                           set block driver read-write whitelist
166108fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
166208fb77edSStefan Weil  --block-drv-ro-whitelist=L
166308fb77edSStefan Weil                           set block driver read-only whitelist
166408fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
16655b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1666c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
166708fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
166808fb77edSStefan Weil                           Default:trace-<pid>
1669c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1670c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
16715a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1672c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1673c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
167408fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
167533c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
167608fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
167708fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1678c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1679c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1680c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1681a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1682c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1683c12d66aaSLin Ma  --enable-profiler        profiler support
1684c12d66aaSLin Ma  --enable-debug-stack-usage
1685c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1686c23f23b9SMichael Tokarev
1687c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1688c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1689c23f23b9SMichael Tokarev
1690c23f23b9SMichael Tokarev  system          all system emulation targets
1691c23f23b9SMichael Tokarev  user            supported user emulation targets
1692c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1693c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1694c23f23b9SMichael Tokarev  docs            build documentation
1695c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1696c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1697c23f23b9SMichael Tokarev  pie             Position Independent Executables
1698c23f23b9SMichael Tokarev  modules         modules support
1699c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1700c23f23b9SMichael Tokarev  debug-info      debugging information
1701c23f23b9SMichael Tokarev  sparse          sparse checker
1702c23f23b9SMichael Tokarev
1703ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
170491bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
170591bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
17068953caf3SDaniel P. Berrange  auth-pam        PAM access control
1707c23f23b9SMichael Tokarev  sdl             SDL UI
1708a442fe2fSDaniel P. Berrangé  sdl_image       SDL Image support for icons
1709c23f23b9SMichael Tokarev  gtk             gtk UI
1710c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1711c23f23b9SMichael Tokarev  curses          curses UI
1712c23f23b9SMichael Tokarev  vnc             VNC UI support
1713c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1714c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1715c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1716c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1717c23f23b9SMichael Tokarev  virtfs          VirtFS
1718fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1719c23f23b9SMichael Tokarev  xen             xen backend driver support
172070c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1721c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1722c23f23b9SMichael Tokarev  curl            curl connectivity
1723a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1724c23f23b9SMichael Tokarev  fdt             fdt device tree
1725c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1726c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1727b0cb0a66SVincent Palatin  hax             HAX acceleration support
1728c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1729d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
173021ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
173121ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1732c23f23b9SMichael Tokarev  vde             support for vde network
1733c23f23b9SMichael Tokarev  netmap          support for netmap network
1734c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1735c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1736c23f23b9SMichael Tokarev  attr            attr and xattr support
1737299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1738299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1739299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1740299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1741299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1742299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1743c23f23b9SMichael Tokarev  spice           spice
1744c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1745c23f23b9SMichael Tokarev  libiscsi        iscsi support
1746c23f23b9SMichael Tokarev  libnfs          nfs support
17477b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1748c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1749ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1750c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1751c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1752c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1753c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1754c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
175583bc1f97SJulio Faracco  lzfse           support of lzfse compression library
175683bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
1757c23f23b9SMichael Tokarev  seccomp         seccomp support
1758c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1759c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1760c23f23b9SMichael Tokarev  tpm             TPM support
1761c23f23b9SMichael Tokarev  libssh2         ssh block device support
1762c23f23b9SMichael Tokarev  numa            libnuma support
1763ed279a06SKlim Kireev  libxml2         for Parallels image format
1764c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
17657b01cb97SAlexandre Derumier  jemalloc        jemalloc support
176686583a07SLiam Merwick  avx2            AVX2 optimization support
1767a6b1d4c0SChanglong Xie  replication     replication support
1768c12d66aaSLin Ma  opengl          opengl support
1769c12d66aaSLin Ma  virglrenderer   virgl rendering support
1770c12d66aaSLin Ma  xfsctl          xfsctl support
1771c12d66aaSLin Ma  qom-cast-debug  cast debugging support
17728de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
1773da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
17742f740136SJeff Cody  bochs           bochs image format support
17752f740136SJeff Cody  cloop           cloop image format support
17762f740136SJeff Cody  dmg             dmg image format support
17772f740136SJeff Cody  qcow1           qcow v1 image format support
17782f740136SJeff Cody  vdi             vdi image format support
17792f740136SJeff Cody  vvfat           vvfat image format support
17802f740136SJeff Cody  qed             qed image format support
17812f740136SJeff Cody  parallels       parallels image format support
17822f740136SJeff Cody  sheepdog        sheepdog block driver support
1783f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
17848ca80760SRichard Henderson  capstone        capstone disassembler support
1785ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
178617824406SJunyan He  libpmem         libpmem support
178708fb77edSStefan Weil
178808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1789af5db58eSpbrookEOF
17902d2ad6d0SFam Zhengexit 0
1791af5db58eSpbrookfi
1792af5db58eSpbrook
1793c53eeaf7SStefan Hajnocziif ! has $python; then
1794c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1795c53eeaf7SStefan Hajnoczifi
1796c53eeaf7SStefan Hajnoczi
1797c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1798c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
17997f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
18007f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1801c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1802c53eeaf7SStefan Hajnoczifi
1803c53eeaf7SStefan Hajnoczi
1804755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1805755ee70fSCleber Rosapython_version=$($python -V 2>&1 | sed -e 's/Python\ //')
1806755ee70fSCleber Rosa
1807c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1808c53eeaf7SStefan Hajnoczipython="$python -B"
1809c53eeaf7SStefan Hajnoczi
18109aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
18119aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
18129aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
18139aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
18149aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
18159aae6e54SDaniel Henrique Barbozaif compile_object ; then
18169aae6e54SDaniel Henrique Barboza  : C compiler works ok
18179aae6e54SDaniel Henrique Barbozaelse
18189aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
18199aae6e54SDaniel Henrique Barbozafi
18209aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
18219aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
18229aae6e54SDaniel Henrique Barbozafi
18239aae6e54SDaniel Henrique Barboza
1824359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1825359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1826359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1827359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1828359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1829359bc95dSPeter Maydell    else
183076ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1831359bc95dSPeter Maydell    fi
1832359bc95dSPeter Maydellfi
1833359bc95dSPeter Maydell
18349c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
18359c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
18369c83ffd8SPeter Maydellif test -z "$werror" ; then
1837fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
1838e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
18399c83ffd8SPeter Maydell        werror="yes"
18409c83ffd8SPeter Maydell    else
18419c83ffd8SPeter Maydell        werror="no"
18429c83ffd8SPeter Maydell    fi
18439c83ffd8SPeter Maydellfi
18449c83ffd8SPeter Maydell
1845fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1846fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1847fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1848fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1849fb59dabdSPeter Maydell    # host OS we should stop now.
1850951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1851fb59dabdSPeter Maydellfi
1852fb59dabdSPeter Maydell
1853efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1854efc6c070SThomas Huthcat > $TMPC << EOF
1855efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1856efc6c070SThomas Huth# ifdef __apple_build_version__
1857efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1858efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
1859efc6c070SThomas Huth#  endif
1860efc6c070SThomas Huth# else
1861efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1862efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
1863efc6c070SThomas Huth#  endif
1864efc6c070SThomas Huth# endif
1865efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1866efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1867efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
1868efc6c070SThomas Huth# endif
1869efc6c070SThomas Huth#else
1870efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1871efc6c070SThomas Huth#endif
1872efc6c070SThomas Huthint main (void) { return 0; }
1873efc6c070SThomas HuthEOF
1874efc6c070SThomas Huthif ! compile_prog "" "" ; then
1875efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1876efc6c070SThomas Huthfi
1877efc6c070SThomas Huth
18788d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
18798d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1880ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1881435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1882b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
188371429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
18846ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
18856ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
18866ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
18876ca026cbSPeter Maydell# so it's too error prone.
188893b25869SJohn Snow
188993b25869SJohn Snowcc_has_warning_flag() {
189093b25869SJohn Snow    write_c_skeleton;
189193b25869SJohn Snow
1892a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1893a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1894a1d29d6cSPeter Maydell    # warning options).
189593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
189693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
189793b25869SJohn Snow}
189893b25869SJohn Snow
189993b25869SJohn Snowfor flag in $gcc_flags; do
190093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
19018d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19028d05095cSPaolo Bonzini    fi
19038d05095cSPaolo Bonzinidone
19048d05095cSPaolo Bonzini
190563678e17SSteven Noonanif test "$stack_protector" != "no"; then
1906fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1907fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1908fccd35a0SRodrigo Rebello{
1909fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1910fccd35a0SRodrigo Rebello    while (*c) {
1911fccd35a0SRodrigo Rebello        *p++ = *c++;
1912fccd35a0SRodrigo Rebello    }
1913fccd35a0SRodrigo Rebello    return 0;
1914fccd35a0SRodrigo Rebello}
1915fccd35a0SRodrigo RebelloEOF
191663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
19173b463a3fSMiroslav Rezanina  sp_on=0
191863678e17SSteven Noonan  for flag in $gcc_flags; do
1919590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1920590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1921590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1922590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
192363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19243b463a3fSMiroslav Rezanina      sp_on=1
192563678e17SSteven Noonan      break
192663678e17SSteven Noonan    fi
192763678e17SSteven Noonan  done
19283b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
19293b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
19303b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
19313b463a3fSMiroslav Rezanina    fi
19323b463a3fSMiroslav Rezanina  fi
193337746c5eSMarc-André Lureaufi
193437746c5eSMarc-André Lureau
193520bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
193620bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
193720bc94a2SPaolo Bonzinicat > $TMPC << EOF
193820bc94a2SPaolo Bonzinistruct {
193920bc94a2SPaolo Bonzini  int a[2];
194020bc94a2SPaolo Bonzini} x = {0};
194120bc94a2SPaolo BonziniEOF
194220bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
194320bc94a2SPaolo Bonzini  :
194420bc94a2SPaolo Bonzinielse
194520bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
194620bc94a2SPaolo Bonzinifi
194720bc94a2SPaolo Bonzini
1948d376e9deSThomas Huth# Static linking is not possible with modules or PIE
194940d6444eSAvi Kivityif test "$static" = "yes" ; then
1950aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1951aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1952aa0d1f44SPaolo Bonzini  fi
195340d6444eSAvi Kivity  if test "$pie" = "yes" ; then
195476ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
195540d6444eSAvi Kivity  else
195640d6444eSAvi Kivity    pie="no"
195740d6444eSAvi Kivity  fi
195840d6444eSAvi Kivityfi
195940d6444eSAvi Kivity
1960768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1961768b7855SEmilio G. Cota  cat > $TMPC << EOF
1962768b7855SEmilio G. Cotastatic __thread int tls_var;
1963768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1964768b7855SEmilio G. CotaEOF
1965768b7855SEmilio G. Cota
1966768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1967768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1968768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1969768b7855SEmilio G. Cotafi
1970768b7855SEmilio G. Cota
197140d6444eSAvi Kivityif test "$pie" = ""; then
197240d6444eSAvi Kivity  case "$cpu-$targetos" in
1973c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
197440d6444eSAvi Kivity      ;;
197540d6444eSAvi Kivity    *)
197640d6444eSAvi Kivity      pie="no"
197740d6444eSAvi Kivity      ;;
197840d6444eSAvi Kivity  esac
197940d6444eSAvi Kivityfi
198040d6444eSAvi Kivity
198140d6444eSAvi Kivityif test "$pie" != "no" ; then
198240d6444eSAvi Kivity  cat > $TMPC << EOF
198321d4a791SAvi Kivity
198421d4a791SAvi Kivity#ifdef __linux__
198521d4a791SAvi Kivity#  define THREAD __thread
198621d4a791SAvi Kivity#else
198721d4a791SAvi Kivity#  define THREAD
198821d4a791SAvi Kivity#endif
198921d4a791SAvi Kivity
199021d4a791SAvi Kivitystatic THREAD int tls_var;
199121d4a791SAvi Kivity
199221d4a791SAvi Kivityint main(void) { return tls_var; }
199321d4a791SAvi Kivity
199440d6444eSAvi KivityEOF
199540d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
199640d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
199740d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
199840d6444eSAvi Kivity    pie="yes"
199940d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
200040d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
200140d6444eSAvi Kivity    fi
200240d6444eSAvi Kivity  else
200340d6444eSAvi Kivity    if test "$pie" = "yes"; then
200476ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
200540d6444eSAvi Kivity    else
200640d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
200740d6444eSAvi Kivity      pie="no"
200840d6444eSAvi Kivity    fi
200940d6444eSAvi Kivity  fi
201046eef33bSBrad
2011e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
201246eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
201346eef33bSBrad    LDFLAGS_NOPIE="-nopie"
201446eef33bSBrad  fi
201540d6444eSAvi Kivityfi
201640d6444eSAvi Kivity
201709dada40SPaolo Bonzini##########################################
201809dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
201909dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
202009dada40SPaolo Bonzini# specification is necessary
202109dada40SPaolo Bonzini
202209dada40SPaolo Bonziniif test "$cpu" = "i386"; then
202309dada40SPaolo Bonzini  cat > $TMPC << EOF
202409dada40SPaolo Bonzinistatic int sfaa(int *ptr)
202509dada40SPaolo Bonzini{
202609dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
202709dada40SPaolo Bonzini}
202809dada40SPaolo Bonzini
202909dada40SPaolo Bonziniint main(void)
203009dada40SPaolo Bonzini{
203109dada40SPaolo Bonzini  int val = 42;
20321405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
203309dada40SPaolo Bonzini  sfaa(&val);
203409dada40SPaolo Bonzini  return val;
203509dada40SPaolo Bonzini}
203609dada40SPaolo BonziniEOF
203709dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
203809dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
203909dada40SPaolo Bonzini  fi
204009dada40SPaolo Bonzinifi
204109dada40SPaolo Bonzini
204209dada40SPaolo Bonzini#########################################
2043ec530c81Sbellard# Solaris specific configure tool chain decisions
204409dada40SPaolo Bonzini
2045ec530c81Sbellardif test "$solaris" = "yes" ; then
20466792aa11SLoïc Minier  if has $install; then
20476792aa11SLoïc Minier    :
20486792aa11SLoïc Minier  else
204976ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
205076ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
205176ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2052ec530c81Sbellard  fi
205389138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
205476ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
205576ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
205676ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2057ec530c81Sbellard  fi
20586792aa11SLoïc Minier  if has ar; then
20596792aa11SLoïc Minier    :
20606792aa11SLoïc Minier  else
2061ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
206276ad07a4SPeter Maydell      error_exit "No path includes ar" \
206376ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2064ec530c81Sbellard    fi
206576ad07a4SPeter Maydell    error_exit "No path includes ar"
2066ec530c81Sbellard  fi
2067ec530c81Sbellardfi
2068ec530c81Sbellard
2069afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2070d880a3baSPaolo Bonzini    for target in $default_target_list; do
2071d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2072d880a3baSPaolo Bonzini            target_list="$target_list $target"
2073d880a3baSPaolo Bonzini    done
2074d880a3baSPaolo Bonzini    target_list="${target_list# }"
2075121afa9eSAnthony Liguorielse
207689138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2077d880a3baSPaolo Bonzini    for target in $target_list; do
207825b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
207925b48338SPeter Maydell        # friendly error message than if we let it fall through.
208025b48338SPeter Maydell        case " $default_target_list " in
208125b48338SPeter Maydell            *" $target "*)
208225b48338SPeter Maydell                ;;
208325b48338SPeter Maydell            *)
208425b48338SPeter Maydell                error_exit "Unknown target name '$target'"
208525b48338SPeter Maydell                ;;
208625b48338SPeter Maydell        esac
2087d880a3baSPaolo Bonzini        supported_target $target || exit 1
208825b48338SPeter Maydell    done
2089d880a3baSPaolo Bonzinifi
209025b48338SPeter Maydell
2091f55fe278SPaolo Bonzini# see if system emulation was really requested
2092f55fe278SPaolo Bonzinicase " $target_list " in
2093f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2094f55fe278SPaolo Bonzini  ;;
2095f55fe278SPaolo Bonzini  *) softmmu=no
2096f55fe278SPaolo Bonzini  ;;
2097f55fe278SPaolo Bonziniesac
20985327cf48Sbellard
2099249247c9SJuan Quintelafeature_not_found() {
2100249247c9SJuan Quintela  feature=$1
210121684af0SStewart Smith  remedy=$2
2102249247c9SJuan Quintela
210376ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
210421684af0SStewart Smith      "configure was not able to find it." \
210521684af0SStewart Smith      "$remedy"
2106249247c9SJuan Quintela}
2107249247c9SJuan Quintela
21087d13299dSbellard# ---
21097d13299dSbellard# big/little endian test
21107d13299dSbellardcat > $TMPC << EOF
211161cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
211261cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
211361cc919fSMike Frysingerextern int foo(short *, short *);
211461cc919fSMike Frysingerint main(int argc, char *argv[]) {
211561cc919fSMike Frysinger    return foo(big_endian, little_endian);
21167d13299dSbellard}
21177d13299dSbellardEOF
21187d13299dSbellard
211961cc919fSMike Frysingerif compile_object ; then
212012f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
212161cc919fSMike Frysinger        bigendian="yes"
212212f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
212361cc919fSMike Frysinger        bigendian="no"
21247d13299dSbellard    else
21257d13299dSbellard        echo big/little test failed
21267d13299dSbellard    fi
21277d13299dSbellardelse
212861cc919fSMike Frysinger    echo big/little test failed
21297d13299dSbellardfi
21307d13299dSbellard
2131b0a47e79SJuan Quintela##########################################
2132a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2133a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2134a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2135a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2136a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2137a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2138a30878e7SPeter Maydell    fi
2139a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2140a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2141a30878e7SPeter Maydell    fi
2142a30878e7SPeter Maydell    gtk=no
2143a30878e7SPeter Maydell    sdl=no
2144a30878e7SPeter Maydellfi
2145a30878e7SPeter Maydell
21466b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
21476b39b063SEric Blakecat > $TMPC << EOF
21486b39b063SEric Blake#include <stdint.h>
21496b39b063SEric Blake#include <stdio.h>
21506b39b063SEric Blakeint main(int argc, char *argv[]) {
21516b39b063SEric Blake    return printf("%zu", SIZE_MAX);
21526b39b063SEric Blake}
21536b39b063SEric BlakeEOF
21546b39b063SEric Blakehave_broken_size_max=no
21556b39b063SEric Blakeif ! compile_object -Werror ; then
21566b39b063SEric Blake    have_broken_size_max=yes
21576b39b063SEric Blakefi
21586b39b063SEric Blake
2159a30878e7SPeter Maydell##########################################
2160015a33bdSGonglei# L2TPV3 probe
2161015a33bdSGonglei
2162015a33bdSGongleicat > $TMPC <<EOF
2163015a33bdSGonglei#include <sys/socket.h>
2164bff6cb72SMichael Tokarev#include <linux/ip.h>
2165015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2166015a33bdSGongleiEOF
2167015a33bdSGongleiif compile_prog "" "" ; then
2168015a33bdSGonglei  l2tpv3=yes
2169015a33bdSGongleielse
2170015a33bdSGonglei  l2tpv3=no
2171015a33bdSGongleifi
2172015a33bdSGonglei
2173299e6f19SPaolo Bonzini#########################################
2174299e6f19SPaolo Bonzini# vhost interdependencies and host support
2175299e6f19SPaolo Bonzini
2176299e6f19SPaolo Bonzini# vhost backends
2177299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2178299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2179299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2180299e6f19SPaolo Bonzinifi
2181299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2182299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2183299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2184299e6f19SPaolo Bonzinifi
2185299e6f19SPaolo Bonzini
2186299e6f19SPaolo Bonzini# vhost-kernel devices
2187299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2188299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2189299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2190299e6f19SPaolo Bonzinifi
2191299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2192299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2193299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2194299e6f19SPaolo Bonzinifi
2195299e6f19SPaolo Bonzini
2196299e6f19SPaolo Bonzini# vhost-user backends
2197299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2198299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2199299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2200299e6f19SPaolo Bonzinifi
2201299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2202299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2203299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2204299e6f19SPaolo Bonzinifi
2205299e6f19SPaolo Bonzini
2206299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2207299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2208299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2209299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2210299e6f19SPaolo Bonzinifi
2211299e6f19SPaolo Bonzini
2212015a33bdSGonglei##########################################
22134d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
22144d9310f4SDaniel P. Berrange
22154d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
22164d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
22174d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
22184d9310f4SDaniel P. Berrange    #
22194d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
22204d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
22214d9310f4SDaniel P. Berrange    #
22224d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
22234d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
22244d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
22254d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
22264d9310f4SDaniel P. Berrange    # that for you.
22274d9310f4SDaniel P. Berrange    #
22284d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
22294d9310f4SDaniel P. Berrange    # are not in fact redundant.
22304d9310f4SDaniel P. Berrangecat > $TMPC << EOF
22314d9310f4SDaniel P. Berrange#include <unistd.h>
22324d9310f4SDaniel P. Berrange#include <time.h>
22334d9310f4SDaniel P. Berrange#undef localtime_r
22344d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
22354d9310f4SDaniel P. BerrangeEOF
22364d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
22374d9310f4SDaniel P. Berrange        localtime_r="yes"
22384d9310f4SDaniel P. Berrange    else
22394d9310f4SDaniel P. Berrange        localtime_r="no"
22404d9310f4SDaniel P. Berrange    fi
22414d9310f4SDaniel P. Berrangefi
22424d9310f4SDaniel P. Berrange
22434d9310f4SDaniel P. Berrange##########################################
2244779ab5e3SStefan Weil# pkg-config probe
2245779ab5e3SStefan Weil
2246779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
224776ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2248779ab5e3SStefan Weilfi
2249779ab5e3SStefan Weil
2250779ab5e3SStefan Weil##########################################
2251b0a47e79SJuan Quintela# NPTL probe
2252b0a47e79SJuan Quintela
225324cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2254bd0c5661Spbrook  cat > $TMPC <<EOF
2255bd0c5661Spbrook#include <sched.h>
225630813ceaSpbrook#include <linux/futex.h>
2257182eacc0SStefan Weilint main(void) {
2258bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2259bd0c5661Spbrook#error bork
2260bd0c5661Spbrook#endif
2261182eacc0SStefan Weil  return 0;
2262bd0c5661Spbrook}
2263bd0c5661SpbrookEOF
226424cb36a6SPeter Maydell  if ! compile_object ; then
226521684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2266b0a47e79SJuan Quintela  fi
2267bd0c5661Spbrookfi
2268bd0c5661Spbrook
2269ac62922eSbalrog##########################################
2270607dacd0Sqiaonuohan# lzo check
2271607dacd0Sqiaonuohan
2272607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2273607dacd0Sqiaonuohan    cat > $TMPC << EOF
2274607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2275607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2276607dacd0SqiaonuohanEOF
2277607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2278607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2279b25c9dffSStefan Weil        lzo="yes"
2280b25c9dffSStefan Weil    else
2281b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2282b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2283b25c9dffSStefan Weil        fi
2284b25c9dffSStefan Weil        lzo="no"
2285b25c9dffSStefan Weil    fi
2286607dacd0Sqiaonuohanfi
2287607dacd0Sqiaonuohan
2288607dacd0Sqiaonuohan##########################################
2289607dacd0Sqiaonuohan# snappy check
2290607dacd0Sqiaonuohan
2291607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2292607dacd0Sqiaonuohan    cat > $TMPC << EOF
2293607dacd0Sqiaonuohan#include <snappy-c.h>
2294607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2295607dacd0SqiaonuohanEOF
2296607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2297607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2298b25c9dffSStefan Weil        snappy="yes"
2299b25c9dffSStefan Weil    else
2300b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2301b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2302b25c9dffSStefan Weil        fi
2303b25c9dffSStefan Weil        snappy="no"
2304b25c9dffSStefan Weil    fi
2305607dacd0Sqiaonuohanfi
2306607dacd0Sqiaonuohan
2307607dacd0Sqiaonuohan##########################################
23086b383c08SPeter Wu# bzip2 check
23096b383c08SPeter Wu
23106b383c08SPeter Wuif test "$bzip2" != "no" ; then
23116b383c08SPeter Wu    cat > $TMPC << EOF
23126b383c08SPeter Wu#include <bzlib.h>
23136b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
23146b383c08SPeter WuEOF
23156b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
23166b383c08SPeter Wu        bzip2="yes"
23176b383c08SPeter Wu    else
23186b383c08SPeter Wu        if test "$bzip2" = "yes"; then
23196b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
23206b383c08SPeter Wu        fi
23216b383c08SPeter Wu        bzip2="no"
23226b383c08SPeter Wu    fi
23236b383c08SPeter Wufi
23246b383c08SPeter Wu
23256b383c08SPeter Wu##########################################
232683bc1f97SJulio Faracco# lzfse check
232783bc1f97SJulio Faracco
232883bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
232983bc1f97SJulio Faracco    cat > $TMPC << EOF
233083bc1f97SJulio Faracco#include <lzfse.h>
233183bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
233283bc1f97SJulio FaraccoEOF
233383bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
233483bc1f97SJulio Faracco        lzfse="yes"
233583bc1f97SJulio Faracco    else
233683bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
233783bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
233883bc1f97SJulio Faracco        fi
233983bc1f97SJulio Faracco        lzfse="no"
234083bc1f97SJulio Faracco    fi
234183bc1f97SJulio Faraccofi
234283bc1f97SJulio Faracco
234383bc1f97SJulio Faracco##########################################
2344f794573eSEduardo Otubo# libseccomp check
2345f794573eSEduardo Otubo
2346d0699bd3SMarc-André Lureaulibseccomp_minver="2.2.0"
2347f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2348693e5910SAndrew Jones    case "$cpu" in
2349d0699bd3SMarc-André Lureau    i386|x86_64|mips)
23505ce43972SJames Hogan        ;;
2351693e5910SAndrew Jones    arm|aarch64)
2352693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2353693e5910SAndrew Jones        ;;
23543aa35fcfSThomas Huth    ppc|ppc64|s390x)
23553e684455SMichael Strosaker        libseccomp_minver="2.3.0"
23563e684455SMichael Strosaker        ;;
2357693e5910SAndrew Jones    *)
2358693e5910SAndrew Jones        libseccomp_minver=""
2359693e5910SAndrew Jones        ;;
2360693e5910SAndrew Jones    esac
2361693e5910SAndrew Jones
2362693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2363693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2364c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2365c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2366f794573eSEduardo Otubo        seccomp="yes"
2367f794573eSEduardo Otubo    else
2368f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2369693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2370693e5910SAndrew Jones                feature_not_found "libseccomp" \
2371693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2372693e5910SAndrew Jones            else
2373693e5910SAndrew Jones                feature_not_found "libseccomp" \
2374693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2375693e5910SAndrew Jones            fi
2376896848f0SEduardo Otubo        fi
2377e84d5956SYann E. MORIN        seccomp="no"
2378f794573eSEduardo Otubo    fi
2379f794573eSEduardo Otubofi
2380f794573eSEduardo Otubo##########################################
2381e37630caSaliguori# xen probe
2382e37630caSaliguori
2383fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2384c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2385c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2386c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2387c1cdd9d5SJuergen Gross
2388c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2389c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2390c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2391c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2392c1cdd9d5SJuergen Gross    xen=yes
2393c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2394c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
239558ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
239658ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
239758ea9a7aSAnthony PERARD    fi
2398c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2399c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2400c1cdd9d5SJuergen Gross  else
2401c1cdd9d5SJuergen Gross
2402b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2403d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2404d5b93ddfSAnthony PERARD
240550ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
240650ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
240750ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
240850ced5b3SStefan Weil
240950ced5b3SStefan Weil    # Xen (any)
241050ced5b3SStefan Weil    cat > $TMPC <<EOF
241150ced5b3SStefan Weil#include <xenctrl.h>
241250ced5b3SStefan Weilint main(void) {
241350ced5b3SStefan Weil  return 0;
241450ced5b3SStefan Weil}
241550ced5b3SStefan WeilEOF
241650ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
241750ced5b3SStefan Weil      # Xen not found
241850ced5b3SStefan Weil      if test "$xen" = "yes" ; then
241921684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
242050ced5b3SStefan Weil      fi
242150ced5b3SStefan Weil      xen=no
242250ced5b3SStefan Weil
2423d5b93ddfSAnthony PERARD    # Xen unstable
242469deef08SPeter Maydell    elif
242569deef08SPeter Maydell        cat > $TMPC <<EOF &&
24262cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
24272cbf8903SRoss Lagerwall#define __XEN_TOOLS__
24282cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2429d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
24302cbf8903SRoss Lagerwallint main(void) {
24312cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2432d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
24332cbf8903SRoss Lagerwall
24342cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
24352cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
24362cbf8903SRoss Lagerwall
2437d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2438d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2439d3c49ebbSPaul Durrant
24402cbf8903SRoss Lagerwall  return 0;
24412cbf8903SRoss Lagerwall}
24422cbf8903SRoss LagerwallEOF
24432cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24442cbf8903SRoss Lagerwall      then
24452cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24462cbf8903SRoss Lagerwall      xen_ctrl_version=41100
24472cbf8903SRoss Lagerwall      xen=yes
24482cbf8903SRoss Lagerwall    elif
24492cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
24505ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
24515ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
245258ea9a7aSAnthony PERARD#include <xentoolcore.h>
24535ba3d756SIgor Druzhininint main(void) {
24545ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
24555ba3d756SIgor Druzhinin
24565ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
24575ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
245858ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
24595ba3d756SIgor Druzhinin
24605ba3d756SIgor Druzhinin  return 0;
24615ba3d756SIgor Druzhinin}
24625ba3d756SIgor DruzhininEOF
246358ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24645ba3d756SIgor Druzhinin      then
246558ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24665ba3d756SIgor Druzhinin      xen_ctrl_version=41000
24675ba3d756SIgor Druzhinin      xen=yes
24685ba3d756SIgor Druzhinin    elif
24695ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2470da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2471da8090ccSPaul Durrant#define __XEN_TOOLS__
2472da8090ccSPaul Durrant#include <xendevicemodel.h>
2473da8090ccSPaul Durrantint main(void) {
2474da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2475da8090ccSPaul Durrant
2476da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2477da8090ccSPaul Durrant  xendevicemodel_close(xd);
2478da8090ccSPaul Durrant
2479da8090ccSPaul Durrant  return 0;
2480da8090ccSPaul Durrant}
2481da8090ccSPaul DurrantEOF
2482da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2483da8090ccSPaul Durrant      then
2484da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2485f1167ee6SJuergen Gross      xen_ctrl_version=40900
2486da8090ccSPaul Durrant      xen=yes
2487da8090ccSPaul Durrant    elif
2488da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
24895eeb39c2SIan Campbell/*
24905eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
24915eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2492b6eb9b45SPaulina Szubarczyk *
2493b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2494b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2495b6eb9b45SPaulina Szubarczyk */
2496b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2497b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2498b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2499b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2500b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2501b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2502b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2503b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2504b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2505b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2506b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2507b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2508b6eb9b45SPaulina Szubarczyk#endif
2509b6eb9b45SPaulina Szubarczykint main(void) {
2510b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2511b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2512b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2513b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2514b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2515b6eb9b45SPaulina Szubarczyk
2516b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2517b6eb9b45SPaulina Szubarczyk
2518b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2519b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2520b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2521b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2522b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2523b6eb9b45SPaulina Szubarczyk
2524b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2525b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2526b6eb9b45SPaulina Szubarczyk
2527b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2528b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2529b6eb9b45SPaulina Szubarczyk
2530b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2531b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2532b6eb9b45SPaulina Szubarczyk
2533b6eb9b45SPaulina Szubarczyk  return 0;
2534b6eb9b45SPaulina Szubarczyk}
2535b6eb9b45SPaulina SzubarczykEOF
2536b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2537b6eb9b45SPaulina Szubarczyk      then
2538f1167ee6SJuergen Gross      xen_ctrl_version=40800
2539b6eb9b45SPaulina Szubarczyk      xen=yes
2540b6eb9b45SPaulina Szubarczyk    elif
2541b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2542b6eb9b45SPaulina Szubarczyk/*
2543b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2544b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
25455eeb39c2SIan Campbell */
25465eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
25475eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
25485eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25495eeb39c2SIan Campbell#include <xenctrl.h>
25505eeb39c2SIan Campbell#include <xenstore.h>
25515eeb39c2SIan Campbell#include <xenevtchn.h>
25525eeb39c2SIan Campbell#include <xengnttab.h>
25535eeb39c2SIan Campbell#include <xenforeignmemory.h>
25545eeb39c2SIan Campbell#include <stdint.h>
25555eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
25565eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
25575eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
25585eeb39c2SIan Campbell#endif
25595eeb39c2SIan Campbellint main(void) {
25605eeb39c2SIan Campbell  xc_interface *xc = NULL;
25615eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
25625eeb39c2SIan Campbell  xenevtchn_handle *xe;
25635eeb39c2SIan Campbell  xengnttab_handle *xg;
25645eeb39c2SIan Campbell
25655eeb39c2SIan Campbell  xs_daemon_open();
25665eeb39c2SIan Campbell
25675eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
25685eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
25695eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25705eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25715eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
25725eeb39c2SIan Campbell
25735eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
25745eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
25755eeb39c2SIan Campbell
25765eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
25775eeb39c2SIan Campbell  xenevtchn_fd(xe);
25785eeb39c2SIan Campbell
25795eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
25805eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
25815eeb39c2SIan Campbell
25825eeb39c2SIan Campbell  return 0;
25835eeb39c2SIan Campbell}
25845eeb39c2SIan CampbellEOF
25855eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
25865eeb39c2SIan Campbell      then
2587f1167ee6SJuergen Gross      xen_ctrl_version=40701
25885eeb39c2SIan Campbell      xen=yes
2589cdadde39SRoger Pau Monne
2590cdadde39SRoger Pau Monne    # Xen 4.6
2591cdadde39SRoger Pau Monne    elif
2592cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2593cdadde39SRoger Pau Monne#include <xenctrl.h>
2594e108a3c1SAnthony PERARD#include <xenstore.h>
2595d5b93ddfSAnthony PERARD#include <stdint.h>
2596d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2597d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2598d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2599d5b93ddfSAnthony PERARD#endif
2600d5b93ddfSAnthony PERARDint main(void) {
2601d5b93ddfSAnthony PERARD  xc_interface *xc;
2602d5b93ddfSAnthony PERARD  xs_daemon_open();
2603d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2604d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2605d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2606b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26078688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2608d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
260920a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2610d8b441a3SJan Beulich  return 0;
2611d8b441a3SJan Beulich}
2612d8b441a3SJan BeulichEOF
2613d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2614d8b441a3SJan Beulich      then
2615f1167ee6SJuergen Gross      xen_ctrl_version=40600
2616d8b441a3SJan Beulich      xen=yes
2617d8b441a3SJan Beulich
2618d8b441a3SJan Beulich    # Xen 4.5
2619d8b441a3SJan Beulich    elif
2620d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2621d8b441a3SJan Beulich#include <xenctrl.h>
2622d8b441a3SJan Beulich#include <xenstore.h>
2623d8b441a3SJan Beulich#include <stdint.h>
2624d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2625d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2626d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2627d8b441a3SJan Beulich#endif
2628d8b441a3SJan Beulichint main(void) {
2629d8b441a3SJan Beulich  xc_interface *xc;
2630d8b441a3SJan Beulich  xs_daemon_open();
2631d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2632d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2633d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2634d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2635d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26363996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
26373996e85cSPaul Durrant  return 0;
26383996e85cSPaul Durrant}
26393996e85cSPaul DurrantEOF
26403996e85cSPaul Durrant        compile_prog "" "$xen_libs"
26413996e85cSPaul Durrant      then
2642f1167ee6SJuergen Gross      xen_ctrl_version=40500
26433996e85cSPaul Durrant      xen=yes
26443996e85cSPaul Durrant
26453996e85cSPaul Durrant    elif
26463996e85cSPaul Durrant        cat > $TMPC <<EOF &&
26473996e85cSPaul Durrant#include <xenctrl.h>
26483996e85cSPaul Durrant#include <xenstore.h>
26493996e85cSPaul Durrant#include <stdint.h>
26503996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
26513996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
26523996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
26533996e85cSPaul Durrant#endif
26543996e85cSPaul Durrantint main(void) {
26553996e85cSPaul Durrant  xc_interface *xc;
26563996e85cSPaul Durrant  xs_daemon_open();
26573996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
26583996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26593996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
26603996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26613996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26628688e065SStefano Stabellini  return 0;
26638688e065SStefano Stabellini}
26648688e065SStefano StabelliniEOF
26658688e065SStefano Stabellini        compile_prog "" "$xen_libs"
266669deef08SPeter Maydell      then
2667f1167ee6SJuergen Gross      xen_ctrl_version=40200
26688688e065SStefano Stabellini      xen=yes
26698688e065SStefano Stabellini
2670e37630caSaliguori    else
2671fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2672edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2673edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2674fc321b4bSJuan Quintela      fi
2675fc321b4bSJuan Quintela      xen=no
2676e37630caSaliguori    fi
2677d5b93ddfSAnthony PERARD
2678d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2679f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
26805eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
26815eeb39c2SIan Campbell      fi
2682d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2683d5b93ddfSAnthony PERARD    fi
2684e37630caSaliguori  fi
2685c1cdd9d5SJuergen Grossfi
2686e37630caSaliguori
2687eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2688edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2689eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2690eb6fda0fSAnthony PERARD  else
2691eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
269276ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
269376ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2694eb6fda0fSAnthony PERARD    fi
2695eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2696eb6fda0fSAnthony PERARD  fi
2697eb6fda0fSAnthony PERARDfi
2698eb6fda0fSAnthony PERARD
2699e37630caSaliguori##########################################
2700d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2701d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2702327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2703d661d9a4SJustin Terry (VM)        whpx="yes"
2704d661d9a4SJustin Terry (VM)    else
2705d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
270653537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2707d661d9a4SJustin Terry (VM)        fi
2708d661d9a4SJustin Terry (VM)        whpx="no"
2709d661d9a4SJustin Terry (VM)    fi
2710d661d9a4SJustin Terry (VM)fi
2711d661d9a4SJustin Terry (VM)
2712d661d9a4SJustin Terry (VM)##########################################
2713dfffc653SJuan Quintela# Sparse probe
2714dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
27150dba6195SLoïc Minier  if has cgcc; then
2716dfffc653SJuan Quintela    sparse=yes
2717dfffc653SJuan Quintela  else
2718dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
271921684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2720dfffc653SJuan Quintela    fi
2721dfffc653SJuan Quintela    sparse=no
2722dfffc653SJuan Quintela  fi
2723dfffc653SJuan Quintelafi
2724dfffc653SJuan Quintela
2725dfffc653SJuan Quintela##########################################
2726f676c67eSJeremy White# X11 probe
2727f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
27288781595bSGerd Hoffmann    have_x11=yes
272989138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
273089138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2731f676c67eSJeremy Whitefi
2732f676c67eSJeremy White
2733f676c67eSJeremy White##########################################
2734a4ccabcfSAnthony Liguori# GTK probe
2735a4ccabcfSAnthony Liguori
27365a464e6cSPeter Xuif test "$gtk" != "no"; then
273789d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
273889d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
273958296cb6SDaniel P. Berrangé    gtkversion="3.14.0"
2740bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
274189138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
274289138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
274389138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
27440a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
27458781595bSGerd Hoffmann            need_x11=yes
2746f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2747f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
27480a337ed0SGerd Hoffmann        fi
2749bbbf9bfbSStefan Weil        gtk="yes"
2750bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
27515fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2752bbbf9bfbSStefan Weil    else
2753bbbf9bfbSStefan Weil        gtk="no"
2754bbbf9bfbSStefan Weil    fi
2755bbbf9bfbSStefan Weilfi
2756bbbf9bfbSStefan Weil
2757ddbb0d09SDaniel P. Berrange
2758ddbb0d09SDaniel P. Berrange##########################################
2759ddbb0d09SDaniel P. Berrange# GNUTLS probe
2760ddbb0d09SDaniel P. Berrange
2761ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2762a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
276389138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
276489138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2765ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2766ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2767ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2768ddbb0d09SDaniel P. Berrange        gnutls="yes"
2769ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2770a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2771ddbb0d09SDaniel P. Berrange    else
2772ddbb0d09SDaniel P. Berrange        gnutls="no"
2773ddbb0d09SDaniel P. Berrange    fi
2774ddbb0d09SDaniel P. Berrangefi
2775ddbb0d09SDaniel P. Berrange
277691bfcdb0SDaniel P. Berrange
277791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
277891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2779a0722409SDaniel P. Berrangé# explicitly
278091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
278191bfcdb0SDaniel P. Berrangethen
2782a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
278391bfcdb0SDaniel P. Berrange    then
278491bfcdb0SDaniel P. Berrange        gcrypt="no"
278591bfcdb0SDaniel P. Berrange    fi
278691bfcdb0SDaniel P. Berrangefi
278791bfcdb0SDaniel P. Berrange
278891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
278991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2790a0722409SDaniel P. Berrangé# explicitly
279191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
279291bfcdb0SDaniel P. Berrangethen
2793a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
279491bfcdb0SDaniel P. Berrange    then
279591bfcdb0SDaniel P. Berrange        nettle="no"
279691bfcdb0SDaniel P. Berrange    fi
279791bfcdb0SDaniel P. Berrangefi
279891bfcdb0SDaniel P. Berrange
2799dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
280091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
280191bfcdb0SDaniel P. Berrange    then
280291bfcdb0SDaniel P. Berrange	return 1
280391bfcdb0SDaniel P. Berrange    fi
280491bfcdb0SDaniel P. Berrange
280591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
280691bfcdb0SDaniel P. Berrange    then
280789138857SStefan Weil	host=$(libgcrypt-config --host)
280891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
280991bfcdb0SDaniel P. Berrange	then
281091bfcdb0SDaniel P. Berrange	    return 1
281191bfcdb0SDaniel P. Berrange	fi
281291bfcdb0SDaniel P. Berrange    fi
281391bfcdb0SDaniel P. Berrange
2814dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2815dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2816dea7a64eSDaniel P. Berrangé
2817dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2818dea7a64eSDaniel P. Berrangé    then
2819dea7a64eSDaniel P. Berrangé       return 1
2820dea7a64eSDaniel P. Berrangé    fi
2821dea7a64eSDaniel P. Berrangé
282291bfcdb0SDaniel P. Berrange    return 0
282391bfcdb0SDaniel P. Berrange}
282491bfcdb0SDaniel P. Berrange
2825a0722409SDaniel P. Berrangé
2826a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
282764dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2828a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2829a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2830a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2831a0722409SDaniel P. Berrangé        libs_softmmu="$nettle_libs $libs_softmmu"
2832a0722409SDaniel P. Berrangé        libs_tools="$nettle_libs $libs_tools"
2833a0722409SDaniel P. Berrangé        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2834a0722409SDaniel P. Berrangé        nettle="yes"
2835a0722409SDaniel P. Berrangé
2836a0722409SDaniel P. Berrangé        if test -z "$gcrypt"; then
2837a0722409SDaniel P. Berrangé           gcrypt="no"
2838a0722409SDaniel P. Berrangé        fi
2839a0722409SDaniel P. Berrangé    else
2840a0722409SDaniel P. Berrangé        if test "$nettle" = "yes"; then
284164dd2f3bSDaniel P. Berrangé            feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2842a0722409SDaniel P. Berrangé        else
2843a0722409SDaniel P. Berrangé            nettle="no"
2844a0722409SDaniel P. Berrangé        fi
2845a0722409SDaniel P. Berrangé    fi
2846a0722409SDaniel P. Berrangéfi
2847a0722409SDaniel P. Berrangé
284891bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2849dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
285089138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
285189138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
285291bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
285391bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
285491bfcdb0SDaniel P. Berrange        # turn breaks static builds...
285591bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
285691bfcdb0SDaniel P. Berrange        then
285791bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
285891bfcdb0SDaniel P. Berrange        fi
285962893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
286062893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
286162893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
286291bfcdb0SDaniel P. Berrange        gcrypt="yes"
28631f923c70SLongpeng(Mike)
28641f923c70SLongpeng(Mike)        cat > $TMPC << EOF
28651f923c70SLongpeng(Mike)#include <gcrypt.h>
28661f923c70SLongpeng(Mike)int main(void) {
28671f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
28681f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
28691f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
28701f923c70SLongpeng(Mike)  return 0;
28711f923c70SLongpeng(Mike)}
28721f923c70SLongpeng(Mike)EOF
28731f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
28741f923c70SLongpeng(Mike)            gcrypt_hmac=yes
28751f923c70SLongpeng(Mike)        fi
287662893b67SDaniel P. Berrange    else
287791bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
2878dea7a64eSDaniel P. Berrangé            feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
287991bfcdb0SDaniel P. Berrange        else
288091bfcdb0SDaniel P. Berrange            gcrypt="no"
288191bfcdb0SDaniel P. Berrange        fi
288262893b67SDaniel P. Berrange    fi
288362893b67SDaniel P. Berrangefi
288462893b67SDaniel P. Berrange
2885ddbb0d09SDaniel P. Berrange
288691bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
288791bfcdb0SDaniel P. Berrangethen
288891bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
288991bfcdb0SDaniel P. Berrangefi
2890ed754746SDaniel P. Berrange
28919a2fd434SDaniel P. Berrange##########################################
28929a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
28939a2fd434SDaniel P. Berrange
28949a2fd434SDaniel P. Berrangetasn1=yes
289590246037SDaniel P. Berrangetasn1_cflags=""
289690246037SDaniel P. Berrangetasn1_libs=""
28979a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
289889138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
289989138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
29009a2fd434SDaniel P. Berrangeelse
29019a2fd434SDaniel P. Berrange    tasn1=no
29029a2fd434SDaniel P. Berrangefi
29039a2fd434SDaniel P. Berrange
2904ed754746SDaniel P. Berrange
2905bbbf9bfbSStefan Weil##########################################
29068953caf3SDaniel P. Berrange# PAM probe
29078953caf3SDaniel P. Berrange
29088953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
29098953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
29108953caf3SDaniel P. Berrange#include <security/pam_appl.h>
29118953caf3SDaniel P. Berrange#include <stdio.h>
29128953caf3SDaniel P. Berrangeint main(void) {
29138953caf3SDaniel P. Berrange   const char *service_name = "qemu";
29148953caf3SDaniel P. Berrange   const char *user = "frank";
29158953caf3SDaniel P. Berrange   const struct pam_conv *pam_conv = NULL;
29168953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
29178953caf3SDaniel P. Berrange   pam_start(service_name, user, pam_conv, &pamh);
29188953caf3SDaniel P. Berrange   return 0;
29198953caf3SDaniel P. Berrange}
29208953caf3SDaniel P. BerrangeEOF
29218953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
29228953caf3SDaniel P. Berrange        auth_pam=yes
29238953caf3SDaniel P. Berrange    else
29248953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
29258953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
29268953caf3SDaniel P. Berrange        else
29278953caf3SDaniel P. Berrange            auth_pam=no
29288953caf3SDaniel P. Berrange        fi
29298953caf3SDaniel P. Berrange    fi
29308953caf3SDaniel P. Berrangefi
29318953caf3SDaniel P. Berrange
29328953caf3SDaniel P. Berrange##########################################
2933559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2934559607eaSDaniel P. Berrange
2935559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2936559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2937559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2938559607eaSDaniel P. Berrangefi
2939559607eaSDaniel P. Berrange
2940559607eaSDaniel P. Berrange##########################################
2941bbbf9bfbSStefan Weil# VTE probe
2942bbbf9bfbSStefan Weil
2943bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2944c6feff9eSCole Robinson    vteminversion="0.32.0"
2945c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
2946c6feff9eSCole Robinson      vtepackage="vte-2.91"
2947c6feff9eSCole Robinson    else
2948528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
2949c6feff9eSCole Robinson    fi
2950c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
295189138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
295289138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
295389138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2954bbbf9bfbSStefan Weil        vte="yes"
2955bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
2956c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
29579e04c683SStefan Weil    else
2958bbbf9bfbSStefan Weil        vte="no"
2959a4ccabcfSAnthony Liguori    fi
2960a4ccabcfSAnthony Liguorifi
2961a4ccabcfSAnthony Liguori
2962a4ccabcfSAnthony Liguori##########################################
296311d9f695Sbellard# SDL probe
296411d9f695Sbellard
29653ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
29663ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
296747c03744SDave Airlie
2968c6093a05SPeter Xusdl_probe ()
2969c6093a05SPeter Xu{
29700015ca5cSDaniel P. Berrangé  if $pkg_config sdl2 --exists; then
29710015ca5cSDaniel P. Berrangé    sdlconfig="$pkg_config sdl2"
297289138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
29733ec87ffeSPaolo Bonzini  elif has ${sdl_config}; then
29740015ca5cSDaniel P. Berrangé    sdlconfig="$sdl2_config"
297589138857SStefan Weil    sdlversion=$($sdlconfig --version)
2976a0dfd8a4SLoïc Minier  else
2977a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
29788f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
2979a0dfd8a4SLoïc Minier    fi
2980a0dfd8a4SLoïc Minier    sdl=no
2981c6093a05SPeter Xu    # no need to do the rest
2982c6093a05SPeter Xu    return
29839316f803SPaolo Bonzini  fi
298429e5badaSScott Wood  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
29853ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
29863ec87ffeSPaolo Bonzini  fi
298711d9f695Sbellard
298811d9f695Sbellard  cat > $TMPC << EOF
298911d9f695Sbellard#include <SDL.h>
299011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
299111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
299211d9f695SbellardEOF
299389138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
29942ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
299574f42e18STeLeMan  if test "$static" = "yes" ; then
29960015ca5cSDaniel P. Berrangé    if $pkg_config sdl2 --exists; then
29970015ca5cSDaniel P. Berrangé      sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
29985f37e6d4SThomas Huth    else
299989138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
30005f37e6d4SThomas Huth    fi
300174f42e18STeLeMan  else
300289138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
300374f42e18STeLeMan  fi
300452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
300511d9f695Sbellard    sdl=yes
30067c1f25b4Sbellard
300767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3008e633a5c6SEric Blake    if test "$sdl" = "yes" && test "$static" = "yes" ; then
300967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
301089138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
301189138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
301211d9f695Sbellard      fi
301352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
30141ac88f28SJuan Quintela	:
30151ac88f28SJuan Quintela      else
30161ac88f28SJuan Quintela        sdl=no
30177c1f25b4Sbellard      fi
30187c1f25b4Sbellard    fi # static link
3019c4198157SJuan Quintela  else # sdl not found
3020c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
30210015ca5cSDaniel P. Berrangé      feature_not_found "sdl" "Install SDL2 devel"
3022c4198157SJuan Quintela    fi
3023c4198157SJuan Quintela    sdl=no
30247c1f25b4Sbellard  fi # sdl compile test
3025c6093a05SPeter Xu}
3026c6093a05SPeter Xu
3027a442fe2fSDaniel P. Berrangésdl_image_probe ()
3028a442fe2fSDaniel P. Berrangé{
3029a442fe2fSDaniel P. Berrangé    if test "$sdl_image" != "no" ; then
3030a442fe2fSDaniel P. Berrangé        if $pkg_config SDL2_image --exists; then
3031a442fe2fSDaniel P. Berrangé            if test "$static" = "yes"; then
3032a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3033a442fe2fSDaniel P. Berrangé            else
3034a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3035a442fe2fSDaniel P. Berrangé            fi
3036a442fe2fSDaniel P. Berrangé            sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3037a442fe2fSDaniel P. Berrangé            sdl_image=yes
3038a442fe2fSDaniel P. Berrangé
3039a442fe2fSDaniel P. Berrangé            sdl_cflags="$sdl_cflags $sdl_image_cflags"
3040a442fe2fSDaniel P. Berrangé            sdl_libs="$sdl_libs $sdl_image_libs"
3041a442fe2fSDaniel P. Berrangé        else
3042a442fe2fSDaniel P. Berrangé            if test "$sdl_image" = "yes" ; then
3043a442fe2fSDaniel P. Berrangé                feature_not_found "sdl_image" "Install SDL Image devel"
3044a442fe2fSDaniel P. Berrangé            else
3045a442fe2fSDaniel P. Berrangé                sdl_image=no
3046a442fe2fSDaniel P. Berrangé            fi
3047a442fe2fSDaniel P. Berrangé        fi
3048a442fe2fSDaniel P. Berrangé    fi
3049a442fe2fSDaniel P. Berrangé}
3050a442fe2fSDaniel P. Berrangé
3051c6093a05SPeter Xuif test "$sdl" != "no" ; then
3052c6093a05SPeter Xu  sdl_probe
3053fd677642Sthsfi
305411d9f695Sbellard
30555368a422Saliguoriif test "$sdl" = "yes" ; then
3056a442fe2fSDaniel P. Berrangé  sdl_image_probe
3057a442fe2fSDaniel P. Berrangéelse
3058a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes"; then
3059a442fe2fSDaniel P. Berrangé    echo "warning: SDL Image requested, but SDL is not available, disabling"
3060a442fe2fSDaniel P. Berrangé  fi
3061a442fe2fSDaniel P. Berrangé  sdl_image=no
3062a442fe2fSDaniel P. Berrangéfi
3063a442fe2fSDaniel P. Berrangé
3064a442fe2fSDaniel P. Berrangéif test "$sdl" = "yes" ; then
30655368a422Saliguori  cat > $TMPC <<EOF
30665368a422Saliguori#include <SDL.h>
30675368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
30685368a422Saliguori#include <X11/XKBlib.h>
30695368a422Saliguori#else
30705368a422Saliguori#error No x11 support
30715368a422Saliguori#endif
30725368a422Saliguoriint main(void) { return 0; }
30735368a422SaliguoriEOF
3074f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
30758781595bSGerd Hoffmann    need_x11=yes
3076f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3077f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
30785368a422Saliguori  fi
30795368a422Saliguorifi
30805368a422Saliguori
30818f28f3fbSths##########################################
30822da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
30832da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
30842da776dbSMichael R. Hines  cat > $TMPC <<EOF
30852da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
30862da776dbSMichael R. Hinesint main(void) { return 0; }
30872da776dbSMichael R. HinesEOF
3088ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
30892da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
30902da776dbSMichael R. Hines    rdma="yes"
3091ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
30922da776dbSMichael R. Hines  else
30932da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
30942da776dbSMichael R. Hines        error_exit \
3095ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
30962da776dbSMichael R. Hines            " Your options:" \
3097ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
30982da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
30992da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
31002da776dbSMichael R. Hines    fi
31012da776dbSMichael R. Hines    rdma="no"
31022da776dbSMichael R. Hines  fi
31032da776dbSMichael R. Hinesfi
31042da776dbSMichael R. Hines
310521ab34c9SMarcel Apfelbaum##########################################
310621ab34c9SMarcel Apfelbaum# PVRDMA detection
310721ab34c9SMarcel Apfelbaum
310821ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
310921ab34c9SMarcel Apfelbaum#include <sys/mman.h>
311021ab34c9SMarcel Apfelbaum
311121ab34c9SMarcel Apfelbaumint
311221ab34c9SMarcel Apfelbaummain(void)
311321ab34c9SMarcel Apfelbaum{
311421ab34c9SMarcel Apfelbaum    char buf = 0;
311521ab34c9SMarcel Apfelbaum    void *addr = &buf;
311621ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
311721ab34c9SMarcel Apfelbaum
311821ab34c9SMarcel Apfelbaum    return 0;
311921ab34c9SMarcel Apfelbaum}
312021ab34c9SMarcel ApfelbaumEOF
312121ab34c9SMarcel Apfelbaum
312221ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
312321ab34c9SMarcel Apfelbaum    case "$pvrdma" in
312421ab34c9SMarcel Apfelbaum    "")
312521ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
312621ab34c9SMarcel Apfelbaum            pvrdma="yes"
312721ab34c9SMarcel Apfelbaum        else
312821ab34c9SMarcel Apfelbaum            pvrdma="no"
312921ab34c9SMarcel Apfelbaum        fi
313021ab34c9SMarcel Apfelbaum        ;;
313121ab34c9SMarcel Apfelbaum    "yes")
313221ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
313321ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
313421ab34c9SMarcel Apfelbaum        fi
313521ab34c9SMarcel Apfelbaum        pvrdma="yes"
313621ab34c9SMarcel Apfelbaum        ;;
313721ab34c9SMarcel Apfelbaum    "no")
313821ab34c9SMarcel Apfelbaum        pvrdma="no"
313921ab34c9SMarcel Apfelbaum        ;;
314021ab34c9SMarcel Apfelbaum    esac
314121ab34c9SMarcel Apfelbaumelse
314221ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
314321ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
314421ab34c9SMarcel Apfelbaum    fi
314521ab34c9SMarcel Apfelbaum    pvrdma="no"
314621ab34c9SMarcel Apfelbaumfi
314795c6bff3SBenoît Canet
314895c6bff3SBenoît Canet##########################################
31492f9606b3Saliguori# VNC SASL detection
3150e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
31512f9606b3Saliguori  cat > $TMPC <<EOF
31522f9606b3Saliguori#include <sasl/sasl.h>
31532f9606b3Saliguori#include <stdio.h>
31542f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
31552f9606b3SaliguoriEOF
31562f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
31572f9606b3Saliguori  vnc_sasl_cflags=""
31582f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
315952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3160ea784e3bSJuan Quintela    vnc_sasl=yes
3161fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3162ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
31632f9606b3Saliguori  else
3164ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
316521684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3166ea784e3bSJuan Quintela    fi
3167ea784e3bSJuan Quintela    vnc_sasl=no
31682f9606b3Saliguori  fi
31692f9606b3Saliguorifi
31702f9606b3Saliguori
31712f9606b3Saliguori##########################################
31722f6f5c7aSCorentin Chary# VNC JPEG detection
3173e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
31742f6f5c7aSCorentin Charycat > $TMPC <<EOF
31752f6f5c7aSCorentin Chary#include <stdio.h>
31762f6f5c7aSCorentin Chary#include <jpeglib.h>
31772f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
31782f6f5c7aSCorentin CharyEOF
31792f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
31802f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
31812f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
31822f6f5c7aSCorentin Chary    vnc_jpeg=yes
31832f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3184ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
31852f6f5c7aSCorentin Chary  else
31862f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
318721684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
31882f6f5c7aSCorentin Chary    fi
31892f6f5c7aSCorentin Chary    vnc_jpeg=no
31902f6f5c7aSCorentin Chary  fi
31912f6f5c7aSCorentin Charyfi
31922f6f5c7aSCorentin Chary
31932f6f5c7aSCorentin Chary##########################################
3194efe556adSCorentin Chary# VNC PNG detection
3195e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3196efe556adSCorentin Charycat > $TMPC <<EOF
3197efe556adSCorentin Chary//#include <stdio.h>
3198efe556adSCorentin Chary#include <png.h>
3199832ce9c2SScott Wood#include <stddef.h>
3200efe556adSCorentin Charyint main(void) {
3201efe556adSCorentin Chary    png_structp png_ptr;
3202efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
32037edc3fedSPeter Maydell    return png_ptr != 0;
3204efe556adSCorentin Chary}
3205efe556adSCorentin CharyEOF
320665d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
320789138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
320889138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
32099af8025eSBrad  else
3210efe556adSCorentin Chary    vnc_png_cflags=""
3211efe556adSCorentin Chary    vnc_png_libs="-lpng"
32129af8025eSBrad  fi
3213efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3214efe556adSCorentin Chary    vnc_png=yes
3215efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
32169af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3217efe556adSCorentin Chary  else
3218efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
321921684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3220efe556adSCorentin Chary    fi
3221efe556adSCorentin Chary    vnc_png=no
3222efe556adSCorentin Chary  fi
3223efe556adSCorentin Charyfi
3224efe556adSCorentin Chary
3225efe556adSCorentin Chary##########################################
32266a021536SGerd Hoffmann# xkbcommon probe
32276a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
32286a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
32296a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
32306a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
32316a021536SGerd Hoffmann    xkbcommon=yes
32326a021536SGerd Hoffmann  else
32336a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
32346a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
32356a021536SGerd Hoffmann    fi
32366a021536SGerd Hoffmann    xkbcommon=no
32376a021536SGerd Hoffmann  fi
32386a021536SGerd Hoffmannfi
32396a021536SGerd Hoffmann
324076655d6dSaliguori
324176655d6dSaliguori##########################################
3242c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3243dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3244dce512deSChristoph Hellwig  cat > $TMPC << EOF
3245ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3246dce512deSChristoph Hellwig#include <xfs/xfs.h>
3247dce512deSChristoph Hellwigint main(void)
3248dce512deSChristoph Hellwig{
3249dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3250dce512deSChristoph Hellwig    return 0;
3251dce512deSChristoph Hellwig}
3252dce512deSChristoph HellwigEOF
3253dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3254dce512deSChristoph Hellwig    xfs="yes"
3255dce512deSChristoph Hellwig  else
3256dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
325721684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3258dce512deSChristoph Hellwig    fi
3259dce512deSChristoph Hellwig    xfs=no
3260dce512deSChristoph Hellwig  fi
3261dce512deSChristoph Hellwigfi
3262dce512deSChristoph Hellwig
3263dce512deSChristoph Hellwig##########################################
32648a16d273Sths# vde libraries probe
3265dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
32664baae0acSJuan Quintela  vde_libs="-lvdeplug"
32678a16d273Sths  cat > $TMPC << EOF
32688a16d273Sths#include <libvdeplug.h>
32694a7f0e06Spbrookint main(void)
32704a7f0e06Spbrook{
32714a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3272fea08e08SPeter Maydell    char s[] = "";
3273fea08e08SPeter Maydell    vde_open(s, s, &a);
32744a7f0e06Spbrook    return 0;
32754a7f0e06Spbrook}
32768a16d273SthsEOF
327752166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
32784baae0acSJuan Quintela    vde=yes
3279dfb278bdSJuan Quintela  else
3280dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
328121684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3282dfb278bdSJuan Quintela    fi
3283dfb278bdSJuan Quintela    vde=no
32848a16d273Sths  fi
32858a16d273Sthsfi
32868a16d273Sths
32878a16d273Sths##########################################
32880a985b37SVincenzo Maffione# netmap support probe
32890a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
32900a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
32910a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
32920a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
32930a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
329458952137SVincenzo Maffioneif test "$netmap" != "no" ; then
329558952137SVincenzo Maffione  cat > $TMPC << EOF
329658952137SVincenzo Maffione#include <inttypes.h>
329758952137SVincenzo Maffione#include <net/if.h>
329858952137SVincenzo Maffione#include <net/netmap.h>
329958952137SVincenzo Maffione#include <net/netmap_user.h>
33000a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
33010a985b37SVincenzo Maffione#error
33020a985b37SVincenzo Maffione#endif
330358952137SVincenzo Maffioneint main(void) { return 0; }
330458952137SVincenzo MaffioneEOF
330558952137SVincenzo Maffione  if compile_prog "" "" ; then
330658952137SVincenzo Maffione    netmap=yes
330758952137SVincenzo Maffione  else
330858952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
330958952137SVincenzo Maffione      feature_not_found "netmap"
331058952137SVincenzo Maffione    fi
331158952137SVincenzo Maffione    netmap=no
331258952137SVincenzo Maffione  fi
331358952137SVincenzo Maffionefi
331458952137SVincenzo Maffione
331558952137SVincenzo Maffione##########################################
331647e98658SCorey Bryant# libcap-ng library probe
331747e98658SCorey Bryantif test "$cap_ng" != "no" ; then
331847e98658SCorey Bryant  cap_libs="-lcap-ng"
331947e98658SCorey Bryant  cat > $TMPC << EOF
332047e98658SCorey Bryant#include <cap-ng.h>
332147e98658SCorey Bryantint main(void)
332247e98658SCorey Bryant{
332347e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
332447e98658SCorey Bryant    return 0;
332547e98658SCorey Bryant}
332647e98658SCorey BryantEOF
332747e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
332847e98658SCorey Bryant    cap_ng=yes
332947e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
333047e98658SCorey Bryant  else
333147e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
333221684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
333347e98658SCorey Bryant    fi
333447e98658SCorey Bryant    cap_ng=no
333547e98658SCorey Bryant  fi
333647e98658SCorey Bryantfi
333747e98658SCorey Bryant
333847e98658SCorey Bryant##########################################
3339c2de5c91Smalc# Sound support libraries probe
33408f28f3fbSths
334189138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3342c2de5c91Smalcfor drv in $audio_drv_list; do
3343c2de5c91Smalc    case $drv in
3344e42975a1SGerd Hoffmann    alsa | try-alsa)
3345c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3346c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3347e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3348e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3349e42975a1SGerd Hoffmann        fi
3350e42975a1SGerd Hoffmann    else
3351e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3352e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3353c80a867fSGerd Hoffmann        else
3354c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3355c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3356c80a867fSGerd Hoffmann        fi
3357e42975a1SGerd Hoffmann    fi
3358c2de5c91Smalc    ;;
3359c2de5c91Smalc
3360e42975a1SGerd Hoffmann    pa | try-pa)
3361c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3362c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
336367f86e8eSJuan Quintela        audio_pt_int="yes"
3364e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3365e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3366e42975a1SGerd Hoffmann        fi
3367e42975a1SGerd Hoffmann    else
3368e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3369e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3370c80a867fSGerd Hoffmann        else
3371c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3372c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3373c80a867fSGerd Hoffmann        fi
3374e42975a1SGerd Hoffmann    fi
3375b8e59f18Smalc    ;;
3376b8e59f18Smalc
3377373967b2SGerd Hoffmann    sdl)
3378373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3379373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3380373967b2SGerd Hoffmann    fi
3381373967b2SGerd Hoffmann    ;;
3382373967b2SGerd Hoffmann
3383e42975a1SGerd Hoffmann    try-sdl)
3384e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3385e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3386e42975a1SGerd Hoffmann    else
3387e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3388e42975a1SGerd Hoffmann    fi
3389e42975a1SGerd Hoffmann    ;;
3390e42975a1SGerd Hoffmann
3391997e690aSJuan Quintela    coreaudio)
3392b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3393997e690aSJuan Quintela    ;;
3394997e690aSJuan Quintela
3395a4bf6780SJuan Quintela    dsound)
3396b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3397d5631638Smalc      audio_win_int="yes"
3398a4bf6780SJuan Quintela    ;;
3399a4bf6780SJuan Quintela
3400a4bf6780SJuan Quintela    oss)
3401b1149911SFam Zheng      oss_libs="$oss_lib"
3402a4bf6780SJuan Quintela    ;;
3403a4bf6780SJuan Quintela
3404e4c63a6aSmalc    *)
34051c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
340676ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
340776ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3408e4c63a6aSmalc    }
3409e4c63a6aSmalc    ;;
3410c2de5c91Smalc    esac
3411c2de5c91Smalcdone
34128f28f3fbSths
34134d3b6f6eSbalrog##########################################
34142e4d9fb1Saurel32# BrlAPI probe
34152e4d9fb1Saurel32
34164ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3417eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
34182e4d9fb1Saurel32  cat > $TMPC << EOF
34192e4d9fb1Saurel32#include <brlapi.h>
3420832ce9c2SScott Wood#include <stddef.h>
34212e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
34222e4d9fb1Saurel32EOF
342352166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
34242e4d9fb1Saurel32    brlapi=yes
34254ffcedb6SJuan Quintela  else
34264ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
342721684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
34284ffcedb6SJuan Quintela    fi
34294ffcedb6SJuan Quintela    brlapi=no
3430eb82284fSJuan Quintela  fi
3431eb82284fSJuan Quintelafi
34322e4d9fb1Saurel32
34332e4d9fb1Saurel32##########################################
34344d3b6f6eSbalrog# curses probe
3435a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3436e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
34378ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
34388ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3439e095e2f3SStefan Weil  else
34407c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
34418ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3442e095e2f3SStefan Weil  fi
3443c584a6d0SJuan Quintela  curses_found=no
34444d3b6f6eSbalrog  cat > $TMPC << EOF
34458ddc5bf9SSamuel Thibault#include <locale.h>
34464d3b6f6eSbalrog#include <curses.h>
34478ddc5bf9SSamuel Thibault#include <wchar.h>
3448ef9a2524SStefan Weilint main(void) {
34498ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
34508ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3451ef9a2524SStefan Weil  resize_term(0, 0);
34528ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
34538ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
34547c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3455271f37abSKamil Rytarowski  return 0;
3456ef9a2524SStefan Weil}
34574d3b6f6eSbalrogEOF
3458ecbe251fSVadim Evard  IFS=:
34598ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3460b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3461b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
34627c703002SSamuel Thibault    IFS=:
34638ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3464ecbe251fSVadim Evard      unset IFS
34658ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3466c584a6d0SJuan Quintela        curses_found=yes
34674f78ef9aSJuan Quintela        break
34684d3b6f6eSbalrog      fi
34694f78ef9aSJuan Quintela    done
34707c703002SSamuel Thibault    if test "$curses_found" = yes ; then
34717c703002SSamuel Thibault      break
34727c703002SSamuel Thibault    fi
34738ddc5bf9SSamuel Thibault  done
3474ecbe251fSVadim Evard  unset IFS
3475c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3476c584a6d0SJuan Quintela    curses=yes
3477c584a6d0SJuan Quintela  else
3478c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
347921684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3480c584a6d0SJuan Quintela    fi
3481c584a6d0SJuan Quintela    curses=no
3482c584a6d0SJuan Quintela  fi
34834f78ef9aSJuan Quintelafi
34844d3b6f6eSbalrog
3485414f0dabSblueswir1##########################################
3486769ce76dSAlexander Graf# curl probe
3487a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
348865d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3489a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
34904e2b0658SPaolo Bonzini  else
34914e2b0658SPaolo Bonzini    curlconfig=curl-config
34924e2b0658SPaolo Bonzini  fi
3493769ce76dSAlexander Graf  cat > $TMPC << EOF
3494769ce76dSAlexander Graf#include <curl/curl.h>
34950b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3496769ce76dSAlexander GrafEOF
349789138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
349889138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3499b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3500769ce76dSAlexander Graf    curl=yes
3501788c8196SJuan Quintela  else
3502788c8196SJuan Quintela    if test "$curl" = "yes" ; then
350321684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3504788c8196SJuan Quintela    fi
3505788c8196SJuan Quintela    curl=no
3506769ce76dSAlexander Graf  fi
3507769ce76dSAlexander Graffi # test "$curl"
3508769ce76dSAlexander Graf
3509769ce76dSAlexander Graf##########################################
3510fb599c9aSbalrog# bluez support probe
3511a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3512e820e3f4Sbalrog  cat > $TMPC << EOF
3513e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3514e820e3f4Sbalrogint main(void) { return bt_error(0); }
3515e820e3f4SbalrogEOF
351689138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
351789138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
351852166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3519a20a6f46SJuan Quintela    bluez=yes
3520e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3521e820e3f4Sbalrog  else
3522a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
352321684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3524a20a6f46SJuan Quintela    fi
3525e820e3f4Sbalrog    bluez="no"
3526e820e3f4Sbalrog  fi
3527fb599c9aSbalrogfi
3528fb599c9aSbalrog
3529fb599c9aSbalrog##########################################
3530e18df141SAnthony Liguori# glib support probe
3531a52d28afSPaolo Bonzini
3532e7b3af81SDaniel P. Berrangéglib_req_ver=2.40
3533aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3534aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3535a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3536aa0d1f44SPaolo Bonzinifi
3537e26110cfSFam Zheng
35384eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
35394eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
35404eaf7202SSameeh Jubran
3541e633a5c6SEric Blakeif test "$static" = yes && test "$mingw32" = yes; then
35424eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
35434eaf7202SSameeh Jubranfi
35444eaf7202SSameeh Jubran
3545aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3546e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
354789138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
354889138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
35494a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
355014015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3551957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3552e18df141SAnthony Liguori    else
3553e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3554e26110cfSFam Zheng    fi
3555e26110cfSFam Zhengdone
3556e26110cfSFam Zheng
3557f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3558f876b765SMarc-André Lureau    gio=yes
3559f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3560f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
3561f876b765SMarc-André Lureauelse
3562f876b765SMarc-André Lureau    gio=no
3563f876b765SMarc-André Lureaufi
3564f876b765SMarc-André Lureau
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
3642e633a5c6SEric Blakeif test "$want_tools" = "no" && test "$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
3757e633a5c6SEric Blakeif test "$mingw32" != yes && test "$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##########################################
38827aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
38833b8acc11SPaolo Bonzini
38847aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
38857aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
38867aaa6a16SPaolo Bonzini    tpm=no
38873b8acc11SPaolo Bonzini  else
38887aaa6a16SPaolo Bonzini    tpm=yes
38897aaa6a16SPaolo Bonzini  fi
38907aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
38917aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
38927aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
38937aaa6a16SPaolo Bonzini  fi
38943b8acc11SPaolo Bonzinifi
38953b8acc11SPaolo Bonzini
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
4050e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
405199e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
405299e1a93bSPhilippe Mathieu-Daudé    case $target in
405399e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
405499e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
405599e1a93bSPhilippe Mathieu-Daudé      ;;
405699e1a93bSPhilippe Mathieu-Daudé    esac
405799e1a93bSPhilippe Mathieu-Daudé  done
405899e1a93bSPhilippe Mathieu-Daudéfi
405999e1a93bSPhilippe Mathieu-Daudé
4060ed279a06SKlim Kireev##########################################
4061ed279a06SKlim Kireev# libxml2 probe
4062ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4063ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4064ed279a06SKlim Kireev        libxml2="yes"
4065ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4066ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4067ed279a06SKlim Kireev    else
4068ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4069ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4070ed279a06SKlim Kireev        fi
4071ed279a06SKlim Kireev        libxml2="no"
4072ed279a06SKlim Kireev    fi
4073ed279a06SKlim Kireevfi
4074c9a12e75SChrysostomos Nanakos
4075eb100396SBharata B Rao##########################################
4076eb100396SBharata B Rao# glusterfs probe
4077eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
407865d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4079e01bee08SBharata B Rao    glusterfs="yes"
408089138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
408189138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4082d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4083d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4084d85fa9ebSJeff Cody    fi
408565d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
40860c14fb47SBharata B Rao      glusterfs_discard="yes"
40870c14fb47SBharata B Rao    fi
40887c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4089df3a429aSNiels de Vos      glusterfs_fallocate="yes"
40907c815372SBharata B Rao      glusterfs_zerofill="yes"
40917c815372SBharata B Rao    fi
4092eb100396SBharata B Rao  else
4093eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
40948efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
40958efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4096eb100396SBharata B Rao    fi
4097e01bee08SBharata B Rao    glusterfs="no"
4098eb100396SBharata B Rao  fi
4099eb100396SBharata B Raofi
4100eb100396SBharata B Rao
410139386ac7Saurel32# Check for inotify functions when we are building linux-user
41023b3f24adSaurel32# emulator.  This is done because older glibc versions don't
41033b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
41043b3f24adSaurel32# don't provide them even if kernel supports them.
41053b3f24adSaurel32#
41063b3f24adSaurel32inotify=no
41073b3f24adSaurel32cat > $TMPC << EOF
41083b3f24adSaurel32#include <sys/inotify.h>
41093b3f24adSaurel32
41103b3f24adSaurel32int
41113b3f24adSaurel32main(void)
41123b3f24adSaurel32{
41133b3f24adSaurel32	/* try to start inotify */
41148690e420Saurel32	return inotify_init();
41153b3f24adSaurel32}
41163b3f24adSaurel32EOF
411752166aa0SJuan Quintelaif compile_prog "" "" ; then
41183b3f24adSaurel32  inotify=yes
41193b3f24adSaurel32fi
41203b3f24adSaurel32
4121c05c7a73SRiku Voipioinotify1=no
4122c05c7a73SRiku Voipiocat > $TMPC << EOF
4123c05c7a73SRiku Voipio#include <sys/inotify.h>
4124c05c7a73SRiku Voipio
4125c05c7a73SRiku Voipioint
4126c05c7a73SRiku Voipiomain(void)
4127c05c7a73SRiku Voipio{
4128c05c7a73SRiku Voipio    /* try to start inotify */
4129c05c7a73SRiku Voipio    return inotify_init1(0);
4130c05c7a73SRiku Voipio}
4131c05c7a73SRiku VoipioEOF
4132c05c7a73SRiku Voipioif compile_prog "" "" ; then
4133c05c7a73SRiku Voipio  inotify1=yes
4134c05c7a73SRiku Voipiofi
4135c05c7a73SRiku Voipio
4136099d6b0fSRiku Voipio# check if pipe2 is there
4137099d6b0fSRiku Voipiopipe2=no
4138099d6b0fSRiku Voipiocat > $TMPC << EOF
4139099d6b0fSRiku Voipio#include <unistd.h>
4140099d6b0fSRiku Voipio#include <fcntl.h>
4141099d6b0fSRiku Voipio
4142099d6b0fSRiku Voipioint main(void)
4143099d6b0fSRiku Voipio{
4144099d6b0fSRiku Voipio    int pipefd[2];
41459bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4146099d6b0fSRiku Voipio}
4147099d6b0fSRiku VoipioEOF
414852166aa0SJuan Quintelaif compile_prog "" "" ; then
4149099d6b0fSRiku Voipio  pipe2=yes
4150099d6b0fSRiku Voipiofi
4151099d6b0fSRiku Voipio
415240ff6d7eSKevin Wolf# check if accept4 is there
415340ff6d7eSKevin Wolfaccept4=no
415440ff6d7eSKevin Wolfcat > $TMPC << EOF
415540ff6d7eSKevin Wolf#include <sys/socket.h>
415640ff6d7eSKevin Wolf#include <stddef.h>
415740ff6d7eSKevin Wolf
415840ff6d7eSKevin Wolfint main(void)
415940ff6d7eSKevin Wolf{
416040ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
416140ff6d7eSKevin Wolf    return 0;
416240ff6d7eSKevin Wolf}
416340ff6d7eSKevin WolfEOF
416440ff6d7eSKevin Wolfif compile_prog "" "" ; then
416540ff6d7eSKevin Wolf  accept4=yes
416640ff6d7eSKevin Wolffi
416740ff6d7eSKevin Wolf
41683ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
41693ce34dfbSvibisreenivasansplice=no
41703ce34dfbSvibisreenivasancat > $TMPC << EOF
41713ce34dfbSvibisreenivasan#include <unistd.h>
41723ce34dfbSvibisreenivasan#include <fcntl.h>
41733ce34dfbSvibisreenivasan#include <limits.h>
41743ce34dfbSvibisreenivasan
41753ce34dfbSvibisreenivasanint main(void)
41763ce34dfbSvibisreenivasan{
417766ea0f22SStefan Weil    int len, fd = 0;
41783ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
41793ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
41803ce34dfbSvibisreenivasan    return 0;
41813ce34dfbSvibisreenivasan}
41823ce34dfbSvibisreenivasanEOF
418352166aa0SJuan Quintelaif compile_prog "" "" ; then
41843ce34dfbSvibisreenivasan  splice=yes
41853ce34dfbSvibisreenivasanfi
41863ce34dfbSvibisreenivasan
4187dcc38d1cSMarcelo Tosatti##########################################
4188a99d57bbSWanlong Gao# libnuma probe
4189a99d57bbSWanlong Gao
4190a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4191a99d57bbSWanlong Gao  cat > $TMPC << EOF
4192a99d57bbSWanlong Gao#include <numa.h>
4193a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4194a99d57bbSWanlong GaoEOF
4195a99d57bbSWanlong Gao
4196a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4197a99d57bbSWanlong Gao    numa=yes
4198a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4199a99d57bbSWanlong Gao  else
4200a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4201a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4202a99d57bbSWanlong Gao    fi
4203a99d57bbSWanlong Gao    numa=no
4204a99d57bbSWanlong Gao  fi
4205a99d57bbSWanlong Gaofi
4206a99d57bbSWanlong Gao
42077b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
42087b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
42097b01cb97SAlexandre Derumier    exit 1
42107b01cb97SAlexandre Derumierfi
42117b01cb97SAlexandre Derumier
42125a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
42135a22ab71SYang Zhong# do not support it.
42145a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
42155a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
42165a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
42175a22ab71SYang Zhong    fi
42185a22ab71SYang Zhong    malloc_trim="no"
42195a22ab71SYang Zhongfi
42205a22ab71SYang Zhong
42215a22ab71SYang Zhong#######################################
42225a22ab71SYang Zhong# malloc_trim
42235a22ab71SYang Zhong
42245a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
42255a22ab71SYang Zhong    cat > $TMPC << EOF
42265a22ab71SYang Zhong#include <malloc.h>
42275a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
42285a22ab71SYang ZhongEOF
42295a22ab71SYang Zhong    if compile_prog "" "" ; then
42305a22ab71SYang Zhong        malloc_trim="yes"
42315a22ab71SYang Zhong    else
42325a22ab71SYang Zhong        malloc_trim="no"
42335a22ab71SYang Zhong    fi
42345a22ab71SYang Zhongfi
42355a22ab71SYang Zhong
4236a99d57bbSWanlong Gao##########################################
42372847b469SFam Zheng# tcmalloc probe
42382847b469SFam Zheng
42392847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
42402847b469SFam Zheng  cat > $TMPC << EOF
42412847b469SFam Zheng#include <stdlib.h>
42422847b469SFam Zhengint main(void) { malloc(1); return 0; }
42432847b469SFam ZhengEOF
42442847b469SFam Zheng
42452847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
42462847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
42472847b469SFam Zheng  else
42482847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
42492847b469SFam Zheng  fi
42502847b469SFam Zhengfi
42512847b469SFam Zheng
42522847b469SFam Zheng##########################################
42537b01cb97SAlexandre Derumier# jemalloc probe
42547b01cb97SAlexandre Derumier
42557b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
42567b01cb97SAlexandre Derumier  cat > $TMPC << EOF
42577b01cb97SAlexandre Derumier#include <stdlib.h>
42587b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
42597b01cb97SAlexandre DerumierEOF
42607b01cb97SAlexandre Derumier
42617b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
42627b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
42637b01cb97SAlexandre Derumier  else
42647b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
42657b01cb97SAlexandre Derumier  fi
42667b01cb97SAlexandre Derumierfi
42677b01cb97SAlexandre Derumier
42687b01cb97SAlexandre Derumier##########################################
4269dcc38d1cSMarcelo Tosatti# signalfd probe
4270dcc38d1cSMarcelo Tosattisignalfd="no"
4271dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4272dcc38d1cSMarcelo Tosatti#include <unistd.h>
4273dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4274dcc38d1cSMarcelo Tosatti#include <signal.h>
4275dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4276dcc38d1cSMarcelo TosattiEOF
4277dcc38d1cSMarcelo Tosatti
4278dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4279dcc38d1cSMarcelo Tosatti  signalfd=yes
4280dcc38d1cSMarcelo Tosattifi
4281dcc38d1cSMarcelo Tosatti
4282d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4283d339d766SRichard W.M. Jonesoptreset="no"
4284d339d766SRichard W.M. Jonescat > $TMPC << EOF
4285d339d766SRichard W.M. Jones#include <getopt.h>
4286d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4287d339d766SRichard W.M. JonesEOF
4288d339d766SRichard W.M. Jones
4289d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4290d339d766SRichard W.M. Jones  optreset=yes
4291d339d766SRichard W.M. Jonesfi
4292d339d766SRichard W.M. Jones
4293c2882b96SRiku Voipio# check if eventfd is supported
4294c2882b96SRiku Voipioeventfd=no
4295c2882b96SRiku Voipiocat > $TMPC << EOF
4296c2882b96SRiku Voipio#include <sys/eventfd.h>
4297c2882b96SRiku Voipio
4298c2882b96SRiku Voipioint main(void)
4299c2882b96SRiku Voipio{
430055cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4301c2882b96SRiku Voipio}
4302c2882b96SRiku VoipioEOF
4303c2882b96SRiku Voipioif compile_prog "" "" ; then
4304c2882b96SRiku Voipio  eventfd=yes
4305c2882b96SRiku Voipiofi
4306c2882b96SRiku Voipio
4307751bcc39SMarc-André Lureau# check if memfd is supported
4308751bcc39SMarc-André Lureaumemfd=no
4309751bcc39SMarc-André Lureaucat > $TMPC << EOF
431075e5b70eSPaolo Bonzini#include <sys/mman.h>
4311751bcc39SMarc-André Lureau
4312751bcc39SMarc-André Lureauint main(void)
4313751bcc39SMarc-André Lureau{
4314751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4315751bcc39SMarc-André Lureau}
4316751bcc39SMarc-André LureauEOF
4317751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4318751bcc39SMarc-André Lureau  memfd=yes
4319751bcc39SMarc-André Lureaufi
4320751bcc39SMarc-André Lureau
4321955727d2SCortland Tölva# check for usbfs
4322955727d2SCortland Tölvahave_usbfs=no
4323955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
432496566d09SThomas Petazzoni  cat > $TMPC << EOF
432596566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
432696566d09SThomas Petazzoni
432796566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
432896566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
432996566d09SThomas Petazzoni#endif
433096566d09SThomas Petazzoni
433196566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
433296566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
433396566d09SThomas Petazzoni#endif
433496566d09SThomas Petazzoni
433596566d09SThomas Petazzoniint main(void)
433696566d09SThomas Petazzoni{
433796566d09SThomas Petazzoni    return 0;
433896566d09SThomas Petazzoni}
433996566d09SThomas PetazzoniEOF
434096566d09SThomas Petazzoni  if compile_prog "" ""; then
4341955727d2SCortland Tölva    have_usbfs=yes
4342955727d2SCortland Tölva  fi
4343955727d2SCortland Tölvafi
4344751bcc39SMarc-André Lureau
4345d0927938SUlrich Hecht# check for fallocate
4346d0927938SUlrich Hechtfallocate=no
4347d0927938SUlrich Hechtcat > $TMPC << EOF
4348d0927938SUlrich Hecht#include <fcntl.h>
4349d0927938SUlrich Hecht
4350d0927938SUlrich Hechtint main(void)
4351d0927938SUlrich Hecht{
4352d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4353d0927938SUlrich Hecht    return 0;
4354d0927938SUlrich Hecht}
4355d0927938SUlrich HechtEOF
43568fb03151SPeter Maydellif compile_prog "" "" ; then
4357d0927938SUlrich Hecht  fallocate=yes
4358d0927938SUlrich Hechtfi
4359d0927938SUlrich Hecht
43603d4fa43eSKusanagi Kouichi# check for fallocate hole punching
43613d4fa43eSKusanagi Kouichifallocate_punch_hole=no
43623d4fa43eSKusanagi Kouichicat > $TMPC << EOF
43633d4fa43eSKusanagi Kouichi#include <fcntl.h>
43643d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
43653d4fa43eSKusanagi Kouichi
43663d4fa43eSKusanagi Kouichiint main(void)
43673d4fa43eSKusanagi Kouichi{
43683d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
43693d4fa43eSKusanagi Kouichi    return 0;
43703d4fa43eSKusanagi Kouichi}
43713d4fa43eSKusanagi KouichiEOF
43723d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
43733d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
43743d4fa43eSKusanagi Kouichifi
43753d4fa43eSKusanagi Kouichi
4376b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4377b953f075SDenis V. Lunevfallocate_zero_range=no
4378b953f075SDenis V. Lunevcat > $TMPC << EOF
4379b953f075SDenis V. Lunev#include <fcntl.h>
4380b953f075SDenis V. Lunev#include <linux/falloc.h>
4381b953f075SDenis V. Lunev
4382b953f075SDenis V. Lunevint main(void)
4383b953f075SDenis V. Lunev{
4384b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4385b953f075SDenis V. Lunev    return 0;
4386b953f075SDenis V. Lunev}
4387b953f075SDenis V. LunevEOF
4388b953f075SDenis V. Lunevif compile_prog "" "" ; then
4389b953f075SDenis V. Lunev  fallocate_zero_range=yes
4390b953f075SDenis V. Lunevfi
4391b953f075SDenis V. Lunev
4392ed911435SKevin Wolf# check for posix_fallocate
4393ed911435SKevin Wolfposix_fallocate=no
4394ed911435SKevin Wolfcat > $TMPC << EOF
4395ed911435SKevin Wolf#include <fcntl.h>
4396ed911435SKevin Wolf
4397ed911435SKevin Wolfint main(void)
4398ed911435SKevin Wolf{
4399ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4400ed911435SKevin Wolf    return 0;
4401ed911435SKevin Wolf}
4402ed911435SKevin WolfEOF
4403ed911435SKevin Wolfif compile_prog "" "" ; then
4404ed911435SKevin Wolf    posix_fallocate=yes
4405ed911435SKevin Wolffi
4406ed911435SKevin Wolf
4407c727f47dSPeter Maydell# check for sync_file_range
4408c727f47dSPeter Maydellsync_file_range=no
4409c727f47dSPeter Maydellcat > $TMPC << EOF
4410c727f47dSPeter Maydell#include <fcntl.h>
4411c727f47dSPeter Maydell
4412c727f47dSPeter Maydellint main(void)
4413c727f47dSPeter Maydell{
4414c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4415c727f47dSPeter Maydell    return 0;
4416c727f47dSPeter Maydell}
4417c727f47dSPeter MaydellEOF
44188fb03151SPeter Maydellif compile_prog "" "" ; then
4419c727f47dSPeter Maydell  sync_file_range=yes
4420c727f47dSPeter Maydellfi
4421c727f47dSPeter Maydell
4422dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4423dace20dcSPeter Maydellfiemap=no
4424dace20dcSPeter Maydellcat > $TMPC << EOF
4425dace20dcSPeter Maydell#include <sys/ioctl.h>
4426dace20dcSPeter Maydell#include <linux/fs.h>
4427dace20dcSPeter Maydell#include <linux/fiemap.h>
4428dace20dcSPeter Maydell
4429dace20dcSPeter Maydellint main(void)
4430dace20dcSPeter Maydell{
4431dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4432dace20dcSPeter Maydell    return 0;
4433dace20dcSPeter Maydell}
4434dace20dcSPeter MaydellEOF
44358fb03151SPeter Maydellif compile_prog "" "" ; then
4436dace20dcSPeter Maydell  fiemap=yes
4437dace20dcSPeter Maydellfi
4438dace20dcSPeter Maydell
4439d0927938SUlrich Hecht# check for dup3
4440d0927938SUlrich Hechtdup3=no
4441d0927938SUlrich Hechtcat > $TMPC << EOF
4442d0927938SUlrich Hecht#include <unistd.h>
4443d0927938SUlrich Hecht
4444d0927938SUlrich Hechtint main(void)
4445d0927938SUlrich Hecht{
4446d0927938SUlrich Hecht    dup3(0, 0, 0);
4447d0927938SUlrich Hecht    return 0;
4448d0927938SUlrich Hecht}
4449d0927938SUlrich HechtEOF
445078f5d726SJan Kiszkaif compile_prog "" "" ; then
4451d0927938SUlrich Hecht  dup3=yes
4452d0927938SUlrich Hechtfi
4453d0927938SUlrich Hecht
44544e0c6529SAlex Bligh# check for ppoll support
44554e0c6529SAlex Blighppoll=no
44564e0c6529SAlex Blighcat > $TMPC << EOF
44574e0c6529SAlex Bligh#include <poll.h>
44584e0c6529SAlex Bligh
44594e0c6529SAlex Blighint main(void)
44604e0c6529SAlex Bligh{
44614e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
44624e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
44634e0c6529SAlex Bligh    return 0;
44644e0c6529SAlex Bligh}
44654e0c6529SAlex BlighEOF
44664e0c6529SAlex Blighif compile_prog "" "" ; then
44674e0c6529SAlex Bligh  ppoll=yes
44684e0c6529SAlex Blighfi
44694e0c6529SAlex Bligh
4470cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4471cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4472cd758dd0SAlex Blighcat > $TMPC << EOF
4473cd758dd0SAlex Bligh#include <sys/prctl.h>
4474cd758dd0SAlex Bligh
4475cd758dd0SAlex Blighint main(void)
4476cd758dd0SAlex Bligh{
4477cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4478cd758dd0SAlex Bligh    return 0;
4479cd758dd0SAlex Bligh}
4480cd758dd0SAlex BlighEOF
4481cd758dd0SAlex Blighif compile_prog "" "" ; then
4482cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4483cd758dd0SAlex Blighfi
4484cd758dd0SAlex Bligh
44853b6edd16SPeter Maydell# check for epoll support
44863b6edd16SPeter Maydellepoll=no
44873b6edd16SPeter Maydellcat > $TMPC << EOF
44883b6edd16SPeter Maydell#include <sys/epoll.h>
44893b6edd16SPeter Maydell
44903b6edd16SPeter Maydellint main(void)
44913b6edd16SPeter Maydell{
44923b6edd16SPeter Maydell    epoll_create(0);
44933b6edd16SPeter Maydell    return 0;
44943b6edd16SPeter Maydell}
44953b6edd16SPeter MaydellEOF
44968fb03151SPeter Maydellif compile_prog "" "" ; then
44973b6edd16SPeter Maydell  epoll=yes
44983b6edd16SPeter Maydellfi
44993b6edd16SPeter Maydell
4500227f0214SPeter Maydell# epoll_create1 is a later addition
4501227f0214SPeter Maydell# so we must check separately for its presence
45023b6edd16SPeter Maydellepoll_create1=no
45033b6edd16SPeter Maydellcat > $TMPC << EOF
45043b6edd16SPeter Maydell#include <sys/epoll.h>
45053b6edd16SPeter Maydell
45063b6edd16SPeter Maydellint main(void)
45073b6edd16SPeter Maydell{
450819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
450919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
451019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
451119e83f6bSPeter Maydell     * the library but not declared in the header file we will
451219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
451319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
451419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
451519e83f6bSPeter Maydell     */
4516c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
45173b6edd16SPeter Maydell}
45183b6edd16SPeter MaydellEOF
45198fb03151SPeter Maydellif compile_prog "" "" ; then
45203b6edd16SPeter Maydell  epoll_create1=yes
45213b6edd16SPeter Maydellfi
45223b6edd16SPeter Maydell
4523a8fd1abaSPeter Maydell# check for sendfile support
4524a8fd1abaSPeter Maydellsendfile=no
4525a8fd1abaSPeter Maydellcat > $TMPC << EOF
4526a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4527a8fd1abaSPeter Maydell
4528a8fd1abaSPeter Maydellint main(void)
4529a8fd1abaSPeter Maydell{
4530a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4531a8fd1abaSPeter Maydell}
4532a8fd1abaSPeter MaydellEOF
4533a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4534a8fd1abaSPeter Maydell  sendfile=yes
4535a8fd1abaSPeter Maydellfi
4536a8fd1abaSPeter Maydell
453751834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
453851834341SRiku Voipiotimerfd=no
453951834341SRiku Voipiocat > $TMPC << EOF
454051834341SRiku Voipio#include <sys/timerfd.h>
454151834341SRiku Voipio
454251834341SRiku Voipioint main(void)
454351834341SRiku Voipio{
454451834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
454551834341SRiku Voipio}
454651834341SRiku VoipioEOF
454751834341SRiku Voipioif compile_prog "" "" ; then
454851834341SRiku Voipio  timerfd=yes
454951834341SRiku Voipiofi
455051834341SRiku Voipio
45519af5c906SRiku Voipio# check for setns and unshare support
45529af5c906SRiku Voipiosetns=no
45539af5c906SRiku Voipiocat > $TMPC << EOF
45549af5c906SRiku Voipio#include <sched.h>
45559af5c906SRiku Voipio
45569af5c906SRiku Voipioint main(void)
45579af5c906SRiku Voipio{
45589af5c906SRiku Voipio    int ret;
45599af5c906SRiku Voipio    ret = setns(0, 0);
45609af5c906SRiku Voipio    ret = unshare(0);
45619af5c906SRiku Voipio    return ret;
45629af5c906SRiku Voipio}
45639af5c906SRiku VoipioEOF
45649af5c906SRiku Voipioif compile_prog "" "" ; then
45659af5c906SRiku Voipio  setns=yes
45669af5c906SRiku Voipiofi
45679af5c906SRiku Voipio
456838860a03SAleksandar Markovic# clock_adjtime probe
456938860a03SAleksandar Markovicclock_adjtime=no
457038860a03SAleksandar Markoviccat > $TMPC <<EOF
457138860a03SAleksandar Markovic#include <time.h>
457238860a03SAleksandar Markovic
457338860a03SAleksandar Markovicint main(void)
457438860a03SAleksandar Markovic{
457538860a03SAleksandar Markovic    return clock_adjtime(0, 0);
457638860a03SAleksandar Markovic}
457738860a03SAleksandar MarkovicEOF
457838860a03SAleksandar Markovicclock_adjtime=no
457938860a03SAleksandar Markovicif compile_prog "" "" ; then
458038860a03SAleksandar Markovic  clock_adjtime=yes
458138860a03SAleksandar Markovicfi
458238860a03SAleksandar Markovic
45835a03cd00SAleksandar Markovic# syncfs probe
45845a03cd00SAleksandar Markovicsyncfs=no
45855a03cd00SAleksandar Markoviccat > $TMPC <<EOF
45865a03cd00SAleksandar Markovic#include <unistd.h>
45875a03cd00SAleksandar Markovic
45885a03cd00SAleksandar Markovicint main(void)
45895a03cd00SAleksandar Markovic{
45905a03cd00SAleksandar Markovic    return syncfs(0);
45915a03cd00SAleksandar Markovic}
45925a03cd00SAleksandar MarkovicEOF
45935a03cd00SAleksandar Markovicsyncfs=no
45945a03cd00SAleksandar Markovicif compile_prog "" "" ; then
45955a03cd00SAleksandar Markovic  syncfs=yes
45965a03cd00SAleksandar Markovicfi
45975a03cd00SAleksandar Markovic
45985f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
45995f71eac0SPeter Maydellhas_sphinx_build() {
46005f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
46015f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
46025f71eac0SPeter Maydell    # version requirement). This will fail if either
46035f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
46045f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
46055f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
46065f71eac0SPeter Maydell    sphinx-build -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
46075f71eac0SPeter Maydell}
46085f71eac0SPeter Maydell
4609cc8ae6deSpbrook# Check if tools are available to build documentation.
4610a25dba17SJuan Quintelaif test "$docs" != "no" ; then
46115f71eac0SPeter Maydell  if has makeinfo && has pod2man && has_sphinx_build; then
4612a25dba17SJuan Quintela    docs=yes
461383a3ab8bSJuan Quintela  else
4614a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
46155f71eac0SPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
461683a3ab8bSJuan Quintela    fi
4617a25dba17SJuan Quintela    docs=no
461883a3ab8bSJuan Quintela  fi
4619cc8ae6deSpbrookfi
4620cc8ae6deSpbrook
4621f514f41cSStefan Weil# Search for bswap_32 function
46226ae9a1f4SJuan Quintelabyteswap_h=no
46236ae9a1f4SJuan Quintelacat > $TMPC << EOF
46246ae9a1f4SJuan Quintela#include <byteswap.h>
46256ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
46266ae9a1f4SJuan QuintelaEOF
462752166aa0SJuan Quintelaif compile_prog "" "" ; then
46286ae9a1f4SJuan Quintela  byteswap_h=yes
46296ae9a1f4SJuan Quintelafi
46306ae9a1f4SJuan Quintela
463175f13596SStefan Weil# Search for bswap32 function
46326ae9a1f4SJuan Quintelabswap_h=no
46336ae9a1f4SJuan Quintelacat > $TMPC << EOF
46346ae9a1f4SJuan Quintela#include <sys/endian.h>
46356ae9a1f4SJuan Quintela#include <sys/types.h>
46366ae9a1f4SJuan Quintela#include <machine/bswap.h>
46376ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
46386ae9a1f4SJuan QuintelaEOF
463952166aa0SJuan Quintelaif compile_prog "" "" ; then
46406ae9a1f4SJuan Quintela  bswap_h=yes
46416ae9a1f4SJuan Quintelafi
46426ae9a1f4SJuan Quintela
4643da93a1fdSaliguori##########################################
4644e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4645c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4646e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
46473c33ea96SPaolo Bonzini    libiscsi="yes"
4648ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4649ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4650c589b249SRonnie Sahlberg  else
4651c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4652e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4653c589b249SRonnie Sahlberg    fi
4654c589b249SRonnie Sahlberg    libiscsi="no"
4655c589b249SRonnie Sahlberg  fi
4656c589b249SRonnie Sahlbergfi
4657c589b249SRonnie Sahlberg
4658c589b249SRonnie Sahlberg##########################################
46598bacde8dSNatanael Copa# Do we need libm
46608bacde8dSNatanael Copacat > $TMPC << EOF
46618bacde8dSNatanael Copa#include <math.h>
4662f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
46638bacde8dSNatanael CopaEOF
46648bacde8dSNatanael Copaif compile_prog "" "" ; then
46658bacde8dSNatanael Copa  :
46668bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
46678bacde8dSNatanael Copa  LIBS="-lm $LIBS"
46688bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
46698bacde8dSNatanael Copaelse
467076ad07a4SPeter Maydell  error_exit "libm check failed"
46718bacde8dSNatanael Copafi
46728bacde8dSNatanael Copa
46738bacde8dSNatanael Copa##########################################
4674da93a1fdSaliguori# Do we need librt
46758bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
46768bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
46778bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
46788bacde8dSNatanael Copa# function in addition.
4679da93a1fdSaliguoricat > $TMPC <<EOF
4680da93a1fdSaliguori#include <signal.h>
4681da93a1fdSaliguori#include <time.h>
46828bacde8dSNatanael Copaint main(void) {
46838bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
46848bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
46858bacde8dSNatanael Copa}
4686da93a1fdSaliguoriEOF
4687da93a1fdSaliguori
468852166aa0SJuan Quintelaif compile_prog "" "" ; then
468907ffa4bdSJuan Quintela  :
46908bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
469118e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
469218e588b1SRick Liu  LIBS="$LIBS -lrt"
469318e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4694da93a1fdSaliguorifi
4695da93a1fdSaliguori
4696d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
4697d99e97e6SThomas Huthcat > $TMPC << EOF
4698d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4699d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4700d99e97e6SThomas HuthEOF
4701d99e97e6SThomas Huth
4702d99e97e6SThomas Huthif ! compile_prog "" "" ; then
4703d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
47046362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
4705d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
4706d99e97e6SThomas Huth  fi
47076362a53fSJuan Quintelafi
47086362a53fSJuan Quintela
4709de5071c5SBlue Swirl##########################################
4710cd4ec0b4SGerd Hoffmann# spice probe
4711cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4712cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4713cd4ec0b4SGerd Hoffmann#include <spice.h>
4714cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4715cd4ec0b4SGerd HoffmannEOF
4716710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4717710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
47181b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
471965d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4720cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4721cd4ec0b4SGerd Hoffmann    spice="yes"
4722cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4723cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
47242e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
47252e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4726cd4ec0b4SGerd Hoffmann  else
4727cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
47288efc9363SHu Tao      feature_not_found "spice" \
47291b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4730cd4ec0b4SGerd Hoffmann    fi
4731cd4ec0b4SGerd Hoffmann    spice="no"
4732cd4ec0b4SGerd Hoffmann  fi
4733cd4ec0b4SGerd Hoffmannfi
4734cd4ec0b4SGerd Hoffmann
47357b02f544SMarc-André Lureau# check for smartcard support
47367b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
47370f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
47387b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
47397b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
47407b02f544SMarc-André Lureau        smartcard="yes"
4741111a38b0SRobert Relyea    else
47427b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
47437b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4744111a38b0SRobert Relyea        fi
47457b02f544SMarc-André Lureau        smartcard="no"
4746111a38b0SRobert Relyea    fi
4747111a38b0SRobert Relyeafi
4748111a38b0SRobert Relyea
47492b2325ffSGerd Hoffmann# check for libusb
47502b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
475165d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
47522b2325ffSGerd Hoffmann        libusb="yes"
4753ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4754ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
47552b2325ffSGerd Hoffmann    else
47562b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
47578efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
47582b2325ffSGerd Hoffmann        fi
47592b2325ffSGerd Hoffmann        libusb="no"
47602b2325ffSGerd Hoffmann    fi
47612b2325ffSGerd Hoffmannfi
47622b2325ffSGerd Hoffmann
476369354a83SHans de Goede# check for usbredirparser for usb network redirection support
476469354a83SHans de Goedeif test "$usb_redir" != "no" ; then
476565d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
476669354a83SHans de Goede        usb_redir="yes"
4767ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4768ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
476969354a83SHans de Goede    else
477069354a83SHans de Goede        if test "$usb_redir" = "yes"; then
477121684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
477269354a83SHans de Goede        fi
477369354a83SHans de Goede        usb_redir="no"
477469354a83SHans de Goede    fi
477569354a83SHans de Goedefi
477669354a83SHans de Goede
4777cd4ec0b4SGerd Hoffmann##########################################
4778d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4779d9840e25STomoki Sekiyama
4780e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4781e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
4782d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4783690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4784d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4785d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4786690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4787d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4788d9840e25STomoki Sekiyama	  ;;
4789690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4790d9840e25STomoki Sekiyama  esac
4791d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4792d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4793d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4794d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4795d9840e25STomoki SekiyamaEOF
4796d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4797d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4798d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4799315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4800f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4801d9840e25STomoki Sekiyama  else
4802d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4803d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4804d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4805d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4806d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4807d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4808d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4809d9840e25STomoki Sekiyama    fi
4810d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4811d9840e25STomoki Sekiyama  fi
4812d9840e25STomoki Sekiyamafi
4813d9840e25STomoki Sekiyama
4814d9840e25STomoki Sekiyama##########################################
4815d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4816d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4817d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4818d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4819d9840e25STomoki Sekiyama
4820e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4821e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4822d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4823d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4824d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4825d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4826d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4827d9840e25STomoki Sekiyama    else
4828d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4829d9840e25STomoki Sekiyama    fi
4830d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4831d9840e25STomoki Sekiyama    win_sdk=""
4832d9840e25STomoki Sekiyama  fi
4833d9840e25STomoki Sekiyamafi
4834d9840e25STomoki Sekiyama
4835d9840e25STomoki Sekiyama##########################################
483650cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4837e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
483850cbebb9SMichael Roth  cat > $TMPC << EOF
483950cbebb9SMichael Roth#include <windows.h>
484050cbebb9SMichael Roth#include <ntddscsi.h>
484150cbebb9SMichael Rothint main(void) {
484250cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
484350cbebb9SMichael Roth#error Missing required ioctl definitions
484450cbebb9SMichael Roth#endif
484550cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
484650cbebb9SMichael Roth  return addr.Lun;
484750cbebb9SMichael Roth}
484850cbebb9SMichael RothEOF
484950cbebb9SMichael Roth  if compile_prog "" "" ; then
485050cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4851c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
485250cbebb9SMichael Roth  fi
485350cbebb9SMichael Rothfi
485450cbebb9SMichael Roth
485550cbebb9SMichael Roth##########################################
48569d9e1521SGerd Hoffmann# virgl renderer probe
48579d9e1521SGerd Hoffmann
48589d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
48599d9e1521SGerd Hoffmann  cat > $TMPC << EOF
48609d9e1521SGerd Hoffmann#include <virglrenderer.h>
48619d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
48629d9e1521SGerd HoffmannEOF
48639d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
48649d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
486547479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
48669d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
48679d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
48689d9e1521SGerd Hoffmann    virglrenderer="yes"
48699d9e1521SGerd Hoffmann  else
48709d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
48719d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
48729d9e1521SGerd Hoffmann    fi
48739d9e1521SGerd Hoffmann    virglrenderer="no"
48749d9e1521SGerd Hoffmann  fi
48759d9e1521SGerd Hoffmannfi
48769d9e1521SGerd Hoffmann
48779d9e1521SGerd Hoffmann##########################################
48788ca80760SRichard Henderson# capstone
48798ca80760SRichard Henderson
4880e219c499SRichard Hendersoncase "$capstone" in
4881e219c499SRichard Henderson  "" | yes)
48828ca80760SRichard Henderson    if $pkg_config capstone; then
4883e219c499SRichard Henderson      capstone=system
4884e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
4885e219c499SRichard Henderson      capstone=git
4886e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4887e219c499SRichard Henderson      capstone=internal
4888e219c499SRichard Henderson    elif test -z "$capstone" ; then
4889e219c499SRichard Henderson      capstone=no
4890e219c499SRichard Henderson    else
4891e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4892e219c499SRichard Henderson    fi
4893e219c499SRichard Henderson    ;;
4894e219c499SRichard Henderson
4895e219c499SRichard Henderson  system)
4896e219c499SRichard Henderson    if ! $pkg_config capstone; then
4897e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4898e219c499SRichard Henderson    fi
4899e219c499SRichard Henderson    ;;
4900e219c499SRichard Hendersonesac
4901e219c499SRichard Henderson
4902e219c499SRichard Hendersoncase "$capstone" in
4903e219c499SRichard Henderson  git | internal)
4904e219c499SRichard Henderson    if test "$capstone" = git; then
4905e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4906e219c499SRichard Henderson    fi
4907e219c499SRichard Henderson    mkdir -p capstone
4908e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4909e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4910e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4911e219c499SRichard Henderson    else
4912e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4913e219c499SRichard Henderson    fi
4914e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4915e219c499SRichard Henderson    ;;
4916e219c499SRichard Henderson
4917e219c499SRichard Henderson  system)
49188ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
49198ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4920e219c499SRichard Henderson    ;;
4921e219c499SRichard Henderson
4922e219c499SRichard Henderson  no)
4923e219c499SRichard Henderson    ;;
4924e219c499SRichard Henderson  *)
4925e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4926e219c499SRichard Henderson    ;;
4927e219c499SRichard Hendersonesac
49288ca80760SRichard Henderson
49298ca80760SRichard Henderson##########################################
49305f6b9e8fSBlue Swirl# check if we have fdatasync
49315f6b9e8fSBlue Swirl
49325f6b9e8fSBlue Swirlfdatasync=no
49335f6b9e8fSBlue Swirlcat > $TMPC << EOF
49345f6b9e8fSBlue Swirl#include <unistd.h>
4935d1722a27SAlexandre Raymondint main(void) {
4936d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4937d1722a27SAlexandre Raymondreturn fdatasync(0);
4938d1722a27SAlexandre Raymond#else
4939e172fe11SStefan Weil#error Not supported
4940d1722a27SAlexandre Raymond#endif
4941d1722a27SAlexandre Raymond}
49425f6b9e8fSBlue SwirlEOF
49435f6b9e8fSBlue Swirlif compile_prog "" "" ; then
49445f6b9e8fSBlue Swirl    fdatasync=yes
49455f6b9e8fSBlue Swirlfi
49465f6b9e8fSBlue Swirl
494794a420b1SStefan Hajnoczi##########################################
4948e78815a5SAndreas Färber# check if we have madvise
4949e78815a5SAndreas Färber
4950e78815a5SAndreas Färbermadvise=no
4951e78815a5SAndreas Färbercat > $TMPC << EOF
4952e78815a5SAndreas Färber#include <sys/types.h>
4953e78815a5SAndreas Färber#include <sys/mman.h>
4954832ce9c2SScott Wood#include <stddef.h>
4955e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4956e78815a5SAndreas FärberEOF
4957e78815a5SAndreas Färberif compile_prog "" "" ; then
4958e78815a5SAndreas Färber    madvise=yes
4959e78815a5SAndreas Färberfi
4960e78815a5SAndreas Färber
4961e78815a5SAndreas Färber##########################################
4962e78815a5SAndreas Färber# check if we have posix_madvise
4963e78815a5SAndreas Färber
4964e78815a5SAndreas Färberposix_madvise=no
4965e78815a5SAndreas Färbercat > $TMPC << EOF
4966e78815a5SAndreas Färber#include <sys/mman.h>
4967832ce9c2SScott Wood#include <stddef.h>
4968e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4969e78815a5SAndreas FärberEOF
4970e78815a5SAndreas Färberif compile_prog "" "" ; then
4971e78815a5SAndreas Färber    posix_madvise=yes
4972e78815a5SAndreas Färberfi
4973e78815a5SAndreas Färber
4974e78815a5SAndreas Färber##########################################
49759bc5a719SAndreas Gustafsson# check if we have posix_memalign()
49769bc5a719SAndreas Gustafsson
49779bc5a719SAndreas Gustafssonposix_memalign=no
49789bc5a719SAndreas Gustafssoncat > $TMPC << EOF
49799bc5a719SAndreas Gustafsson#include <stdlib.h>
49809bc5a719SAndreas Gustafssonint main(void) {
49819bc5a719SAndreas Gustafsson    void *p;
49829bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
49839bc5a719SAndreas Gustafsson}
49849bc5a719SAndreas GustafssonEOF
49859bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
49869bc5a719SAndreas Gustafsson    posix_memalign=yes
49879bc5a719SAndreas Gustafssonfi
49889bc5a719SAndreas Gustafsson
49899bc5a719SAndreas Gustafsson##########################################
49900a852417SPaul Durrant# check if we have posix_syslog
49910a852417SPaul Durrant
49920a852417SPaul Durrantposix_syslog=no
49930a852417SPaul Durrantcat > $TMPC << EOF
49940a852417SPaul Durrant#include <syslog.h>
49950a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
49960a852417SPaul DurrantEOF
49970a852417SPaul Durrantif compile_prog "" "" ; then
49980a852417SPaul Durrant    posix_syslog=yes
49990a852417SPaul Durrantfi
50000a852417SPaul Durrant
50010a852417SPaul Durrant##########################################
5002401bc051SPeter Maydell# check if we have sem_timedwait
5003401bc051SPeter Maydell
5004401bc051SPeter Maydellsem_timedwait=no
5005401bc051SPeter Maydellcat > $TMPC << EOF
5006401bc051SPeter Maydell#include <semaphore.h>
5007401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
5008401bc051SPeter MaydellEOF
5009401bc051SPeter Maydellif compile_prog "" "" ; then
5010401bc051SPeter Maydell    sem_timedwait=yes
5011401bc051SPeter Maydellfi
5012401bc051SPeter Maydell
5013401bc051SPeter Maydell##########################################
50145c99fa37SKeno Fischer# check if we have strchrnul
50155c99fa37SKeno Fischer
50165c99fa37SKeno Fischerstrchrnul=no
50175c99fa37SKeno Fischercat > $TMPC << EOF
50185c99fa37SKeno Fischer#include <string.h>
50195c99fa37SKeno Fischerint main(void);
50205c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
50215c99fa37SKeno Fischerchar *haystack = (char*)&main;
50225c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
50235c99fa37SKeno FischerEOF
50245c99fa37SKeno Fischerif compile_prog "" "" ; then
50255c99fa37SKeno Fischer    strchrnul=yes
50265c99fa37SKeno Fischerfi
50275c99fa37SKeno Fischer
50285c99fa37SKeno Fischer##########################################
502994a420b1SStefan Hajnoczi# check if trace backend exists
503094a420b1SStefan Hajnoczi
50315b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
503294a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
50335b808275SLluís Vilanova  error_exit "invalid trace backends" \
50345b808275SLluís Vilanova      "Please choose supported trace backends."
503594a420b1SStefan Hajnoczifi
503694a420b1SStefan Hajnoczi
50377e24e92aSStefan Hajnoczi##########################################
50387e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
50395b808275SLluís Vilanovaif have_backend "ust"; then
50407e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5041bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
50427e24e92aSStefan Hajnocziint main(void) { return 0; }
50437e24e92aSStefan HajnocziEOF
5044c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5045bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
504689138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
50477e24e92aSStefan Hajnoczi    else
5048c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5049bf15f63cSMohamad Gebai    fi
5050bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
505189138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5052bf15f63cSMohamad Gebai    else
5053bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5054bf15f63cSMohamad Gebai    fi
5055bf15f63cSMohamad Gebai
5056bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5057bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5058bf15f63cSMohamad Gebai  else
5059bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
50607e24e92aSStefan Hajnoczi  fi
50617e24e92aSStefan Hajnoczifi
5062b3d08c02SDaniel P. Berrange
5063b3d08c02SDaniel P. Berrange##########################################
5064b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
50655b808275SLluís Vilanovaif have_backend "dtrace"; then
5066b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
506776ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5068b3d08c02SDaniel P. Berrange  fi
5069c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5070c276b17dSDaniel P. Berrange  if has 'stap' ; then
5071c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5072c276b17dSDaniel P. Berrange  fi
5073b3d08c02SDaniel P. Berrangefi
5074b3d08c02SDaniel P. Berrange
50757e24e92aSStefan Hajnoczi##########################################
5076519175a2SAlex Barcelo# check and set a backend for coroutine
5077d0e2fce5SAneesh Kumar K.V
50787c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
507933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
508033c53c54SDaniel P. Berrange# specific one.
50817c2acc70SPeter Maydell
50827c2acc70SPeter Maydellucontext_works=no
5083d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5084d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5085d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5086cdf84806SPeter Maydell#ifdef __stub_makecontext
5087cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5088cdf84806SPeter Maydell#endif
508975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5090d0e2fce5SAneesh Kumar K.VEOF
5091d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
50927c2acc70SPeter Maydell    ucontext_works=yes
5093d0e2fce5SAneesh Kumar K.V  fi
5094519175a2SAlex Barcelofi
50957c2acc70SPeter Maydell
50967c2acc70SPeter Maydellif test "$coroutine" = ""; then
50977c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
50987c2acc70SPeter Maydell    coroutine=win32
50997c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
51007c2acc70SPeter Maydell    coroutine=ucontext
5101519175a2SAlex Barcelo  else
51027c2acc70SPeter Maydell    coroutine=sigaltstack
51037c2acc70SPeter Maydell  fi
51047c2acc70SPeter Maydellelse
51057c2acc70SPeter Maydell  case $coroutine in
51067c2acc70SPeter Maydell  windows)
51077c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
51087c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
51097c2acc70SPeter Maydell    fi
51107c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
51117c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
51127c2acc70SPeter Maydell    coroutine=win32
51137c2acc70SPeter Maydell    ;;
51147c2acc70SPeter Maydell  ucontext)
51157c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
51167c2acc70SPeter Maydell      feature_not_found "ucontext"
51177c2acc70SPeter Maydell    fi
51187c2acc70SPeter Maydell    ;;
511933c53c54SDaniel P. Berrange  sigaltstack)
51207c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
51217c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
51227c2acc70SPeter Maydell    fi
51237c2acc70SPeter Maydell    ;;
51247c2acc70SPeter Maydell  *)
512576ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
51267c2acc70SPeter Maydell    ;;
51277c2acc70SPeter Maydell  esac
5128d0e2fce5SAneesh Kumar K.Vfi
5129d0e2fce5SAneesh Kumar K.V
513070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
513170c60c08SStefan Hajnoczi  coroutine_pool=yes
513270c60c08SStefan Hajnoczifi
513370c60c08SStefan Hajnoczi
51347d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
51357d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
51367d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
51377d992e4dSPeter Lieven    coroutine_pool=no
51387d992e4dSPeter Lieven  fi
51397d992e4dSPeter Lievenfi
51407d992e4dSPeter Lieven
51417d992e4dSPeter Lieven
5142d0e2fce5SAneesh Kumar K.V##########################################
5143d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5144d2042378SAneesh Kumar K.V
51454e1797f9SStefan Weilopen_by_handle_at=no
5146d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5147d2042378SAneesh Kumar K.V#include <fcntl.h>
5148acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5149acc55ba8SStefan Weil# error missing definition
5150acc55ba8SStefan Weil#else
515175cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5152acc55ba8SStefan Weil#endif
5153d2042378SAneesh Kumar K.VEOF
5154d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5155d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5156d2042378SAneesh Kumar K.Vfi
5157d2042378SAneesh Kumar K.V
5158e06a765eSHarsh Prateek Bora########################################
5159e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5160e06a765eSHarsh Prateek Bora
5161e06a765eSHarsh Prateek Boralinux_magic_h=no
5162e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5163e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5164e06a765eSHarsh Prateek Boraint main(void) {
516575cafad7SStefan Weil  return 0;
5166e06a765eSHarsh Prateek Bora}
5167e06a765eSHarsh Prateek BoraEOF
5168e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5169e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5170e06a765eSHarsh Prateek Borafi
5171e06a765eSHarsh Prateek Bora
51728ab1bf12SLuiz Capitulino########################################
5173c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
5174c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
5175c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
5176c95e3080SKevin Wolf# only a warning.
5177c95e3080SKevin Wolf#
5178c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
5179c95e3080SKevin Wolf# the build doesn't fail anyway.
5180c95e3080SKevin Wolf
518106d71fa1SPeter Maydellpragma_disable_unused_but_set=no
518206d71fa1SPeter Maydellcat > $TMPC << EOF
5183e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
5184c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5185e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
5186c95e3080SKevin Wolf
518706d71fa1SPeter Maydellint main(void) {
518806d71fa1SPeter Maydell    return 0;
518906d71fa1SPeter Maydell}
519006d71fa1SPeter MaydellEOF
519106d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
5192cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
5193c95e3080SKevin Wolfelse
5194c95e3080SKevin Wolf    werror=no
519506d71fa1SPeter Maydellfi
519606d71fa1SPeter Maydell
519706d71fa1SPeter Maydell########################################
5198541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
51993f4349dcSKevin Wolf
52003f4349dcSKevin Wolfvalgrind_h=no
52013f4349dcSKevin Wolfcat > $TMPC << EOF
52023f4349dcSKevin Wolf#include <valgrind/valgrind.h>
52033f4349dcSKevin Wolfint main(void) {
52043f4349dcSKevin Wolf  return 0;
52053f4349dcSKevin Wolf}
52063f4349dcSKevin WolfEOF
52073f4349dcSKevin Wolfif compile_prog "" "" ; then
52083f4349dcSKevin Wolf    valgrind_h=yes
52093f4349dcSKevin Wolffi
52103f4349dcSKevin Wolf
52113f4349dcSKevin Wolf########################################
52128ab1bf12SLuiz Capitulino# check if environ is declared
52138ab1bf12SLuiz Capitulino
52148ab1bf12SLuiz Capitulinohas_environ=no
52158ab1bf12SLuiz Capitulinocat > $TMPC << EOF
52168ab1bf12SLuiz Capitulino#include <unistd.h>
52178ab1bf12SLuiz Capitulinoint main(void) {
5218c075a723SBlue Swirl    environ = 0;
52198ab1bf12SLuiz Capitulino    return 0;
52208ab1bf12SLuiz Capitulino}
52218ab1bf12SLuiz CapitulinoEOF
52228ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
52238ab1bf12SLuiz Capitulino    has_environ=yes
52248ab1bf12SLuiz Capitulinofi
52258ab1bf12SLuiz Capitulino
522676a347e1SRichard Henderson########################################
522776a347e1SRichard Henderson# check if cpuid.h is usable.
522876a347e1SRichard Henderson
522976a347e1SRichard Hendersoncat > $TMPC << EOF
523076a347e1SRichard Henderson#include <cpuid.h>
523176a347e1SRichard Hendersonint main(void) {
5232774d566cSPeter Maydell    unsigned a, b, c, d;
5233774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5234774d566cSPeter Maydell
5235774d566cSPeter Maydell    if (max >= 1) {
5236774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5237774d566cSPeter Maydell    }
5238774d566cSPeter Maydell
5239774d566cSPeter Maydell    if (max >= 7) {
5240774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5241774d566cSPeter Maydell    }
5242774d566cSPeter Maydell
524376a347e1SRichard Henderson    return 0;
524476a347e1SRichard Henderson}
524576a347e1SRichard HendersonEOF
524676a347e1SRichard Hendersonif compile_prog "" "" ; then
524776a347e1SRichard Henderson    cpuid_h=yes
524876a347e1SRichard Hendersonfi
524976a347e1SRichard Henderson
52505dd89908SRichard Henderson##########################################
52515dd89908SRichard Henderson# avx2 optimization requirement check
52525dd89908SRichard Henderson#
52535dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
52545dd89908SRichard Henderson# since we won't be able to select the new routines.
52555dd89908SRichard Henderson
5256e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
52575dd89908SRichard Henderson  cat > $TMPC << EOF
52585dd89908SRichard Henderson#pragma GCC push_options
52595dd89908SRichard Henderson#pragma GCC target("avx2")
52605dd89908SRichard Henderson#include <cpuid.h>
52615dd89908SRichard Henderson#include <immintrin.h>
52625dd89908SRichard Hendersonstatic int bar(void *a) {
52635dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
52645dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
52655dd89908SRichard Henderson}
52665dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
52675dd89908SRichard HendersonEOF
52685dd89908SRichard Henderson  if compile_object "" ; then
52695dd89908SRichard Henderson    avx2_opt="yes"
527086583a07SLiam Merwick  else
527186583a07SLiam Merwick    avx2_opt="no"
52725dd89908SRichard Henderson  fi
52735dd89908SRichard Hendersonfi
52745dd89908SRichard Henderson
5275f540166bSRichard Henderson########################################
5276f540166bSRichard Henderson# check if __[u]int128_t is usable.
5277f540166bSRichard Henderson
5278f540166bSRichard Hendersonint128=no
5279f540166bSRichard Hendersoncat > $TMPC << EOF
5280f540166bSRichard Henderson__int128_t a;
5281f540166bSRichard Henderson__uint128_t b;
5282f540166bSRichard Hendersonint main (void) {
5283f540166bSRichard Henderson  a = a + b;
5284f540166bSRichard Henderson  b = a * b;
5285464e3671SPeter Maydell  a = a * a;
5286f540166bSRichard Henderson  return 0;
5287f540166bSRichard Henderson}
5288f540166bSRichard HendersonEOF
5289f540166bSRichard Hendersonif compile_prog "" "" ; then
5290f540166bSRichard Henderson    int128=yes
5291f540166bSRichard Hendersonfi
529276a347e1SRichard Henderson
52937ebee43eSRichard Henderson#########################################
52947ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
52957ebee43eSRichard Henderson
52967ebee43eSRichard Hendersonatomic128=no
52977ebee43eSRichard Hendersonif test "$int128" = "yes"; then
52987ebee43eSRichard Henderson  cat > $TMPC << EOF
52997ebee43eSRichard Hendersonint main(void)
53007ebee43eSRichard Henderson{
53017ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
53027ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
53037ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
53047ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
53057ebee43eSRichard Henderson  return 0;
53067ebee43eSRichard Henderson}
53077ebee43eSRichard HendersonEOF
53087ebee43eSRichard Henderson  if compile_prog "" "" ; then
53097ebee43eSRichard Henderson    atomic128=yes
53107ebee43eSRichard Henderson  fi
53117ebee43eSRichard Hendersonfi
53127ebee43eSRichard Henderson
5313e6cd4bb5SRichard Hendersoncmpxchg128=no
5314e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5315e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5316e6cd4bb5SRichard Hendersonint main(void)
5317e6cd4bb5SRichard Henderson{
5318e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5319e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5320e6cd4bb5SRichard Henderson  return 0;
5321e6cd4bb5SRichard Henderson}
5322e6cd4bb5SRichard HendersonEOF
5323e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5324e6cd4bb5SRichard Henderson    cmpxchg128=yes
5325e6cd4bb5SRichard Henderson  fi
5326e6cd4bb5SRichard Hendersonfi
5327e6cd4bb5SRichard Henderson
5328df79b996SRichard Henderson#########################################
5329df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5330df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5331df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5332df79b996SRichard Henderson
5333df79b996SRichard Hendersoncat > $TMPC << EOF
5334df79b996SRichard Henderson#include <stdint.h>
5335df79b996SRichard Hendersonint main(void)
5336df79b996SRichard Henderson{
5337df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5338df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5339df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5340df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5341df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5342df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5343df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5344df79b996SRichard Henderson#else
5345df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5346df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5347df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5348df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5349df79b996SRichard Henderson#endif
5350df79b996SRichard Henderson  return 0;
5351df79b996SRichard Henderson}
5352df79b996SRichard HendersonEOF
5353df79b996SRichard Hendersonif compile_prog "" "" ; then
5354df79b996SRichard Henderson  atomic64=yes
5355df79b996SRichard Hendersonfi
5356df79b996SRichard Henderson
53571e6e9acaSRichard Henderson########################################
5358db432672SRichard Henderson# See if 16-byte vector operations are supported.
5359db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5360db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5361db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5362db432672SRichard Henderson
5363db432672SRichard Hendersoncat > $TMPC << EOF
5364db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5365db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5366db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5367db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5368db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5369db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5370db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5371db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5372db432672SRichard Hendersonstatic U1 a1, b1;
5373db432672SRichard Hendersonstatic U2 a2, b2;
5374db432672SRichard Hendersonstatic U4 a4, b4;
5375db432672SRichard Hendersonstatic U8 a8, b8;
5376db432672SRichard Hendersonstatic S1 c1;
5377db432672SRichard Hendersonstatic S2 c2;
5378db432672SRichard Hendersonstatic S4 c4;
5379db432672SRichard Hendersonstatic S8 c8;
5380db432672SRichard Hendersonstatic int i;
538174912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
538274912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
538374912f6dSLaurent Vivier{
538474912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
538574912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
538674912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
538774912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
538874912f6dSLaurent Vivier}
5389db432672SRichard Hendersonint main(void)
5390db432672SRichard Henderson{
5391db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5392db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5393db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5394db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5395db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5396db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5397db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5398db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5399db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5400db432672SRichard Henderson  return 0;
5401db432672SRichard Henderson}
5402db432672SRichard HendersonEOF
5403db432672SRichard Henderson
5404db432672SRichard Hendersonvector16=no
5405db432672SRichard Hendersonif compile_prog "" "" ; then
5406db432672SRichard Henderson  vector16=yes
5407db432672SRichard Hendersonfi
5408db432672SRichard Henderson
5409db432672SRichard Henderson########################################
54101e6e9acaSRichard Henderson# check if getauxval is available.
54111e6e9acaSRichard Henderson
54121e6e9acaSRichard Hendersongetauxval=no
54131e6e9acaSRichard Hendersoncat > $TMPC << EOF
54141e6e9acaSRichard Henderson#include <sys/auxv.h>
54151e6e9acaSRichard Hendersonint main(void) {
54161e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
54171e6e9acaSRichard Henderson}
54181e6e9acaSRichard HendersonEOF
54191e6e9acaSRichard Hendersonif compile_prog "" "" ; then
54201e6e9acaSRichard Henderson    getauxval=yes
54211e6e9acaSRichard Hendersonfi
54221e6e9acaSRichard Henderson
5423fd0e6053SJohn Snow########################################
5424fd0e6053SJohn Snow# check if ccache is interfering with
5425fd0e6053SJohn Snow# semantic analysis of macros
5426fd0e6053SJohn Snow
54275e4dfd3dSJohn Snowunset CCACHE_CPP2
5428fd0e6053SJohn Snowccache_cpp2=no
5429fd0e6053SJohn Snowcat > $TMPC << EOF
5430fd0e6053SJohn Snowstatic const int Z = 1;
5431fd0e6053SJohn Snow#define fn() ({ Z; })
5432fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5433fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5434fd0e6053SJohn Snow#define ID(X) (X)
5435fd0e6053SJohn Snowint main(int argc, char *argv[])
5436fd0e6053SJohn Snow{
5437fd0e6053SJohn Snow    int x = 0, y = 0;
5438fd0e6053SJohn Snow    x = ID(x);
5439fd0e6053SJohn Snow    x = fn();
5440fd0e6053SJohn Snow    fn();
5441fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5442fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5443fd0e6053SJohn Snow    return 0;
5444fd0e6053SJohn Snow}
5445fd0e6053SJohn SnowEOF
5446fd0e6053SJohn Snow
5447fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5448fd0e6053SJohn Snow    ccache_cpp2=yes
5449fd0e6053SJohn Snowfi
5450fd0e6053SJohn Snow
5451b553a042SJohn Snow#################################################
5452b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5453b553a042SJohn Snow
5454b553a042SJohn Snowif test "$fortify_source" != "no"; then
5455b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5456b553a042SJohn Snow    fortify_source="no";
5457e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5458cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5459b553a042SJohn Snow    fortify_source="no";
5460b553a042SJohn Snow  else
5461b553a042SJohn Snow    fortify_source="yes"
5462b553a042SJohn Snow  fi
5463b553a042SJohn Snowfi
5464b553a042SJohn Snow
54651efad060SFam Zheng###############################################
54661efad060SFam Zheng# Check if copy_file_range is provided by glibc
54671efad060SFam Zhenghave_copy_file_range=no
54681efad060SFam Zhengcat > $TMPC << EOF
54691efad060SFam Zheng#include <unistd.h>
54701efad060SFam Zhengint main(void) {
54711efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
54721efad060SFam Zheng  return 0;
54731efad060SFam Zheng}
54741efad060SFam ZhengEOF
54751efad060SFam Zhengif compile_prog "" "" ; then
54761efad060SFam Zheng    have_copy_file_range=yes
54771efad060SFam Zhengfi
54781efad060SFam Zheng
5479d2042378SAneesh Kumar K.V##########################################
5480277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5481277abf15SJan Vesely
5482277abf15SJan Veselyhave_fsxattr=no
5483277abf15SJan Veselycat > $TMPC << EOF
5484277abf15SJan Vesely#include <linux/fs.h>
5485277abf15SJan Veselystruct fsxattr foo;
5486277abf15SJan Veselyint main(void) {
5487277abf15SJan Vesely  return 0;
5488277abf15SJan Vesely}
5489277abf15SJan VeselyEOF
5490277abf15SJan Veselyif compile_prog "" "" ; then
5491277abf15SJan Vesely    have_fsxattr=yes
5492277abf15SJan Veselyfi
5493277abf15SJan Vesely
5494b66e10e4SPeter Maydell##########################################
5495a40161cbSPaolo Bonzini# check for usable membarrier system call
5496a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5497a40161cbSPaolo Bonzini    have_membarrier=no
5498a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5499a40161cbSPaolo Bonzini        have_membarrier=yes
5500a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5501a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5502a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5503a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5504a40161cbSPaolo Bonzini    #include <unistd.h>
5505a40161cbSPaolo Bonzini    #include <stdlib.h>
5506a40161cbSPaolo Bonzini    int main(void) {
5507a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5508a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5509a40161cbSPaolo Bonzini	exit(0);
5510a40161cbSPaolo Bonzini    }
5511a40161cbSPaolo BonziniEOF
5512a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5513a40161cbSPaolo Bonzini            have_membarrier=yes
5514a40161cbSPaolo Bonzini        fi
5515a40161cbSPaolo Bonzini    fi
5516a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5517a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5518a40161cbSPaolo Bonzini    fi
5519a40161cbSPaolo Bonzinielse
5520a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5521a40161cbSPaolo Bonzini    # work on Wine.
5522a40161cbSPaolo Bonzini    membarrier=no
5523a40161cbSPaolo Bonzinifi
5524a40161cbSPaolo Bonzini
5525a40161cbSPaolo Bonzini##########################################
5526b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5527575b22b1SLaurent Vivierhave_rtnetlink=no
5528575b22b1SLaurent Viviercat > $TMPC << EOF
5529575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5530575b22b1SLaurent Vivierint main(void) {
5531575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5532575b22b1SLaurent Vivier}
5533575b22b1SLaurent VivierEOF
5534575b22b1SLaurent Vivierif compile_prog "" "" ; then
5535575b22b1SLaurent Vivier    have_rtnetlink=yes
5536575b22b1SLaurent Vivierfi
5537575b22b1SLaurent Vivier
55386a02c806SStefan Hajnoczi##########################################
55396a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
55406a02c806SStefan Hajnoczihave_af_vsock=no
55416a02c806SStefan Hajnoczicat > $TMPC << EOF
55426a02c806SStefan Hajnoczi#include <errno.h>
55436a02c806SStefan Hajnoczi#include <sys/types.h>
55446a02c806SStefan Hajnoczi#include <sys/socket.h>
55456a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
55466a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
55476a02c806SStefan Hajnoczi#endif
55486a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
55496a02c806SStefan Hajnocziint main(void) {
55506a02c806SStefan Hajnoczi    int sock, ret;
55516a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
55526a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
55536a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
55546a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
55556a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
55566a02c806SStefan Hajnoczi        return 0;
55576a02c806SStefan Hajnoczi    }
55586a02c806SStefan Hajnoczi    return -1;
55596a02c806SStefan Hajnoczi}
55606a02c806SStefan HajnocziEOF
55616a02c806SStefan Hajnocziif compile_prog "" "" ; then
55626a02c806SStefan Hajnoczi    have_af_vsock=yes
55636a02c806SStefan Hajnoczifi
55646a02c806SStefan Hajnoczi
5565f0d92b56SLongpeng(Mike)##########################################
5566f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5567f0d92b56SLongpeng(Mike)hava_afalg=no
5568f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5569f0d92b56SLongpeng(Mike)#include <errno.h>
5570f0d92b56SLongpeng(Mike)#include <sys/types.h>
5571f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5572f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5573f0d92b56SLongpeng(Mike)int main(void) {
5574f0d92b56SLongpeng(Mike)    int sock;
5575f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5576f0d92b56SLongpeng(Mike)    return sock;
5577f0d92b56SLongpeng(Mike)}
5578f0d92b56SLongpeng(Mike)EOF
5579f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5580f0d92b56SLongpeng(Mike)    have_afalg=yes
5581f0d92b56SLongpeng(Mike)fi
5582f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5583f0d92b56SLongpeng(Mike)then
5584f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5585f0d92b56SLongpeng(Mike)    then
5586f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5587f0d92b56SLongpeng(Mike)    fi
5588f0d92b56SLongpeng(Mike)fi
5589f0d92b56SLongpeng(Mike)
5590f0d92b56SLongpeng(Mike)
55916969ec6cSJames Clarke#################################################
5592c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5593d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5594c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5595c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5596c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5597c97d6d2cSSergio Andres Gomez Del RealEOF
5598c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5599c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5600c97d6d2cSSergio Andres Gomez Del Real  else
5601c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5602c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5603c97d6d2cSSergio Andres Gomez Del Real  fi
5604c97d6d2cSSergio Andres Gomez Del Realfi
5605c97d6d2cSSergio Andres Gomez Del Real
5606c97d6d2cSSergio Andres Gomez Del Real#################################################
56076969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
56086969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
56096969ec6cSJames Clarke# given. It does no harm to give it on other
56106969ec6cSJames Clarke# platforms too.
56116969ec6cSJames Clarke
56126969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
56136969ec6cSJames Clarke#       contains -Wmissing-prototypes
56146969ec6cSJames Clarkecat > $TMPC << EOF
56156969ec6cSJames Clarkeextern int foo(void);
56166969ec6cSJames Clarkeint foo(void) { return 0; }
56176969ec6cSJames ClarkeEOF
56186969ec6cSJames Clarkeif ! compile_object ""; then
56196969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
56206969ec6cSJames Clarkefi
56217ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
56227ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
56237ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
56247ecf44a5SPaolo Bonzini    break
56257ecf44a5SPaolo Bonzini  fi
56267ecf44a5SPaolo Bonzinidone
56277ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
56287ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
56296969ec6cSJames Clarkefi
56306969ec6cSJames Clarke
5631277abf15SJan Vesely##########################################
56324d04351fSChristopher Covington# check for sysmacros.h
56334d04351fSChristopher Covington
56344d04351fSChristopher Covingtonhave_sysmacros=no
56354d04351fSChristopher Covingtoncat > $TMPC << EOF
56364d04351fSChristopher Covington#include <sys/sysmacros.h>
56374d04351fSChristopher Covingtonint main(void) {
56384d04351fSChristopher Covington    return makedev(0, 0);
56394d04351fSChristopher Covington}
56404d04351fSChristopher CovingtonEOF
56414d04351fSChristopher Covingtonif compile_prog "" "" ; then
56424d04351fSChristopher Covington    have_sysmacros=yes
56434d04351fSChristopher Covingtonfi
56444d04351fSChristopher Covington
56454d04351fSChristopher Covington##########################################
5646da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5647da92c3ffSAshish Mittal# Check if libvxhs is installed
5648da92c3ffSAshish Mittal
5649da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5650da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5651da92c3ffSAshish Mittal#include <stdint.h>
5652da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5653da92c3ffSAshish Mittal
5654da92c3ffSAshish Mittalvoid *vxhs_callback;
5655da92c3ffSAshish Mittal
5656da92c3ffSAshish Mittalint main(void) {
5657da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5658da92c3ffSAshish Mittal    return 0;
5659da92c3ffSAshish Mittal}
5660da92c3ffSAshish MittalEOF
5661da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5662da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5663da92c3ffSAshish Mittal    vxhs=yes
5664da92c3ffSAshish Mittal  else
5665da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5666da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5667da92c3ffSAshish Mittal    fi
5668da92c3ffSAshish Mittal    vxhs=no
5669da92c3ffSAshish Mittal  fi
5670da92c3ffSAshish Mittalfi
5671da92c3ffSAshish Mittal
5672da92c3ffSAshish Mittal##########################################
567349e00a18SAndreas Grapentin# check for _Static_assert()
567449e00a18SAndreas Grapentin
567549e00a18SAndreas Grapentinhave_static_assert=no
567649e00a18SAndreas Grapentincat > $TMPC << EOF
567749e00a18SAndreas Grapentin_Static_assert(1, "success");
567849e00a18SAndreas Grapentinint main(void) {
567949e00a18SAndreas Grapentin    return 0;
568049e00a18SAndreas Grapentin}
568149e00a18SAndreas GrapentinEOF
568249e00a18SAndreas Grapentinif compile_prog "" "" ; then
568349e00a18SAndreas Grapentin    have_static_assert=yes
568449e00a18SAndreas Grapentinfi
568549e00a18SAndreas Grapentin
568649e00a18SAndreas Grapentin##########################################
5687e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5688e674605fSTomáš Golembiovský
5689e674605fSTomáš Golembiovskýhave_utmpx=no
5690e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5691e674605fSTomáš Golembiovský#include <utmpx.h>
5692e674605fSTomáš Golembiovskýstruct utmpx user_info;
5693e674605fSTomáš Golembiovskýint main(void) {
5694e674605fSTomáš Golembiovský    return 0;
5695e674605fSTomáš Golembiovský}
5696e674605fSTomáš GolembiovskýEOF
5697e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5698e674605fSTomáš Golembiovský    have_utmpx=yes
5699e674605fSTomáš Golembiovskýfi
5700e674605fSTomáš Golembiovský
5701e674605fSTomáš Golembiovský##########################################
5702247724cbSMarc-André Lureau# checks for sanitizers
5703247724cbSMarc-André Lureau
5704247724cbSMarc-André Lureauhave_asan=no
5705247724cbSMarc-André Lureauhave_ubsan=no
5706d83414e1SMarc-André Lureauhave_asan_iface_h=no
5707d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5708247724cbSMarc-André Lureau
5709247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5710b9f44da2SMarc-André Lureau  write_c_skeleton
5711247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5712247724cbSMarc-André Lureau      have_asan=yes
5713247724cbSMarc-André Lureau  fi
5714b9f44da2SMarc-André Lureau
5715b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5716b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5717b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5718b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5719b9f44da2SMarc-André Lureau#include <stdlib.h>
5720b9f44da2SMarc-André Lureauint main(void) {
5721b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5722b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5723b9f44da2SMarc-André Lureau}
5724b9f44da2SMarc-André LureauEOF
5725247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5726247724cbSMarc-André Lureau      have_ubsan=yes
5727247724cbSMarc-André Lureau  fi
5728d83414e1SMarc-André Lureau
5729d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5730d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5731d83414e1SMarc-André Lureau  fi
5732d83414e1SMarc-André Lureau
5733d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5734d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5735d83414e1SMarc-André Lureauint main(void) {
5736d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5737d83414e1SMarc-André Lureau  return 0;
5738d83414e1SMarc-André Lureau}
5739d83414e1SMarc-André LureauEOF
5740d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5741d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5742d83414e1SMarc-André Lureau  fi
5743247724cbSMarc-André Lureaufi
5744247724cbSMarc-André Lureau
5745247724cbSMarc-André Lureau##########################################
574651a12b51SAlex Bennée# Docker and cross-compiler support
574751a12b51SAlex Bennée#
574851a12b51SAlex Bennée# This is specifically for building test
574951a12b51SAlex Bennée# cases for foreign architectures, not
575051a12b51SAlex Bennée# cross-compiling QEMU itself.
575151a12b51SAlex Bennée
575251a12b51SAlex Bennéeif has "docker"; then
575351a12b51SAlex Bennée    docker=$($python $source_path/tests/docker/docker.py probe)
575451a12b51SAlex Bennéefi
575551a12b51SAlex Bennée
575651a12b51SAlex Bennée##########################################
575717824406SJunyan He# check for libpmem
575817824406SJunyan He
575917824406SJunyan Heif test "$libpmem" != "no"; then
576017824406SJunyan He	if $pkg_config --exists "libpmem"; then
576117824406SJunyan He		libpmem="yes"
576217824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
576317824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
576417824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
576517824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
576617824406SJunyan He	else
576717824406SJunyan He		if test "$libpmem" = "yes" ; then
576817824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
576917824406SJunyan He		fi
577017824406SJunyan He		libpmem="no"
577117824406SJunyan He	fi
577217824406SJunyan Hefi
577317824406SJunyan He
577417824406SJunyan He##########################################
5775675b9b53SMarc-André Lureau# check for slirp
5776675b9b53SMarc-André Lureau
5777675b9b53SMarc-André Lureaucase "$slirp" in
5778675b9b53SMarc-André Lureau  "" | yes)
5779675b9b53SMarc-André Lureau    if $pkg_config slirp; then
5780675b9b53SMarc-André Lureau      slirp=system
5781675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
5782675b9b53SMarc-André Lureau      slirp=internal
5783675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
5784675b9b53SMarc-André Lureau      slirp=no
5785675b9b53SMarc-André Lureau    else
5786675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
5787675b9b53SMarc-André Lureau    fi
5788675b9b53SMarc-André Lureau    ;;
5789675b9b53SMarc-André Lureau
5790675b9b53SMarc-André Lureau  system)
5791675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
5792675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
5793675b9b53SMarc-André Lureau    fi
5794675b9b53SMarc-André Lureau    ;;
5795675b9b53SMarc-André Lureauesac
5796675b9b53SMarc-André Lureau
5797675b9b53SMarc-André Lureaucase "$slirp" in
5798*1f773d9dSDaniel P. Berrangé  internal)
5799675b9b53SMarc-André Lureau    mkdir -p slirp
5800675b9b53SMarc-André Lureau    slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
5801675b9b53SMarc-André Lureau    slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
5802675b9b53SMarc-André Lureau    ;;
5803675b9b53SMarc-André Lureau
5804675b9b53SMarc-André Lureau  system)
5805675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
5806675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
5807675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
5808675b9b53SMarc-André Lureau    ;;
5809675b9b53SMarc-André Lureau
5810675b9b53SMarc-André Lureau  no)
5811675b9b53SMarc-André Lureau    ;;
5812675b9b53SMarc-André Lureau  *)
5813675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
5814675b9b53SMarc-André Lureau    ;;
5815675b9b53SMarc-André Lureauesac
5816675b9b53SMarc-André Lureau
5817675b9b53SMarc-André Lureau
5818675b9b53SMarc-André Lureau##########################################
5819e86ecd4bSJuan Quintela# End of CC checks
5820e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5821e86ecd4bSJuan Quintela
5822d83414e1SMarc-André Lureauwrite_c_skeleton
5823d83414e1SMarc-André Lureau
58241d728c39SBlue Swirlif test "$gcov" = "yes" ; then
58251d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
58261d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5827b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5828e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
582948e56d50SPaolo Bonzinielif test "$debug" = "no"; then
5830ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5831e86ecd4bSJuan Quintelafi
5832a316e378SJuan Quintela
5833247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5834247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
5835d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5836d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5837d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5838d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5839d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5840d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5841d83414e1SMarc-André Lureau  fi
5842247724cbSMarc-André Lureaufi
5843247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5844247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
5845247724cbSMarc-André Lureaufi
5846247724cbSMarc-André Lureau
58476542aa9cSPeter Lieven##########################################
58486542aa9cSPeter Lieven# Do we have libnfs
58496542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5850b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
58516542aa9cSPeter Lieven    libnfs="yes"
58526542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
58536542aa9cSPeter Lieven  else
58546542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
58558efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
58566542aa9cSPeter Lieven    fi
58576542aa9cSPeter Lieven    libnfs="no"
58586542aa9cSPeter Lieven  fi
58596542aa9cSPeter Lievenfi
58601d728c39SBlue Swirl
58613efac6ebSTomáš Golembiovský##########################################
58623efac6ebSTomáš Golembiovský# Do we have libudev
58633efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
58643efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
58653efac6ebSTomáš Golembiovský    libudev="yes"
58663efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
58673efac6ebSTomáš Golembiovský  else
58683efac6ebSTomáš Golembiovský    libudev="no"
58693efac6ebSTomáš Golembiovský  fi
58703efac6ebSTomáš Golembiovskýfi
58713efac6ebSTomáš Golembiovský
58726ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
58736ca026cbSPeter Maydellif test "$werror" = "yes"; then
58746ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
58756ca026cbSPeter Maydellfi
58766ca026cbSPeter Maydell
5877e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5878e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
58791156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5880e86ecd4bSJuan Quintela    fi
5881e86ecd4bSJuan Quintelafi
5882e86ecd4bSJuan Quintela
588394dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
588494dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
588594dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
588694dd53c5SGerd Hoffmannelse
588794dd53c5SGerd Hoffmann    POD2MAN="pod2man"
588894dd53c5SGerd Hoffmannfi
588994dd53c5SGerd Hoffmann
5890952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5891952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5892952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5893e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5894952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5895952afb71SBlue Swirl        fi
5896952afb71SBlue Swirl    done
5897952afb71SBlue Swirlfi
5898952afb71SBlue Swirl
58997776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
59007776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
59017776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
59027776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
59037776ea6bSPhilippe Mathieu-DaudéEOF
59047776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
59057776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
59067776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
59077776ea6bSPhilippe Mathieu-Daudé    fi
59087776ea6bSPhilippe Mathieu-Daudéfi
59097776ea6bSPhilippe Mathieu-Daudé
591010ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5911e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5912528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5913834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
5914a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
591567ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
59165a67135aSbellard
5917e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5918e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5919e0580342SKamil Rytarowski  ivshmem=yes
5920e0580342SKamil Rytarowskifi
5921e0580342SKamil Rytarowski
59224b1c11fdSDaniel P. Berrangetools=""
59234b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
592472d277a7SGerd Hoffmann  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
59254b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
59264b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5927b1449edbSKamil Rytarowski  fi
5928b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5929a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
59304b1c11fdSDaniel P. Berrange  fi
59311b9d35f3SViktor Prutyanov  if [ "$curl" = "yes" ]; then
59321b9d35f3SViktor Prutyanov      tools="elf2dmp\$(EXESUF) $tools"
59333fa2d384SViktor Prutyanov  fi
59344b1c11fdSDaniel P. Berrangefi
59354b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5936b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5937b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5938983eef5aSMeador Inge      virtfs=yes
593917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5940983eef5aSMeador Inge    else
5941983eef5aSMeador Inge      if test "$virtfs" = yes; then
5942b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5943983eef5aSMeador Inge      fi
594417500370SAndreas Färber      virtfs=no
5945983eef5aSMeador Inge    fi
5946fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5947fe8fc5aeSPaolo Bonzini      mpath=yes
5948fe8fc5aeSPaolo Bonzini    else
5949fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5950fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5951fe8fc5aeSPaolo Bonzini      fi
5952fe8fc5aeSPaolo Bonzini      mpath=no
5953fe8fc5aeSPaolo Bonzini    fi
5954b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5955b855f8d1SPaolo Bonzini  else
5956b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5957b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5958b855f8d1SPaolo Bonzini    fi
5959b855f8d1SPaolo Bonzini    virtfs=no
5960fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5961fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5962fe8fc5aeSPaolo Bonzini    fi
5963fe8fc5aeSPaolo Bonzini    mpath=no
596417bff52bSM. Mohan Kumar  fi
59656a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
59666a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
59676a021536SGerd Hoffmann  fi
5968ff69fd8cSLaurent Vivierfi
59699d6bc27bSMichael Roth
59709d6bc27bSMichael Roth# Probe for guest agent support/options
59719d6bc27bSMichael Roth
5972e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5973b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5974fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5975e8ef31a3SMichael Tokarev      guest_agent=yes
5976e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5977e8ef31a3SMichael Tokarev      guest_agent=no
5978e8ef31a3SMichael Tokarev  else
5979e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5980ca35f780SPaolo Bonzini  fi
59814b1c11fdSDaniel P. Berrangefi
5982ca35f780SPaolo Bonzini
59839d6bc27bSMichael Roth# Guest agent Window MSI  package
59849d6bc27bSMichael Roth
59859d6bc27bSMichael Rothif test "$guest_agent" != yes; then
59869d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
59879d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
59889d6bc27bSMichael Roth  fi
59899d6bc27bSMichael Roth  guest_agent_msi=no
59909d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
59919d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
59929d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
59939d6bc27bSMichael Roth  fi
59949d6bc27bSMichael Roth  guest_agent_msi=no
59959d6bc27bSMichael Rothelif ! has wixl; then
59969d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
59979d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
59989d6bc27bSMichael Roth  fi
59999d6bc27bSMichael Roth  guest_agent_msi=no
60001a34904eSMichael Rothelse
60011a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
60021a34904eSMichael Roth  # disabled explicitly
60031a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
60041a34904eSMichael Roth    guest_agent_msi=yes
60051a34904eSMichael Roth  fi
60069d6bc27bSMichael Rothfi
60079d6bc27bSMichael Roth
60081a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
60099d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
60109d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
60119d6bc27bSMichael Roth  fi
60129d6bc27bSMichael Roth
60139d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
60149d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
60159d6bc27bSMichael Roth  fi
60169d6bc27bSMichael Roth
60179d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
60189d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
60199d6bc27bSMichael Roth  fi
60209d6bc27bSMichael Roth
60219d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
602289138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
60239d6bc27bSMichael Roth  fi
60249d6bc27bSMichael Roth
602589138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
60269d6bc27bSMichael Roth
60279d6bc27bSMichael Roth  case "$cpu" in
60289d6bc27bSMichael Roth  x86_64)
60299d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
60309d6bc27bSMichael Roth    ;;
60319d6bc27bSMichael Roth  i386)
60329d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
60339d6bc27bSMichael Roth    ;;
60349d6bc27bSMichael Roth  *)
60359d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
60369d6bc27bSMichael Roth    ;;
60379d6bc27bSMichael Roth  esac
60389d6bc27bSMichael Rothfi
60399d6bc27bSMichael Roth
6040ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6041ca35f780SPaolo Bonziniroms=
6042e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6043e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6044e633a5c6SEric Blake        test "$softmmu" = yes ; then
6045e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6046c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6047c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6048c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6049e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6050e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6051ca35f780SPaolo Bonzini            roms="optionrom"
6052e57218b6SPeter Maydell            break
6053e57218b6SPeter Maydell        fi
6054e57218b6SPeter Maydell    done
6055ca35f780SPaolo Bonzinifi
6056e633a5c6SEric Blakeif test "$cpu" = "ppc64" && test "$targetos" != "Darwin" ; then
605739ac8455SDavid Gibson  roms="$roms spapr-rtas"
605839ac8455SDavid Gibsonfi
6059ca35f780SPaolo Bonzini
60602e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
60619933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
60622e33c3f8SThomas Huth  write_c_skeleton
60632e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
60649933c305SChristian Borntraeger    roms="$roms s390-ccw"
60659933c305SChristian Borntraeger  fi
60662e33c3f8SThomas Huthfi
60679933c305SChristian Borntraeger
6068964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
606992fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
6070964c6fa1SRichard Henderson  textseg_addr=
6071964c6fa1SRichard Henderson  case "$cpu" in
6072479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
6073479eb121SRichard Henderson      # ??? Rationale for choosing this address
6074964c6fa1SRichard Henderson      textseg_addr=0x60000000
6075964c6fa1SRichard Henderson      ;;
6076964c6fa1SRichard Henderson    mips)
6077479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
6078479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
6079479eb121SRichard Henderson      textseg_addr=0x60000000
6080964c6fa1SRichard Henderson      ;;
6081964c6fa1SRichard Henderson  esac
6082964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
6083964c6fa1SRichard Henderson    cat > $TMPC <<EOF
6084964c6fa1SRichard Henderson    int main(void) { return 0; }
6085964c6fa1SRichard HendersonEOF
6086964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
6087964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
6088964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
6089964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
6090964c6fa1SRichard Henderson      # at least.
609192fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
609292fe2ba8SPeter Maydell        error_exit \
609392fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
609492fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
609592fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
609692fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
609792fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
609892fe2ba8SPeter Maydell            "--disable-user option to configure."
609992fe2ba8SPeter Maydell      fi
610092fe2ba8SPeter Maydell
6101964c6fa1SRichard Henderson      $ld --verbose | sed \
6102964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
6103964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
6104964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
6105964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
6106964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
6107964c6fa1SRichard Henderson    fi
6108964c6fa1SRichard Henderson  fi
6109964c6fa1SRichard Hendersonfi
6110964c6fa1SRichard Henderson
611111cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
611211cde1c8SBruno 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.
611311cde1c8SBruno Dominguezif has $cxx; then
611411cde1c8SBruno Dominguez    cat > $TMPC <<EOF
611511cde1c8SBruno Dominguezint c_function(void);
611611cde1c8SBruno Dominguezint main(void) { return c_function(); }
611711cde1c8SBruno DominguezEOF
611811cde1c8SBruno Dominguez
611911cde1c8SBruno Dominguez    compile_object
612011cde1c8SBruno Dominguez
612111cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
612211cde1c8SBruno Dominguezextern "C" {
612311cde1c8SBruno Dominguez   int c_function(void);
612411cde1c8SBruno Dominguez}
612511cde1c8SBruno Dominguezint c_function(void) { return 42; }
612611cde1c8SBruno DominguezEOF
612711cde1c8SBruno Dominguez
612811cde1c8SBruno Dominguez    update_cxxflags
612911cde1c8SBruno Dominguez
613011cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
613111cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
613211cde1c8SBruno Dominguez        :
613311cde1c8SBruno Dominguez    else
613411cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
613511cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
613611cde1c8SBruno Dominguez        cxx=
613711cde1c8SBruno Dominguez    fi
613811cde1c8SBruno Dominguezelse
613911cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
614011cde1c8SBruno Dominguez    cxx=
614111cde1c8SBruno Dominguezfi
614211cde1c8SBruno Dominguez
614302d34f62SCole Robinsonecho_version() {
614402d34f62SCole Robinson    if test "$1" = "yes" ; then
614502d34f62SCole Robinson        echo "($2)"
614602d34f62SCole Robinson    fi
614702d34f62SCole Robinson}
614802d34f62SCole Robinson
614950e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
615050e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
61518a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
615250e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
61535ca9388aSGerd Hoffmann
61547d13299dSbellardecho "Install prefix    $prefix"
615589138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
61563d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
615789138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
615889138857SStefan Weilecho "library directory $(eval echo $libdir)"
615989138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
616089138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
616189138857SStefan Weilecho "include directory $(eval echo $includedir)"
616289138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
616311d9f695Sbellardif test "$mingw32" = "no" ; then
616489138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
616589138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
616643ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
61675a699bbbSLaszlo Ersekelse
61685a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
6169d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
617011d9f695Sbellardfi
61715a67135aSbellardecho "Source path       $source_path"
6172cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
6173aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
61747d13299dSbellardecho "C compiler        $cc"
617583469015Sbellardecho "Host C compiler   $host_cc"
617683f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
61773c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
617845d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
61790c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
6180a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
61810c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
61828a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
61837d13299dSbellardecho "make              $make"
61846a882643Spbrookecho "install           $install"
6185755ee70fSCleber Rosaecho "python            $python ($python_version)"
6186675b9b53SMarc-André Lureauecho "slirp support     $slirp $(echo_version $slirp $slirp_version)"
6187675b9b53SMarc-André Lureauif test "$slirp" != "no" ; then
6188e2d8830eSBrad    echo "smbd              $smbd"
6189e2d8830eSBradfi
619017969268SFam Zhengecho "module support    $modules"
6191a98fd896Sbellardecho "host CPU          $cpu"
6192de83cd02Sbellardecho "host big endian   $bigendian"
619397a847bcSbellardecho "target list       $target_list"
61947d13299dSbellardecho "gprof enabled     $gprof"
619503b4fe7dSaliguoriecho "sparse enabled    $sparse"
61961625af87Saliguoriecho "strip binaries    $strip_opt"
619705c2a3e7Sbellardecho "profiler          $profiler"
619843ce4dfeSbellardecho "static build      $static"
61995b0753e0Sbellardif test "$darwin" = "yes" ; then
62005b0753e0Sbellard    echo "Cocoa support     $cocoa"
62015b0753e0Sbellardfi
620289138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
6203a442fe2fSDaniel P. Berrangéecho "SDL image support $sdl_image"
620489138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
6205925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
620689138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
6207a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
6208ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
620991bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
621089138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
62119a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
62128953caf3SDaniel P. Berrangeecho "PAM               $auth_pam"
62134d3b6f6eSbalrogecho "curses support    $curses"
621447479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6215769ce76dSAlexander Grafecho "curl support      $curl"
621667b915a5Sbellardecho "mingw32 support   $mingw32"
62170c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
6218b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
6219b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
6220983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
6221fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
6222821601eaSJes Sorensenecho "VNC support       $vnc"
6223821601eaSJes Sorensenif test "$vnc" = "yes" ; then
62242f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
62252f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
6226efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
6227821601eaSJes Sorensenfi
62283142255cSblueswir1if test -n "$sparc_cpu"; then
62293142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
62303142255cSblueswir1fi
6231e37630caSaliguoriecho "xen support       $xen"
62323996e85cSPaul Durrantif test "$xen" = "yes" ; then
62333996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
62343996e85cSPaul Durrantfi
62352e4d9fb1Saurel32echo "brlapi support    $brlapi"
6236a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
6237a25dba17SJuan Quintelaecho "Documentation     $docs"
623840d6444eSAvi Kivityecho "PIE               $pie"
62398a16d273Sthsecho "vde support       $vde"
624058952137SVincenzo Maffioneecho "netmap support    $netmap"
62415c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
6242758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
624377755340Sthsecho "Install blobs     $blobs"
6244b31a0277SJuan Quintelaecho "KVM support       $kvm"
6245b0cb0a66SVincent Palatinecho "HAX support       $hax"
6246c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
6247d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
6248b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
6249b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
6250b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
62519195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
6252b3f6ea7eSPaolo Bonzinifi
62535a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
6254b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
625521ab34c9SMarcel Apfelbaumecho "PVRDMA support    $pvrdma"
6256f652e6afSaurel32echo "fdt support       $fdt"
6257a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
6258ceb42de8Saliguoriecho "preadv support    $preadv"
62595f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
6260e78815a5SAndreas Färberecho "madvise           $madvise"
6261e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
62629bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
626347e98658SCorey Bryantecho "libcap-ng support $cap_ng"
6264d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
6265042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
62665e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
6267fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
6268e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
62695b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
6270713572a7SMarc-André Lureauif have_backend "simple"; then
62719410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
6272e00e36fbSStefan Weilfi
627389138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6274f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
6275dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
62767b02f544SMarc-André Lureauecho "smartcard support $smartcard"
62772b2325ffSGerd Hoffmannecho "libusb            $libusb"
627869354a83SHans de Goedeecho "usb net redir     $usb_redir"
6279da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
6280014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
6281c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
62826542aa9cSPeter Lievenecho "libnfs support    $libnfs"
6283d138cee9SMichael Rothecho "build guest agent $guest_agent"
6284d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
628550cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
62864c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
6287f794573eSEduardo Otuboecho "seccomp support   $seccomp"
62887c2acc70SPeter Maydellecho "coroutine backend $coroutine"
628970c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
62907d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
6291ba59fb77SPaolo Bonziniecho "mutex debugging   $debug_mutex"
6292f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
6293eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
62941d728c39SBlue Swirlecho "gcov              $gcov_tool"
62951d728c39SBlue Swirlecho "gcov enabled      $gcov"
6296ab214c29SStefan Bergerecho "TPM support       $tpm"
62970a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
62983b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
6299f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
63003556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
6301ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
6302607dacd0Sqiaonuohanecho "lzo support       $lzo"
6303607dacd0Sqiaonuohanecho "snappy support    $snappy"
63046b383c08SPeter Wuecho "bzip2 support     $bzip2"
630583bc1f97SJulio Faraccoecho "lzfse support     $lzfse"
6306a99d57bbSWanlong Gaoecho "NUMA host support $numa"
6307ed279a06SKlim Kireevecho "libxml2           $libxml2"
63082847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
63097b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
631099f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
6311a6b1d4c0SChanglong Xieecho "replication support $replication"
6312da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
63132f740136SJeff Codyecho "bochs support     $bochs"
63142f740136SJeff Codyecho "cloop support     $cloop"
63152f740136SJeff Codyecho "dmg support       $dmg"
63162f740136SJeff Codyecho "qcow v1 support   $qcow1"
63172f740136SJeff Codyecho "vdi support       $vdi"
63182f740136SJeff Codyecho "vvfat support     $vvfat"
63192f740136SJeff Codyecho "qed support       $qed"
63202f740136SJeff Codyecho "parallels support $parallels"
63212f740136SJeff Codyecho "sheepdog support  $sheepdog"
63228ca80760SRichard Hendersonecho "capstone          $capstone"
632351a12b51SAlex Bennéeecho "docker            $docker"
632417824406SJunyan Heecho "libpmem support   $libpmem"
63253efac6ebSTomáš Golembiovskýecho "libudev           $libudev"
6326f3494749SPaolo Bonziniecho "default devices   $default_devices"
632767b915a5Sbellard
6328898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
6329898be3e0SPeter Maydell    echo
6330898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6331898be3e0SPeter Maydell    echo
6332898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
6333898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
6334898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6335898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6336898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6337898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6338898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6339898be3e0SPeter Maydellfi
6340898be3e0SPeter Maydell
6341898be3e0SPeter Maydellif test "$supported_os" = "no"; then
6342898be3e0SPeter Maydell    echo
6343898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6344898be3e0SPeter Maydell    echo
6345c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
6346c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
6347898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6348898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6349898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6350898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6351898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6352898be3e0SPeter Maydellfi
6353898be3e0SPeter Maydell
635498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
635597a847bcSbellard
6356dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6357dbd99ae3SStefan Weil
635898ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
635998ec69acSJuan Quintelaecho >> $config_host_mak
636098ec69acSJuan Quintela
6361e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
636299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
636399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
63643aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
63658bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
63660f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
636799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
636899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
636922d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
63709afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
63713d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
63729afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6373e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
63745a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6375785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
63765a699bbbSLaszlo Ersekfi
6377f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6378834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6379a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
638067ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6381f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6382cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6383aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6384f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6385804edf29SJuan Quintela
638698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6387727e5283SPaolo Bonzini
6388f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6389f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6390f3494749SPaolo Bonzinielse
6391f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6392f3494749SPaolo Bonzinifi
6393f8393946Saurel32if test "$debug_tcg" = "yes" ; then
63942358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6395f8393946Saurel32fi
63961625af87Saliguoriif test "$strip_opt" = "yes" ; then
639752ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
63981625af87Saliguorifi
63997d13299dSbellardif test "$bigendian" = "yes" ; then
6400e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
640197a847bcSbellardfi
640267b915a5Sbellardif test "$mingw32" = "yes" ; then
640398ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
640489138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
64059fe6de94SBlue Swirl  version_major=${rc_version%%.*}
64069fe6de94SBlue Swirl  rc_version=${rc_version#*.}
64079fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
64089fe6de94SBlue Swirl  rc_version=${rc_version#*.}
64099fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
64109fe6de94SBlue Swirl  version_micro=0
64119fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
64129fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6413d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6414d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6415f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6416d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6417d9840e25STomoki Sekiyama  fi
641850cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
641976dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
642050cbebb9SMichael Roth  fi
64211a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
64229dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
64239dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
64249dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
64259dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
64269dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
64279dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
64289dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
64299dacf32dSYossi Hindin  fi
6430210fa556Spbrookelse
643135f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6432210fa556Spbrookfi
6433128ab2ffSblueswir1
6434dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6435dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6436dffcb71cSMark McLoughlinfi
6437dffcb71cSMark McLoughlin
643883fb7adfSbellardif test "$darwin" = "yes" ; then
643998ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
644083fb7adfSbellardfi
6441b29fe3edSmalc
6442ec530c81Sbellardif test "$solaris" = "yes" ; then
644398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6444ec530c81Sbellardfi
6445179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6446179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6447179cf400SAndreas Färberfi
644897a847bcSbellardif test "$static" = "yes" ; then
644998ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
645097a847bcSbellardfi
64511ba16968SStefan Weilif test "$profiler" = "yes" ; then
64522358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
645305c2a3e7Sbellardfi
6454675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
645598ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6456e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6457675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6458675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6459675b9b53SMarc-André Lureaufi
6460*1f773d9dSDaniel P. Berrangéif [ "$slirp" = "internal" ]; then
6461675b9b53SMarc-André Lureau    echo "config-host.h: subdir-slirp" >> $config_host_mak
6462c20709aaSbellardfi
64638a16d273Sthsif test "$vde" = "yes" ; then
646498ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6465e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
64668a16d273Sthsfi
646758952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
646858952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
646958952137SVincenzo Maffionefi
6470015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6471015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6472015a33bdSGongleifi
647347e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
647447e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
647547e98658SCorey Bryantfi
64762358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
64770c58ac1cSmalcfor drv in $audio_drv_list; do
64781ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6479ce3dc033SGerd Hoffmann    case "$drv" in
6480051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6481ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6482ce3dc033SGerd Hoffmann	*)
6483ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6484ce3dc033SGerd Hoffmann    esac
64850c58ac1cSmalcdone
6486b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6487b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6488b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6489b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6490b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
649167f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
649267f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
649367f86e8eSJuan Quintelafi
6494d5631638Smalcif test "$audio_win_int" = "yes" ; then
6495d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6496d5631638Smalcfi
6497b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6498b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6499821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6500821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6501821601eaSJes Sorensenfi
65022f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
650398ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
65042f9606b3Saliguorifi
6505821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
65062f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
65072f6f5c7aSCorentin Charyfi
6508821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6509efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6510efe556adSCorentin Charyfi
65116a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
65126a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
65136a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
65146a021536SGerd Hoffmannfi
6515dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6516dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6517dce512deSChristoph Hellwigfi
651889138857SStefan Weilqemu_version=$(head $source_path/VERSION)
651998ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
65202358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
652198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
65222b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6523a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
652498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6525cc8ae6deSpbrookfi
652617969268SFam Zhengif test "$modules" = "yes"; then
6527e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6528e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
652989138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
653017969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
653117969268SFam Zhengfi
6532e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
65338781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
65348781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
65358781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
65368781595bSGerd Hoffmannfi
65371ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
653896400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
65398ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
65408ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6541a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes" ; then
6542a442fe2fSDaniel P. Berrangé      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
6543a442fe2fSDaniel P. Berrangé  fi
654449ecc3faSbellardfi
654549ecc3faSbellardif test "$cocoa" = "yes" ; then
654698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
654749ecc3faSbellardfi
65484d3b6f6eSbalrogif test "$curses" = "yes" ; then
65492373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
65502373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
65512373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6552ab4e5602SJan Kiszkafi
6553099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
65542358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6555099d6b0fSRiku Voipiofi
655640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
655740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
655840ff6d7eSKevin Wolffi
65593ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
65602358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
65613ce34dfbSvibisreenivasanfi
6562c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6563c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6564c2882b96SRiku Voipiofi
6565751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6566751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6567751bcc39SMarc-André Lureaufi
6568955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6569955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6570955727d2SCortland Tölvafi
6571d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6572d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6573d0927938SUlrich Hechtfi
65743d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
65753d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
65763d4fa43eSKusanagi Kouichifi
6577b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6578b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6579b953f075SDenis V. Lunevfi
6580ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6581ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6582ed911435SKevin Wolffi
6583c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6584c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6585c727f47dSPeter Maydellfi
6586dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6587dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6588dace20dcSPeter Maydellfi
6589d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6590d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6591d0927938SUlrich Hechtfi
65924e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
65934e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
65944e0c6529SAlex Blighfi
6595cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6596cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6597cd758dd0SAlex Blighfi
65983b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
65993b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
66003b6edd16SPeter Maydellfi
66013b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
66023b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
66033b6edd16SPeter Maydellfi
6604a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6605a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6606a8fd1abaSPeter Maydellfi
660751834341SRiku Voipioif test "$timerfd" = "yes" ; then
660851834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
660951834341SRiku Voipiofi
66109af5c906SRiku Voipioif test "$setns" = "yes" ; then
66119af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
66129af5c906SRiku Voipiofi
661338860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
661438860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
661538860a03SAleksandar Markovicfi
66165a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
66175a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
66185a03cd00SAleksandar Markovicfi
66193b3f24adSaurel32if test "$inotify" = "yes" ; then
66202358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
66213b3f24adSaurel32fi
6622c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6623c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6624c05c7a73SRiku Voipiofi
6625401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6626401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6627401bc051SPeter Maydellfi
66285c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
66295c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
66305c99fa37SKeno Fischerfi
66316ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
66326ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
66336ae9a1f4SJuan Quintelafi
66346ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
66356ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
66366ae9a1f4SJuan Quintelafi
6637769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6638d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6639b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
66406ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6641769ce76dSAlexander Graffi
66422e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
664398ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
66448eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
66452e4d9fb1Saurel32fi
6646fb599c9aSbalrogif test "$bluez" = "yes" ; then
664798ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
6648ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6649fb599c9aSbalrogfi
6650a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6651e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6652a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6653014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6654925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6655925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6656925a0400SGerd Hoffmann  fi
6657bbbf9bfbSStefan Weilfi
6658f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6659f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6660f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6661f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
6662f876b765SMarc-André Lureaufi
6663a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6664ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6665ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6666ddbb0d09SDaniel P. Berrangefi
666791bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
666891bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
66691f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
66701f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
66711f923c70SLongpeng(Mike)  fi
667262893b67SDaniel P. Berrangefi
667391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
667491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6675becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6676ed754746SDaniel P. Berrangefi
66779a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
66789a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
66799a2fd434SDaniel P. Berrangefi
66808953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
66818953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
66828953caf3SDaniel P. Berrangefi
6683559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6684559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6685559607eaSDaniel P. Berrangefi
66866b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
66876b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
66886b39b063SEric Blakefi
6689277abf15SJan Vesely
6690277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6691277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6692277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6693277abf15SJan Vesely# if this macro is set.
6694277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6695277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6696277abf15SJan Veselyfi
66971efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
66981efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
66991efad060SFam Zhengfi
6700bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6701bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6702a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6703e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6704a4ccabcfSAnthony Liguorifi
67059d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
67069d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
67079d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
67089d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
67099d9e1521SGerd Hoffmannfi
6710e37630caSaliguoriif test "$xen" = "yes" ; then
67116dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6712d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6713e37630caSaliguorifi
67145c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
67155c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
67165c6c3a6cSChristoph Hellwigfi
6717758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6718758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6719758e8e38SVenkateswararao Jujjuri (JV)fi
67204f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
67214f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
67224f26f2b6SAvi Kivityfi
6723983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6724758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6725758e8e38SVenkateswararao Jujjuri (JV)fi
6726fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6727fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
67281b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
67291b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
67301b0578f5SMurilo Opsfelder Araujo  fi
6731fe8fc5aeSPaolo Bonzinifi
67325e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
67335e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
67345e9be92dSNicholas Bellingerfi
6735af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
6736af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
6737af3bba76SPaolo Bonzinifi
6738af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
673956f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
674003ce5744SNikolay Nikolaevfi
6741042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6742042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6743042cea27SGongleifi
6744fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6745fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6746fc0b9b0eSStefan Hajnoczifi
6747299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
6748299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
6749299e6f19SPaolo Bonzinifi
6750e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6751e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6752e6a74868SMarc-André Lureaufi
675377755340Sthsif test "$blobs" = "yes" ; then
675498ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
675577755340Sthsfi
6756bf9298b9Saliguoriif test "$iovec" = "yes" ; then
67572358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6758bf9298b9Saliguorifi
6759ceb42de8Saliguoriif test "$preadv" = "yes" ; then
67602358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6761ceb42de8Saliguorifi
6762e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
67633f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6764f652e6afSaurel32fi
6765a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6766a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6767a40161cbSPaolo Bonzinifi
6768dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6769dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6770dcc38d1cSMarcelo Tosattifi
6771d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
6772d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
6773d339d766SRichard W.M. Jonesfi
6774b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6775b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
67769195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
67779195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
67789195b2c2SStefan Weil  fi
6779b3f6ea7eSPaolo Bonzinifi
67805f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
67815f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
67825f6b9e8fSBlue Swirlfi
6783e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6784e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6785e78815a5SAndreas Färberfi
6786e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6787e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6788e78815a5SAndreas Färberfi
67899bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
67909bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
67919bc5a719SAndreas Gustafssonfi
679297a847bcSbellard
6793cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6794cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6795cd4ec0b4SGerd Hoffmannfi
6796cd4ec0b4SGerd Hoffmann
67977b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
67987b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
67997b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
68007b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6801111a38b0SRobert Relyeafi
6802111a38b0SRobert Relyea
68032b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
68042b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6805b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6806b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
68072b2325ffSGerd Hoffmannfi
68082b2325ffSGerd Hoffmann
680969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
681069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6811cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6812cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
681369354a83SHans de Goedefi
681469354a83SHans de Goede
6815da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6816da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6817da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6818014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6819014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6820014cb152SGerd Hoffmann  fi
682120ff075bSMichael Wallefi
682220ff075bSMichael Walle
68235a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
68245a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
68255a22ab71SYang Zhongfi
68265a22ab71SYang Zhong
682799f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
682899f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
682999f2dbd3SLiang Lifi
683099f2dbd3SLiang Li
6831607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6832607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6833607dacd0Sqiaonuohanfi
6834607dacd0Sqiaonuohan
6835607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6836607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6837607dacd0Sqiaonuohanfi
6838607dacd0Sqiaonuohan
68396b383c08SPeter Wuif test "$bzip2" = "yes" ; then
68406b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
68416b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
68426b383c08SPeter Wufi
68436b383c08SPeter Wu
684483bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
684583bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
684683bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
684783bc1f97SJulio Faraccofi
684883bc1f97SJulio Faracco
6849c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6850d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
68516ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
68526ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6853c589b249SRonnie Sahlbergfi
6854c589b249SRonnie Sahlberg
68556542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
68564be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
68574be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
68586542aa9cSPeter Lievenfi
68596542aa9cSPeter Lieven
6860f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6861f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6862c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6863c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6864f794573eSEduardo Otubofi
6865f794573eSEduardo Otubo
686683fb7adfSbellard# XXX: suppress that
68677d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
68682358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
68697d3505c5Sbellardfi
68707d3505c5Sbellard
68714d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
68724d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
68734d9310f4SDaniel P. Berrangefi
68743556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
68753556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
68763556c233SPaolo Bonzinifi
6877f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6878d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
68796ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
68806ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6881f27aaf4bSChristian Brunnerfi
688220ff6c80SAnthony Liguori
68837c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
688470c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
688570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
688670c60c08SStefan Hajnoczielse
688770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
688870c60c08SStefan Hajnoczifi
6889d0e2fce5SAneesh Kumar K.V
68907d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
68917d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
68927d992e4dSPeter Lievenfi
68937d992e4dSPeter Lieven
6894f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6895f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6896f0d92b56SLongpeng(Mike)fi
6897f0d92b56SLongpeng(Mike)
6898d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6899d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6900d2042378SAneesh Kumar K.Vfi
6901d2042378SAneesh Kumar K.V
6902e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6903e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6904e06a765eSHarsh Prateek Borafi
6905e06a765eSHarsh Prateek Bora
6906cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6907cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
690806d71fa1SPeter Maydellfi
690906d71fa1SPeter Maydell
69103f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
69113f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
69123f4349dcSKevin Wolffi
69133f4349dcSKevin Wolf
6914d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
6915d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6916d83414e1SMarc-André Lureaufi
6917d83414e1SMarc-André Lureau
69188ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
69198ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
69208ab1bf12SLuiz Capitulinofi
69218ab1bf12SLuiz Capitulino
692276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
692376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
692476a347e1SRichard Hendersonfi
692576a347e1SRichard Henderson
6926f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6927f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6928f540166bSRichard Hendersonfi
6929f540166bSRichard Henderson
69307ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
69317ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
69327ebee43eSRichard Hendersonfi
69337ebee43eSRichard Henderson
6934e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
6935e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
6936e6cd4bb5SRichard Hendersonfi
6937e6cd4bb5SRichard Henderson
6938df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6939df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6940df79b996SRichard Hendersonfi
6941df79b996SRichard Henderson
6942db432672SRichard Hendersonif test "$vector16" = "yes" ; then
6943db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
6944db432672SRichard Hendersonfi
6945db432672SRichard Henderson
69461e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
69471e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
69481e6e9acaSRichard Hendersonfi
69491e6e9acaSRichard Henderson
6950eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6951d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
69526ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
69536ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6954eb100396SBharata B Raofi
6955eb100396SBharata B Rao
6956d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6957d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6958d85fa9ebSJeff Codyfi
6959d85fa9ebSJeff Cody
69600c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
69610c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
69620c14fb47SBharata B Raofi
69630c14fb47SBharata B Rao
6964df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6965df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6966df3a429aSNiels de Vosfi
6967df3a429aSNiels de Vos
69687c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
69697c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
69707c815372SBharata B Raofi
69717c815372SBharata B Rao
69720a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6973d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
69746ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
69756ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
69760a12ec87SRichard W.M. Jonesfi
69770a12ec87SRichard W.M. Jones
6978ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6979ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6980ed1701c6SDr. David Alan Gilbertfi
6981ed1701c6SDr. David Alan Gilbert
69823b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
69833b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6984f4ede81eSAmarnath Valluri  # TPM passthrough support?
69853b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
69863b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
69873b8acc11SPaolo Bonzini  fi
6988f4ede81eSAmarnath Valluri  # TPM emulator support?
6989f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6990f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6991f4ede81eSAmarnath Valluri  fi
69923b8acc11SPaolo Bonzinifi
69933b8acc11SPaolo Bonzini
69945b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
69955b808275SLluís Vilanovaif have_backend "nop"; then
69966d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
699722890ab5SPrerna Saxenafi
69985b808275SLluís Vilanovaif have_backend "simple"; then
69996d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
70006d8a764eSLluís  # Set the appropriate trace file.
7001953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
70029410b56cSPrerna Saxenafi
7003ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7004ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
70056d8a764eSLluísfi
70065b808275SLluís Vilanovaif have_backend "ust"; then
70076d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
70086d8a764eSLluísfi
70095b808275SLluís Vilanovaif have_backend "dtrace"; then
70106d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
70116d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
70126d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
70136d8a764eSLluís  fi
7014c276b17dSDaniel P. Berrangefi
70155b808275SLluís Vilanovaif have_backend "ftrace"; then
7016781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7017781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7018781e9545SEiichi Tsukata  else
701921684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7020781e9545SEiichi Tsukata  fi
7021781e9545SEiichi Tsukatafi
70220a852417SPaul Durrantif have_backend "syslog"; then
70230a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
70240a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
70250a852417SPaul Durrant  else
70260a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
70270a852417SPaul Durrant  fi
70280a852417SPaul Durrantfi
70299410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
70309410b56cSPrerna Saxena
70312da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
70322da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7033392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
70342da776dbSMichael R. Hinesfi
70352da776dbSMichael R. Hines
703621ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
703721ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
703821ab34c9SMarcel Apfelbaumfi
703921ab34c9SMarcel Apfelbaum
7040575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7041575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7042575b22b1SLaurent Vivierfi
7043575b22b1SLaurent Vivier
7044ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7045ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7046ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7047ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7048ed279a06SKlim Kireevfi
7049ed279a06SKlim Kireev
7050a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7051a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7052a6b1d4c0SChanglong Xiefi
7053a6b1d4c0SChanglong Xie
70546a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
70556a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
70566a02c806SStefan Hajnoczifi
70576a02c806SStefan Hajnoczi
70584d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
70594d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
70604d04351fSChristopher Covingtonfi
70614d04351fSChristopher Covington
706249e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
706349e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
706449e00a18SAndreas Grapentinfi
706549e00a18SAndreas Grapentin
7066e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7067e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7068e674605fSTomáš Golembiovskýfi
7069e674605fSTomáš Golembiovský
7070e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7071e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7072e0580342SKamil Rytarowskifi
7073e219c499SRichard Hendersonif test "$capstone" != "no" ; then
70748ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
70758ca80760SRichard Hendersonfi
7076ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7077ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7078ba59fb77SPaolo Bonzinifi
7079e0580342SKamil Rytarowski
70805c312079SDr. David Alan Gilbert# Hold two types of flag:
70815c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
70825c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7083479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
70845c312079SDr. David Alan Gilbert#                                     platform
7085479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
70865c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7087479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7088479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7089479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7090479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
70915c312079SDr. David Alan Gilbertfi
70925c312079SDr. David Alan Gilbert
7093da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
7094da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
7095da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
7096da92c3ffSAshish Mittalfi
7097da92c3ffSAshish Mittal
709817824406SJunyan Heif test "$libpmem" = "yes" ; then
709917824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
710017824406SJunyan Hefi
710117824406SJunyan He
71022f740136SJeff Codyif test "$bochs" = "yes" ; then
71032f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
71042f740136SJeff Codyfi
71052f740136SJeff Codyif test "$cloop" = "yes" ; then
71062f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
71072f740136SJeff Codyfi
71082f740136SJeff Codyif test "$dmg" = "yes" ; then
71092f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
71102f740136SJeff Codyfi
71112f740136SJeff Codyif test "$qcow1" = "yes" ; then
71122f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
71132f740136SJeff Codyfi
71142f740136SJeff Codyif test "$vdi" = "yes" ; then
71152f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
71162f740136SJeff Codyfi
71172f740136SJeff Codyif test "$vvfat" = "yes" ; then
71182f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
71192f740136SJeff Codyfi
71202f740136SJeff Codyif test "$qed" = "yes" ; then
71212f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
71222f740136SJeff Codyfi
71232f740136SJeff Codyif test "$parallels" = "yes" ; then
71242f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
71252f740136SJeff Codyfi
71262f740136SJeff Codyif test "$sheepdog" = "yes" ; then
71272f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
71282f740136SJeff Codyfi
71292f740136SJeff Cody
71305b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
71319edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
71325b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
71339edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
71345b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
71359edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7136e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
71379edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
713840d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
71399edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7140e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
7141c4f80543SAlistair Francis  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
71425b5e3037SPaolo Bonzinielse
71439edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
71445b5e3037SPaolo Bonzinifi
71459edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
71465b5e3037SPaolo Bonzini
714798ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
714898ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7149804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7150804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
71511901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
71521901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
71531901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
715421655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7155c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
7156755ee70fSCleber Rosaecho "PYTHON_VERSION=$python_version" >> $config_host_mak
7157804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7158a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7159a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
7160a31a8642SMichael S. Tsirkinfi
7161804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
716283f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
71633c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7164804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
716545d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7166cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
71675f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
71683dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7169804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7170804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
71719f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
71724852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
71739fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7174e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
717546eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7176a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
717711cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7178f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7179e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7180e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
718180fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
71822944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
7183e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
7184e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7185e39f0062SPaolo Bonzinifi
718642da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
718742da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
718842da6041SGerd Hoffmannelse
718942da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
719042da6041SGerd Hoffmannfi
7191e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
719246eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
71938a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
71946969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7195e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
719673da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
71973e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7198409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7199804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
720017969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
720117969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7202957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
720390246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
720490246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
720594dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
72061d728c39SBlue Swirlif test "$gcov" = "yes" ; then
72071d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
72081d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
72091d728c39SBlue Swirlfi
7210804edf29SJuan Quintela
721151a12b51SAlex Bennéeif test "$docker" != "no"; then
721251a12b51SAlex Bennée    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
721351a12b51SAlex Bennéefi
721451a12b51SAlex Bennée
72153efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
72163efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
72173efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
72183efac6ebSTomáš Golembiovskýfi
72193efac6ebSTomáš Golembiovský
72206efd7517SPeter Maydell# use included Linux headers
72216efd7517SPeter Maydellif test "$linux" = "yes" ; then
7222a307beb6SAndreas Färber  mkdir -p linux-headers
72236efd7517SPeter Maydell  case "$cpu" in
7224c72b26ecSRichard Henderson  i386|x86_64|x32)
722508312a63SPeter Maydell    linux_arch=x86
72266efd7517SPeter Maydell    ;;
7227a69dc537SThomas Huth  ppc|ppc64)
722808312a63SPeter Maydell    linux_arch=powerpc
72296efd7517SPeter Maydell    ;;
72306efd7517SPeter Maydell  s390x)
723108312a63SPeter Maydell    linux_arch=s390
723208312a63SPeter Maydell    ;;
72331f080313SClaudio Fontana  aarch64)
72341f080313SClaudio Fontana    linux_arch=arm64
72351f080313SClaudio Fontana    ;;
7236222e7d11SSanjay Lal  mips64)
7237222e7d11SSanjay Lal    linux_arch=mips
7238222e7d11SSanjay Lal    ;;
723908312a63SPeter Maydell  *)
724008312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
724108312a63SPeter Maydell    linux_arch="$cpu"
72426efd7517SPeter Maydell    ;;
72436efd7517SPeter Maydell  esac
724408312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
724508312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
724608312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
724708312a63SPeter Maydell    fi
72486efd7517SPeter Maydellfi
72496efd7517SPeter Maydell
725097a847bcSbellardfor target in $target_list; do
725197a847bcSbellardtarget_dir="$target"
725225be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
725389138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
725497a847bcSbellardtarget_bigendian="no"
72551f3d3c8fSJuan Quintela
7256c1799a84SPaolo Bonzinicase "$target_name" in
7257a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7258ea2d6a39SJuan Quintela  target_bigendian=yes
7259ea2d6a39SJuan Quintela  ;;
7260ea2d6a39SJuan Quintelaesac
726197a847bcSbellardtarget_softmmu="no"
7262997344f3Sbellardtarget_user_only="no"
7263831b7825Sthstarget_linux_user="no"
726484778508Sblueswir1target_bsd_user="no"
72659e407a85Spbrookcase "$target" in
7266c1799a84SPaolo Bonzini  ${target_name}-softmmu)
72679e407a85Spbrook    target_softmmu="yes"
72689e407a85Spbrook    ;;
7269c1799a84SPaolo Bonzini  ${target_name}-linux-user)
72709e407a85Spbrook    target_user_only="yes"
72719e407a85Spbrook    target_linux_user="yes"
72729e407a85Spbrook    ;;
7273c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
727484778508Sblueswir1    target_user_only="yes"
727584778508Sblueswir1    target_bsd_user="yes"
727684778508Sblueswir1    ;;
72779e407a85Spbrook  *)
727876ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
72799e407a85Spbrook    exit 1
72809e407a85Spbrook    ;;
72819e407a85Spbrookesac
7282831b7825Sths
7283d75402b5SAlex Bennéetarget_compiler=""
7284d75402b5SAlex Bennéetarget_compiler_static=""
7285716a507cSAlex Bennéetarget_compiler_cflags=""
7286d75402b5SAlex Bennée
728797a847bcSbellardmkdir -p $target_dir
728825be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
728997a847bcSbellard
7290e5fe0c52Spbrookbflt="no"
7291ca759f9eSAlex Bennéemttcg="no"
729289138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
729356aebc89Spbrookgdb_xml_files=""
72947ba1e619Saliguori
7295c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
72966acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7297e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
7298e73aae67SJuan Quintela
7299c1799a84SPaolo Bonzinicase "$target_name" in
73002408a527Saurel32  i386)
73010a7fa00aSEmilio G. Cota    mttcg="yes"
73027b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
7303d75402b5SAlex Bennée    target_compiler=$cross_cc_i386
7304716a507cSAlex Bennée    target_compiler_cflags=$cross_cc_ccflags_i386
73052408a527Saurel32  ;;
73062408a527Saurel32  x86_64)
73076acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
73080a7fa00aSEmilio G. Cota    mttcg="yes"
73097b0f97baSDoug Gale	gdb_xml_files="i386-64bit.xml"
7310d75402b5SAlex Bennée    target_compiler=$cross_cc_x86_64
73112408a527Saurel32  ;;
73122408a527Saurel32  alpha)
73135ee4f3c2SRichard Henderson    mttcg="yes"
7314d75402b5SAlex Bennée    target_compiler=$cross_cc_alpha
73152408a527Saurel32  ;;
73162408a527Saurel32  arm|armeb)
7317b498c8a0SJuan Quintela    TARGET_ARCH=arm
7318e5fe0c52Spbrook    bflt="yes"
7319ca759f9eSAlex Bennée    mttcg="yes"
732056aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7321d75402b5SAlex Bennée    target_compiler=$cross_cc_arm
7322d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
73232408a527Saurel32  ;;
7324722dd7beSMichael Weiser  aarch64|aarch64_be)
7325722dd7beSMichael Weiser    TARGET_ARCH=aarch64
73266a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
73276a49fa95SAlexander Graf    bflt="yes"
7328ca759f9eSAlex Bennée    mttcg="yes"
73298f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7330d75402b5SAlex Bennée    target_compiler=$cross_cc_aarch64
7331d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
73326a49fa95SAlexander Graf  ;;
73332408a527Saurel32  cris)
7334d75402b5SAlex Bennée    target_compiler=$cross_cc_cris
73352408a527Saurel32  ;;
733661766fe9SRichard Henderson  hppa)
73377b93dab5SRichard Henderson    mttcg="yes"
7338d75402b5SAlex Bennée    target_compiler=$cross_cc_hppa
733961766fe9SRichard Henderson  ;;
7340613a22c9SMichael Walle  lm32)
7341d75402b5SAlex Bennée    target_compiler=$cross_cc_lm32
7342613a22c9SMichael Walle  ;;
73432408a527Saurel32  m68k)
73440938cda5Saurel32    bflt="yes"
73455a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7346d75402b5SAlex Bennée    target_compiler=$cross_cc_m68k
73472408a527Saurel32  ;;
7348877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7349877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
735072b675caSEdgar E. Iglesias    bflt="yes"
7351be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
7352d75402b5SAlex Bennée    target_compiler=$cross_cc_microblaze
735372b675caSEdgar E. Iglesias  ;;
73542408a527Saurel32  mips|mipsel)
73550454728cSAleksandar Markovic    mttcg="yes"
7356b498c8a0SJuan Quintela    TARGET_ARCH=mips
7357d75402b5SAlex Bennée    target_compiler=$cross_cc_mips
735825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
73592408a527Saurel32  ;;
73602408a527Saurel32  mipsn32|mipsn32el)
73610454728cSAleksandar Markovic    mttcg="yes"
7362597e2cecSRichard Henderson    TARGET_ARCH=mips64
73636acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7364d75402b5SAlex Bennée    target_compiler=$cross_cc_mipsn32
736525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7366597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
73672408a527Saurel32  ;;
73682408a527Saurel32  mips64|mips64el)
73690454728cSAleksandar Markovic    mttcg="yes"
7370b498c8a0SJuan Quintela    TARGET_ARCH=mips64
73716acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7372d75402b5SAlex Bennée    target_compiler=$cross_cc_mips64
737325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
73742408a527Saurel32  ;;
7375d15a9c23SAnthony Green  moxie)
7376d75402b5SAlex Bennée    target_compiler=$cross_cc_moxie
7377d15a9c23SAnthony Green  ;;
7378e671711cSMarek Vasut  nios2)
7379d75402b5SAlex Bennée    target_compiler=$cross_cc_nios2
7380e671711cSMarek Vasut  ;;
73814a09d0bbSRichard Henderson  or1k)
7382d75402b5SAlex Bennée    target_compiler=$cross_cc_or1k
7383e67db06eSJia Liu    TARGET_ARCH=openrisc
7384e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7385e67db06eSJia Liu  ;;
73862408a527Saurel32  ppc)
7387c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7388d75402b5SAlex Bennée    target_compiler=$cross_cc_powerpc
73892408a527Saurel32  ;;
73902408a527Saurel32  ppc64)
73916acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7392e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7393f0b0685dSNikunj A Dadhania    mttcg=yes
73941438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7395d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64
73962408a527Saurel32  ;;
73979c35126cSDoug Kwan  ppc64le)
73989c35126cSDoug Kwan    TARGET_ARCH=ppc64
73999c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
74009c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
7401f0b0685dSNikunj A Dadhania    mttcg=yes
74021438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7403d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64le
74049c35126cSDoug Kwan  ;;
74052408a527Saurel32  ppc64abi32)
7406b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
74076acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7408e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
740925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
74101438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7411d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64abi32
74122408a527Saurel32  ;;
741325fa194bSMichael Clark  riscv32)
741425fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
741525fa194bSMichael Clark    TARGET_ABI_DIR=riscv
741625fa194bSMichael Clark    mttcg=yes
7417d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv32
741825fa194bSMichael Clark  ;;
741925fa194bSMichael Clark  riscv64)
742025fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
742125fa194bSMichael Clark    TARGET_ABI_DIR=riscv
742225fa194bSMichael Clark    mttcg=yes
7423d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv64
742425fa194bSMichael Clark  ;;
74252408a527Saurel32  sh4|sh4eb)
7426b498c8a0SJuan Quintela    TARGET_ARCH=sh4
74274dbed897Spbrook    bflt="yes"
7428d75402b5SAlex Bennée    target_compiler=$cross_cc_sh4
74292408a527Saurel32  ;;
74302408a527Saurel32  sparc)
7431d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc
74322408a527Saurel32  ;;
74332408a527Saurel32  sparc64)
74346acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7435d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc64
74362408a527Saurel32  ;;
74372408a527Saurel32  sparc32plus)
7438b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
74396acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7440e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7441d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc32plus
744225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
74432408a527Saurel32  ;;
744424e804ecSAlexander Graf  s390x)
744563685bc4SDavid Hildenbrand    mttcg=yes
744686158a2aSChristian 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"
7447d75402b5SAlex Bennée    target_compiler=$cross_cc_s390x
744824e804ecSAlexander Graf  ;;
7449444e06b1SChen Gang  tilegx)
7450d75402b5SAlex Bennée    target_compiler=$cross_cc_tilegx
7451444e06b1SChen Gang  ;;
74525ecaa4edSPeter Crosthwaite  tricore)
7453d75402b5SAlex Bennée    target_compiler=$cross_cc_tricore
74545ecaa4edSPeter Crosthwaite  ;;
7455d2fbca94SGuan Xuetao  unicore32)
7456d75402b5SAlex Bennée    target_compiler=$cross_cc_unicore32
7457d2fbca94SGuan Xuetao  ;;
7458cfa550c6SMax Filippov  xtensa|xtensaeb)
7459cfa550c6SMax Filippov    TARGET_ARCH=xtensa
746002e33e9fSMax Filippov    bflt="yes"
74619fb40342SMax Filippov    mttcg="yes"
7462d75402b5SAlex Bennée    target_compiler=$cross_cc_xtensa
7463cfa550c6SMax Filippov  ;;
74642408a527Saurel32  *)
746576ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
74662408a527Saurel32  ;;
74672408a527Saurel32esac
74685e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
74695e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
74705e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
74715e8861a0SPaolo Bonzinifi
74725e8861a0SPaolo Bonzini
7473d75402b5SAlex Bennée# Do we have a cross compiler for this target?
7474d75402b5SAlex Bennéeif has $target_compiler; then
7475d75402b5SAlex Bennée
7476d75402b5SAlex Bennée    write_c_skeleton
7477d75402b5SAlex Bennée
7478716a507cSAlex Bennée    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7479d75402b5SAlex Bennée        # For host systems we might get away with building without -static
7480716a507cSAlex Bennée        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7481d75402b5SAlex Bennée            target_compiler=""
7482d75402b5SAlex Bennée        else
7483d75402b5SAlex Bennée            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7484d75402b5SAlex Bennée            target_compiler_static="n"
7485d75402b5SAlex Bennée        fi
7486d75402b5SAlex Bennée    else
7487d75402b5SAlex Bennée        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7488d75402b5SAlex Bennée        target_compiler_static="y"
7489d75402b5SAlex Bennée    fi
7490d75402b5SAlex Bennéeelse
7491d75402b5SAlex Bennée    target_compiler=""
7492d75402b5SAlex Bennéefi
7493d75402b5SAlex Bennée
74945e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
74955e8861a0SPaolo Bonzini
749699afc91dSDaniel P. Berrangeupper() {
749799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
749899afc91dSDaniel P. Berrange}
749999afc91dSDaniel P. Berrange
750089138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
750125be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7502c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
750325be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7504e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7505e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7506e6e91b9cSJuan Quintelafi
750725be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7508adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7509adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7510adfc3e91SStacey Sonfi
75113b6b7550SPaolo Bonzini
75123b6b7550SPaolo Bonziniif supported_xen_target $target; then
751325be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7514e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
7515eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7516eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7517eb6fda0fSAnthony PERARD    fi
7518e0e312f3SPaolo Bonzinielse
7519e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
7520432d268cSJun Nakajimafi
75213b6b7550SPaolo Bonziniif supported_kvm_target $target; then
752225be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
7523e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
7524e0e312f3SPaolo Bonzinielse
7525e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
7526c59249f9SJuan Quintelafi
75273b6b7550SPaolo Bonziniif supported_hax_target $target; then
7528b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7529b0cb0a66SVincent Palatinfi
7530c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7531c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7532c97d6d2cSSergio Andres Gomez Del Realfi
7533d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7534d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7535d661d9a4SJustin Terry (VM)fi
7536de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
753725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
753897a847bcSbellardfi
753997a847bcSbellardif test "$target_softmmu" = "yes" ; then
754025be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7541ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7542ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7543ca759f9eSAlex Bennée  fi
7544de83cd02Sbellardfi
7545997344f3Sbellardif test "$target_user_only" = "yes" ; then
754625be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7547a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7548997344f3Sbellardfi
7549831b7825Sthsif test "$target_linux_user" = "yes" ; then
755025be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7551831b7825Sthsfi
755256aebc89Spbrooklist=""
755356aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
755456aebc89Spbrook  for x in $gdb_xml_files; do
755556aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
755656aebc89Spbrook  done
755725be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
75583d0f1517SJuan Quintelafi
7559de83cd02Sbellard
7560e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
756125be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7562e5fe0c52Spbrookfi
756384778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
756425be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
756584778508Sblueswir1fi
75665b0753e0Sbellard
7567d75402b5SAlex Bennéeif test -n "$target_compiler"; then
7568d75402b5SAlex Bennée  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7569d75402b5SAlex Bennée
7570d75402b5SAlex Bennée  if test -n "$target_compiler_static"; then
7571d75402b5SAlex Bennée      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7572d75402b5SAlex Bennée  fi
7573716a507cSAlex Bennée
7574716a507cSAlex Bennée  if test -n "$target_compiler_cflags"; then
7575716a507cSAlex Bennée      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7576d75402b5SAlex Bennée  fi
7577716a507cSAlex Bennéefi
7578716a507cSAlex Bennée
7579d75402b5SAlex Bennée
75804afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7581fa282484SJuan Quintela
75824afddb55SJuan Quintelacflags=""
7583fa282484SJuan Quintelaldflags=""
75849b8e111fSJuan Quintela
7585c765fcacSPeter Crosthwaitedisas_config() {
7586c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7587c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7588c765fcacSPeter Crosthwaite}
7589c765fcacSPeter Crosthwaite
759064656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
759164656024SJuan Quintela  case "$i" in
759264656024SJuan Quintela  alpha)
7593c765fcacSPeter Crosthwaite    disas_config "ALPHA"
759464656024SJuan Quintela  ;;
759582295d8aSRichard Henderson  aarch64)
759682295d8aSRichard Henderson    if test -n "${cxx}"; then
7597c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
759882295d8aSRichard Henderson    fi
759982295d8aSRichard Henderson  ;;
760064656024SJuan Quintela  arm)
7601c765fcacSPeter Crosthwaite    disas_config "ARM"
7602999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7603c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7604999b53ecSClaudio Fontana    fi
760564656024SJuan Quintela  ;;
760664656024SJuan Quintela  cris)
7607c765fcacSPeter Crosthwaite    disas_config "CRIS"
760864656024SJuan Quintela  ;;
7609429b31a2SRichard Henderson  hppa)
7610429b31a2SRichard Henderson    disas_config "HPPA"
7611429b31a2SRichard Henderson  ;;
7612c72b26ecSRichard Henderson  i386|x86_64|x32)
7613c765fcacSPeter Crosthwaite    disas_config "I386"
761464656024SJuan Quintela  ;;
761579368f49SMichael Walle  lm32)
7616c765fcacSPeter Crosthwaite    disas_config "LM32"
761779368f49SMichael Walle  ;;
761864656024SJuan Quintela  m68k)
7619c765fcacSPeter Crosthwaite    disas_config "M68K"
762064656024SJuan Quintela  ;;
7621877fdc12SEdgar E. Iglesias  microblaze*)
7622c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
762364656024SJuan Quintela  ;;
762464656024SJuan Quintela  mips*)
7625c765fcacSPeter Crosthwaite    disas_config "MIPS"
762689a955e8SAleksandar Markovic    if test -n "${cxx}"; then
762789a955e8SAleksandar Markovic      disas_config "NANOMIPS"
762889a955e8SAleksandar Markovic    fi
762964656024SJuan Quintela  ;;
7630d15a9c23SAnthony Green  moxie*)
7631c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7632d15a9c23SAnthony Green  ;;
7633e671711cSMarek Vasut  nios2)
7634e671711cSMarek Vasut    disas_config "NIOS2"
7635e671711cSMarek Vasut  ;;
76364a09d0bbSRichard Henderson  or1k)
7637c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7638e67db06eSJia Liu  ;;
763964656024SJuan Quintela  ppc*)
7640c765fcacSPeter Crosthwaite    disas_config "PPC"
764164656024SJuan Quintela  ;;
7642c4f80543SAlistair Francis  riscv*)
764325fa194bSMichael Clark    disas_config "RISCV"
764425fa194bSMichael Clark  ;;
764524e804ecSAlexander Graf  s390*)
7646c765fcacSPeter Crosthwaite    disas_config "S390"
764764656024SJuan Quintela  ;;
764864656024SJuan Quintela  sh4)
7649c765fcacSPeter Crosthwaite    disas_config "SH4"
765064656024SJuan Quintela  ;;
765164656024SJuan Quintela  sparc*)
7652c765fcacSPeter Crosthwaite    disas_config "SPARC"
765364656024SJuan Quintela  ;;
7654cfa550c6SMax Filippov  xtensa*)
7655c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7656cfa550c6SMax Filippov  ;;
765764656024SJuan Quintela  esac
765864656024SJuan Quinteladone
76599195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7660c765fcacSPeter Crosthwaite  disas_config "TCI"
76619195b2c2SStefan Weilfi
766264656024SJuan Quintela
76636ee7126fSJuan Quintelacase "$ARCH" in
76646ee7126fSJuan Quintelaalpha)
76656ee7126fSJuan Quintela  # Ensure there's only a single GP
76666ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
76676ee7126fSJuan Quintela;;
76686ee7126fSJuan Quintelaesac
76696ee7126fSJuan Quintela
7670d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
76710acf7dedSPhilippe Mathieu-Daudé  echo "TARGET_GPROF=y" >> $config_target_mak
7672d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7673d02c1db3SJuan Quintela    cflags="-p $cflags"
7674d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7675d02c1db3SJuan Quintela  fi
7676d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7677d02c1db3SJuan Quintela    ldflags="-p $ldflags"
767825be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7679d02c1db3SJuan Quintela  fi
7680d02c1db3SJuan Quintelafi
7681d02c1db3SJuan Quintela
7682e633a5c6SEric Blakeif test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
7683964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7684fa282484SJuan Quintelafi
7685fa282484SJuan Quintela
7686e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7687e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7688e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7689e9a3591fSChristian Borntraeger# header if
7690e9a3591fSChristian Borntraeger#  - we build on s390x
7691e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7692e9a3591fSChristian Borntraeger#  - KVM is enabled
7693e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7694e633a5c6SEric Blakeif test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
7695e633a5c6SEric Blake        test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
7696e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7697e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7698e9a3591fSChristian Borntraeger    fi
7699e9a3591fSChristian Borntraegerfi
7700e9a3591fSChristian Borntraeger
770125be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
770225be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7703fa282484SJuan Quintela
770497a847bcSbellarddone # for target in $targets
77057d13299dSbellard
7706d75402b5SAlex Bennéeif test -n "$enabled_cross_compilers"; then
7707d75402b5SAlex Bennée    echo
7708d75402b5SAlex Bennée    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7709d75402b5SAlex Bennéefi
7710d75402b5SAlex Bennée
7711e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
7712a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
7713a540f158SPeter Crosthwaitefi
7714e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7715e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
7716e219c499SRichard Hendersonfi
7717e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7718e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7719e219c499SRichard Hendersonfi
7720a540f158SPeter Crosthwaite
7721a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7722a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7723a99d57bbSWanlong Gaofi
7724a99d57bbSWanlong Gao
7725fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7726fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7727fd0e6053SJohn Snowfi
7728fd0e6053SJohn Snow
7729e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
7730e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
7731e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
7732e29e5c6eSPeter Maydell# (these can be both files and directories).
7733e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
7734e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
7735e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
7736e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
7737e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
7738e29e5c6eSPeter Maydell# directory and symlink the directory instead.
7739b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
7740fc281c80SEmanuele Giuseppe EspositoDIRS="$DIRS tests/fp tests/qgraph"
7741b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
77429933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
77432d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
7744fe07b62cSPhilippe Mathieu-DaudéLINKS="Makefile tests/tcg/Makefile"
7745e29e5c6eSPeter MaydellLINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7746e29e5c6eSPeter MaydellLINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7747e29e5c6eSPeter MaydellLINKS="$LINKS tests/fp/Makefile"
7748e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7749e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/spapr-rtas/Makefile"
7750e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
7751e29e5c6eSPeter MaydellLINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7752e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
7753e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
775439950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
775539950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
77568f8fd9edSCleber RosaLINKS="$LINKS python"
7757753d11f2SRichard Hendersonfor bios_file in \
7758753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7759225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
77605acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
7761753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7762753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7763e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7764753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
77654e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
7766753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7767753d11f2SRichard Hendersondo
7768e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
77697ea78b74SJan Kiszkadone
7770d1807a4fSPaolo Bonzinimkdir -p $DIRS
7771e29e5c6eSPeter Maydellfor f in $LINKS ; do
7772cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7773f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7774f9245e10SPeter Maydell    fi
77757d13299dSbellarddone
77761ad2134fSPaul Brook
7777c34ebfdcSAnthony Liguori# temporary config to build submodules
77782d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
7779c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
778037116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7781c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7782cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
77835f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7784c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7785c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
77863dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7787c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7788a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7789c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
77909f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7791c34ebfdcSAnthony Liguoridone
7792c34ebfdcSAnthony Liguori
779376c7560aSMax Reitz# set up qemu-iotests in this build directory
779476c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
779576c7560aSMax Reitz
779676c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
779776c7560aSMax Reitzecho >> "$iotests_common_env"
779876c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
779976c7560aSMax Reitz
7800dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7801dc655404SMichael S. Tsirkincat <<EOD >config.status
7802dc655404SMichael S. Tsirkin#!/bin/sh
7803dc655404SMichael S. Tsirkin# Generated by configure.
7804dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7805dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7806dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7807dc655404SMichael S. TsirkinEOD
7808e811da7fSDaniel P. Berrangé
7809e811da7fSDaniel P. Berrangépreserve_env() {
7810e811da7fSDaniel P. Berrangé    envname=$1
7811e811da7fSDaniel P. Berrangé
7812e811da7fSDaniel P. Berrangé    eval envval=\$$envname
7813e811da7fSDaniel P. Berrangé
7814e811da7fSDaniel P. Berrangé    if test -n "$envval"
7815e811da7fSDaniel P. Berrangé    then
7816e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
7817e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
7818e811da7fSDaniel P. Berrangé    else
7819e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
7820e811da7fSDaniel P. Berrangé    fi
7821e811da7fSDaniel P. Berrangé}
7822e811da7fSDaniel P. Berrangé
7823e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
7824e811da7fSDaniel P. Berrangé# features/build target configure will detect
7825e811da7fSDaniel P. Berrangépreserve_env AR
7826e811da7fSDaniel P. Berrangépreserve_env AS
7827e811da7fSDaniel P. Berrangépreserve_env CC
7828e811da7fSDaniel P. Berrangépreserve_env CPP
7829e811da7fSDaniel P. Berrangépreserve_env CXX
7830e811da7fSDaniel P. Berrangépreserve_env INSTALL
7831e811da7fSDaniel P. Berrangépreserve_env LD
7832e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
7833e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
7834e811da7fSDaniel P. Berrangépreserve_env MAKE
7835e811da7fSDaniel P. Berrangépreserve_env NM
7836e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
7837e811da7fSDaniel P. Berrangépreserve_env PATH
7838e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
7839e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
7840e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
7841e811da7fSDaniel P. Berrangépreserve_env PYTHON
7842e811da7fSDaniel P. Berrangépreserve_env SDL_CONFIG
7843e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
7844e811da7fSDaniel P. Berrangépreserve_env SMBD
7845e811da7fSDaniel P. Berrangépreserve_env STRIP
7846e811da7fSDaniel P. Berrangépreserve_env WINDRES
7847e811da7fSDaniel P. Berrangé
7848dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7849dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
7850cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7851dc655404SMichael S. Tsirkinchmod +x config.status
7852dc655404SMichael S. Tsirkin
78538cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7854