xref: /openbmc/qemu/configure (revision 1b0578f5)
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                ;;
1109c83ffd8SPeter Maydell            *)
1119c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1129c83ffd8SPeter Maydell                ;;
1139c83ffd8SPeter Maydell        esac
1149c83ffd8SPeter Maydell    done
1159c83ffd8SPeter Maydell}
1169c83ffd8SPeter Maydell
11752166aa0SJuan Quintelacompile_object() {
118fd0e6053SJohn Snow  local_cflags="$1"
119fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
12052166aa0SJuan Quintela}
12152166aa0SJuan Quintela
12252166aa0SJuan Quintelacompile_prog() {
12352166aa0SJuan Quintela  local_cflags="$1"
12452166aa0SJuan Quintela  local_ldflags="$2"
1258dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
12652166aa0SJuan Quintela}
12752166aa0SJuan Quintela
12811568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
12911568d6dSPaolo Bonzinisymlink() {
13072b8b5a1SStefan Weil  rm -rf "$2"
131ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
13272b8b5a1SStefan Weil  ln -s "$1" "$2"
13311568d6dSPaolo Bonzini}
13411568d6dSPaolo Bonzini
1350dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1360dba6195SLoïc Minier# executable or a builtin)
1370dba6195SLoïc Minierhas() {
1380dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1390dba6195SLoïc Minier}
1400dba6195SLoïc Minier
1410dba6195SLoïc Minier# search for an executable in PATH
1420dba6195SLoïc Minierpath_of() {
1430dba6195SLoïc Minier    local_command="$1"
1440dba6195SLoïc Minier    local_ifs="$IFS"
1450dba6195SLoïc Minier    local_dir=""
1460dba6195SLoïc Minier
1470dba6195SLoïc Minier    # pathname has a dir component?
1480dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1490dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1500dba6195SLoïc Minier            echo "$local_command"
1510dba6195SLoïc Minier            return 0
1520dba6195SLoïc Minier        fi
1530dba6195SLoïc Minier    fi
1540dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1550dba6195SLoïc Minier        return 1
1560dba6195SLoïc Minier    fi
1570dba6195SLoïc Minier
1580dba6195SLoïc Minier    IFS=:
1590dba6195SLoïc Minier    for local_dir in $PATH; do
1600dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1610dba6195SLoïc Minier            echo "$local_dir/$local_command"
1620dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1630dba6195SLoïc Minier            return 0
1640dba6195SLoïc Minier        fi
1650dba6195SLoïc Minier    done
1660dba6195SLoïc Minier    # not found
1670dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1680dba6195SLoïc Minier    return 1
1690dba6195SLoïc Minier}
1700dba6195SLoïc Minier
1715b808275SLluís Vilanovahave_backend () {
1725b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1735b808275SLluís Vilanova}
1745b808275SLluís Vilanova
1753b6b7550SPaolo Bonziniglob() {
1763b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1773b6b7550SPaolo Bonzini}
1783b6b7550SPaolo Bonzini
1793b6b7550SPaolo Bonzinisupported_hax_target() {
1803b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1813b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1823b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1833b6b7550SPaolo Bonzini        i386|x86_64)
1843b6b7550SPaolo Bonzini            return 0
1853b6b7550SPaolo Bonzini        ;;
1863b6b7550SPaolo Bonzini    esac
1873b6b7550SPaolo Bonzini    return 1
1883b6b7550SPaolo Bonzini}
1893b6b7550SPaolo Bonzini
1903b6b7550SPaolo Bonzinisupported_kvm_target() {
1913b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1923b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1933b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1943b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1953b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
1963b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
1973b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
1983b6b7550SPaolo Bonzini        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
1993b6b7550SPaolo Bonzini        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
2003b6b7550SPaolo Bonzini        s390x:s390x)
2013b6b7550SPaolo Bonzini            return 0
2023b6b7550SPaolo Bonzini        ;;
2033b6b7550SPaolo Bonzini    esac
2043b6b7550SPaolo Bonzini    return 1
2053b6b7550SPaolo Bonzini}
2063b6b7550SPaolo Bonzini
2073b6b7550SPaolo Bonzinisupported_xen_target() {
2083b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2093b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
210b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
211b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
212b5ed2e11SPaolo Bonzini        i386|x86_64)
2133b6b7550SPaolo Bonzini            return 0
2143b6b7550SPaolo Bonzini        ;;
2153b6b7550SPaolo Bonzini    esac
2163b6b7550SPaolo Bonzini    return 1
2173b6b7550SPaolo Bonzini}
2183b6b7550SPaolo Bonzini
219c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
220c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
221c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
222c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
223c97d6d2cSSergio Andres Gomez Del Real        x86_64)
224c97d6d2cSSergio Andres Gomez Del Real            return 0
225c97d6d2cSSergio Andres Gomez Del Real        ;;
226c97d6d2cSSergio Andres Gomez Del Real    esac
227c97d6d2cSSergio Andres Gomez Del Real    return 1
228c97d6d2cSSergio Andres Gomez Del Real}
229c97d6d2cSSergio Andres Gomez Del Real
230d661d9a4SJustin Terry (VM)supported_whpx_target() {
231d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
232d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
233d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
234d661d9a4SJustin Terry (VM)        i386|x86_64)
235d661d9a4SJustin Terry (VM)            return 0
236d661d9a4SJustin Terry (VM)        ;;
237d661d9a4SJustin Terry (VM)    esac
238d661d9a4SJustin Terry (VM)    return 1
239d661d9a4SJustin Terry (VM)}
240d661d9a4SJustin Terry (VM)
241d880a3baSPaolo Bonzinisupported_target() {
242d880a3baSPaolo Bonzini    case "$1" in
243d880a3baSPaolo Bonzini        *-softmmu)
244d880a3baSPaolo Bonzini            ;;
245d880a3baSPaolo Bonzini        *-linux-user)
246d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
247d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
248d880a3baSPaolo Bonzini                return 1
249d880a3baSPaolo Bonzini            fi
250d880a3baSPaolo Bonzini            ;;
251d880a3baSPaolo Bonzini        *-bsd-user)
252d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
253d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
254d880a3baSPaolo Bonzini                return 1
255d880a3baSPaolo Bonzini            fi
256d880a3baSPaolo Bonzini            ;;
257d880a3baSPaolo Bonzini        *)
258d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
259d880a3baSPaolo Bonzini            return 1
260d880a3baSPaolo Bonzini            ;;
261d880a3baSPaolo Bonzini    esac
262b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
263b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
264b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
265b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
266c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
267d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
268b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
269b3f6ea7eSPaolo Bonzini    return 1
270d880a3baSPaolo Bonzini}
271d880a3baSPaolo Bonzini
272e9a3591fSChristian Borntraeger
273e9a3591fSChristian Borntraegerld_has() {
274e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
275e9a3591fSChristian Borntraeger}
276e9a3591fSChristian Borntraeger
2777d13299dSbellard# default parameters
27889138857SStefan Weilsource_path=$(dirname "$0")
2792ff6b91eSJuan Quintelacpu=""
280a31a8642SMichael S. Tsirkiniasl="iasl"
2811e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
28243ce4dfeSbellardstatic="no"
2837d13299dSbellardcross_prefix=""
2840c58ac1cSmalcaudio_drv_list=""
285b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
286b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
287e49d021eSPeter Maydellhost_cc="cc"
28873da375eSJuan Quintelalibs_softmmu=""
2893e2e0e6bSJuan Quintelalibs_tools=""
29067f86e8eSJuan Quintelaaudio_pt_int=""
291d5631638Smalcaudio_win_int=""
292957f1f99SMichael Rothlibs_qga=""
2935bc62e01SGerd Hoffmanndebug_info="yes"
29463678e17SSteven Noonanstack_protector=""
295ac0df51dSaliguori
29692712822SDaniel P. Berrangeif test -e "$source_path/.git"
29792712822SDaniel P. Berrangethen
298f62bbee5SDaniel P. Berrange    git_update=yes
29992712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
30092712822SDaniel P. Berrangeelse
301f62bbee5SDaniel P. Berrange    git_update=no
302aef45d51SDaniel P. Berrange    git_submodules=""
3035c0ef67aSDaniel P. Berrangé
3045c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3055c0ef67aSDaniel P. Berrangé    then
3065c0ef67aSDaniel P. Berrangé        echo
3075c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3085c0ef67aSDaniel P. Berrangé        echo
3095c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3105c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3115c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3125c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3135c0ef67aSDaniel P. Berrangé        echo
3145c0ef67aSDaniel P. Berrangé        echo "  https://www.qemu.org/download/"
3155c0ef67aSDaniel P. Berrangé        echo
3165c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3175c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3185c0ef67aSDaniel P. Berrangé        echo
3195c0ef67aSDaniel P. Berrangé        exit 1
3205c0ef67aSDaniel P. Berrangé    fi
32192712822SDaniel P. Berrangefi
322cc84d63aSDaniel P. Berrangegit="git"
323ac0df51dSaliguori
324afb63ebdSStefan Weil# Don't accept a target_list environment variable.
325afb63ebdSStefan Weilunset target_list
326377529c0SPaolo Bonzini
327377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
328377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
329377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
330377529c0SPaolo Bonzini#              unless --disable-foo is given
331377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
332377529c0SPaolo Bonzini#              feature will searched for,
333377529c0SPaolo Bonzini#              if not found, configure exits with error
334377529c0SPaolo Bonzini#
335377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
336377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
337377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
338377529c0SPaolo Bonzini
339377529c0SPaolo Bonzinibluez=""
340377529c0SPaolo Bonzinibrlapi=""
341377529c0SPaolo Bonzinicurl=""
342377529c0SPaolo Bonzinicurses=""
343377529c0SPaolo Bonzinidocs=""
344377529c0SPaolo Bonzinifdt=""
34558952137SVincenzo Maffionenetmap="no"
346377529c0SPaolo Bonzinisdl=""
347ee8466d0SCole Robinsonsdlabi=""
348983eef5aSMeador Ingevirtfs=""
349fe8fc5aeSPaolo Bonzinimpath=""
350821601eaSJes Sorensenvnc="yes"
351377529c0SPaolo Bonzinisparse="no"
352377529c0SPaolo Bonzinivde=""
353377529c0SPaolo Bonzinivnc_sasl=""
354377529c0SPaolo Bonzinivnc_jpeg=""
355377529c0SPaolo Bonzinivnc_png=""
3566a021536SGerd Hoffmannxkbcommon=""
357377529c0SPaolo Bonzinixen=""
358d5b93ddfSAnthony PERARDxen_ctrl_version=""
35964a7ad6fSIan Campbellxen_pv_domain_build="no"
360eb6fda0fSAnthony PERARDxen_pci_passthrough=""
361377529c0SPaolo Bonzinilinux_aio=""
36247e98658SCorey Bryantcap_ng=""
363377529c0SPaolo Bonziniattr=""
3644f26f2b6SAvi Kivitylibattr=""
365377529c0SPaolo Bonzinixfs=""
366b3f6ea7eSPaolo Bonzinitcg="yes"
367a40161cbSPaolo Bonzinimembarrier=""
368d41a75a2SBradvhost_net="no"
369042cea27SGongleivhost_crypto="no"
3705e9be92dSNicholas Bellingervhost_scsi="no"
371fc0b9b0eSStefan Hajnoczivhost_vsock="no"
372e6a74868SMarc-André Lureauvhost_user=""
373d41a75a2SBradkvm="no"
374b0cb0a66SVincent Palatinhax="no"
375c97d6d2cSSergio Andres Gomez Del Realhvf="no"
376d661d9a4SJustin Terry (VM)whpx="no"
3772da776dbSMichael R. Hinesrdma=""
37821ab34c9SMarcel Apfelbaumpvrdma=""
379377529c0SPaolo Bonzinigprof="no"
380377529c0SPaolo Bonzinidebug_tcg="no"
381377529c0SPaolo Bonzinidebug="no"
382247724cbSMarc-André Lureausanitizers="no"
383b553a042SJohn Snowfortify_source=""
384377529c0SPaolo Bonzinistrip_opt="yes"
3859195b2c2SStefan Weiltcg_interpreter="no"
386377529c0SPaolo Bonzinibigendian="no"
387377529c0SPaolo Bonzinimingw32="no"
3881d728c39SBlue Swirlgcov="no"
3891d728c39SBlue Swirlgcov_tool="gcov"
390377529c0SPaolo BonziniEXESUF=""
39117969268SFam ZhengDSOSUF=".so"
39217969268SFam ZhengLDFLAGS_SHARED="-shared"
39317969268SFam Zhengmodules="no"
394377529c0SPaolo Bonziniprefix="/usr/local"
395377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
396528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
3973d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
398850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
399377529c0SPaolo Bonzinibindir="\${prefix}/bin"
4003aa5d2beSAlon Levylibdir="\${prefix}/lib"
4018bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
4020f94d6daSAlon Levyincludedir="\${prefix}/include"
403377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
404785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
405377529c0SPaolo Bonziniconfsuffix="/qemu"
406377529c0SPaolo Bonzinislirp="yes"
407377529c0SPaolo Bonzinioss_lib=""
408377529c0SPaolo Bonzinibsd="no"
409377529c0SPaolo Bonzinilinux="no"
410377529c0SPaolo Bonzinisolaris="no"
411377529c0SPaolo Bonziniprofiler="no"
412377529c0SPaolo Bonzinicocoa="no"
413377529c0SPaolo Bonzinisoftmmu="yes"
414377529c0SPaolo Bonzinilinux_user="no"
415377529c0SPaolo Bonzinibsd_user="no"
416377529c0SPaolo Bonziniblobs="yes"
417377529c0SPaolo Bonzinipkgversion=""
41840d6444eSAvi Kivitypie=""
4193556c233SPaolo Bonziniqom_cast_debug="yes"
420baf86d6bSPaolo Bonzinitrace_backends="log"
421377529c0SPaolo Bonzinitrace_file="trace"
422377529c0SPaolo Bonzinispice=""
423377529c0SPaolo Bonzinirbd=""
4247b02f544SMarc-André Lureausmartcard=""
4252b2325ffSGerd Hoffmannlibusb=""
42669354a83SHans de Goedeusb_redir=""
427da076ffeSGerd Hoffmannopengl=""
428014cb152SGerd Hoffmannopengl_dmabuf="no"
4295dd89908SRichard Hendersoncpuid_h="no"
43099f2dbd3SLiang Liavx2_opt="no"
4311ece9905SAlon Levyzlib="yes"
4328ca80760SRichard Hendersoncapstone=""
433b25c9dffSStefan Weillzo=""
434b25c9dffSStefan Weilsnappy=""
4356b383c08SPeter Wubzip2=""
436e8ef31a3SMichael Tokarevguest_agent=""
437d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
43850cbebb9SMichael Rothguest_agent_ntddscsi="no"
4399dacf32dSYossi Hindinguest_agent_msi=""
440d9840e25STomoki Sekiyamavss_win32_sdk=""
441d9840e25STomoki Sekiyamawin_sdk="no"
4424b1c11fdSDaniel P. Berrangewant_tools="yes"
443c589b249SRonnie Sahlberglibiscsi=""
4446542aa9cSPeter Lievenlibnfs=""
445519175a2SAlex Barcelocoroutine=""
44670c60c08SStefan Hajnoczicoroutine_pool=""
4477d992e4dSPeter Lievendebug_stack_usage="no"
448f0d92b56SLongpeng(Mike)crypto_afalg="no"
449f794573eSEduardo Otuboseccomp=""
450eb100396SBharata B Raoglusterfs=""
451d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4520c14fb47SBharata B Raoglusterfs_discard="no"
453df3a429aSNiels de Vosglusterfs_fallocate="no"
4547c815372SBharata B Raoglusterfs_zerofill="no"
455a4ccabcfSAnthony Liguorigtk=""
4569e04c683SStefan Weilgtkabi=""
457925a0400SGerd Hoffmanngtk_gl="no"
458a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
459ddbb0d09SDaniel P. Berrangegnutls=""
460b917da4cSDaniel P. Berrangegnutls_rnd=""
46191bfcdb0SDaniel P. Berrangenettle=""
462fff2f982SDaniel P. Berrangenettle_kdf="no"
46391bfcdb0SDaniel P. Berrangegcrypt=""
4641f923c70SLongpeng(Mike)gcrypt_hmac="no"
46537788f25SDaniel P. Berrangegcrypt_kdf="no"
466bbbf9bfbSStefan Weilvte=""
4679d9e1521SGerd Hoffmannvirglrenderer=""
468e91c793cSCole Robinsontpm="yes"
4690a12ec87SRichard W.M. Joneslibssh2=""
470ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
471a99d57bbSWanlong Gaonuma=""
4722847b469SFam Zhengtcmalloc="no"
4737b01cb97SAlexandre Derumierjemalloc="no"
474a6b1d4c0SChanglong Xiereplication="yes"
475da92c3ffSAshish Mittalvxhs=""
476ed279a06SKlim Kireevlibxml2=""
47751a12b51SAlex Bennéedocker="no"
478ba59fb77SPaolo Bonzinidebug_mutex="no"
47917824406SJunyan Helibpmem=""
480377529c0SPaolo Bonzini
481d75402b5SAlex Bennée# cross compilers defaults, can be overridden with --cross-cc-ARCH
482d75402b5SAlex Bennéecross_cc_aarch64="aarch64-linux-gnu-gcc"
483d422b2bcSAlex Bennéecross_cc_aarch64_be="$cross_cc_aarch64"
484d422b2bcSAlex Bennéecross_cc_cflags_aarch64_be="-mbig-endian"
485d75402b5SAlex Bennéecross_cc_arm="arm-linux-gnueabihf-gcc"
486d422b2bcSAlex Bennéecross_cc_cflags_armeb="-mbig-endian"
487716a507cSAlex Bennéecross_cc_i386="i386-pc-linux-gnu-gcc"
488716a507cSAlex Bennéecross_cc_cflags_i386=""
489d75402b5SAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
490d422b2bcSAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
491d75402b5SAlex Bennée
492d75402b5SAlex Bennéeenabled_cross_compilers=""
493d75402b5SAlex Bennée
494898be3e0SPeter Maydellsupported_cpu="no"
495898be3e0SPeter Maydellsupported_os="no"
496fb59dabdSPeter Maydellbogus_os="no"
4975a22ab71SYang Zhongmalloc_trim=""
498898be3e0SPeter Maydell
499ac0df51dSaliguori# parse CC options first
500ac0df51dSaliguorifor opt do
50189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
502ac0df51dSaliguori  case "$opt" in
503ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
504ac0df51dSaliguori  ;;
5053d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
506ac0df51dSaliguori  ;;
50783f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
50883f73fceSTomoki Sekiyama  ;;
509ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
510ca4deeb1SPaolo Bonzini  ;;
5112ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5122ff6b91eSJuan Quintela  ;;
513de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
514e2a2ed06SJuan Quintela  ;;
51511cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
51611cde1c8SBruno Dominguez  ;;
517a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
518f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
519e2a2ed06SJuan Quintela  ;;
5205bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5215bc62e01SGerd Hoffmann  ;;
5225bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
5235bc62e01SGerd Hoffmann  ;;
524d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
525d75402b5SAlex Bennée  ;;
526d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
527d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
528d422b2bcSAlex Bennée  ;;
529d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
530d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
531d75402b5SAlex Bennée  ;;
532ac0df51dSaliguori  esac
533ac0df51dSaliguoridone
534ac0df51dSaliguori# OS specific
535ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
53693148aa5SStefan Weil# we can eliminate its usage altogether.
537ac0df51dSaliguori
538e49d021eSPeter Maydell# Preferred compiler:
539e49d021eSPeter Maydell#  ${CC} (if set)
540e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
541e49d021eSPeter Maydell#  system compiler
542e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
543e49d021eSPeter Maydell  cc="$host_cc"
544e49d021eSPeter Maydellelse
545b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
546e49d021eSPeter Maydellfi
547e49d021eSPeter Maydell
54883f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
54983f73fceSTomoki Sekiyama  cxx="c++"
55083f73fceSTomoki Sekiyamaelse
55183f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
55283f73fceSTomoki Sekiyamafi
55383f73fceSTomoki Sekiyama
554b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
555cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5565f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5573dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
558b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
559b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5609f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5614852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
562b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
563b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
56417884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
56517884d7bSSergei Trofimovichquery_pkg_config() {
56617884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
56717884d7bSSergei Trofimovich}
56817884d7bSSergei Trofimovichpkg_config=query_pkg_config
569b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
57047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
571ac0df51dSaliguori
57245d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
57345d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
57445d285abSPeter Maydell
575be17dc90SMichael S. Tsirkin# default flags for all hosts
5762d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5772d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5782d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5792d31515bSPeter Maydell# provides these semantics.)
5802d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
581f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
582c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
583be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5849edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5855bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5865bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
587be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5885bc62e01SGerd Hoffmannfi
589be17dc90SMichael S. Tsirkin
590ca4deeb1SPaolo Bonzini# make source path absolute
59189138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
592ca4deeb1SPaolo Bonzini
593cab00a5aSMichael S. Tsirkin# running configure in the source tree?
594cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
595cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
596cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
597cab00a5aSMichael S. Tsirkinelse
598cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
599cab00a5aSMichael S. Tsirkinfi
600cab00a5aSMichael S. Tsirkin
601ac0df51dSaliguoricheck_define() {
602ac0df51dSaliguoricat > $TMPC <<EOF
603ac0df51dSaliguori#if !defined($1)
604fd786e1aSPeter Maydell#error $1 not defined
605ac0df51dSaliguori#endif
606ac0df51dSaliguoriint main(void) { return 0; }
607ac0df51dSaliguoriEOF
60852166aa0SJuan Quintela  compile_object
609ac0df51dSaliguori}
610ac0df51dSaliguori
611307119e7SGerd Hoffmanncheck_include() {
612307119e7SGerd Hoffmanncat > $TMPC <<EOF
613307119e7SGerd Hoffmann#include <$1>
614307119e7SGerd Hoffmannint main(void) { return 0; }
615307119e7SGerd HoffmannEOF
616307119e7SGerd Hoffmann  compile_object
617307119e7SGerd Hoffmann}
618307119e7SGerd Hoffmann
61993b25869SJohn Snowwrite_c_skeleton() {
62093b25869SJohn Snow    cat > $TMPC <<EOF
62193b25869SJohn Snowint main(void) { return 0; }
62293b25869SJohn SnowEOF
62393b25869SJohn Snow}
62493b25869SJohn Snow
625bbea4050SPeter Maydellif check_define __linux__ ; then
626bbea4050SPeter Maydell  targetos="Linux"
627bbea4050SPeter Maydellelif check_define _WIN32 ; then
628bbea4050SPeter Maydell  targetos='MINGW32'
629bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
630bbea4050SPeter Maydell  targetos='OpenBSD'
631bbea4050SPeter Maydellelif check_define __sun__ ; then
632bbea4050SPeter Maydell  targetos='SunOS'
633bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
634bbea4050SPeter Maydell  targetos='Haiku'
635951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
636951fedfcSPeter Maydell  targetos='FreeBSD'
637951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
638951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
639951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
640951fedfcSPeter Maydell  targetos='DragonFly'
641951fedfcSPeter Maydellelif check_define __NetBSD__; then
642951fedfcSPeter Maydell  targetos='NetBSD'
643951fedfcSPeter Maydellelif check_define __APPLE__; then
644951fedfcSPeter Maydell  targetos='Darwin'
645bbea4050SPeter Maydellelse
646951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
647951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
648951fedfcSPeter Maydell  # be the result of a missing compiler.
649951fedfcSPeter Maydell  targetos='bogus'
650951fedfcSPeter Maydell  bogus_os='yes'
651bbea4050SPeter Maydellfi
652bbea4050SPeter Maydell
653bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
654bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
655bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
656bbea4050SPeter Maydell# the correct CPU with the --cpu option.
657bbea4050SPeter Maydellcase $targetos in
658bbea4050SPeter MaydellDarwin)
659bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
660bbea4050SPeter Maydell  # run 64-bit userspace code.
661bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
662bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
663bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
664bbea4050SPeter Maydell    cpu="x86_64"
665bbea4050SPeter Maydell  fi
666bbea4050SPeter Maydell  ;;
667bbea4050SPeter MaydellSunOS)
66889138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
669bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
670bbea4050SPeter Maydell    cpu="x86_64"
671bbea4050SPeter Maydell  fi
672bbea4050SPeter Maydellesac
673bbea4050SPeter Maydell
6742ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6752ff6b91eSJuan Quintela  # command line argument
6762ff6b91eSJuan Quintela  :
6772ff6b91eSJuan Quintelaelif check_define __i386__ ; then
678ac0df51dSaliguori  cpu="i386"
679ac0df51dSaliguorielif check_define __x86_64__ ; then
680c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
681c72b26ecSRichard Henderson    cpu="x32"
682c72b26ecSRichard Henderson  else
683ac0df51dSaliguori    cpu="x86_64"
684c72b26ecSRichard Henderson  fi
6853aa9bd6cSblueswir1elif check_define __sparc__ ; then
6863aa9bd6cSblueswir1  if check_define __arch64__ ; then
6873aa9bd6cSblueswir1    cpu="sparc64"
6883aa9bd6cSblueswir1  else
6893aa9bd6cSblueswir1    cpu="sparc"
6903aa9bd6cSblueswir1  fi
691fdf7ed96Smalcelif check_define _ARCH_PPC ; then
692fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
693fdf7ed96Smalc    cpu="ppc64"
694ac0df51dSaliguori  else
695fdf7ed96Smalc    cpu="ppc"
696fdf7ed96Smalc  fi
697afa05235SAurelien Jarnoelif check_define __mips__ ; then
698afa05235SAurelien Jarno  cpu="mips"
699d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
700d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
701d66ed0eaSAurelien Jarno    cpu="s390x"
702d66ed0eaSAurelien Jarno  else
703d66ed0eaSAurelien Jarno    cpu="s390"
704d66ed0eaSAurelien Jarno  fi
70521d89f84SPeter Maydellelif check_define __arm__ ; then
70621d89f84SPeter Maydell  cpu="arm"
7071f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7081f080313SClaudio Fontana  cpu="aarch64"
709fdf7ed96Smalcelse
71089138857SStefan Weil  cpu=$(uname -m)
711ac0df51dSaliguorifi
712ac0df51dSaliguori
713359bc95dSPeter MaydellARCH=
714359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
715359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7167d13299dSbellardcase "$cpu" in
7176499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
718898be3e0SPeter Maydell    cpu="$cpu"
719898be3e0SPeter Maydell    supported_cpu="yes"
720d75402b5SAlex Bennée    eval "cross_cc_${cpu}=\$host_cc"
721898be3e0SPeter Maydell  ;;
7227d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
72397a847bcSbellard    cpu="i386"
724898be3e0SPeter Maydell    supported_cpu="yes"
725d75402b5SAlex Bennée    cross_cc_i386=$host_cc
7267d13299dSbellard  ;;
727aaa5fa14Saurel32  x86_64|amd64)
728aaa5fa14Saurel32    cpu="x86_64"
729898be3e0SPeter Maydell    supported_cpu="yes"
730d75402b5SAlex Bennée    cross_cc_x86_64=$host_cc
731aaa5fa14Saurel32  ;;
73221d89f84SPeter Maydell  armv*b|armv*l|arm)
73321d89f84SPeter Maydell    cpu="arm"
734898be3e0SPeter Maydell    supported_cpu="yes"
735d75402b5SAlex Bennée    cross_cc_arm=$host_cc
7367d13299dSbellard  ;;
7371f080313SClaudio Fontana  aarch64)
7381f080313SClaudio Fontana    cpu="aarch64"
739898be3e0SPeter Maydell    supported_cpu="yes"
740d75402b5SAlex Bennée    cross_cc_aarch64=$host_cc
7411f080313SClaudio Fontana  ;;
742afa05235SAurelien Jarno  mips*)
743afa05235SAurelien Jarno    cpu="mips"
744898be3e0SPeter Maydell    supported_cpu="yes"
745d75402b5SAlex Bennée    cross_cc_mips=$host_cc
746afa05235SAurelien Jarno  ;;
7473142255cSblueswir1  sparc|sun4[cdmuv])
748ae228531Sbellard    cpu="sparc"
7496499fd15SPeter Maydell    supported_cpu="yes"
750d75402b5SAlex Bennée    cross_cc_sparc=$host_cc
751ae228531Sbellard  ;;
7527d13299dSbellard  *)
753359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
754359bc95dSPeter Maydell    ARCH=unknown
7557d13299dSbellard  ;;
7567d13299dSbellardesac
757359bc95dSPeter Maydellif test -z "$ARCH"; then
758359bc95dSPeter Maydell  ARCH="$cpu"
759359bc95dSPeter Maydellfi
760e2d52ad3SJuan Quintela
7617d13299dSbellard# OS specific
7620dbfc675SJuan Quintela
763adfc3e91SStacey Son# host *BSD for user mode
764adfc3e91SStacey SonHOST_VARIANT_DIR=""
765adfc3e91SStacey Son
7667d13299dSbellardcase $targetos in
76767b915a5SbellardMINGW32*)
76867b915a5Sbellard  mingw32="yes"
769b0cb0a66SVincent Palatin  hax="yes"
7703cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
771307119e7SGerd Hoffmann  if check_include dsound.h; then
7723cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
773307119e7SGerd Hoffmann  else
774307119e7SGerd Hoffmann    audio_drv_list=""
775307119e7SGerd Hoffmann  fi
776898be3e0SPeter Maydell  supported_os="yes"
77767b915a5Sbellard;;
7785c40d2bdSthsGNU/kFreeBSD)
779a167ba50SAurelien Jarno  bsd="yes"
7800c58ac1cSmalc  audio_drv_list="oss"
7810bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7825c40d2bdSths;;
7837d3505c5SbellardFreeBSD)
7847d3505c5Sbellard  bsd="yes"
7850db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7860c58ac1cSmalc  audio_drv_list="oss"
7870bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
788f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
789f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
790a7764f15SEd Maste  # needed for kinfo_getproc
791a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
79258952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
793adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
794898be3e0SPeter Maydell  supported_os="yes"
7957d3505c5Sbellard;;
796c5e97233Sblueswir1DragonFly)
797c5e97233Sblueswir1  bsd="yes"
7980db4a067SPaolo Bonzini  make="${MAKE-gmake}"
799c5e97233Sblueswir1  audio_drv_list="oss"
8000bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
801adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
802c5e97233Sblueswir1;;
8037d3505c5SbellardNetBSD)
8047d3505c5Sbellard  bsd="yes"
8050db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8060c58ac1cSmalc  audio_drv_list="oss"
8070bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8088ef92a88Sblueswir1  oss_lib="-lossaudio"
809adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8103c2bdbc1SKamil Rytarowski  supported_os="yes"
8117d3505c5Sbellard;;
8127d3505c5SbellardOpenBSD)
8137d3505c5Sbellard  bsd="yes"
8140db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8154f6ab397SBrad Smith  audio_drv_list="sdl"
8160bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
817adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8180a773d55SBrad Smith  supported_os="yes"
8197d3505c5Sbellard;;
82083fb7adfSbellardDarwin)
82183fb7adfSbellard  bsd="yes"
82283fb7adfSbellard  darwin="yes"
823b0cb0a66SVincent Palatin  hax="yes"
824c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
82517969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8261b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
827a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
8280c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8291b0f9cc2Saliguori  fi
830fd677642Sths  cocoa="yes"
8310c58ac1cSmalc  audio_drv_list="coreaudio"
83214382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8330c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8347973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
835a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
836a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
837a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
838adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
839898be3e0SPeter Maydell  supported_os="yes"
84083fb7adfSbellard;;
841ec530c81SbellardSunOS)
842ec530c81Sbellard  solaris="yes"
8430db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8440db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
845e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8466b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8470c58ac1cSmalc    audio_drv_list="oss"
8486b4d2ba1Sths  fi
849c2de5c91Smalc  audio_possible_drivers="oss sdl"
850d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
851d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
852d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
853d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
854a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
855560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
856560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
857560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
858ec530c81Sbellard;;
859179cf400SAndreas FärberHaiku)
860179cf400SAndreas Färber  haiku="yes"
861179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
862179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
863179cf400SAndreas Färber;;
864898be3e0SPeter MaydellLinux)
8650c58ac1cSmalc  audio_drv_list="oss"
8660bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8675327cf48Sbellard  linux="yes"
868831b7825Sths  linux_user="yes"
869af2be207SJan Kiszka  kvm="yes"
870af2be207SJan Kiszka  vhost_net="yes"
871042cea27SGonglei  vhost_crypto="yes"
8725e9be92dSNicholas Bellinger  vhost_scsi="yes"
873fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
874a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
875898be3e0SPeter Maydell  supported_os="yes"
876898be3e0SPeter Maydell;;
8777d13299dSbellardesac
8787d13299dSbellard
8797d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
880b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
88184778508Sblueswir1    bsd_user="yes"
8827d3505c5Sbellard  fi
88308de3949SAndreas Färberfi
8847d3505c5Sbellard
8850db4a067SPaolo Bonzini: ${make=${MAKE-make}}
8860db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
88752510f8bSStefan Weil: ${python=${PYTHON-python}}
888e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8890db4a067SPaolo Bonzini
8903c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8913c4a4d0dSPeter Maydellif has clang; then
8923c4a4d0dSPeter Maydell  objcc=clang
8933c4a4d0dSPeter Maydellelse
8943c4a4d0dSPeter Maydell  objcc="$cc"
8953c4a4d0dSPeter Maydellfi
8963c4a4d0dSPeter Maydell
8973457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8983457a3f8SJuan Quintela  EXESUF=".exe"
89917969268SFam Zheng  DSOSUF=".dll"
900a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
901e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
902e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
90378e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
90478e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
905f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
90693b25869SJohn Snow  write_c_skeleton;
907f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
908f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
909f7cf5d5bSStefan Weil  fi
910c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
911683035deSPaolo Bonzini  mandir="\${prefix}"
912528ae5b8SEduardo Habkost  datadir="\${prefix}"
913850da188SEduardo Habkost  qemu_docdir="\${prefix}"
914683035deSPaolo Bonzini  bindir="\${prefix}"
915683035deSPaolo Bonzini  sysconfdir="\${prefix}"
9165a699bbbSLaszlo Ersek  local_statedir=
917683035deSPaolo Bonzini  confsuffix=""
918105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9193457a3f8SJuan Quintelafi
9203457a3f8SJuan Quintela
921487fefdbSAnthony Liguoriwerror=""
92285aa5189Sbellard
9237d13299dSbellardfor opt do
92489138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9257d13299dSbellard  case "$opt" in
9262efc3265Sbellard  --help|-h) show_help=yes
9272efc3265Sbellard  ;;
92899123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
92999123e13SMike Frysinger  ;;
930b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9317d13299dSbellard  ;;
932b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
93332ce6337Sbellard  ;;
934ca4deeb1SPaolo Bonzini  --source-path=*)
9357d13299dSbellard  ;;
936ac0df51dSaliguori  --cross-prefix=*)
9377d13299dSbellard  ;;
938ac0df51dSaliguori  --cc=*)
9397d13299dSbellard  ;;
940b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
94183469015Sbellard  ;;
94283f73fceSTomoki Sekiyama  --cxx=*)
94383f73fceSTomoki Sekiyama  ;;
944e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
945e007dbecSMichael S. Tsirkin  ;;
9463c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9473c4a4d0dSPeter Maydell  ;;
948b1a550a0Spbrook  --make=*) make="$optarg"
9497d13299dSbellard  ;;
9506a882643Spbrook  --install=*) install="$optarg"
9516a882643Spbrook  ;;
952c886edfbSBlue Swirl  --python=*) python="$optarg"
953c886edfbSBlue Swirl  ;;
9541d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9551d728c39SBlue Swirl  ;;
956e2d8830eSBrad  --smbd=*) smbd="$optarg"
957e2d8830eSBrad  ;;
958e2a2ed06SJuan Quintela  --extra-cflags=*)
9597d13299dSbellard  ;;
96011cde1c8SBruno Dominguez  --extra-cxxflags=*)
96111cde1c8SBruno Dominguez  ;;
962e2a2ed06SJuan Quintela  --extra-ldflags=*)
9637d13299dSbellard  ;;
9645bc62e01SGerd Hoffmann  --enable-debug-info)
9655bc62e01SGerd Hoffmann  ;;
9665bc62e01SGerd Hoffmann  --disable-debug-info)
9675bc62e01SGerd Hoffmann  ;;
968d75402b5SAlex Bennée  --cross-cc-*)
969d75402b5SAlex Bennée  ;;
97017969268SFam Zheng  --enable-modules)
97117969268SFam Zheng      modules="yes"
97217969268SFam Zheng  ;;
9733aa88b31SStefan Hajnoczi  --disable-modules)
9743aa88b31SStefan Hajnoczi      modules="no"
9753aa88b31SStefan Hajnoczi  ;;
9762ff6b91eSJuan Quintela  --cpu=*)
9777d13299dSbellard  ;;
978b1a550a0Spbrook  --target-list=*) target_list="$optarg"
979de83cd02Sbellard  ;;
9805b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9815b808275SLluís Vilanova  ;;
9825b808275SLluís Vilanova  # XXX: backwards compatibility
9835b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
98494a420b1SStefan Hajnoczi  ;;
98574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9869410b56cSPrerna Saxena  ;;
9877d13299dSbellard  --enable-gprof) gprof="yes"
9887d13299dSbellard  ;;
9891d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9901d728c39SBlue Swirl  ;;
99179427693SLoïc Minier  --static)
99279427693SLoïc Minier    static="yes"
99379427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
99417884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
99543ce4dfeSbellard  ;;
9960b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9970b24e75fSPaolo Bonzini  ;;
9980b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9990b24e75fSPaolo Bonzini  ;;
10003aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10013aa5d2beSAlon Levy  ;;
10028bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10038bf188aaSMichael Tokarev  ;;
10040f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10050f94d6daSAlon Levy  ;;
1006528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10070b24e75fSPaolo Bonzini  ;;
1008023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1009023d3d67SEduardo Habkost  ;;
1010850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10110b24e75fSPaolo Bonzini  ;;
1012ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
101307381cc1SAnthony Liguori  ;;
1014785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1015785c23aeSLuiz Capitulino  ;;
10163d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10173d5eecabSGerd Hoffmann  ;;
1018181ce1d0SOlaf Hering  --host=*|--build=*|\
1019181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1020785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1021023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1022023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1023023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1024023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1025023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1026023ddd74SMax Filippov    # lots of directory switches by default.
1027023ddd74SMax Filippov  ;;
102897a847bcSbellard  --disable-sdl) sdl="no"
102997a847bcSbellard  ;;
1030c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1031c4198157SJuan Quintela  ;;
103247c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
103347c03744SDave Airlie  ;;
10343556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10353556c233SPaolo Bonzini  ;;
10363556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10373556c233SPaolo Bonzini  ;;
1038983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1039983eef5aSMeador Inge  ;;
1040983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1041983eef5aSMeador Inge  ;;
1042fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1043fe8fc5aeSPaolo Bonzini  ;;
1044fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1045fe8fc5aeSPaolo Bonzini  ;;
1046821601eaSJes Sorensen  --disable-vnc) vnc="no"
1047821601eaSJes Sorensen  ;;
1048821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1049821601eaSJes Sorensen  ;;
10502f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10512f6a1ab0Sblueswir1  ;;
10520c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10530c58ac1cSmalc  ;;
105489138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1055b64ec4e4SFam Zheng  ;;
105689138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1057eb852011SMarkus Armbruster  ;;
1058f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1059f8393946Saurel32  ;;
1060f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1061f8393946Saurel32  ;;
1062f3d08ee6SPaul Brook  --enable-debug)
1063f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1064f3d08ee6SPaul Brook      debug_tcg="yes"
10651fcc6d42SPeter Xu      debug_mutex="yes"
1066f3d08ee6SPaul Brook      debug="yes"
1067f3d08ee6SPaul Brook      strip_opt="no"
1068b553a042SJohn Snow      fortify_source="no"
1069f3d08ee6SPaul Brook  ;;
1070247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1071247724cbSMarc-André Lureau  ;;
1072247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1073247724cbSMarc-André Lureau  ;;
107403b4fe7dSaliguori  --enable-sparse) sparse="yes"
107503b4fe7dSaliguori  ;;
107603b4fe7dSaliguori  --disable-sparse) sparse="no"
107703b4fe7dSaliguori  ;;
10781625af87Saliguori  --disable-strip) strip_opt="no"
10791625af87Saliguori  ;;
10802f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
10812f9606b3Saliguori  ;;
1082ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1083ea784e3bSJuan Quintela  ;;
10842f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
10852f6f5c7aSCorentin Chary  ;;
10862f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
10872f6f5c7aSCorentin Chary  ;;
1088efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1089efe556adSCorentin Chary  ;;
1090efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1091efe556adSCorentin Chary  ;;
1092443f1376Sbellard  --disable-slirp) slirp="no"
1093c20709aaSbellard  ;;
1094e0e6c8c0Saliguori  --disable-vde) vde="no"
10958a16d273Sths  ;;
1096dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1097dfb278bdSJuan Quintela  ;;
109858952137SVincenzo Maffione  --disable-netmap) netmap="no"
109958952137SVincenzo Maffione  ;;
110058952137SVincenzo Maffione  --enable-netmap) netmap="yes"
110158952137SVincenzo Maffione  ;;
1102e37630caSaliguori  --disable-xen) xen="no"
1103e37630caSaliguori  ;;
1104fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1105fc321b4bSJuan Quintela  ;;
1106eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1107eb6fda0fSAnthony PERARD  ;;
1108eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1109eb6fda0fSAnthony PERARD  ;;
111064a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
111164a7ad6fSIan Campbell  ;;
111264a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
111364a7ad6fSIan Campbell  ;;
11142e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
11152e4d9fb1Saurel32  ;;
11164ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
11174ffcedb6SJuan Quintela  ;;
1118fb599c9aSbalrog  --disable-bluez) bluez="no"
1119fb599c9aSbalrog  ;;
1120a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1121a20a6f46SJuan Quintela  ;;
11227ba1e619Saliguori  --disable-kvm) kvm="no"
11237ba1e619Saliguori  ;;
1124b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1125b31a0277SJuan Quintela  ;;
1126b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1127180fb750Szhanghailiang  ;;
1128b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1129180fb750Szhanghailiang  ;;
1130c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1131c97d6d2cSSergio Andres Gomez Del Real  ;;
1132c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1133c97d6d2cSSergio Andres Gomez Del Real  ;;
1134d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1135d661d9a4SJustin Terry (VM)  ;;
1136d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1137d661d9a4SJustin Terry (VM)  ;;
11389195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11399195b2c2SStefan Weil  ;;
11409195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11419195b2c2SStefan Weil  ;;
114247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
114347e98658SCorey Bryant  ;;
114447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
114547e98658SCorey Bryant  ;;
1146b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1147b3f6ea7eSPaolo Bonzini  ;;
1148b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1149b3f6ea7eSPaolo Bonzini  ;;
11505a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11515a22ab71SYang Zhong  ;;
11525a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11535a22ab71SYang Zhong  ;;
1154cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1155cd4ec0b4SGerd Hoffmann  ;;
1156cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1157cd4ec0b4SGerd Hoffmann  ;;
1158c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1159c589b249SRonnie Sahlberg  ;;
1160c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1161c589b249SRonnie Sahlberg  ;;
11626542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11636542aa9cSPeter Lieven  ;;
11646542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11656542aa9cSPeter Lieven  ;;
116605c2a3e7Sbellard  --enable-profiler) profiler="yes"
116705c2a3e7Sbellard  ;;
116814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
116914821030SPavel Borzenkov  ;;
1170c2de5c91Smalc  --enable-cocoa)
1171c2de5c91Smalc      cocoa="yes" ;
117289138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
11735b0753e0Sbellard  ;;
1174cad25d69Spbrook  --disable-system) softmmu="no"
11750a8e90f4Spbrook  ;;
1176cad25d69Spbrook  --enable-system) softmmu="yes"
11770a8e90f4Spbrook  ;;
11780953a80fSZachary Amsden  --disable-user)
11790953a80fSZachary Amsden      linux_user="no" ;
11800953a80fSZachary Amsden      bsd_user="no" ;
11810953a80fSZachary Amsden  ;;
11820953a80fSZachary Amsden  --enable-user) ;;
1183831b7825Sths  --disable-linux-user) linux_user="no"
11840a8e90f4Spbrook  ;;
1185831b7825Sths  --enable-linux-user) linux_user="yes"
1186831b7825Sths  ;;
118784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
118884778508Sblueswir1  ;;
118984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
119084778508Sblueswir1  ;;
119140d6444eSAvi Kivity  --enable-pie) pie="yes"
119234005a00SKirill A. Shutemov  ;;
119340d6444eSAvi Kivity  --disable-pie) pie="no"
119434005a00SKirill A. Shutemov  ;;
119585aa5189Sbellard  --enable-werror) werror="yes"
119685aa5189Sbellard  ;;
119785aa5189Sbellard  --disable-werror) werror="no"
119885aa5189Sbellard  ;;
119963678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
120063678e17SSteven Noonan  ;;
120163678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
120263678e17SSteven Noonan  ;;
12034d3b6f6eSbalrog  --disable-curses) curses="no"
12044d3b6f6eSbalrog  ;;
1205c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1206c584a6d0SJuan Quintela  ;;
1207769ce76dSAlexander Graf  --disable-curl) curl="no"
1208769ce76dSAlexander Graf  ;;
1209788c8196SJuan Quintela  --enable-curl) curl="yes"
1210788c8196SJuan Quintela  ;;
12112df87df7SJuan Quintela  --disable-fdt) fdt="no"
12122df87df7SJuan Quintela  ;;
12132df87df7SJuan Quintela  --enable-fdt) fdt="yes"
12142df87df7SJuan Quintela  ;;
12155c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12165c6c3a6cSChristoph Hellwig  ;;
12175c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12185c6c3a6cSChristoph Hellwig  ;;
1219758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1220758e8e38SVenkateswararao Jujjuri (JV)  ;;
1221758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1222758e8e38SVenkateswararao Jujjuri (JV)  ;;
1223a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1224a40161cbSPaolo Bonzini  ;;
1225a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1226a40161cbSPaolo Bonzini  ;;
122777755340Sths  --disable-blobs) blobs="no"
122877755340Sths  ;;
12297e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12304a19f1ecSpbrook  ;;
1231519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1232519175a2SAlex Barcelo  ;;
123370c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
123470c60c08SStefan Hajnoczi  ;;
123570c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
123670c60c08SStefan Hajnoczi  ;;
12377d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12387d992e4dSPeter Lieven  ;;
1239f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1240f0d92b56SLongpeng(Mike)  ;;
1241f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1242f0d92b56SLongpeng(Mike)  ;;
1243a25dba17SJuan Quintela  --disable-docs) docs="no"
124470ec5dc0SAnthony Liguori  ;;
1245a25dba17SJuan Quintela  --enable-docs) docs="yes"
124683a3ab8bSJuan Quintela  ;;
1247d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1248d5970055SMichael S. Tsirkin  ;;
1249d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1250d5970055SMichael S. Tsirkin  ;;
1251042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1252042cea27SGonglei  ;;
1253042cea27SGonglei  --enable-vhost-crypto)
1254042cea27SGonglei      vhost_crypto="yes"
1255042cea27SGonglei      if test "$mingw32" = "yes"; then
1256042cea27SGonglei          error_exit "vhost-crypto isn't available on win32"
1257042cea27SGonglei      fi
1258042cea27SGonglei  ;;
12595e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12605e9be92dSNicholas Bellinger  ;;
12615e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12625e9be92dSNicholas Bellinger  ;;
1263fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1264fc0b9b0eSStefan Hajnoczi  ;;
1265fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1266fc0b9b0eSStefan Hajnoczi  ;;
1267da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
126820ff075bSMichael Walle  ;;
1269da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
127020ff075bSMichael Walle  ;;
1271f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1272f27aaf4bSChristian Brunner  ;;
1273f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1274f27aaf4bSChristian Brunner  ;;
12758c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12768c84cf11SSergei Trofimovich  ;;
12778c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12788c84cf11SSergei Trofimovich  ;;
12797b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1280111a38b0SRobert Relyea  ;;
12817b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1282111a38b0SRobert Relyea  ;;
12832b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
12842b2325ffSGerd Hoffmann  ;;
12852b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
12862b2325ffSGerd Hoffmann  ;;
128769354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
128869354a83SHans de Goede  ;;
128969354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
129069354a83SHans de Goede  ;;
12911ece9905SAlon Levy  --disable-zlib-test) zlib="no"
12921ece9905SAlon Levy  ;;
1293b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1294b25c9dffSStefan Weil  ;;
1295607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1296607dacd0Sqiaonuohan  ;;
1297b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1298b25c9dffSStefan Weil  ;;
1299607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1300607dacd0Sqiaonuohan  ;;
13016b383c08SPeter Wu  --disable-bzip2) bzip2="no"
13026b383c08SPeter Wu  ;;
13036b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13046b383c08SPeter Wu  ;;
1305d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1306d138cee9SMichael Roth  ;;
1307d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1308d138cee9SMichael Roth  ;;
13099dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13109dacf32dSYossi Hindin  ;;
13119dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13129dacf32dSYossi Hindin  ;;
1313d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1314d9840e25STomoki Sekiyama  ;;
1315d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1316d9840e25STomoki Sekiyama  ;;
1317d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1318d9840e25STomoki Sekiyama  ;;
1319d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1320d9840e25STomoki Sekiyama  ;;
1321d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1322d9840e25STomoki Sekiyama  ;;
1323d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1324d9840e25STomoki Sekiyama  ;;
13254b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13264b1c11fdSDaniel P. Berrange  ;;
13274b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13284b1c11fdSDaniel P. Berrange  ;;
1329f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1330f794573eSEduardo Otubo  ;;
1331f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1332f794573eSEduardo Otubo  ;;
1333eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1334eb100396SBharata B Rao  ;;
1335eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1336eb100396SBharata B Rao  ;;
133752b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
133852b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1339583f6e7bSStefan Hajnoczi  ;;
1340cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1341cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1342cb6414dfSFam Zheng  ;;
1343315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1344315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1345315d3184SFam Zheng  ;;
1346a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1347a4ccabcfSAnthony Liguori  ;;
1348a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1349a4ccabcfSAnthony Liguori  ;;
1350a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1351a1c5e949SDaniel P. Berrange  ;;
1352ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1353ddbb0d09SDaniel P. Berrange  ;;
1354ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1355ddbb0d09SDaniel P. Berrange  ;;
135691bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
135791bfcdb0SDaniel P. Berrange  ;;
135891bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
135991bfcdb0SDaniel P. Berrange  ;;
136091bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
136191bfcdb0SDaniel P. Berrange  ;;
136291bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
136391bfcdb0SDaniel P. Berrange  ;;
13642da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13652da776dbSMichael R. Hines  ;;
13662da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13672da776dbSMichael R. Hines  ;;
136821ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
136921ab34c9SMarcel Apfelbaum  ;;
137021ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
137121ab34c9SMarcel Apfelbaum  ;;
1372528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1373528de90aSDaniel P. Berrange  ;;
1374bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1375bbbf9bfbSStefan Weil  ;;
1376bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1377bbbf9bfbSStefan Weil  ;;
13789d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
13799d9e1521SGerd Hoffmann  ;;
13809d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
13819d9e1521SGerd Hoffmann  ;;
1382e91c793cSCole Robinson  --disable-tpm) tpm="no"
1383e91c793cSCole Robinson  ;;
1384ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1385ab214c29SStefan Berger  ;;
13860a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
13870a12ec87SRichard W.M. Jones  ;;
13880a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
13890a12ec87SRichard W.M. Jones  ;;
1390ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1391ed1701c6SDr. David Alan Gilbert  ;;
1392ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1393ed1701c6SDr. David Alan Gilbert  ;;
1394a99d57bbSWanlong Gao  --disable-numa) numa="no"
1395a99d57bbSWanlong Gao  ;;
1396a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1397a99d57bbSWanlong Gao  ;;
1398ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1399ed279a06SKlim Kireev  ;;
1400ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1401ed279a06SKlim Kireev  ;;
14022847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14032847b469SFam Zheng  ;;
14042847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14052847b469SFam Zheng  ;;
14067b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14077b01cb97SAlexandre Derumier  ;;
14087b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14097b01cb97SAlexandre Derumier  ;;
1410a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1411a6b1d4c0SChanglong Xie  ;;
1412a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1413a6b1d4c0SChanglong Xie  ;;
1414da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1415da92c3ffSAshish Mittal  ;;
1416da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1417da92c3ffSAshish Mittal  ;;
1418e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1419e6a74868SMarc-André Lureau  ;;
1420e6a74868SMarc-André Lureau  --enable-vhost-user)
1421e6a74868SMarc-André Lureau      vhost_user="yes"
1422e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1423e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1424e6a74868SMarc-André Lureau      fi
1425e6a74868SMarc-André Lureau  ;;
14268ca80760SRichard Henderson  --disable-capstone) capstone="no"
14278ca80760SRichard Henderson  ;;
14288ca80760SRichard Henderson  --enable-capstone) capstone="yes"
14298ca80760SRichard Henderson  ;;
1430e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1431e219c499SRichard Henderson  ;;
1432e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1433e219c499SRichard Henderson  ;;
1434cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1435cc84d63aSDaniel P. Berrange  ;;
1436f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1437f62bbee5SDaniel P. Berrange  ;;
1438f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1439f62bbee5SDaniel P. Berrange  ;;
1440ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1441ba59fb77SPaolo Bonzini  ;;
1442ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1443ba59fb77SPaolo Bonzini  ;;
144417824406SJunyan He  --enable-libpmem) libpmem=yes
144517824406SJunyan He  ;;
144617824406SJunyan He  --disable-libpmem) libpmem=no
144717824406SJunyan He  ;;
14482d2ad6d0SFam Zheng  *)
14492d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
14502d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
14512d2ad6d0SFam Zheng      exit 1
14527f1559c6Sbalrog  ;;
14537d13299dSbellard  esac
14547d13299dSbellarddone
14557d13299dSbellard
1456e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1457e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1458e6a74868SMarc-André Lureau        vhost_user="no"
1459e6a74868SMarc-André Lureau    else
1460e6a74868SMarc-André Lureau        vhost_user="yes"
1461e6a74868SMarc-André Lureau    fi
1462e6a74868SMarc-André Lureaufi
1463e6a74868SMarc-André Lureau
146440293e58Sbellardcase "$cpu" in
1465e3608d66SRichard Henderson    ppc)
1466e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1467e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
146813a5abe2SAlex Bennée           cross_cc_powerpc=$cc
146913a5abe2SAlex Bennée           cross_cc_cflags_powerpc=$CPU_CFLAGS
1470e3608d66SRichard Henderson           ;;
1471e3608d66SRichard Henderson    ppc64)
1472e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1473e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
147413a5abe2SAlex Bennée           cross_cc_ppc64=$cc
147513a5abe2SAlex Bennée           cross_cc_cflags_ppc64=$CPU_CFLAGS
1476e3608d66SRichard Henderson           ;;
14779b9c37c3SRichard Henderson    sparc)
1478f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1479f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
148013a5abe2SAlex Bennée           cross_cc_sparc=$cc
148113a5abe2SAlex Bennée           cross_cc_cflags_sparc=$CPU_CFLAGS
14823142255cSblueswir1           ;;
1483ed968ff1SJuan Quintela    sparc64)
148479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1485f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
148613a5abe2SAlex Bennée           cross_cc_sparc64=$cc
148713a5abe2SAlex Bennée           cross_cc_cflags_sparc64=$CPU_CFLAGS
14883142255cSblueswir1           ;;
148976d83bdeSths    s390)
1490061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
149128d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
149213a5abe2SAlex Bennée           cross_cc_s390=$cc
149313a5abe2SAlex Bennée           cross_cc_cflags_s390=$CPU_CFLAGS
149428d7cc49SRichard Henderson           ;;
149528d7cc49SRichard Henderson    s390x)
1496061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
149728d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
149813a5abe2SAlex Bennée           cross_cc_s390x=$cc
149913a5abe2SAlex Bennée           cross_cc_cflags_s390x=$CPU_CFLAGS
150076d83bdeSths           ;;
150140293e58Sbellard    i386)
150279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
15030c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
1504716a507cSAlex Bennée           cross_cc_i386=$cc
1505716a507cSAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
150640293e58Sbellard           ;;
150740293e58Sbellard    x86_64)
15087ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15097ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
15107ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
15117ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
15120c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
1513716a507cSAlex Bennée           cross_cc_x86_64=$cc
1514716a507cSAlex Bennée           cross_cc_cflags_x86_64=$CPU_CFLAGS
1515379f6698SPaul Brook           ;;
1516c72b26ecSRichard Henderson    x32)
1517c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1518c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1519716a507cSAlex Bennée           cross_cc_i386=$cc
152013a5abe2SAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
1521c72b26ecSRichard Henderson           ;;
152230163d89SPeter Maydell    # No special flags required for other host CPUs
15233142255cSblueswir1esac
15243142255cSblueswir1
152579f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
152679f3b12fSPeter Crosthwaite
1527affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1528affc88ccSPeter Maydell# support, even if we're using TCI.
1529affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1530affc88ccSPeter Maydell  bsd_user="no"
1531affc88ccSPeter Maydell  linux_user="no"
1532affc88ccSPeter Maydellfi
1533affc88ccSPeter Maydell
153460e0df25SPeter Maydelldefault_target_list=""
153560e0df25SPeter Maydell
15366e92f823SPeter Maydellmak_wilds=""
15376e92f823SPeter Maydell
153860e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
15396e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
154060e0df25SPeter Maydellfi
154160e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
15426e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
154360e0df25SPeter Maydellfi
154460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
15456e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
154660e0df25SPeter Maydellfi
154760e0df25SPeter Maydell
15486e92f823SPeter Maydellfor config in $mak_wilds; do
15496e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
15506e92f823SPeter Maydelldone
15516e92f823SPeter Maydell
1552c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
155364a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1554c53eeaf7SStefan Hajnoczi
1555af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1556af5db58eSpbrookcat << EOF
1557af5db58eSpbrook
1558af5db58eSpbrookUsage: configure [options]
1559af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1560af5db58eSpbrook
156108fb77edSStefan WeilStandard options:
156208fb77edSStefan Weil  --help                   print this message
156308fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
156408fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
156508fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
156608fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
156708fb77edSStefan Weil$(echo Available targets: $default_target_list | \
156808fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
156908fb77edSStefan Weil
157008fb77edSStefan WeilAdvanced options (experts only):
157108fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
157208fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
157308fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
157408fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
157508fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
157608fb77edSStefan Weil                           build time
157708fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
157808fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
157908fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
158011cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
158108fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1582d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1583d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
158408fb77edSStefan Weil  --make=MAKE              use specified make [$make]
158508fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
158608fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
158708fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1588db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
158908fb77edSStefan Weil  --static                 enable static build [$static]
159008fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
159108fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
159208fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
159308fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
159408fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1595db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
159608fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
159708fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
15983d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1599e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1600db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
160108fb77edSStefan Weil  --enable-debug           enable common debug build options
1602247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
160308fb77edSStefan Weil  --disable-strip          disable stripping binaries
160408fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
160563678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
160608fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
160708fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
160808fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
160908fb77edSStefan Weil  --block-drv-rw-whitelist=L
161008fb77edSStefan Weil                           set block driver read-write whitelist
161108fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
161208fb77edSStefan Weil  --block-drv-ro-whitelist=L
161308fb77edSStefan Weil                           set block driver read-only whitelist
161408fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
16155b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1616c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
161708fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
161808fb77edSStefan Weil                           Default:trace-<pid>
1619c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1620c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
16215a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1622c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1623c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
162408fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
162533c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
162608fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
162708fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1628c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1629c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1630c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1631a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1632c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1633c12d66aaSLin Ma  --enable-profiler        profiler support
1634c12d66aaSLin Ma  --enable-xen-pv-domain-build
1635c12d66aaSLin Ma                           xen pv domain builder
1636c12d66aaSLin Ma  --enable-debug-stack-usage
1637c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1638c23f23b9SMichael Tokarev
1639c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1640c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1641c23f23b9SMichael Tokarev
1642c23f23b9SMichael Tokarev  system          all system emulation targets
1643c23f23b9SMichael Tokarev  user            supported user emulation targets
1644c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1645c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1646c23f23b9SMichael Tokarev  docs            build documentation
1647c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1648c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1649c23f23b9SMichael Tokarev  pie             Position Independent Executables
1650c23f23b9SMichael Tokarev  modules         modules support
1651c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1652c23f23b9SMichael Tokarev  debug-info      debugging information
1653c23f23b9SMichael Tokarev  sparse          sparse checker
1654c23f23b9SMichael Tokarev
1655ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
165691bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
165791bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1658c23f23b9SMichael Tokarev  sdl             SDL UI
1659c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1660c23f23b9SMichael Tokarev  gtk             gtk UI
1661c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1662c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1663c23f23b9SMichael Tokarev  curses          curses UI
1664c23f23b9SMichael Tokarev  vnc             VNC UI support
1665c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1666c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1667c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1668c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1669c23f23b9SMichael Tokarev  virtfs          VirtFS
1670fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1671c23f23b9SMichael Tokarev  xen             xen backend driver support
167270c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1673c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1674c23f23b9SMichael Tokarev  curl            curl connectivity
1675a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1676c23f23b9SMichael Tokarev  fdt             fdt device tree
1677c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1678c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1679b0cb0a66SVincent Palatin  hax             HAX acceleration support
1680c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1681d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
168221ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
168321ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1684c23f23b9SMichael Tokarev  vde             support for vde network
1685c23f23b9SMichael Tokarev  netmap          support for netmap network
1686c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1687c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1688c23f23b9SMichael Tokarev  attr            attr and xattr support
1689c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1690042cea27SGonglei  vhost-crypto    vhost-crypto acceleration support
1691c23f23b9SMichael Tokarev  spice           spice
1692c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1693c23f23b9SMichael Tokarev  libiscsi        iscsi support
1694c23f23b9SMichael Tokarev  libnfs          nfs support
16957b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1696c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1697ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1698c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1699c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1700c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1701c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1702c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1703c23f23b9SMichael Tokarev  seccomp         seccomp support
1704c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1705c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1706c23f23b9SMichael Tokarev  tpm             TPM support
1707c23f23b9SMichael Tokarev  libssh2         ssh block device support
1708c23f23b9SMichael Tokarev  numa            libnuma support
1709ed279a06SKlim Kireev  libxml2         for Parallels image format
1710c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
17117b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1712a6b1d4c0SChanglong Xie  replication     replication support
1713c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1714c12d66aaSLin Ma  opengl          opengl support
1715c12d66aaSLin Ma  virglrenderer   virgl rendering support
1716c12d66aaSLin Ma  xfsctl          xfsctl support
1717c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1718c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1719da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1720f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1721e6a74868SMarc-André Lureau  vhost-user      vhost-user support
17228ca80760SRichard Henderson  capstone        capstone disassembler support
1723ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
172417824406SJunyan He  libpmem         libpmem support
172508fb77edSStefan Weil
172608fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1727af5db58eSpbrookEOF
17282d2ad6d0SFam Zhengexit 0
1729af5db58eSpbrookfi
1730af5db58eSpbrook
1731c53eeaf7SStefan Hajnocziif ! has $python; then
1732c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1733c53eeaf7SStefan Hajnoczifi
1734c53eeaf7SStefan Hajnoczi
1735c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1736c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
17377f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
17387f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1739c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1740c53eeaf7SStefan Hajnoczifi
1741c53eeaf7SStefan Hajnoczi
1742c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1743c53eeaf7SStefan Hajnoczipython="$python -B"
1744c53eeaf7SStefan Hajnoczi
17459aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
17469aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
17479aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
17489aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
17499aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
17509aae6e54SDaniel Henrique Barbozaif compile_object ; then
17519aae6e54SDaniel Henrique Barboza  : C compiler works ok
17529aae6e54SDaniel Henrique Barbozaelse
17539aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
17549aae6e54SDaniel Henrique Barbozafi
17559aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
17569aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
17579aae6e54SDaniel Henrique Barbozafi
17589aae6e54SDaniel Henrique Barboza
1759359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1760359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1761359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1762359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1763359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1764359bc95dSPeter Maydell    else
176576ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1766359bc95dSPeter Maydell    fi
1767359bc95dSPeter Maydellfi
1768359bc95dSPeter Maydell
17699c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
17709c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
17719c83ffd8SPeter Maydellif test -z "$werror" ; then
17729c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1773e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
17749c83ffd8SPeter Maydell        werror="yes"
17759c83ffd8SPeter Maydell    else
17769c83ffd8SPeter Maydell        werror="no"
17779c83ffd8SPeter Maydell    fi
17789c83ffd8SPeter Maydellfi
17799c83ffd8SPeter Maydell
1780fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1781fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1782fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1783fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1784fb59dabdSPeter Maydell    # host OS we should stop now.
1785951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1786fb59dabdSPeter Maydellfi
1787fb59dabdSPeter Maydell
17888d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
17898d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1790ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1791435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1792b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
179371429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
17940e39c4aaSGerd Hoffmanngcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
17956ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
17966ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
17976ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
17986ca026cbSPeter Maydell# so it's too error prone.
179993b25869SJohn Snow
180093b25869SJohn Snowcc_has_warning_flag() {
180193b25869SJohn Snow    write_c_skeleton;
180293b25869SJohn Snow
1803a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1804a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1805a1d29d6cSPeter Maydell    # warning options).
180693b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
180793b25869SJohn Snow    compile_prog "-Werror $optflag" ""
180893b25869SJohn Snow}
180993b25869SJohn Snow
181093b25869SJohn Snowfor flag in $gcc_flags; do
181193b25869SJohn Snow    if cc_has_warning_flag $flag ; then
18128d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
18138d05095cSPaolo Bonzini    fi
18148d05095cSPaolo Bonzinidone
18158d05095cSPaolo Bonzini
181663678e17SSteven Noonanif test "$stack_protector" != "no"; then
1817fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1818fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1819fccd35a0SRodrigo Rebello{
1820fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1821fccd35a0SRodrigo Rebello    while (*c) {
1822fccd35a0SRodrigo Rebello        *p++ = *c++;
1823fccd35a0SRodrigo Rebello    }
1824fccd35a0SRodrigo Rebello    return 0;
1825fccd35a0SRodrigo Rebello}
1826fccd35a0SRodrigo RebelloEOF
182763678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
18283b463a3fSMiroslav Rezanina  sp_on=0
182963678e17SSteven Noonan  for flag in $gcc_flags; do
1830590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1831590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1832590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1833590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
183463678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
18353b463a3fSMiroslav Rezanina      sp_on=1
183663678e17SSteven Noonan      break
183763678e17SSteven Noonan    fi
183863678e17SSteven Noonan  done
18393b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
18403b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
18413b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
18423b463a3fSMiroslav Rezanina    fi
18433b463a3fSMiroslav Rezanina  fi
184437746c5eSMarc-André Lureaufi
184537746c5eSMarc-André Lureau
184620bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
184720bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
184820bc94a2SPaolo Bonzinicat > $TMPC << EOF
184920bc94a2SPaolo Bonzinistruct {
185020bc94a2SPaolo Bonzini  int a[2];
185120bc94a2SPaolo Bonzini} x = {0};
185220bc94a2SPaolo BonziniEOF
185320bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
185420bc94a2SPaolo Bonzini  :
185520bc94a2SPaolo Bonzinielse
185620bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
185720bc94a2SPaolo Bonzinifi
185820bc94a2SPaolo Bonzini
1859cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1860cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1861cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1862cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1863cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1864cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1865cbdd1999SPaolo Bonziniint main(void) { return 0; }
1866cbdd1999SPaolo Bonzini#else
1867cbdd1999SPaolo Bonzini#error No bug in this compiler.
1868cbdd1999SPaolo Bonzini#endif
1869cbdd1999SPaolo BonziniEOF
1870cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1871cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1872cbdd1999SPaolo Bonzinifi
1873cbdd1999SPaolo Bonzini
187440d6444eSAvi Kivityif test "$static" = "yes" ; then
1875aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1876aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1877aa0d1f44SPaolo Bonzini  fi
187840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
187976ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
188040d6444eSAvi Kivity  else
188140d6444eSAvi Kivity    pie="no"
188240d6444eSAvi Kivity  fi
188340d6444eSAvi Kivityfi
188440d6444eSAvi Kivity
1885768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1886768b7855SEmilio G. Cota  cat > $TMPC << EOF
1887768b7855SEmilio G. Cotastatic __thread int tls_var;
1888768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1889768b7855SEmilio G. CotaEOF
1890768b7855SEmilio G. Cota
1891768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1892768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1893768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1894768b7855SEmilio G. Cotafi
1895768b7855SEmilio G. Cota
189640d6444eSAvi Kivityif test "$pie" = ""; then
189740d6444eSAvi Kivity  case "$cpu-$targetos" in
1898c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
189940d6444eSAvi Kivity      ;;
190040d6444eSAvi Kivity    *)
190140d6444eSAvi Kivity      pie="no"
190240d6444eSAvi Kivity      ;;
190340d6444eSAvi Kivity  esac
190440d6444eSAvi Kivityfi
190540d6444eSAvi Kivity
190640d6444eSAvi Kivityif test "$pie" != "no" ; then
190740d6444eSAvi Kivity  cat > $TMPC << EOF
190821d4a791SAvi Kivity
190921d4a791SAvi Kivity#ifdef __linux__
191021d4a791SAvi Kivity#  define THREAD __thread
191121d4a791SAvi Kivity#else
191221d4a791SAvi Kivity#  define THREAD
191321d4a791SAvi Kivity#endif
191421d4a791SAvi Kivity
191521d4a791SAvi Kivitystatic THREAD int tls_var;
191621d4a791SAvi Kivity
191721d4a791SAvi Kivityint main(void) { return tls_var; }
191821d4a791SAvi Kivity
191940d6444eSAvi KivityEOF
192040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
192140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
192240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
192340d6444eSAvi Kivity    pie="yes"
192440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
192540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
192640d6444eSAvi Kivity    fi
192740d6444eSAvi Kivity  else
192840d6444eSAvi Kivity    if test "$pie" = "yes"; then
192976ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
193040d6444eSAvi Kivity    else
193140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
193240d6444eSAvi Kivity      pie="no"
193340d6444eSAvi Kivity    fi
193440d6444eSAvi Kivity  fi
193546eef33bSBrad
1936e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
193746eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
193846eef33bSBrad    LDFLAGS_NOPIE="-nopie"
193946eef33bSBrad  fi
194040d6444eSAvi Kivityfi
194140d6444eSAvi Kivity
194209dada40SPaolo Bonzini##########################################
194309dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
194409dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
194509dada40SPaolo Bonzini# specification is necessary
194609dada40SPaolo Bonzini
194709dada40SPaolo Bonziniif test "$cpu" = "i386"; then
194809dada40SPaolo Bonzini  cat > $TMPC << EOF
194909dada40SPaolo Bonzinistatic int sfaa(int *ptr)
195009dada40SPaolo Bonzini{
195109dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
195209dada40SPaolo Bonzini}
195309dada40SPaolo Bonzini
195409dada40SPaolo Bonziniint main(void)
195509dada40SPaolo Bonzini{
195609dada40SPaolo Bonzini  int val = 42;
19571405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
195809dada40SPaolo Bonzini  sfaa(&val);
195909dada40SPaolo Bonzini  return val;
196009dada40SPaolo Bonzini}
196109dada40SPaolo BonziniEOF
196209dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
196309dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
196409dada40SPaolo Bonzini  fi
196509dada40SPaolo Bonzinifi
196609dada40SPaolo Bonzini
196709dada40SPaolo Bonzini#########################################
1968ec530c81Sbellard# Solaris specific configure tool chain decisions
196909dada40SPaolo Bonzini
1970ec530c81Sbellardif test "$solaris" = "yes" ; then
19716792aa11SLoïc Minier  if has $install; then
19726792aa11SLoïc Minier    :
19736792aa11SLoïc Minier  else
197476ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
197576ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
197676ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1977ec530c81Sbellard  fi
197889138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
197976ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
198076ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
198176ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1982ec530c81Sbellard  fi
19836792aa11SLoïc Minier  if has ar; then
19846792aa11SLoïc Minier    :
19856792aa11SLoïc Minier  else
1986ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
198776ad07a4SPeter Maydell      error_exit "No path includes ar" \
198876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1989ec530c81Sbellard    fi
199076ad07a4SPeter Maydell    error_exit "No path includes ar"
1991ec530c81Sbellard  fi
1992ec530c81Sbellardfi
1993ec530c81Sbellard
1994afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1995d880a3baSPaolo Bonzini    for target in $default_target_list; do
1996d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1997d880a3baSPaolo Bonzini            target_list="$target_list $target"
1998d880a3baSPaolo Bonzini    done
1999d880a3baSPaolo Bonzini    target_list="${target_list# }"
2000121afa9eSAnthony Liguorielse
200189138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2002d880a3baSPaolo Bonzini    for target in $target_list; do
200325b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
200425b48338SPeter Maydell        # friendly error message than if we let it fall through.
200525b48338SPeter Maydell        case " $default_target_list " in
200625b48338SPeter Maydell            *" $target "*)
200725b48338SPeter Maydell                ;;
200825b48338SPeter Maydell            *)
200925b48338SPeter Maydell                error_exit "Unknown target name '$target'"
201025b48338SPeter Maydell                ;;
201125b48338SPeter Maydell        esac
2012d880a3baSPaolo Bonzini        supported_target $target || exit 1
201325b48338SPeter Maydell    done
2014d880a3baSPaolo Bonzinifi
201525b48338SPeter Maydell
2016f55fe278SPaolo Bonzini# see if system emulation was really requested
2017f55fe278SPaolo Bonzinicase " $target_list " in
2018f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2019f55fe278SPaolo Bonzini  ;;
2020f55fe278SPaolo Bonzini  *) softmmu=no
2021f55fe278SPaolo Bonzini  ;;
2022f55fe278SPaolo Bonziniesac
20235327cf48Sbellard
2024249247c9SJuan Quintelafeature_not_found() {
2025249247c9SJuan Quintela  feature=$1
202621684af0SStewart Smith  remedy=$2
2027249247c9SJuan Quintela
202876ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
202921684af0SStewart Smith      "configure was not able to find it." \
203021684af0SStewart Smith      "$remedy"
2031249247c9SJuan Quintela}
2032249247c9SJuan Quintela
20337d13299dSbellard# ---
20347d13299dSbellard# big/little endian test
20357d13299dSbellardcat > $TMPC << EOF
203661cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
203761cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
203861cc919fSMike Frysingerextern int foo(short *, short *);
203961cc919fSMike Frysingerint main(int argc, char *argv[]) {
204061cc919fSMike Frysinger    return foo(big_endian, little_endian);
20417d13299dSbellard}
20427d13299dSbellardEOF
20437d13299dSbellard
204461cc919fSMike Frysingerif compile_object ; then
204512f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
204661cc919fSMike Frysinger        bigendian="yes"
204712f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
204861cc919fSMike Frysinger        bigendian="no"
20497d13299dSbellard    else
20507d13299dSbellard        echo big/little test failed
20517d13299dSbellard    fi
20527d13299dSbellardelse
205361cc919fSMike Frysinger    echo big/little test failed
20547d13299dSbellardfi
20557d13299dSbellard
2056b0a47e79SJuan Quintela##########################################
2057a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2058a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2059a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2060a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2061a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2062a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2063a30878e7SPeter Maydell    fi
2064a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2065a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2066a30878e7SPeter Maydell    fi
2067a30878e7SPeter Maydell    gtk=no
2068a30878e7SPeter Maydell    sdl=no
2069a30878e7SPeter Maydellfi
2070a30878e7SPeter Maydell
20716b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
20726b39b063SEric Blakecat > $TMPC << EOF
20736b39b063SEric Blake#include <stdint.h>
20746b39b063SEric Blake#include <stdio.h>
20756b39b063SEric Blakeint main(int argc, char *argv[]) {
20766b39b063SEric Blake    return printf("%zu", SIZE_MAX);
20776b39b063SEric Blake}
20786b39b063SEric BlakeEOF
20796b39b063SEric Blakehave_broken_size_max=no
20806b39b063SEric Blakeif ! compile_object -Werror ; then
20816b39b063SEric Blake    have_broken_size_max=yes
20826b39b063SEric Blakefi
20836b39b063SEric Blake
2084a30878e7SPeter Maydell##########################################
2085015a33bdSGonglei# L2TPV3 probe
2086015a33bdSGonglei
2087015a33bdSGongleicat > $TMPC <<EOF
2088015a33bdSGonglei#include <sys/socket.h>
2089bff6cb72SMichael Tokarev#include <linux/ip.h>
2090015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2091015a33bdSGongleiEOF
2092015a33bdSGongleiif compile_prog "" "" ; then
2093015a33bdSGonglei  l2tpv3=yes
2094015a33bdSGongleielse
2095015a33bdSGonglei  l2tpv3=no
2096015a33bdSGongleifi
2097015a33bdSGonglei
2098015a33bdSGonglei##########################################
20994d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
21004d9310f4SDaniel P. Berrange
21014d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
21024d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
21034d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
21044d9310f4SDaniel P. Berrange    #
21054d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
21064d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
21074d9310f4SDaniel P. Berrange    #
21084d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
21094d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
21104d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
21114d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
21124d9310f4SDaniel P. Berrange    # that for you.
21134d9310f4SDaniel P. Berrange    #
21144d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
21154d9310f4SDaniel P. Berrange    # are not in fact redundant.
21164d9310f4SDaniel P. Berrangecat > $TMPC << EOF
21174d9310f4SDaniel P. Berrange#include <unistd.h>
21184d9310f4SDaniel P. Berrange#include <time.h>
21194d9310f4SDaniel P. Berrange#undef localtime_r
21204d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
21214d9310f4SDaniel P. BerrangeEOF
21224d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
21234d9310f4SDaniel P. Berrange        localtime_r="yes"
21244d9310f4SDaniel P. Berrange    else
21254d9310f4SDaniel P. Berrange        localtime_r="no"
21264d9310f4SDaniel P. Berrange    fi
21274d9310f4SDaniel P. Berrangefi
21284d9310f4SDaniel P. Berrange
21294d9310f4SDaniel P. Berrange##########################################
2130779ab5e3SStefan Weil# pkg-config probe
2131779ab5e3SStefan Weil
2132779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
213376ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2134779ab5e3SStefan Weilfi
2135779ab5e3SStefan Weil
2136779ab5e3SStefan Weil##########################################
2137b0a47e79SJuan Quintela# NPTL probe
2138b0a47e79SJuan Quintela
213924cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2140bd0c5661Spbrook  cat > $TMPC <<EOF
2141bd0c5661Spbrook#include <sched.h>
214230813ceaSpbrook#include <linux/futex.h>
2143182eacc0SStefan Weilint main(void) {
2144bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2145bd0c5661Spbrook#error bork
2146bd0c5661Spbrook#endif
2147182eacc0SStefan Weil  return 0;
2148bd0c5661Spbrook}
2149bd0c5661SpbrookEOF
215024cb36a6SPeter Maydell  if ! compile_object ; then
215121684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2152b0a47e79SJuan Quintela  fi
2153bd0c5661Spbrookfi
2154bd0c5661Spbrook
215599f2dbd3SLiang Li#########################################
2156ac62922eSbalrog# zlib check
2157ac62922eSbalrog
21581ece9905SAlon Levyif test "$zlib" != "no" ; then
2159ac62922eSbalrog    cat > $TMPC << EOF
2160ac62922eSbalrog#include <zlib.h>
2161ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
2162ac62922eSbalrogEOF
216352166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
2164ac62922eSbalrog        :
2165ac62922eSbalrog    else
216676ad07a4SPeter Maydell        error_exit "zlib check failed" \
216776ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
2168ac62922eSbalrog    fi
21691ece9905SAlon Levyfi
2170eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
2171ac62922eSbalrog
2172ac62922eSbalrog##########################################
2173607dacd0Sqiaonuohan# lzo check
2174607dacd0Sqiaonuohan
2175607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2176607dacd0Sqiaonuohan    cat > $TMPC << EOF
2177607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2178607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2179607dacd0SqiaonuohanEOF
2180607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2181607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2182b25c9dffSStefan Weil        lzo="yes"
2183b25c9dffSStefan Weil    else
2184b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2185b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2186b25c9dffSStefan Weil        fi
2187b25c9dffSStefan Weil        lzo="no"
2188b25c9dffSStefan Weil    fi
2189607dacd0Sqiaonuohanfi
2190607dacd0Sqiaonuohan
2191607dacd0Sqiaonuohan##########################################
2192607dacd0Sqiaonuohan# snappy check
2193607dacd0Sqiaonuohan
2194607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2195607dacd0Sqiaonuohan    cat > $TMPC << EOF
2196607dacd0Sqiaonuohan#include <snappy-c.h>
2197607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2198607dacd0SqiaonuohanEOF
2199607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2200607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2201b25c9dffSStefan Weil        snappy="yes"
2202b25c9dffSStefan Weil    else
2203b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2204b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2205b25c9dffSStefan Weil        fi
2206b25c9dffSStefan Weil        snappy="no"
2207b25c9dffSStefan Weil    fi
2208607dacd0Sqiaonuohanfi
2209607dacd0Sqiaonuohan
2210607dacd0Sqiaonuohan##########################################
22116b383c08SPeter Wu# bzip2 check
22126b383c08SPeter Wu
22136b383c08SPeter Wuif test "$bzip2" != "no" ; then
22146b383c08SPeter Wu    cat > $TMPC << EOF
22156b383c08SPeter Wu#include <bzlib.h>
22166b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
22176b383c08SPeter WuEOF
22186b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
22196b383c08SPeter Wu        bzip2="yes"
22206b383c08SPeter Wu    else
22216b383c08SPeter Wu        if test "$bzip2" = "yes"; then
22226b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
22236b383c08SPeter Wu        fi
22246b383c08SPeter Wu        bzip2="no"
22256b383c08SPeter Wu    fi
22266b383c08SPeter Wufi
22276b383c08SPeter Wu
22286b383c08SPeter Wu##########################################
2229f794573eSEduardo Otubo# libseccomp check
2230f794573eSEduardo Otubo
2231f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2232693e5910SAndrew Jones    case "$cpu" in
2233693e5910SAndrew Jones    i386|x86_64)
2234ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2235693e5910SAndrew Jones        ;;
22365ce43972SJames Hogan    mips)
22375ce43972SJames Hogan        libseccomp_minver="2.2.0"
22385ce43972SJames Hogan        ;;
2239693e5910SAndrew Jones    arm|aarch64)
2240693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2241693e5910SAndrew Jones        ;;
22423aa35fcfSThomas Huth    ppc|ppc64|s390x)
22433e684455SMichael Strosaker        libseccomp_minver="2.3.0"
22443e684455SMichael Strosaker        ;;
2245693e5910SAndrew Jones    *)
2246693e5910SAndrew Jones        libseccomp_minver=""
2247693e5910SAndrew Jones        ;;
2248693e5910SAndrew Jones    esac
2249693e5910SAndrew Jones
2250693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2251693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2252c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2253c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2254f794573eSEduardo Otubo        seccomp="yes"
2255f794573eSEduardo Otubo    else
2256f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2257693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2258693e5910SAndrew Jones                feature_not_found "libseccomp" \
2259693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2260693e5910SAndrew Jones            else
2261693e5910SAndrew Jones                feature_not_found "libseccomp" \
2262693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2263693e5910SAndrew Jones            fi
2264896848f0SEduardo Otubo        fi
2265e84d5956SYann E. MORIN        seccomp="no"
2266f794573eSEduardo Otubo    fi
2267f794573eSEduardo Otubofi
2268f794573eSEduardo Otubo##########################################
2269e37630caSaliguori# xen probe
2270e37630caSaliguori
2271fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2272c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2273c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2274c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2275c1cdd9d5SJuergen Gross
2276c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2277c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2278c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2279c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2280c1cdd9d5SJuergen Gross    xen=yes
2281c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2282c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
228358ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
228458ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
228558ea9a7aSAnthony PERARD    fi
2286c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2287c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2288c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2289c1cdd9d5SJuergen Gross  else
2290c1cdd9d5SJuergen Gross
2291b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2292d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2293d5b93ddfSAnthony PERARD
229450ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
229550ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
229650ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
229750ced5b3SStefan Weil
229850ced5b3SStefan Weil    # Xen (any)
229950ced5b3SStefan Weil    cat > $TMPC <<EOF
230050ced5b3SStefan Weil#include <xenctrl.h>
230150ced5b3SStefan Weilint main(void) {
230250ced5b3SStefan Weil  return 0;
230350ced5b3SStefan Weil}
230450ced5b3SStefan WeilEOF
230550ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
230650ced5b3SStefan Weil      # Xen not found
230750ced5b3SStefan Weil      if test "$xen" = "yes" ; then
230821684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
230950ced5b3SStefan Weil      fi
231050ced5b3SStefan Weil      xen=no
231150ced5b3SStefan Weil
2312d5b93ddfSAnthony PERARD    # Xen unstable
231369deef08SPeter Maydell    elif
231469deef08SPeter Maydell        cat > $TMPC <<EOF &&
23152cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
23162cbf8903SRoss Lagerwall#define __XEN_TOOLS__
23172cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2318d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
23192cbf8903SRoss Lagerwallint main(void) {
23202cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2321d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
23222cbf8903SRoss Lagerwall
23232cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
23242cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
23252cbf8903SRoss Lagerwall
2326d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2327d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2328d3c49ebbSPaul Durrant
23292cbf8903SRoss Lagerwall  return 0;
23302cbf8903SRoss Lagerwall}
23312cbf8903SRoss LagerwallEOF
23322cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
23332cbf8903SRoss Lagerwall      then
23342cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
23352cbf8903SRoss Lagerwall      xen_ctrl_version=41100
23362cbf8903SRoss Lagerwall      xen=yes
23372cbf8903SRoss Lagerwall    elif
23382cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
23395ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
23405ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
234158ea9a7aSAnthony PERARD#include <xentoolcore.h>
23425ba3d756SIgor Druzhininint main(void) {
23435ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
23445ba3d756SIgor Druzhinin
23455ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
23465ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
234758ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
23485ba3d756SIgor Druzhinin
23495ba3d756SIgor Druzhinin  return 0;
23505ba3d756SIgor Druzhinin}
23515ba3d756SIgor DruzhininEOF
235258ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
23535ba3d756SIgor Druzhinin      then
235458ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
23555ba3d756SIgor Druzhinin      xen_ctrl_version=41000
23565ba3d756SIgor Druzhinin      xen=yes
23575ba3d756SIgor Druzhinin    elif
23585ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2359da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2360da8090ccSPaul Durrant#define __XEN_TOOLS__
2361da8090ccSPaul Durrant#include <xendevicemodel.h>
2362da8090ccSPaul Durrantint main(void) {
2363da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2364da8090ccSPaul Durrant
2365da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2366da8090ccSPaul Durrant  xendevicemodel_close(xd);
2367da8090ccSPaul Durrant
2368da8090ccSPaul Durrant  return 0;
2369da8090ccSPaul Durrant}
2370da8090ccSPaul DurrantEOF
2371da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2372da8090ccSPaul Durrant      then
2373da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2374f1167ee6SJuergen Gross      xen_ctrl_version=40900
2375da8090ccSPaul Durrant      xen=yes
2376da8090ccSPaul Durrant    elif
2377da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
23785eeb39c2SIan Campbell/*
23795eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
23805eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2381b6eb9b45SPaulina Szubarczyk *
2382b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2383b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2384b6eb9b45SPaulina Szubarczyk */
2385b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2386b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2387b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2388b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2389b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2390b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2391b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2392b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2393b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2394b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2395b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2396b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2397b6eb9b45SPaulina Szubarczyk#endif
2398b6eb9b45SPaulina Szubarczykint main(void) {
2399b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2400b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2401b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2402b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2403b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2404b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2405b6eb9b45SPaulina Szubarczyk
2406b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2407b6eb9b45SPaulina Szubarczyk
2408b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2409b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2410b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2411b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2412b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2413b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2414b6eb9b45SPaulina Szubarczyk
2415b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2416b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2417b6eb9b45SPaulina Szubarczyk
2418b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2419b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2420b6eb9b45SPaulina Szubarczyk
2421b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2422b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2423b6eb9b45SPaulina Szubarczyk
2424b6eb9b45SPaulina Szubarczyk  return 0;
2425b6eb9b45SPaulina Szubarczyk}
2426b6eb9b45SPaulina SzubarczykEOF
2427b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2428b6eb9b45SPaulina Szubarczyk      then
2429f1167ee6SJuergen Gross      xen_ctrl_version=40800
2430b6eb9b45SPaulina Szubarczyk      xen=yes
2431b6eb9b45SPaulina Szubarczyk    elif
2432b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2433b6eb9b45SPaulina Szubarczyk/*
2434b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2435b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
24365eeb39c2SIan Campbell */
24375eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
24385eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
24395eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
24405eeb39c2SIan Campbell#include <xenctrl.h>
24415eeb39c2SIan Campbell#include <xenstore.h>
24425eeb39c2SIan Campbell#include <xenevtchn.h>
24435eeb39c2SIan Campbell#include <xengnttab.h>
24445eeb39c2SIan Campbell#include <xenforeignmemory.h>
24455eeb39c2SIan Campbell#include <stdint.h>
24465eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
24475eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
24485eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
24495eeb39c2SIan Campbell#endif
24505eeb39c2SIan Campbellint main(void) {
24515eeb39c2SIan Campbell  xc_interface *xc = NULL;
24525eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
24535eeb39c2SIan Campbell  xenevtchn_handle *xe;
24545eeb39c2SIan Campbell  xengnttab_handle *xg;
24555eeb39c2SIan Campbell  xen_domain_handle_t handle;
24565eeb39c2SIan Campbell
24575eeb39c2SIan Campbell  xs_daemon_open();
24585eeb39c2SIan Campbell
24595eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
24605eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
24615eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
24625eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
24635eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
24645eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
24655eeb39c2SIan Campbell
24665eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
24675eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
24685eeb39c2SIan Campbell
24695eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
24705eeb39c2SIan Campbell  xenevtchn_fd(xe);
24715eeb39c2SIan Campbell
24725eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
24735eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
24745eeb39c2SIan Campbell
24755eeb39c2SIan Campbell  return 0;
24765eeb39c2SIan Campbell}
24775eeb39c2SIan CampbellEOF
24785eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
24795eeb39c2SIan Campbell      then
2480f1167ee6SJuergen Gross      xen_ctrl_version=40701
24815eeb39c2SIan Campbell      xen=yes
24825eeb39c2SIan Campbell    elif
24835eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2484e37630caSaliguori#include <xenctrl.h>
2485cdadde39SRoger Pau Monne#include <stdint.h>
2486cdadde39SRoger Pau Monneint main(void) {
2487cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2488cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2489cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2490cdadde39SRoger Pau Monne  return 0;
2491cdadde39SRoger Pau Monne}
2492cdadde39SRoger Pau MonneEOF
2493cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2494cdadde39SRoger Pau Monne      then
2495f1167ee6SJuergen Gross      xen_ctrl_version=40700
2496cdadde39SRoger Pau Monne      xen=yes
2497cdadde39SRoger Pau Monne
2498cdadde39SRoger Pau Monne    # Xen 4.6
2499cdadde39SRoger Pau Monne    elif
2500cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2501cdadde39SRoger Pau Monne#include <xenctrl.h>
2502e108a3c1SAnthony PERARD#include <xenstore.h>
2503d5b93ddfSAnthony PERARD#include <stdint.h>
2504d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2505d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2506d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2507d5b93ddfSAnthony PERARD#endif
2508d5b93ddfSAnthony PERARDint main(void) {
2509d5b93ddfSAnthony PERARD  xc_interface *xc;
2510d5b93ddfSAnthony PERARD  xs_daemon_open();
2511d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2512d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2513d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2514b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25158688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2516d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
251720a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2518d8b441a3SJan Beulich  return 0;
2519d8b441a3SJan Beulich}
2520d8b441a3SJan BeulichEOF
2521d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2522d8b441a3SJan Beulich      then
2523f1167ee6SJuergen Gross      xen_ctrl_version=40600
2524d8b441a3SJan Beulich      xen=yes
2525d8b441a3SJan Beulich
2526d8b441a3SJan Beulich    # Xen 4.5
2527d8b441a3SJan Beulich    elif
2528d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2529d8b441a3SJan Beulich#include <xenctrl.h>
2530d8b441a3SJan Beulich#include <xenstore.h>
2531d8b441a3SJan Beulich#include <stdint.h>
2532d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2533d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2534d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2535d8b441a3SJan Beulich#endif
2536d8b441a3SJan Beulichint main(void) {
2537d8b441a3SJan Beulich  xc_interface *xc;
2538d8b441a3SJan Beulich  xs_daemon_open();
2539d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2540d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2541d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2542d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2543d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25443996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
25453996e85cSPaul Durrant  return 0;
25463996e85cSPaul Durrant}
25473996e85cSPaul DurrantEOF
25483996e85cSPaul Durrant        compile_prog "" "$xen_libs"
25493996e85cSPaul Durrant      then
2550f1167ee6SJuergen Gross      xen_ctrl_version=40500
25513996e85cSPaul Durrant      xen=yes
25523996e85cSPaul Durrant
25533996e85cSPaul Durrant    elif
25543996e85cSPaul Durrant        cat > $TMPC <<EOF &&
25553996e85cSPaul Durrant#include <xenctrl.h>
25563996e85cSPaul Durrant#include <xenstore.h>
25573996e85cSPaul Durrant#include <stdint.h>
25583996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
25593996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
25603996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
25613996e85cSPaul Durrant#endif
25623996e85cSPaul Durrantint main(void) {
25633996e85cSPaul Durrant  xc_interface *xc;
25643996e85cSPaul Durrant  xs_daemon_open();
25653996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
25663996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
25673996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
25683996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25693996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25708688e065SStefano Stabellini  return 0;
25718688e065SStefano Stabellini}
25728688e065SStefano StabelliniEOF
25738688e065SStefano Stabellini        compile_prog "" "$xen_libs"
257469deef08SPeter Maydell      then
2575f1167ee6SJuergen Gross      xen_ctrl_version=40200
25768688e065SStefano Stabellini      xen=yes
25778688e065SStefano Stabellini
2578e37630caSaliguori    else
2579fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2580edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2581edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2582fc321b4bSJuan Quintela      fi
2583fc321b4bSJuan Quintela      xen=no
2584e37630caSaliguori    fi
2585d5b93ddfSAnthony PERARD
2586d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2587f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
25885eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
25895eeb39c2SIan Campbell      fi
2590d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2591d5b93ddfSAnthony PERARD    fi
2592e37630caSaliguori  fi
2593c1cdd9d5SJuergen Grossfi
2594e37630caSaliguori
2595eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2596edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2597eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2598eb6fda0fSAnthony PERARD  else
2599eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
260076ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
260176ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2602eb6fda0fSAnthony PERARD    fi
2603eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2604eb6fda0fSAnthony PERARD  fi
2605eb6fda0fSAnthony PERARDfi
2606eb6fda0fSAnthony PERARD
260764a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
260864a7ad6fSIan Campbell   test "$xen" != "yes"; then
260964a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
261064a7ad6fSIan Campbell	       "which requires Xen support."
261164a7ad6fSIan Campbellfi
261264a7ad6fSIan Campbell
2613e37630caSaliguori##########################################
2614d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2615d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2616327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2617d661d9a4SJustin Terry (VM)        whpx="yes"
2618d661d9a4SJustin Terry (VM)    else
2619d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
262053537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2621d661d9a4SJustin Terry (VM)        fi
2622d661d9a4SJustin Terry (VM)        whpx="no"
2623d661d9a4SJustin Terry (VM)    fi
2624d661d9a4SJustin Terry (VM)fi
2625d661d9a4SJustin Terry (VM)
2626d661d9a4SJustin Terry (VM)##########################################
2627dfffc653SJuan Quintela# Sparse probe
2628dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
26290dba6195SLoïc Minier  if has cgcc; then
2630dfffc653SJuan Quintela    sparse=yes
2631dfffc653SJuan Quintela  else
2632dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
263321684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2634dfffc653SJuan Quintela    fi
2635dfffc653SJuan Quintela    sparse=no
2636dfffc653SJuan Quintela  fi
2637dfffc653SJuan Quintelafi
2638dfffc653SJuan Quintela
2639dfffc653SJuan Quintela##########################################
2640f676c67eSJeremy White# X11 probe
2641f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
26428781595bSGerd Hoffmann    have_x11=yes
264389138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
264489138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2645f676c67eSJeremy Whitefi
2646f676c67eSJeremy White
2647f676c67eSJeremy White##########################################
2648a4ccabcfSAnthony Liguori# GTK probe
2649a4ccabcfSAnthony Liguori
26505a464e6cSPeter Xuif test "$gtk" != "no"; then
26519e04c683SStefan Weil    if test "$gtkabi" = ""; then
26525fe309ffSGerd Hoffmann        # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
26535fe309ffSGerd Hoffmann        # Use 2.0 as a fallback if that is available.
26545fe309ffSGerd Hoffmann        if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
26559e04c683SStefan Weil            gtkabi=3.0
26565fe309ffSGerd Hoffmann        elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
26579e04c683SStefan Weil            gtkabi=2.0
26585fe309ffSGerd Hoffmann        else
26595fe309ffSGerd Hoffmann            gtkabi=3.0
26609e04c683SStefan Weil        fi
26619e04c683SStefan Weil    fi
2662528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
26630a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2664528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2665528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2666bbbf9bfbSStefan Weil    else
2667bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2668bbbf9bfbSStefan Weil    fi
2669bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
267089138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
267189138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
267289138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
26730a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
26748781595bSGerd Hoffmann            need_x11=yes
2675f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2676f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
26770a337ed0SGerd Hoffmann        fi
2678bbbf9bfbSStefan Weil        gtk="yes"
2679bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
26805fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2681bbbf9bfbSStefan Weil    else
2682bbbf9bfbSStefan Weil        gtk="no"
2683bbbf9bfbSStefan Weil    fi
2684bbbf9bfbSStefan Weilfi
2685bbbf9bfbSStefan Weil
2686ddbb0d09SDaniel P. Berrange
2687ddbb0d09SDaniel P. Berrange##########################################
2688ddbb0d09SDaniel P. Berrange# GNUTLS probe
2689ddbb0d09SDaniel P. Berrange
269037371299SPeter Maydellgnutls_works() {
269137371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
269237371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
269337371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
269437371299SPeter Maydell    # builds doesn't work:
269537371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
269637371299SPeter Maydell    #
269737371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
269837371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
269937371299SPeter Maydell        return 1
270037371299SPeter Maydell    fi
270137371299SPeter Maydell
270237371299SPeter Maydell    write_c_skeleton
270337371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
270437371299SPeter Maydell}
270537371299SPeter Maydell
270662893b67SDaniel P. Berrangegnutls_gcrypt=no
2707ed754746SDaniel P. Berrangegnutls_nettle=no
2708ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
270937371299SPeter Maydell    if gnutls_works; then
271089138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
271189138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2712ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2713ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2714ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2715ddbb0d09SDaniel P. Berrange        gnutls="yes"
2716ddbb0d09SDaniel P. Berrange
2717b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2718b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2719b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2720b917da4cSDaniel P. Berrange	else
2721b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2722b917da4cSDaniel P. Berrange	fi
2723b917da4cSDaniel P. Berrange
272462893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
272562893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2726ed754746SDaniel P. Berrange	    gnutls_nettle=yes
272762893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
272889138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2729ed754746SDaniel P. Berrange		*gcrypt*)
2730ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2731ed754746SDaniel P. Berrange		    gnutls_nettle=no
2732ed754746SDaniel P. Berrange		    ;;
2733ed754746SDaniel P. Berrange		*nettle*)
2734ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2735ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2736ed754746SDaniel P. Berrange		    ;;
2737ed754746SDaniel P. Berrange		*)
2738ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2739ed754746SDaniel P. Berrange		    gnutls_nettle=no
2740ed754746SDaniel P. Berrange		    ;;
274162893b67SDaniel P. Berrange	    esac
274262893b67SDaniel P. Berrange	else
274362893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2744ed754746SDaniel P. Berrange	    gnutls_nettle=no
274562893b67SDaniel P. Berrange	fi
2746ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2747ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2748ddbb0d09SDaniel P. Berrange    else
2749ddbb0d09SDaniel P. Berrange        gnutls="no"
2750b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2751ddbb0d09SDaniel P. Berrange    fi
2752ddbb0d09SDaniel P. Berrangeelse
2753b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2754ddbb0d09SDaniel P. Berrangefi
2755ddbb0d09SDaniel P. Berrange
275691bfcdb0SDaniel P. Berrange
275791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
275891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
275991bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
276091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
276191bfcdb0SDaniel P. Berrangethen
276291bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
276391bfcdb0SDaniel P. Berrange    then
276491bfcdb0SDaniel P. Berrange        gcrypt="no"
276591bfcdb0SDaniel P. Berrange    fi
276691bfcdb0SDaniel P. Berrangefi
276791bfcdb0SDaniel P. Berrange
276891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
276991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
277091bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
277191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
277291bfcdb0SDaniel P. Berrangethen
277391bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
277491bfcdb0SDaniel P. Berrange    then
277591bfcdb0SDaniel P. Berrange        nettle="no"
277691bfcdb0SDaniel P. Berrange    fi
277791bfcdb0SDaniel P. Berrangefi
277891bfcdb0SDaniel P. Berrange
277991bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
278091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
278191bfcdb0SDaniel P. Berrange    then
278291bfcdb0SDaniel P. Berrange	return 1
278391bfcdb0SDaniel P. Berrange    fi
278491bfcdb0SDaniel P. Berrange
278591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
278691bfcdb0SDaniel P. Berrange    then
278789138857SStefan Weil	host=$(libgcrypt-config --host)
278891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
278991bfcdb0SDaniel P. Berrange	then
279091bfcdb0SDaniel P. Berrange	    return 1
279191bfcdb0SDaniel P. Berrange	fi
279291bfcdb0SDaniel P. Berrange    fi
279391bfcdb0SDaniel P. Berrange
279491bfcdb0SDaniel P. Berrange    return 0
279591bfcdb0SDaniel P. Berrange}
279691bfcdb0SDaniel P. Berrange
279791bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
279891bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
279989138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
280089138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
280191bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
280291bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
280391bfcdb0SDaniel P. Berrange        # turn breaks static builds...
280491bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
280591bfcdb0SDaniel P. Berrange        then
280691bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
280791bfcdb0SDaniel P. Berrange        fi
280862893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
280962893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
281062893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
281191bfcdb0SDaniel P. Berrange        gcrypt="yes"
281291bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
281391bfcdb0SDaniel P. Berrange           nettle="no"
281491bfcdb0SDaniel P. Berrange        fi
281537788f25SDaniel P. Berrange
281637788f25SDaniel P. Berrange        cat > $TMPC << EOF
281737788f25SDaniel P. Berrange#include <gcrypt.h>
281837788f25SDaniel P. Berrangeint main(void) {
281937788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
282037788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
282137788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
282237788f25SDaniel P. Berrange return 0;
282337788f25SDaniel P. Berrange}
282437788f25SDaniel P. BerrangeEOF
282537788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
282637788f25SDaniel P. Berrange            gcrypt_kdf=yes
282737788f25SDaniel P. Berrange        fi
28281f923c70SLongpeng(Mike)
28291f923c70SLongpeng(Mike)        cat > $TMPC << EOF
28301f923c70SLongpeng(Mike)#include <gcrypt.h>
28311f923c70SLongpeng(Mike)int main(void) {
28321f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
28331f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
28341f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
28351f923c70SLongpeng(Mike)  return 0;
28361f923c70SLongpeng(Mike)}
28371f923c70SLongpeng(Mike)EOF
28381f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
28391f923c70SLongpeng(Mike)            gcrypt_hmac=yes
28401f923c70SLongpeng(Mike)        fi
284162893b67SDaniel P. Berrange    else
284291bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
284362893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
284491bfcdb0SDaniel P. Berrange        else
284591bfcdb0SDaniel P. Berrange            gcrypt="no"
284691bfcdb0SDaniel P. Berrange        fi
284762893b67SDaniel P. Berrange    fi
284862893b67SDaniel P. Berrangefi
284962893b67SDaniel P. Berrange
2850ddbb0d09SDaniel P. Berrange
285191bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2852ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
285389138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
285489138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
285589138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2856ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2857ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2858ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
285991bfcdb0SDaniel P. Berrange        nettle="yes"
2860fff2f982SDaniel P. Berrange
2861fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
28629e87a691SSteven Luo#include <stddef.h>
2863fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2864fff2f982SDaniel P. Berrangeint main(void) {
2865fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2866fff2f982SDaniel P. Berrange     return 0;
2867fff2f982SDaniel P. Berrange}
2868fff2f982SDaniel P. BerrangeEOF
2869fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2870fff2f982SDaniel P. Berrange            nettle_kdf=yes
2871fff2f982SDaniel P. Berrange        fi
2872ed754746SDaniel P. Berrange    else
287391bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2874ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
287591bfcdb0SDaniel P. Berrange        else
287691bfcdb0SDaniel P. Berrange            nettle="no"
2877ed754746SDaniel P. Berrange        fi
2878ed754746SDaniel P. Berrange    fi
287991bfcdb0SDaniel P. Berrangefi
288091bfcdb0SDaniel P. Berrange
288191bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
288291bfcdb0SDaniel P. Berrangethen
288391bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
288491bfcdb0SDaniel P. Berrangefi
2885ed754746SDaniel P. Berrange
28869a2fd434SDaniel P. Berrange##########################################
28879a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
28889a2fd434SDaniel P. Berrange
28899a2fd434SDaniel P. Berrangetasn1=yes
289090246037SDaniel P. Berrangetasn1_cflags=""
289190246037SDaniel P. Berrangetasn1_libs=""
28929a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
289389138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
289489138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
28959a2fd434SDaniel P. Berrangeelse
28969a2fd434SDaniel P. Berrange    tasn1=no
28979a2fd434SDaniel P. Berrangefi
28989a2fd434SDaniel P. Berrange
2899ed754746SDaniel P. Berrange
2900bbbf9bfbSStefan Weil##########################################
2901559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2902559607eaSDaniel P. Berrange
2903559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2904559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2905559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2906559607eaSDaniel P. Berrangefi
2907559607eaSDaniel P. Berrange
2908559607eaSDaniel P. Berrange##########################################
2909bbbf9bfbSStefan Weil# VTE probe
2910bbbf9bfbSStefan Weil
2911bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2912bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2913c6feff9eSCole Robinson      vteminversion="0.32.0"
2914c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2915c6feff9eSCole Robinson        vtepackage="vte-2.91"
2916c6feff9eSCole Robinson      else
2917528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2918c6feff9eSCole Robinson      fi
2919528de90aSDaniel P. Berrange    else
2920528de90aSDaniel P. Berrange      vtepackage="vte"
2921c6feff9eSCole Robinson      vteminversion="0.24.0"
2922528de90aSDaniel P. Berrange    fi
2923c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
292489138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
292589138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
292689138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2927bbbf9bfbSStefan Weil        vte="yes"
2928bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
29299e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2930c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
29319e04c683SStefan Weil        else
29329e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
29339e04c683SStefan Weil        fi
2934bbbf9bfbSStefan Weil    else
2935bbbf9bfbSStefan Weil        vte="no"
2936a4ccabcfSAnthony Liguori    fi
2937a4ccabcfSAnthony Liguorifi
2938a4ccabcfSAnthony Liguori
2939a4ccabcfSAnthony Liguori##########################################
294011d9f695Sbellard# SDL probe
294111d9f695Sbellard
29423ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
29433ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
294447c03744SDave Airlie
2945c6093a05SPeter Xusdl_probe ()
2946c6093a05SPeter Xu{
2947c6093a05SPeter Xu  sdl_too_old=no
2948ee8466d0SCole Robinson  if test "$sdlabi" = ""; then
29498f4ea9cdSGerd Hoffmann      if $pkg_config --exists "sdl2"; then
2950ee8466d0SCole Robinson          sdlabi=2.0
29518f4ea9cdSGerd Hoffmann      elif $pkg_config --exists "sdl"; then
2952ee8466d0SCole Robinson          sdlabi=1.2
29538f4ea9cdSGerd Hoffmann      else
29548f4ea9cdSGerd Hoffmann          sdlabi=2.0
2955ee8466d0SCole Robinson      fi
2956ee8466d0SCole Robinson  fi
2957ee8466d0SCole Robinson
295847c03744SDave Airlie  if test $sdlabi = "2.0"; then
295947c03744SDave Airlie      sdl_config=$sdl2_config
296047c03744SDave Airlie      sdlname=sdl2
296147c03744SDave Airlie      sdlconfigname=sdl2_config
2962e07047cfSCole Robinson  elif test $sdlabi = "1.2"; then
296347c03744SDave Airlie      sdlname=sdl
296447c03744SDave Airlie      sdlconfigname=sdl_config
2965e07047cfSCole Robinson  else
2966e07047cfSCole Robinson      error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
29673ec87ffeSPaolo Bonzini  fi
29683ec87ffeSPaolo Bonzini
296989138857SStefan Weil  if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
297047c03744SDave Airlie    sdl_config=$sdlconfigname
297147c03744SDave Airlie  fi
297247c03744SDave Airlie
297347c03744SDave Airlie  if $pkg_config $sdlname --exists; then
297447c03744SDave Airlie    sdlconfig="$pkg_config $sdlname"
297589138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
29763ec87ffeSPaolo Bonzini  elif has ${sdl_config}; then
29773ec87ffeSPaolo Bonzini    sdlconfig="$sdl_config"
297889138857SStefan Weil    sdlversion=$($sdlconfig --version)
2979a0dfd8a4SLoïc Minier  else
2980a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
29818f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
2982a0dfd8a4SLoïc Minier    fi
2983a0dfd8a4SLoïc Minier    sdl=no
2984c6093a05SPeter Xu    # no need to do the rest
2985c6093a05SPeter Xu    return
29869316f803SPaolo Bonzini  fi
298729e5badaSScott Wood  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
29883ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
29893ec87ffeSPaolo Bonzini  fi
299011d9f695Sbellard
299111d9f695Sbellard  cat > $TMPC << EOF
299211d9f695Sbellard#include <SDL.h>
299311d9f695Sbellard#undef main /* We don't want SDL to override our main() */
299411d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
299511d9f695SbellardEOF
299689138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
29972ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
299874f42e18STeLeMan  if test "$static" = "yes" ; then
29995f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
30005f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
30015f37e6d4SThomas Huth    else
300289138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
30035f37e6d4SThomas Huth    fi
300474f42e18STeLeMan  else
300589138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
300674f42e18STeLeMan  fi
300752166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
300889138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
300911d9f695Sbellard      sdl_too_old=yes
301011d9f695Sbellard    else
301111d9f695Sbellard      sdl=yes
301211d9f695Sbellard    fi
30137c1f25b4Sbellard
301467c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
30151ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
301667c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
301789138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
301889138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
301911d9f695Sbellard      fi
302052166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
30211ac88f28SJuan Quintela	:
30221ac88f28SJuan Quintela      else
30231ac88f28SJuan Quintela        sdl=no
30247c1f25b4Sbellard      fi
30257c1f25b4Sbellard    fi # static link
3026c4198157SJuan Quintela  else # sdl not found
3027c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
302821684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
3029c4198157SJuan Quintela    fi
3030c4198157SJuan Quintela    sdl=no
30317c1f25b4Sbellard  fi # sdl compile test
3032c6093a05SPeter Xu}
3033c6093a05SPeter Xu
3034c6093a05SPeter Xuif test "$sdl" != "no" ; then
3035c6093a05SPeter Xu  sdl_probe
3036fd677642Sthsfi
303711d9f695Sbellard
30385368a422Saliguoriif test "$sdl" = "yes" ; then
30395368a422Saliguori  cat > $TMPC <<EOF
30405368a422Saliguori#include <SDL.h>
30415368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
30425368a422Saliguori#include <X11/XKBlib.h>
30435368a422Saliguori#else
30445368a422Saliguori#error No x11 support
30455368a422Saliguori#endif
30465368a422Saliguoriint main(void) { return 0; }
30475368a422SaliguoriEOF
3048f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
30498781595bSGerd Hoffmann    need_x11=yes
3050f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3051f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
30525368a422Saliguori  fi
30535368a422Saliguorifi
30545368a422Saliguori
30558f28f3fbSths##########################################
30562da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
30572da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
30582da776dbSMichael R. Hines  cat > $TMPC <<EOF
30592da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
30602da776dbSMichael R. Hinesint main(void) { return 0; }
30612da776dbSMichael R. HinesEOF
3062ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
30632da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
30642da776dbSMichael R. Hines    rdma="yes"
3065ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
30662da776dbSMichael R. Hines  else
30672da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
30682da776dbSMichael R. Hines        error_exit \
3069ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
30702da776dbSMichael R. Hines            " Your options:" \
3071ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
30722da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
30732da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
30742da776dbSMichael R. Hines    fi
30752da776dbSMichael R. Hines    rdma="no"
30762da776dbSMichael R. Hines  fi
30772da776dbSMichael R. Hinesfi
30782da776dbSMichael R. Hines
307921ab34c9SMarcel Apfelbaum##########################################
308021ab34c9SMarcel Apfelbaum# PVRDMA detection
308121ab34c9SMarcel Apfelbaum
308221ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
308321ab34c9SMarcel Apfelbaum#include <sys/mman.h>
308421ab34c9SMarcel Apfelbaum
308521ab34c9SMarcel Apfelbaumint
308621ab34c9SMarcel Apfelbaummain(void)
308721ab34c9SMarcel Apfelbaum{
308821ab34c9SMarcel Apfelbaum    char buf = 0;
308921ab34c9SMarcel Apfelbaum    void *addr = &buf;
309021ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
309121ab34c9SMarcel Apfelbaum
309221ab34c9SMarcel Apfelbaum    return 0;
309321ab34c9SMarcel Apfelbaum}
309421ab34c9SMarcel ApfelbaumEOF
309521ab34c9SMarcel Apfelbaum
309621ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
309721ab34c9SMarcel Apfelbaum    case "$pvrdma" in
309821ab34c9SMarcel Apfelbaum    "")
309921ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
310021ab34c9SMarcel Apfelbaum            pvrdma="yes"
310121ab34c9SMarcel Apfelbaum        else
310221ab34c9SMarcel Apfelbaum            pvrdma="no"
310321ab34c9SMarcel Apfelbaum        fi
310421ab34c9SMarcel Apfelbaum        ;;
310521ab34c9SMarcel Apfelbaum    "yes")
310621ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
310721ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
310821ab34c9SMarcel Apfelbaum        fi
310921ab34c9SMarcel Apfelbaum        pvrdma="yes"
311021ab34c9SMarcel Apfelbaum        ;;
311121ab34c9SMarcel Apfelbaum    "no")
311221ab34c9SMarcel Apfelbaum        pvrdma="no"
311321ab34c9SMarcel Apfelbaum        ;;
311421ab34c9SMarcel Apfelbaum    esac
311521ab34c9SMarcel Apfelbaumelse
311621ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
311721ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
311821ab34c9SMarcel Apfelbaum    fi
311921ab34c9SMarcel Apfelbaum    pvrdma="no"
312021ab34c9SMarcel Apfelbaumfi
312195c6bff3SBenoît Canet
312295c6bff3SBenoît Canet##########################################
31232f9606b3Saliguori# VNC SASL detection
3124821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
31252f9606b3Saliguori  cat > $TMPC <<EOF
31262f9606b3Saliguori#include <sasl/sasl.h>
31272f9606b3Saliguori#include <stdio.h>
31282f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
31292f9606b3SaliguoriEOF
31302f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
31312f9606b3Saliguori  vnc_sasl_cflags=""
31322f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
313352166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3134ea784e3bSJuan Quintela    vnc_sasl=yes
3135fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3136ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
31372f9606b3Saliguori  else
3138ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
313921684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3140ea784e3bSJuan Quintela    fi
3141ea784e3bSJuan Quintela    vnc_sasl=no
31422f9606b3Saliguori  fi
31432f9606b3Saliguorifi
31442f9606b3Saliguori
31452f9606b3Saliguori##########################################
31462f6f5c7aSCorentin Chary# VNC JPEG detection
3147821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
31482f6f5c7aSCorentin Charycat > $TMPC <<EOF
31492f6f5c7aSCorentin Chary#include <stdio.h>
31502f6f5c7aSCorentin Chary#include <jpeglib.h>
31512f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
31522f6f5c7aSCorentin CharyEOF
31532f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
31542f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
31552f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
31562f6f5c7aSCorentin Chary    vnc_jpeg=yes
31572f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3158ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
31592f6f5c7aSCorentin Chary  else
31602f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
316121684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
31622f6f5c7aSCorentin Chary    fi
31632f6f5c7aSCorentin Chary    vnc_jpeg=no
31642f6f5c7aSCorentin Chary  fi
31652f6f5c7aSCorentin Charyfi
31662f6f5c7aSCorentin Chary
31672f6f5c7aSCorentin Chary##########################################
3168efe556adSCorentin Chary# VNC PNG detection
3169821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
3170efe556adSCorentin Charycat > $TMPC <<EOF
3171efe556adSCorentin Chary//#include <stdio.h>
3172efe556adSCorentin Chary#include <png.h>
3173832ce9c2SScott Wood#include <stddef.h>
3174efe556adSCorentin Charyint main(void) {
3175efe556adSCorentin Chary    png_structp png_ptr;
3176efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
31777edc3fedSPeter Maydell    return png_ptr != 0;
3178efe556adSCorentin Chary}
3179efe556adSCorentin CharyEOF
318065d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
318189138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
318289138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
31839af8025eSBrad  else
3184efe556adSCorentin Chary    vnc_png_cflags=""
3185efe556adSCorentin Chary    vnc_png_libs="-lpng"
31869af8025eSBrad  fi
3187efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3188efe556adSCorentin Chary    vnc_png=yes
3189efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
31909af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3191efe556adSCorentin Chary  else
3192efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
319321684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3194efe556adSCorentin Chary    fi
3195efe556adSCorentin Chary    vnc_png=no
3196efe556adSCorentin Chary  fi
3197efe556adSCorentin Charyfi
3198efe556adSCorentin Chary
3199efe556adSCorentin Chary##########################################
32006a021536SGerd Hoffmann# xkbcommon probe
32016a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
32026a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
32036a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
32046a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
32056a021536SGerd Hoffmann    xkbcommon=yes
32066a021536SGerd Hoffmann  else
32076a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
32086a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
32096a021536SGerd Hoffmann    fi
32106a021536SGerd Hoffmann    xkbcommon=no
32116a021536SGerd Hoffmann  fi
32126a021536SGerd Hoffmannfi
32136a021536SGerd Hoffmann
32146a021536SGerd Hoffmann##########################################
321576655d6dSaliguori# fnmatch() probe, used for ACL routines
321676655d6dSaliguorifnmatch="no"
321776655d6dSaliguoricat > $TMPC << EOF
321876655d6dSaliguori#include <fnmatch.h>
321976655d6dSaliguoriint main(void)
322076655d6dSaliguori{
322176655d6dSaliguori    fnmatch("foo", "foo", 0);
322276655d6dSaliguori    return 0;
322376655d6dSaliguori}
322476655d6dSaliguoriEOF
322552166aa0SJuan Quintelaif compile_prog "" "" ; then
322676655d6dSaliguori   fnmatch="yes"
322776655d6dSaliguorifi
322876655d6dSaliguori
322976655d6dSaliguori##########################################
3230c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3231dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3232dce512deSChristoph Hellwig  cat > $TMPC << EOF
3233ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3234dce512deSChristoph Hellwig#include <xfs/xfs.h>
3235dce512deSChristoph Hellwigint main(void)
3236dce512deSChristoph Hellwig{
3237dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3238dce512deSChristoph Hellwig    return 0;
3239dce512deSChristoph Hellwig}
3240dce512deSChristoph HellwigEOF
3241dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3242dce512deSChristoph Hellwig    xfs="yes"
3243dce512deSChristoph Hellwig  else
3244dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
324521684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3246dce512deSChristoph Hellwig    fi
3247dce512deSChristoph Hellwig    xfs=no
3248dce512deSChristoph Hellwig  fi
3249dce512deSChristoph Hellwigfi
3250dce512deSChristoph Hellwig
3251dce512deSChristoph Hellwig##########################################
32528a16d273Sths# vde libraries probe
3253dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
32544baae0acSJuan Quintela  vde_libs="-lvdeplug"
32558a16d273Sths  cat > $TMPC << EOF
32568a16d273Sths#include <libvdeplug.h>
32574a7f0e06Spbrookint main(void)
32584a7f0e06Spbrook{
32594a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3260fea08e08SPeter Maydell    char s[] = "";
3261fea08e08SPeter Maydell    vde_open(s, s, &a);
32624a7f0e06Spbrook    return 0;
32634a7f0e06Spbrook}
32648a16d273SthsEOF
326552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
32664baae0acSJuan Quintela    vde=yes
3267dfb278bdSJuan Quintela  else
3268dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
326921684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3270dfb278bdSJuan Quintela    fi
3271dfb278bdSJuan Quintela    vde=no
32728a16d273Sths  fi
32738a16d273Sthsfi
32748a16d273Sths
32758a16d273Sths##########################################
32760a985b37SVincenzo Maffione# netmap support probe
32770a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
32780a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
32790a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
32800a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
32810a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
328258952137SVincenzo Maffioneif test "$netmap" != "no" ; then
328358952137SVincenzo Maffione  cat > $TMPC << EOF
328458952137SVincenzo Maffione#include <inttypes.h>
328558952137SVincenzo Maffione#include <net/if.h>
328658952137SVincenzo Maffione#include <net/netmap.h>
328758952137SVincenzo Maffione#include <net/netmap_user.h>
32880a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
32890a985b37SVincenzo Maffione#error
32900a985b37SVincenzo Maffione#endif
329158952137SVincenzo Maffioneint main(void) { return 0; }
329258952137SVincenzo MaffioneEOF
329358952137SVincenzo Maffione  if compile_prog "" "" ; then
329458952137SVincenzo Maffione    netmap=yes
329558952137SVincenzo Maffione  else
329658952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
329758952137SVincenzo Maffione      feature_not_found "netmap"
329858952137SVincenzo Maffione    fi
329958952137SVincenzo Maffione    netmap=no
330058952137SVincenzo Maffione  fi
330158952137SVincenzo Maffionefi
330258952137SVincenzo Maffione
330358952137SVincenzo Maffione##########################################
330447e98658SCorey Bryant# libcap-ng library probe
330547e98658SCorey Bryantif test "$cap_ng" != "no" ; then
330647e98658SCorey Bryant  cap_libs="-lcap-ng"
330747e98658SCorey Bryant  cat > $TMPC << EOF
330847e98658SCorey Bryant#include <cap-ng.h>
330947e98658SCorey Bryantint main(void)
331047e98658SCorey Bryant{
331147e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
331247e98658SCorey Bryant    return 0;
331347e98658SCorey Bryant}
331447e98658SCorey BryantEOF
331547e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
331647e98658SCorey Bryant    cap_ng=yes
331747e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
331847e98658SCorey Bryant  else
331947e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
332021684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
332147e98658SCorey Bryant    fi
332247e98658SCorey Bryant    cap_ng=no
332347e98658SCorey Bryant  fi
332447e98658SCorey Bryantfi
332547e98658SCorey Bryant
332647e98658SCorey Bryant##########################################
3327c2de5c91Smalc# Sound support libraries probe
33288f28f3fbSths
3329c2de5c91Smalcaudio_drv_probe()
3330c2de5c91Smalc{
3331c2de5c91Smalc    drv=$1
3332c2de5c91Smalc    hdr=$2
3333c2de5c91Smalc    lib=$3
3334c2de5c91Smalc    exp=$4
3335c2de5c91Smalc    cfl=$5
33368f28f3fbSths        cat > $TMPC << EOF
3337c2de5c91Smalc#include <$hdr>
3338c2de5c91Smalcint main(void) { $exp }
33398f28f3fbSthsEOF
334052166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
33418f28f3fbSths        :
33428f28f3fbSths    else
334376ad07a4SPeter Maydell        error_exit "$drv check failed" \
334476ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
33458f28f3fbSths    fi
3346c2de5c91Smalc}
3347c2de5c91Smalc
334889138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3349c2de5c91Smalcfor drv in $audio_drv_list; do
3350c2de5c91Smalc    case $drv in
3351c2de5c91Smalc    alsa)
3352c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3353e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3354b1149911SFam Zheng    alsa_libs="-lasound"
3355c2de5c91Smalc    ;;
3356c2de5c91Smalc
3357b8e59f18Smalc    pa)
3358e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3359e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3360b1149911SFam Zheng    pulse_libs="-lpulse"
336167f86e8eSJuan Quintela    audio_pt_int="yes"
3362b8e59f18Smalc    ;;
3363b8e59f18Smalc
3364373967b2SGerd Hoffmann    sdl)
3365373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3366373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3367373967b2SGerd Hoffmann    fi
3368373967b2SGerd Hoffmann    ;;
3369373967b2SGerd Hoffmann
3370997e690aSJuan Quintela    coreaudio)
3371b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3372997e690aSJuan Quintela    ;;
3373997e690aSJuan Quintela
3374a4bf6780SJuan Quintela    dsound)
3375b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3376d5631638Smalc      audio_win_int="yes"
3377a4bf6780SJuan Quintela    ;;
3378a4bf6780SJuan Quintela
3379a4bf6780SJuan Quintela    oss)
3380b1149911SFam Zheng      oss_libs="$oss_lib"
3381a4bf6780SJuan Quintela    ;;
3382a4bf6780SJuan Quintela
3383373967b2SGerd Hoffmann    wav)
3384373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
33852f6a1ab0Sblueswir1    ;;
33862f6a1ab0Sblueswir1
3387e4c63a6aSmalc    *)
33881c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
338976ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
339076ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3391e4c63a6aSmalc    }
3392e4c63a6aSmalc    ;;
3393c2de5c91Smalc    esac
3394c2de5c91Smalcdone
33958f28f3fbSths
33964d3b6f6eSbalrog##########################################
33972e4d9fb1Saurel32# BrlAPI probe
33982e4d9fb1Saurel32
33994ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3400eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
34012e4d9fb1Saurel32  cat > $TMPC << EOF
34022e4d9fb1Saurel32#include <brlapi.h>
3403832ce9c2SScott Wood#include <stddef.h>
34042e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
34052e4d9fb1Saurel32EOF
340652166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
34072e4d9fb1Saurel32    brlapi=yes
34084ffcedb6SJuan Quintela  else
34094ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
341021684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
34114ffcedb6SJuan Quintela    fi
34124ffcedb6SJuan Quintela    brlapi=no
3413eb82284fSJuan Quintela  fi
3414eb82284fSJuan Quintelafi
34152e4d9fb1Saurel32
34162e4d9fb1Saurel32##########################################
34174d3b6f6eSbalrog# curses probe
3418a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3419e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
34208ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
34218ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3422e095e2f3SStefan Weil  else
34237c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
34248ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3425e095e2f3SStefan Weil  fi
3426c584a6d0SJuan Quintela  curses_found=no
34274d3b6f6eSbalrog  cat > $TMPC << EOF
34288ddc5bf9SSamuel Thibault#include <locale.h>
34294d3b6f6eSbalrog#include <curses.h>
34308ddc5bf9SSamuel Thibault#include <wchar.h>
3431ef9a2524SStefan Weilint main(void) {
34328ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
34338ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3434ef9a2524SStefan Weil  resize_term(0, 0);
34358ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
34368ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
34377c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3438271f37abSKamil Rytarowski  return 0;
3439ef9a2524SStefan Weil}
34404d3b6f6eSbalrogEOF
3441ecbe251fSVadim Evard  IFS=:
34428ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3443b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3444b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
34457c703002SSamuel Thibault    IFS=:
34468ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3447ecbe251fSVadim Evard      unset IFS
34488ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3449c584a6d0SJuan Quintela        curses_found=yes
34504f78ef9aSJuan Quintela        break
34514d3b6f6eSbalrog      fi
34524f78ef9aSJuan Quintela    done
34537c703002SSamuel Thibault    if test "$curses_found" = yes ; then
34547c703002SSamuel Thibault      break
34557c703002SSamuel Thibault    fi
34568ddc5bf9SSamuel Thibault  done
3457ecbe251fSVadim Evard  unset IFS
3458c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3459c584a6d0SJuan Quintela    curses=yes
3460c584a6d0SJuan Quintela  else
3461c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
346221684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3463c584a6d0SJuan Quintela    fi
3464c584a6d0SJuan Quintela    curses=no
3465c584a6d0SJuan Quintela  fi
34664f78ef9aSJuan Quintelafi
34674d3b6f6eSbalrog
3468414f0dabSblueswir1##########################################
3469769ce76dSAlexander Graf# curl probe
3470a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
347165d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3472a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
34734e2b0658SPaolo Bonzini  else
34744e2b0658SPaolo Bonzini    curlconfig=curl-config
34754e2b0658SPaolo Bonzini  fi
3476769ce76dSAlexander Graf  cat > $TMPC << EOF
3477769ce76dSAlexander Graf#include <curl/curl.h>
34780b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3479769ce76dSAlexander GrafEOF
348089138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
348189138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3482b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3483769ce76dSAlexander Graf    curl=yes
3484788c8196SJuan Quintela  else
3485788c8196SJuan Quintela    if test "$curl" = "yes" ; then
348621684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3487788c8196SJuan Quintela    fi
3488788c8196SJuan Quintela    curl=no
3489769ce76dSAlexander Graf  fi
3490769ce76dSAlexander Graffi # test "$curl"
3491769ce76dSAlexander Graf
3492769ce76dSAlexander Graf##########################################
3493fb599c9aSbalrog# bluez support probe
3494a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3495e820e3f4Sbalrog  cat > $TMPC << EOF
3496e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3497e820e3f4Sbalrogint main(void) { return bt_error(0); }
3498e820e3f4SbalrogEOF
349989138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
350089138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
350152166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3502a20a6f46SJuan Quintela    bluez=yes
3503e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3504e820e3f4Sbalrog  else
3505a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
350621684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3507a20a6f46SJuan Quintela    fi
3508e820e3f4Sbalrog    bluez="no"
3509e820e3f4Sbalrog  fi
3510fb599c9aSbalrogfi
3511fb599c9aSbalrog
3512fb599c9aSbalrog##########################################
3513e18df141SAnthony Liguori# glib support probe
3514a52d28afSPaolo Bonzini
3515e7b3af81SDaniel P. Berrangéglib_req_ver=2.40
3516aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3517aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3518a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3519aa0d1f44SPaolo Bonzinifi
3520e26110cfSFam Zheng
35214eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
35224eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
35234eaf7202SSameeh Jubran
35244eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
35254eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
35264eaf7202SSameeh Jubranfi
35274eaf7202SSameeh Jubran
3528aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3529e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
353089138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
353189138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
35324a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
353314015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3534957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3535e18df141SAnthony Liguori    else
3536e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3537e26110cfSFam Zheng    fi
3538e26110cfSFam Zhengdone
3539e26110cfSFam Zheng
3540977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3541977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3542977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3543977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3544977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3545977a82abSDaniel P. Berrange#include <glib.h>
3546977a82abSDaniel P. Berrange#include <unistd.h>
3547977a82abSDaniel P. Berrange
3548977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3549977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3550977a82abSDaniel P. Berrange
3551977a82abSDaniel P. Berrangeint main(void) {
3552977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3553977a82abSDaniel P. Berrange   return 0;
3554977a82abSDaniel P. Berrange}
3555977a82abSDaniel P. BerrangeEOF
3556977a82abSDaniel P. Berrange
35575919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3558977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3559977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3560977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3561977a82abSDaniel P. Berrange	       "build target"
3562977a82abSDaniel P. Berrangefi
3563977a82abSDaniel P. Berrange
35649d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
35659d41401bSMichael S. Tsirkinglib_subprocess=yes
3566a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
35679d41401bSMichael S. Tsirkin    glib_subprocess=no
35689d41401bSMichael S. Tsirkinfi
35699d41401bSMichael S. Tsirkin
3570bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3571bbbf2e04SJohn Snowcat > $TMPC << EOF
3572bbbf2e04SJohn Snow#include <glib.h>
3573bbbf2e04SJohn Snowint main(void) { return 0; }
3574bbbf2e04SJohn SnowEOF
3575bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3576bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3577bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3578bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3579bbbf2e04SJohn Snow    fi
3580bbbf2e04SJohn Snowfi
3581bbbf2e04SJohn Snow
3582e26110cfSFam Zheng##########################################
3583e26110cfSFam Zheng# SHA command probe for modules
3584e26110cfSFam Zhengif test "$modules" = yes; then
3585e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3586e26110cfSFam Zheng    for c in $shacmd_probe; do
35878ccefb91SFam Zheng        if has $c; then
3588e26110cfSFam Zheng            shacmd="$c"
3589e26110cfSFam Zheng            break
3590e26110cfSFam Zheng        fi
3591e26110cfSFam Zheng    done
3592e26110cfSFam Zheng    if test "$shacmd" = ""; then
3593e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3594e26110cfSFam Zheng    fi
3595e18df141SAnthony Liguorifi
3596e18df141SAnthony Liguori
3597e18df141SAnthony Liguori##########################################
3598e2134eb9SGerd Hoffmann# pixman support probe
3599e2134eb9SGerd Hoffmann
360074880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
360174880fe2SRobert Schiele  pixman_cflags=
360274880fe2SRobert Schiele  pixman_libs=
360335c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
360489138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
360589138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3606e2134eb9SGerd Hoffmannelse
3607c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3608c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3609e2134eb9SGerd Hoffmannfi
3610e2134eb9SGerd Hoffmann
3611e2134eb9SGerd Hoffmann##########################################
3612fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3613fe8fc5aeSPaolo Bonzini
3614fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
3615*1b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3616fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3617fe8fc5aeSPaolo Bonzini#include <libudev.h>
3618fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3619fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3620fe8fc5aeSPaolo Bonziniint logsink;
3621b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3622b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3623b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3624b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3625b3f1c8c4SPaolo Bonzinistruct udev *udev;
3626b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3627b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3628b3f1c8c4SPaolo Bonzini
3629fe8fc5aeSPaolo Bonziniint main(void) {
3630b3f1c8c4SPaolo Bonzini    udev = udev_new();
3631b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3632fe8fc5aeSPaolo Bonzini    return 0;
3633fe8fc5aeSPaolo Bonzini}
3634fe8fc5aeSPaolo BonziniEOF
3635fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3636fe8fc5aeSPaolo Bonzini    mpathpersist=yes
3637*1b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
3638*1b0578f5SMurilo Opsfelder Araujo  else
3639*1b0578f5SMurilo Opsfelder Araujo    # probe for the old API
3640*1b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
3641*1b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
3642*1b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
3643*1b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
3644*1b0578f5SMurilo Opsfelder Araujoint logsink;
3645*1b0578f5SMurilo Opsfelder Araujoint main(void) {
3646*1b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
3647*1b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
3648*1b0578f5SMurilo Opsfelder Araujo    return 0;
3649*1b0578f5SMurilo Opsfelder Araujo}
3650*1b0578f5SMurilo Opsfelder AraujoEOF
3651*1b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3652*1b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
3653*1b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3654fe8fc5aeSPaolo Bonzini    else
3655fe8fc5aeSPaolo Bonzini      mpathpersist=no
3656fe8fc5aeSPaolo Bonzini    fi
3657*1b0578f5SMurilo Opsfelder Araujo  fi
3658fe8fc5aeSPaolo Bonzinielse
3659fe8fc5aeSPaolo Bonzini  mpathpersist=no
3660fe8fc5aeSPaolo Bonzinifi
3661fe8fc5aeSPaolo Bonzini
3662fe8fc5aeSPaolo Bonzini##########################################
366317bff52bSM. Mohan Kumar# libcap probe
366417bff52bSM. Mohan Kumar
366517bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
366617bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
366717bff52bSM. Mohan Kumar#include <stdio.h>
366817bff52bSM. Mohan Kumar#include <sys/capability.h>
3669cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
367017bff52bSM. Mohan KumarEOF
367117bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
367217bff52bSM. Mohan Kumar    cap=yes
367317bff52bSM. Mohan Kumar  else
367417bff52bSM. Mohan Kumar    cap=no
367517bff52bSM. Mohan Kumar  fi
367617bff52bSM. Mohan Kumarfi
367717bff52bSM. Mohan Kumar
367817bff52bSM. Mohan Kumar##########################################
3679e5d355d1Saliguori# pthread probe
36804b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
36813c529d93Saliguori
3682e5d355d1Saliguoripthread=no
3683414f0dabSblueswir1cat > $TMPC << EOF
36843c529d93Saliguori#include <pthread.h>
36857a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
36867a42bbe4SStefan Weilint main(void) {
36877a42bbe4SStefan Weil  pthread_t thread;
36887a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
36897a42bbe4SStefan Weil  return 0;
36907a42bbe4SStefan Weil}
3691414f0dabSblueswir1EOF
3692bd00d539SAndreas Färberif compile_prog "" "" ; then
3693bd00d539SAndreas Färber  pthread=yes
3694bd00d539SAndreas Färberelse
3695de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
369652166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3697e5d355d1Saliguori      pthread=yes
3698e3c56761SPeter Portante      found=no
3699e3c56761SPeter Portante      for lib_entry in $LIBS; do
3700e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3701e3c56761SPeter Portante          found=yes
3702e3c56761SPeter Portante          break
3703e3c56761SPeter Portante        fi
3704e3c56761SPeter Portante      done
3705e3c56761SPeter Portante      if test "$found" = "no"; then
37065572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
370714ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3708e3c56761SPeter Portante      fi
3709409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3710de65fe0fSSebastian Herbszt      break
3711414f0dabSblueswir1    fi
3712de65fe0fSSebastian Herbszt  done
3713bd00d539SAndreas Färberfi
3714414f0dabSblueswir1
37154617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
371676ad07a4SPeter Maydell  error_exit "pthread check failed" \
371776ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3718e5d355d1Saliguorifi
3719e5d355d1Saliguori
37205c312079SDr. David Alan Gilbert# check for pthread_setname_np
37215c312079SDr. David Alan Gilbertpthread_setname_np=no
37225c312079SDr. David Alan Gilbertcat > $TMPC << EOF
37235c312079SDr. David Alan Gilbert#include <pthread.h>
37245c312079SDr. David Alan Gilbert
37255c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
37265c312079SDr. David Alan Gilbertint main(void)
37275c312079SDr. David Alan Gilbert{
37285c312079SDr. David Alan Gilbert    pthread_t thread;
37295c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
37305c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
37315c312079SDr. David Alan Gilbert    return 0;
37325c312079SDr. David Alan Gilbert}
37335c312079SDr. David Alan GilbertEOF
37345c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
37355c312079SDr. David Alan Gilbert  pthread_setname_np=yes
37365c312079SDr. David Alan Gilbertfi
37375c312079SDr. David Alan Gilbert
3738bf9298b9Saliguori##########################################
3739f27aaf4bSChristian Brunner# rbd probe
3740f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3741f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3742f27aaf4bSChristian Brunner#include <stdio.h>
3743ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3744f27aaf4bSChristian Brunnerint main(void) {
3745ad32e9c0SJosh Durgin    rados_t cluster;
3746ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3747f27aaf4bSChristian Brunner    return 0;
3748f27aaf4bSChristian Brunner}
3749f27aaf4bSChristian BrunnerEOF
3750ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3751f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3752f27aaf4bSChristian Brunner    rbd=yes
3753f27aaf4bSChristian Brunner  else
3754f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
375521684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3756f27aaf4bSChristian Brunner    fi
3757f27aaf4bSChristian Brunner    rbd=no
3758f27aaf4bSChristian Brunner  fi
3759f27aaf4bSChristian Brunnerfi
3760f27aaf4bSChristian Brunner
3761f27aaf4bSChristian Brunner##########################################
37620a12ec87SRichard W.M. Jones# libssh2 probe
37634fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
37640a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
376565d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
376689138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
376789138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
37680a12ec87SRichard W.M. Jones    libssh2=yes
37690a12ec87SRichard W.M. Jones  else
37700a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
37714fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
37720a12ec87SRichard W.M. Jones    fi
37730a12ec87SRichard W.M. Jones    libssh2=no
37740a12ec87SRichard W.M. Jones  fi
37750a12ec87SRichard W.M. Jonesfi
37760a12ec87SRichard W.M. Jones
37770a12ec87SRichard W.M. Jones##########################################
37789a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
37799a2d462eSRichard W.M. Jones
37809a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
37819a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
37829a2d462eSRichard W.M. Jones#include <stdio.h>
37839a2d462eSRichard W.M. Jones#include <libssh2.h>
37849a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
37859a2d462eSRichard W.M. Jonesint main(void) {
37869a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
37879a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
37889a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
37899a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
37909a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
37919a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
37929a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
37939a2d462eSRichard W.M. Jones    return 0;
37949a2d462eSRichard W.M. Jones}
37959a2d462eSRichard W.M. JonesEOF
37969a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
37979a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
37989a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
37999a2d462eSRichard W.M. Jones  fi
38009a2d462eSRichard W.M. Jonesfi
38019a2d462eSRichard W.M. Jones
38029a2d462eSRichard W.M. Jones##########################################
38035c6c3a6cSChristoph Hellwig# linux-aio probe
38045c6c3a6cSChristoph Hellwig
38055c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
38065c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
38075c6c3a6cSChristoph Hellwig#include <libaio.h>
38085c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3809832ce9c2SScott Wood#include <stddef.h>
38105c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
38115c6c3a6cSChristoph HellwigEOF
38125c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
38135c6c3a6cSChristoph Hellwig    linux_aio=yes
38145c6c3a6cSChristoph Hellwig  else
38155c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
381621684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
38175c6c3a6cSChristoph Hellwig    fi
38183cfcae3cSLuiz Capitulino    linux_aio=no
38195c6c3a6cSChristoph Hellwig  fi
38205c6c3a6cSChristoph Hellwigfi
38215c6c3a6cSChristoph Hellwig
38225c6c3a6cSChristoph Hellwig##########################################
38233b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
38243b8acc11SPaolo Bonzini
38253b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
38263b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
38273b8acc11SPaolo Bonzinielse
38283b8acc11SPaolo Bonzini  tpm_passthrough=no
38293b8acc11SPaolo Bonzinifi
38303b8acc11SPaolo Bonzini
3831f4ede81eSAmarnath Valluri# TPM emulator is for all posix systems
3832f4ede81eSAmarnath Valluriif test "$mingw32" != "yes"; then
3833f4ede81eSAmarnath Valluri  tpm_emulator=$tpm
3834f4ede81eSAmarnath Vallurielse
3835f4ede81eSAmarnath Valluri  tpm_emulator=no
3836f4ede81eSAmarnath Vallurifi
38373b8acc11SPaolo Bonzini##########################################
3838758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3839758e8e38SVenkateswararao Jujjuri (JV)
3840758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3841758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3842758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3843758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3844f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3845f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3846f2338fb4SPavel Borzenkov#else
38474f26f2b6SAvi Kivity#include <sys/xattr.h>
3848f2338fb4SPavel Borzenkov#endif
3849758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3850758e8e38SVenkateswararao Jujjuri (JV)EOF
38514f26f2b6SAvi Kivity  if compile_prog "" "" ; then
38524f26f2b6SAvi Kivity    attr=yes
38534f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3854f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3855758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3856758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
38574f26f2b6SAvi Kivity    libattr=yes
3858758e8e38SVenkateswararao Jujjuri (JV)  else
3859758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
386021684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3861758e8e38SVenkateswararao Jujjuri (JV)    fi
3862758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3863758e8e38SVenkateswararao Jujjuri (JV)  fi
3864758e8e38SVenkateswararao Jujjuri (JV)fi
3865758e8e38SVenkateswararao Jujjuri (JV)
3866758e8e38SVenkateswararao Jujjuri (JV)##########################################
3867bf9298b9Saliguori# iovec probe
3868bf9298b9Saliguoricat > $TMPC <<EOF
3869db34f0b3Sblueswir1#include <sys/types.h>
3870bf9298b9Saliguori#include <sys/uio.h>
3871db34f0b3Sblueswir1#include <unistd.h>
3872f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3873bf9298b9SaliguoriEOF
3874bf9298b9Saliguoriiovec=no
387552166aa0SJuan Quintelaif compile_prog "" "" ; then
3876bf9298b9Saliguori  iovec=yes
3877bf9298b9Saliguorifi
3878bf9298b9Saliguori
3879f652e6afSaurel32##########################################
3880ceb42de8Saliguori# preadv probe
3881ceb42de8Saliguoricat > $TMPC <<EOF
3882ceb42de8Saliguori#include <sys/types.h>
3883ceb42de8Saliguori#include <sys/uio.h>
3884ceb42de8Saliguori#include <unistd.h>
3885c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3886ceb42de8SaliguoriEOF
3887ceb42de8Saliguoripreadv=no
388852166aa0SJuan Quintelaif compile_prog "" "" ; then
3889ceb42de8Saliguori  preadv=yes
3890ceb42de8Saliguorifi
3891ceb42de8Saliguori
3892ceb42de8Saliguori##########################################
3893f652e6afSaurel32# fdt probe
3894e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3895e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3896e169e1e1SPeter Maydellfdt_required=no
3897e169e1e1SPeter Maydellfor target in $target_list; do
3898e169e1e1SPeter Maydell  case $target in
3899a666409fSKONRAD Frederic    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3900e169e1e1SPeter Maydell      fdt_required=yes
3901e169e1e1SPeter Maydell    ;;
3902e169e1e1SPeter Maydell  esac
3903e169e1e1SPeter Maydelldone
3904e169e1e1SPeter Maydell
3905e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3906e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3907e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3908e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3909e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3910e169e1e1SPeter Maydell  fi
3911e169e1e1SPeter Maydell  fdt=yes
3912e169e1e1SPeter Maydellfi
3913e169e1e1SPeter Maydell
39142df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3915b41af4baSJuan Quintela  fdt_libs="-lfdt"
391696ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
39176e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3918f652e6afSaurel32  cat > $TMPC << EOF
391931ce0adbSThomas Huth#include <libfdt.h>
392096ce6545SPeter Crosthwaite#include <libfdt_env.h>
39216e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3922f652e6afSaurel32EOF
392352166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3924a540f158SPeter Crosthwaite    # system DTC is good - use it
3925e3971d61SPhilippe Mathieu-Daudé    fdt=system
3926aef45d51SDaniel P. Berrange  else
3927aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3928aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3929aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3930aef45d51SDaniel P. Berrange      fi
3931aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3932e3971d61SPhilippe Mathieu-Daudé          fdt=git
3933a540f158SPeter Crosthwaite          mkdir -p dtc
3934cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3935a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3936a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
39372df87df7SJuan Quintela          fi
3938a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
39398a99e9a3SPhilippe Mathieu-Daudé          fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
39408a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
3941a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
3942aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
3943aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3944aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
3945a540f158SPeter Crosthwaite      else
3946a540f158SPeter Crosthwaite          # don't have and don't want
3947de3a354aSMichael Walle          fdt_libs=
39482df87df7SJuan Quintela          fdt=no
3949f652e6afSaurel32      fi
3950f652e6afSaurel32  fi
3951aef45d51SDaniel P. Berrangefi
3952f652e6afSaurel32
3953a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3954a540f158SPeter Crosthwaite
395520ff075bSMichael Walle##########################################
3956fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3957b1546f32SGerd Hoffmann
3958da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
39594939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
39605f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
39615f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
39625f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3963da076ffeSGerd Hoffmann    opengl=yes
3964925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3965925a0400SGerd Hoffmann        gtk_gl="yes"
3966925a0400SGerd Hoffmann    fi
3967cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
396820ff075bSMichael Walle  else
3969da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3970dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
397120ff075bSMichael Walle    fi
3972f676c67eSJeremy White    opengl_cflags=""
3973da076ffeSGerd Hoffmann    opengl_libs=""
3974da076ffeSGerd Hoffmann    opengl=no
397520ff075bSMichael Walle  fi
397620ff075bSMichael Wallefi
397720ff075bSMichael Walle
3978014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3979014cb152SGerd Hoffmann  cat > $TMPC << EOF
3980014cb152SGerd Hoffmann#include <epoxy/egl.h>
3981014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3982014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3983014cb152SGerd Hoffmann#endif
3984014cb152SGerd Hoffmannint main(void) { return 0; }
3985014cb152SGerd HoffmannEOF
3986014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3987014cb152SGerd Hoffmann    opengl_dmabuf=yes
3988014cb152SGerd Hoffmann  fi
3989014cb152SGerd Hoffmannfi
3990c9a12e75SChrysostomos Nanakos
3991ed279a06SKlim Kireev##########################################
3992ed279a06SKlim Kireev# libxml2 probe
3993ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3994ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3995ed279a06SKlim Kireev        libxml2="yes"
3996ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3997ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3998ed279a06SKlim Kireev    else
3999ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4000ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4001ed279a06SKlim Kireev        fi
4002ed279a06SKlim Kireev        libxml2="no"
4003ed279a06SKlim Kireev    fi
4004ed279a06SKlim Kireevfi
4005c9a12e75SChrysostomos Nanakos
4006eb100396SBharata B Rao##########################################
4007eb100396SBharata B Rao# glusterfs probe
4008eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
400965d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4010e01bee08SBharata B Rao    glusterfs="yes"
401189138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
401289138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4013d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4014d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4015d85fa9ebSJeff Cody    fi
401665d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
40170c14fb47SBharata B Rao      glusterfs_discard="yes"
40180c14fb47SBharata B Rao    fi
40197c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4020df3a429aSNiels de Vos      glusterfs_fallocate="yes"
40217c815372SBharata B Rao      glusterfs_zerofill="yes"
40227c815372SBharata B Rao    fi
4023eb100396SBharata B Rao  else
4024eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
40258efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
40268efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4027eb100396SBharata B Rao    fi
4028e01bee08SBharata B Rao    glusterfs="no"
4029eb100396SBharata B Rao  fi
4030eb100396SBharata B Raofi
4031eb100396SBharata B Rao
403239386ac7Saurel32# Check for inotify functions when we are building linux-user
40333b3f24adSaurel32# emulator.  This is done because older glibc versions don't
40343b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
40353b3f24adSaurel32# don't provide them even if kernel supports them.
40363b3f24adSaurel32#
40373b3f24adSaurel32inotify=no
40383b3f24adSaurel32cat > $TMPC << EOF
40393b3f24adSaurel32#include <sys/inotify.h>
40403b3f24adSaurel32
40413b3f24adSaurel32int
40423b3f24adSaurel32main(void)
40433b3f24adSaurel32{
40443b3f24adSaurel32	/* try to start inotify */
40458690e420Saurel32	return inotify_init();
40463b3f24adSaurel32}
40473b3f24adSaurel32EOF
404852166aa0SJuan Quintelaif compile_prog "" "" ; then
40493b3f24adSaurel32  inotify=yes
40503b3f24adSaurel32fi
40513b3f24adSaurel32
4052c05c7a73SRiku Voipioinotify1=no
4053c05c7a73SRiku Voipiocat > $TMPC << EOF
4054c05c7a73SRiku Voipio#include <sys/inotify.h>
4055c05c7a73SRiku Voipio
4056c05c7a73SRiku Voipioint
4057c05c7a73SRiku Voipiomain(void)
4058c05c7a73SRiku Voipio{
4059c05c7a73SRiku Voipio    /* try to start inotify */
4060c05c7a73SRiku Voipio    return inotify_init1(0);
4061c05c7a73SRiku Voipio}
4062c05c7a73SRiku VoipioEOF
4063c05c7a73SRiku Voipioif compile_prog "" "" ; then
4064c05c7a73SRiku Voipio  inotify1=yes
4065c05c7a73SRiku Voipiofi
4066c05c7a73SRiku Voipio
4067099d6b0fSRiku Voipio# check if pipe2 is there
4068099d6b0fSRiku Voipiopipe2=no
4069099d6b0fSRiku Voipiocat > $TMPC << EOF
4070099d6b0fSRiku Voipio#include <unistd.h>
4071099d6b0fSRiku Voipio#include <fcntl.h>
4072099d6b0fSRiku Voipio
4073099d6b0fSRiku Voipioint main(void)
4074099d6b0fSRiku Voipio{
4075099d6b0fSRiku Voipio    int pipefd[2];
40769bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4077099d6b0fSRiku Voipio}
4078099d6b0fSRiku VoipioEOF
407952166aa0SJuan Quintelaif compile_prog "" "" ; then
4080099d6b0fSRiku Voipio  pipe2=yes
4081099d6b0fSRiku Voipiofi
4082099d6b0fSRiku Voipio
408340ff6d7eSKevin Wolf# check if accept4 is there
408440ff6d7eSKevin Wolfaccept4=no
408540ff6d7eSKevin Wolfcat > $TMPC << EOF
408640ff6d7eSKevin Wolf#include <sys/socket.h>
408740ff6d7eSKevin Wolf#include <stddef.h>
408840ff6d7eSKevin Wolf
408940ff6d7eSKevin Wolfint main(void)
409040ff6d7eSKevin Wolf{
409140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
409240ff6d7eSKevin Wolf    return 0;
409340ff6d7eSKevin Wolf}
409440ff6d7eSKevin WolfEOF
409540ff6d7eSKevin Wolfif compile_prog "" "" ; then
409640ff6d7eSKevin Wolf  accept4=yes
409740ff6d7eSKevin Wolffi
409840ff6d7eSKevin Wolf
40993ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
41003ce34dfbSvibisreenivasansplice=no
41013ce34dfbSvibisreenivasancat > $TMPC << EOF
41023ce34dfbSvibisreenivasan#include <unistd.h>
41033ce34dfbSvibisreenivasan#include <fcntl.h>
41043ce34dfbSvibisreenivasan#include <limits.h>
41053ce34dfbSvibisreenivasan
41063ce34dfbSvibisreenivasanint main(void)
41073ce34dfbSvibisreenivasan{
410866ea0f22SStefan Weil    int len, fd = 0;
41093ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
41103ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
41113ce34dfbSvibisreenivasan    return 0;
41123ce34dfbSvibisreenivasan}
41133ce34dfbSvibisreenivasanEOF
411452166aa0SJuan Quintelaif compile_prog "" "" ; then
41153ce34dfbSvibisreenivasan  splice=yes
41163ce34dfbSvibisreenivasanfi
41173ce34dfbSvibisreenivasan
4118dcc38d1cSMarcelo Tosatti##########################################
4119a99d57bbSWanlong Gao# libnuma probe
4120a99d57bbSWanlong Gao
4121a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4122a99d57bbSWanlong Gao  cat > $TMPC << EOF
4123a99d57bbSWanlong Gao#include <numa.h>
4124a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4125a99d57bbSWanlong GaoEOF
4126a99d57bbSWanlong Gao
4127a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4128a99d57bbSWanlong Gao    numa=yes
4129a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4130a99d57bbSWanlong Gao  else
4131a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4132a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4133a99d57bbSWanlong Gao    fi
4134a99d57bbSWanlong Gao    numa=no
4135a99d57bbSWanlong Gao  fi
4136a99d57bbSWanlong Gaofi
4137a99d57bbSWanlong Gao
41387b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
41397b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
41407b01cb97SAlexandre Derumier    exit 1
41417b01cb97SAlexandre Derumierfi
41427b01cb97SAlexandre Derumier
41435a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
41445a22ab71SYang Zhong# do not support it.
41455a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
41465a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
41475a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
41485a22ab71SYang Zhong    fi
41495a22ab71SYang Zhong    malloc_trim="no"
41505a22ab71SYang Zhongfi
41515a22ab71SYang Zhong
41525a22ab71SYang Zhong#######################################
41535a22ab71SYang Zhong# malloc_trim
41545a22ab71SYang Zhong
41555a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
41565a22ab71SYang Zhong    cat > $TMPC << EOF
41575a22ab71SYang Zhong#include <malloc.h>
41585a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
41595a22ab71SYang ZhongEOF
41605a22ab71SYang Zhong    if compile_prog "" "" ; then
41615a22ab71SYang Zhong        malloc_trim="yes"
41625a22ab71SYang Zhong    else
41635a22ab71SYang Zhong        malloc_trim="no"
41645a22ab71SYang Zhong    fi
41655a22ab71SYang Zhongfi
41665a22ab71SYang Zhong
4167a99d57bbSWanlong Gao##########################################
41682847b469SFam Zheng# tcmalloc probe
41692847b469SFam Zheng
41702847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
41712847b469SFam Zheng  cat > $TMPC << EOF
41722847b469SFam Zheng#include <stdlib.h>
41732847b469SFam Zhengint main(void) { malloc(1); return 0; }
41742847b469SFam ZhengEOF
41752847b469SFam Zheng
41762847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
41772847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
41782847b469SFam Zheng  else
41792847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
41802847b469SFam Zheng  fi
41812847b469SFam Zhengfi
41822847b469SFam Zheng
41832847b469SFam Zheng##########################################
41847b01cb97SAlexandre Derumier# jemalloc probe
41857b01cb97SAlexandre Derumier
41867b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
41877b01cb97SAlexandre Derumier  cat > $TMPC << EOF
41887b01cb97SAlexandre Derumier#include <stdlib.h>
41897b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
41907b01cb97SAlexandre DerumierEOF
41917b01cb97SAlexandre Derumier
41927b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
41937b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
41947b01cb97SAlexandre Derumier  else
41957b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
41967b01cb97SAlexandre Derumier  fi
41977b01cb97SAlexandre Derumierfi
41987b01cb97SAlexandre Derumier
41997b01cb97SAlexandre Derumier##########################################
4200dcc38d1cSMarcelo Tosatti# signalfd probe
4201dcc38d1cSMarcelo Tosattisignalfd="no"
4202dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4203dcc38d1cSMarcelo Tosatti#include <unistd.h>
4204dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4205dcc38d1cSMarcelo Tosatti#include <signal.h>
4206dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4207dcc38d1cSMarcelo TosattiEOF
4208dcc38d1cSMarcelo Tosatti
4209dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4210dcc38d1cSMarcelo Tosatti  signalfd=yes
4211dcc38d1cSMarcelo Tosattifi
4212dcc38d1cSMarcelo Tosatti
4213c2882b96SRiku Voipio# check if eventfd is supported
4214c2882b96SRiku Voipioeventfd=no
4215c2882b96SRiku Voipiocat > $TMPC << EOF
4216c2882b96SRiku Voipio#include <sys/eventfd.h>
4217c2882b96SRiku Voipio
4218c2882b96SRiku Voipioint main(void)
4219c2882b96SRiku Voipio{
422055cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4221c2882b96SRiku Voipio}
4222c2882b96SRiku VoipioEOF
4223c2882b96SRiku Voipioif compile_prog "" "" ; then
4224c2882b96SRiku Voipio  eventfd=yes
4225c2882b96SRiku Voipiofi
4226c2882b96SRiku Voipio
4227751bcc39SMarc-André Lureau# check if memfd is supported
4228751bcc39SMarc-André Lureaumemfd=no
4229751bcc39SMarc-André Lureaucat > $TMPC << EOF
423075e5b70eSPaolo Bonzini#include <sys/mman.h>
4231751bcc39SMarc-André Lureau
4232751bcc39SMarc-André Lureauint main(void)
4233751bcc39SMarc-André Lureau{
4234751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4235751bcc39SMarc-André Lureau}
4236751bcc39SMarc-André LureauEOF
4237751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4238751bcc39SMarc-André Lureau  memfd=yes
4239751bcc39SMarc-André Lureaufi
4240751bcc39SMarc-André Lureau
4241751bcc39SMarc-André Lureau
4242751bcc39SMarc-André Lureau
4243d0927938SUlrich Hecht# check for fallocate
4244d0927938SUlrich Hechtfallocate=no
4245d0927938SUlrich Hechtcat > $TMPC << EOF
4246d0927938SUlrich Hecht#include <fcntl.h>
4247d0927938SUlrich Hecht
4248d0927938SUlrich Hechtint main(void)
4249d0927938SUlrich Hecht{
4250d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4251d0927938SUlrich Hecht    return 0;
4252d0927938SUlrich Hecht}
4253d0927938SUlrich HechtEOF
42548fb03151SPeter Maydellif compile_prog "" "" ; then
4255d0927938SUlrich Hecht  fallocate=yes
4256d0927938SUlrich Hechtfi
4257d0927938SUlrich Hecht
42583d4fa43eSKusanagi Kouichi# check for fallocate hole punching
42593d4fa43eSKusanagi Kouichifallocate_punch_hole=no
42603d4fa43eSKusanagi Kouichicat > $TMPC << EOF
42613d4fa43eSKusanagi Kouichi#include <fcntl.h>
42623d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
42633d4fa43eSKusanagi Kouichi
42643d4fa43eSKusanagi Kouichiint main(void)
42653d4fa43eSKusanagi Kouichi{
42663d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
42673d4fa43eSKusanagi Kouichi    return 0;
42683d4fa43eSKusanagi Kouichi}
42693d4fa43eSKusanagi KouichiEOF
42703d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
42713d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
42723d4fa43eSKusanagi Kouichifi
42733d4fa43eSKusanagi Kouichi
4274b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4275b953f075SDenis V. Lunevfallocate_zero_range=no
4276b953f075SDenis V. Lunevcat > $TMPC << EOF
4277b953f075SDenis V. Lunev#include <fcntl.h>
4278b953f075SDenis V. Lunev#include <linux/falloc.h>
4279b953f075SDenis V. Lunev
4280b953f075SDenis V. Lunevint main(void)
4281b953f075SDenis V. Lunev{
4282b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4283b953f075SDenis V. Lunev    return 0;
4284b953f075SDenis V. Lunev}
4285b953f075SDenis V. LunevEOF
4286b953f075SDenis V. Lunevif compile_prog "" "" ; then
4287b953f075SDenis V. Lunev  fallocate_zero_range=yes
4288b953f075SDenis V. Lunevfi
4289b953f075SDenis V. Lunev
4290ed911435SKevin Wolf# check for posix_fallocate
4291ed911435SKevin Wolfposix_fallocate=no
4292ed911435SKevin Wolfcat > $TMPC << EOF
4293ed911435SKevin Wolf#include <fcntl.h>
4294ed911435SKevin Wolf
4295ed911435SKevin Wolfint main(void)
4296ed911435SKevin Wolf{
4297ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4298ed911435SKevin Wolf    return 0;
4299ed911435SKevin Wolf}
4300ed911435SKevin WolfEOF
4301ed911435SKevin Wolfif compile_prog "" "" ; then
4302ed911435SKevin Wolf    posix_fallocate=yes
4303ed911435SKevin Wolffi
4304ed911435SKevin Wolf
4305c727f47dSPeter Maydell# check for sync_file_range
4306c727f47dSPeter Maydellsync_file_range=no
4307c727f47dSPeter Maydellcat > $TMPC << EOF
4308c727f47dSPeter Maydell#include <fcntl.h>
4309c727f47dSPeter Maydell
4310c727f47dSPeter Maydellint main(void)
4311c727f47dSPeter Maydell{
4312c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4313c727f47dSPeter Maydell    return 0;
4314c727f47dSPeter Maydell}
4315c727f47dSPeter MaydellEOF
43168fb03151SPeter Maydellif compile_prog "" "" ; then
4317c727f47dSPeter Maydell  sync_file_range=yes
4318c727f47dSPeter Maydellfi
4319c727f47dSPeter Maydell
4320dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4321dace20dcSPeter Maydellfiemap=no
4322dace20dcSPeter Maydellcat > $TMPC << EOF
4323dace20dcSPeter Maydell#include <sys/ioctl.h>
4324dace20dcSPeter Maydell#include <linux/fs.h>
4325dace20dcSPeter Maydell#include <linux/fiemap.h>
4326dace20dcSPeter Maydell
4327dace20dcSPeter Maydellint main(void)
4328dace20dcSPeter Maydell{
4329dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4330dace20dcSPeter Maydell    return 0;
4331dace20dcSPeter Maydell}
4332dace20dcSPeter MaydellEOF
43338fb03151SPeter Maydellif compile_prog "" "" ; then
4334dace20dcSPeter Maydell  fiemap=yes
4335dace20dcSPeter Maydellfi
4336dace20dcSPeter Maydell
4337d0927938SUlrich Hecht# check for dup3
4338d0927938SUlrich Hechtdup3=no
4339d0927938SUlrich Hechtcat > $TMPC << EOF
4340d0927938SUlrich Hecht#include <unistd.h>
4341d0927938SUlrich Hecht
4342d0927938SUlrich Hechtint main(void)
4343d0927938SUlrich Hecht{
4344d0927938SUlrich Hecht    dup3(0, 0, 0);
4345d0927938SUlrich Hecht    return 0;
4346d0927938SUlrich Hecht}
4347d0927938SUlrich HechtEOF
434878f5d726SJan Kiszkaif compile_prog "" "" ; then
4349d0927938SUlrich Hecht  dup3=yes
4350d0927938SUlrich Hechtfi
4351d0927938SUlrich Hecht
43524e0c6529SAlex Bligh# check for ppoll support
43534e0c6529SAlex Blighppoll=no
43544e0c6529SAlex Blighcat > $TMPC << EOF
43554e0c6529SAlex Bligh#include <poll.h>
43564e0c6529SAlex Bligh
43574e0c6529SAlex Blighint main(void)
43584e0c6529SAlex Bligh{
43594e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
43604e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
43614e0c6529SAlex Bligh    return 0;
43624e0c6529SAlex Bligh}
43634e0c6529SAlex BlighEOF
43644e0c6529SAlex Blighif compile_prog "" "" ; then
43654e0c6529SAlex Bligh  ppoll=yes
43664e0c6529SAlex Blighfi
43674e0c6529SAlex Bligh
4368cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4369cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4370cd758dd0SAlex Blighcat > $TMPC << EOF
4371cd758dd0SAlex Bligh#include <sys/prctl.h>
4372cd758dd0SAlex Bligh
4373cd758dd0SAlex Blighint main(void)
4374cd758dd0SAlex Bligh{
4375cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4376cd758dd0SAlex Bligh    return 0;
4377cd758dd0SAlex Bligh}
4378cd758dd0SAlex BlighEOF
4379cd758dd0SAlex Blighif compile_prog "" "" ; then
4380cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4381cd758dd0SAlex Blighfi
4382cd758dd0SAlex Bligh
43833b6edd16SPeter Maydell# check for epoll support
43843b6edd16SPeter Maydellepoll=no
43853b6edd16SPeter Maydellcat > $TMPC << EOF
43863b6edd16SPeter Maydell#include <sys/epoll.h>
43873b6edd16SPeter Maydell
43883b6edd16SPeter Maydellint main(void)
43893b6edd16SPeter Maydell{
43903b6edd16SPeter Maydell    epoll_create(0);
43913b6edd16SPeter Maydell    return 0;
43923b6edd16SPeter Maydell}
43933b6edd16SPeter MaydellEOF
43948fb03151SPeter Maydellif compile_prog "" "" ; then
43953b6edd16SPeter Maydell  epoll=yes
43963b6edd16SPeter Maydellfi
43973b6edd16SPeter Maydell
4398227f0214SPeter Maydell# epoll_create1 is a later addition
4399227f0214SPeter Maydell# so we must check separately for its presence
44003b6edd16SPeter Maydellepoll_create1=no
44013b6edd16SPeter Maydellcat > $TMPC << EOF
44023b6edd16SPeter Maydell#include <sys/epoll.h>
44033b6edd16SPeter Maydell
44043b6edd16SPeter Maydellint main(void)
44053b6edd16SPeter Maydell{
440619e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
440719e83f6bSPeter Maydell     * a function being called. This is necessary so that on
440819e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
440919e83f6bSPeter Maydell     * the library but not declared in the header file we will
441019e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
441119e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
441219e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
441319e83f6bSPeter Maydell     */
4414c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
44153b6edd16SPeter Maydell}
44163b6edd16SPeter MaydellEOF
44178fb03151SPeter Maydellif compile_prog "" "" ; then
44183b6edd16SPeter Maydell  epoll_create1=yes
44193b6edd16SPeter Maydellfi
44203b6edd16SPeter Maydell
4421a8fd1abaSPeter Maydell# check for sendfile support
4422a8fd1abaSPeter Maydellsendfile=no
4423a8fd1abaSPeter Maydellcat > $TMPC << EOF
4424a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4425a8fd1abaSPeter Maydell
4426a8fd1abaSPeter Maydellint main(void)
4427a8fd1abaSPeter Maydell{
4428a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4429a8fd1abaSPeter Maydell}
4430a8fd1abaSPeter MaydellEOF
4431a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4432a8fd1abaSPeter Maydell  sendfile=yes
4433a8fd1abaSPeter Maydellfi
4434a8fd1abaSPeter Maydell
443551834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
443651834341SRiku Voipiotimerfd=no
443751834341SRiku Voipiocat > $TMPC << EOF
443851834341SRiku Voipio#include <sys/timerfd.h>
443951834341SRiku Voipio
444051834341SRiku Voipioint main(void)
444151834341SRiku Voipio{
444251834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
444351834341SRiku Voipio}
444451834341SRiku VoipioEOF
444551834341SRiku Voipioif compile_prog "" "" ; then
444651834341SRiku Voipio  timerfd=yes
444751834341SRiku Voipiofi
444851834341SRiku Voipio
44499af5c906SRiku Voipio# check for setns and unshare support
44509af5c906SRiku Voipiosetns=no
44519af5c906SRiku Voipiocat > $TMPC << EOF
44529af5c906SRiku Voipio#include <sched.h>
44539af5c906SRiku Voipio
44549af5c906SRiku Voipioint main(void)
44559af5c906SRiku Voipio{
44569af5c906SRiku Voipio    int ret;
44579af5c906SRiku Voipio    ret = setns(0, 0);
44589af5c906SRiku Voipio    ret = unshare(0);
44599af5c906SRiku Voipio    return ret;
44609af5c906SRiku Voipio}
44619af5c906SRiku VoipioEOF
44629af5c906SRiku Voipioif compile_prog "" "" ; then
44639af5c906SRiku Voipio  setns=yes
44649af5c906SRiku Voipiofi
44659af5c906SRiku Voipio
446638860a03SAleksandar Markovic# clock_adjtime probe
446738860a03SAleksandar Markovicclock_adjtime=no
446838860a03SAleksandar Markoviccat > $TMPC <<EOF
446938860a03SAleksandar Markovic#include <time.h>
447038860a03SAleksandar Markovic
447138860a03SAleksandar Markovicint main(void)
447238860a03SAleksandar Markovic{
447338860a03SAleksandar Markovic    return clock_adjtime(0, 0);
447438860a03SAleksandar Markovic}
447538860a03SAleksandar MarkovicEOF
447638860a03SAleksandar Markovicclock_adjtime=no
447738860a03SAleksandar Markovicif compile_prog "" "" ; then
447838860a03SAleksandar Markovic  clock_adjtime=yes
447938860a03SAleksandar Markovicfi
448038860a03SAleksandar Markovic
44815a03cd00SAleksandar Markovic# syncfs probe
44825a03cd00SAleksandar Markovicsyncfs=no
44835a03cd00SAleksandar Markoviccat > $TMPC <<EOF
44845a03cd00SAleksandar Markovic#include <unistd.h>
44855a03cd00SAleksandar Markovic
44865a03cd00SAleksandar Markovicint main(void)
44875a03cd00SAleksandar Markovic{
44885a03cd00SAleksandar Markovic    return syncfs(0);
44895a03cd00SAleksandar Markovic}
44905a03cd00SAleksandar MarkovicEOF
44915a03cd00SAleksandar Markovicsyncfs=no
44925a03cd00SAleksandar Markovicif compile_prog "" "" ; then
44935a03cd00SAleksandar Markovic  syncfs=yes
44945a03cd00SAleksandar Markovicfi
44955a03cd00SAleksandar Markovic
4496cc8ae6deSpbrook# Check if tools are available to build documentation.
4497a25dba17SJuan Quintelaif test "$docs" != "no" ; then
449801668d98SStefan Weil  if has makeinfo && has pod2man; then
4499a25dba17SJuan Quintela    docs=yes
450083a3ab8bSJuan Quintela  else
4501a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
450221684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
450383a3ab8bSJuan Quintela    fi
4504a25dba17SJuan Quintela    docs=no
450583a3ab8bSJuan Quintela  fi
4506cc8ae6deSpbrookfi
4507cc8ae6deSpbrook
4508f514f41cSStefan Weil# Search for bswap_32 function
45096ae9a1f4SJuan Quintelabyteswap_h=no
45106ae9a1f4SJuan Quintelacat > $TMPC << EOF
45116ae9a1f4SJuan Quintela#include <byteswap.h>
45126ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
45136ae9a1f4SJuan QuintelaEOF
451452166aa0SJuan Quintelaif compile_prog "" "" ; then
45156ae9a1f4SJuan Quintela  byteswap_h=yes
45166ae9a1f4SJuan Quintelafi
45176ae9a1f4SJuan Quintela
451875f13596SStefan Weil# Search for bswap32 function
45196ae9a1f4SJuan Quintelabswap_h=no
45206ae9a1f4SJuan Quintelacat > $TMPC << EOF
45216ae9a1f4SJuan Quintela#include <sys/endian.h>
45226ae9a1f4SJuan Quintela#include <sys/types.h>
45236ae9a1f4SJuan Quintela#include <machine/bswap.h>
45246ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
45256ae9a1f4SJuan QuintelaEOF
452652166aa0SJuan Quintelaif compile_prog "" "" ; then
45276ae9a1f4SJuan Quintela  bswap_h=yes
45286ae9a1f4SJuan Quintelafi
45296ae9a1f4SJuan Quintela
4530da93a1fdSaliguori##########################################
4531e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4532c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4533e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
45343c33ea96SPaolo Bonzini    libiscsi="yes"
4535ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4536ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4537c589b249SRonnie Sahlberg  else
4538c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4539e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4540c589b249SRonnie Sahlberg    fi
4541c589b249SRonnie Sahlberg    libiscsi="no"
4542c589b249SRonnie Sahlberg  fi
4543c589b249SRonnie Sahlbergfi
4544c589b249SRonnie Sahlberg
4545c589b249SRonnie Sahlberg##########################################
45468bacde8dSNatanael Copa# Do we need libm
45478bacde8dSNatanael Copacat > $TMPC << EOF
45488bacde8dSNatanael Copa#include <math.h>
4549f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
45508bacde8dSNatanael CopaEOF
45518bacde8dSNatanael Copaif compile_prog "" "" ; then
45528bacde8dSNatanael Copa  :
45538bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
45548bacde8dSNatanael Copa  LIBS="-lm $LIBS"
45558bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
45568bacde8dSNatanael Copaelse
455776ad07a4SPeter Maydell  error_exit "libm check failed"
45588bacde8dSNatanael Copafi
45598bacde8dSNatanael Copa
45608bacde8dSNatanael Copa##########################################
4561da93a1fdSaliguori# Do we need librt
45628bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
45638bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
45648bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
45658bacde8dSNatanael Copa# function in addition.
4566da93a1fdSaliguoricat > $TMPC <<EOF
4567da93a1fdSaliguori#include <signal.h>
4568da93a1fdSaliguori#include <time.h>
45698bacde8dSNatanael Copaint main(void) {
45708bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
45718bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
45728bacde8dSNatanael Copa}
4573da93a1fdSaliguoriEOF
4574da93a1fdSaliguori
457552166aa0SJuan Quintelaif compile_prog "" "" ; then
457607ffa4bdSJuan Quintela  :
45778bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
457818e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
457918e588b1SRick Liu  LIBS="$LIBS -lrt"
458018e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4581da93a1fdSaliguorifi
4582da93a1fdSaliguori
458331ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
458478723752SPeter Maydell        "$haiku" != "yes" ; then
45856362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
45866362a53fSJuan Quintelafi
45876362a53fSJuan Quintela
4588de5071c5SBlue Swirl##########################################
4589cd4ec0b4SGerd Hoffmann# spice probe
4590cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4591cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4592cd4ec0b4SGerd Hoffmann#include <spice.h>
4593cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4594cd4ec0b4SGerd HoffmannEOF
4595710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4596710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
459765d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
459865d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4599cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4600cd4ec0b4SGerd Hoffmann    spice="yes"
4601cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4602cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
46032e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
46042e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4605cd4ec0b4SGerd Hoffmann  else
4606cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
46078efc9363SHu Tao      feature_not_found "spice" \
46088efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4609cd4ec0b4SGerd Hoffmann    fi
4610cd4ec0b4SGerd Hoffmann    spice="no"
4611cd4ec0b4SGerd Hoffmann  fi
4612cd4ec0b4SGerd Hoffmannfi
4613cd4ec0b4SGerd Hoffmann
46147b02f544SMarc-André Lureau# check for smartcard support
46157b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
46160f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
46177b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
46187b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
46197b02f544SMarc-André Lureau        smartcard="yes"
4620111a38b0SRobert Relyea    else
46217b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
46227b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4623111a38b0SRobert Relyea        fi
46247b02f544SMarc-André Lureau        smartcard="no"
4625111a38b0SRobert Relyea    fi
4626111a38b0SRobert Relyeafi
4627111a38b0SRobert Relyea
46282b2325ffSGerd Hoffmann# check for libusb
46292b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
463065d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
46312b2325ffSGerd Hoffmann        libusb="yes"
4632ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4633ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
46342b2325ffSGerd Hoffmann    else
46352b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
46368efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
46372b2325ffSGerd Hoffmann        fi
46382b2325ffSGerd Hoffmann        libusb="no"
46392b2325ffSGerd Hoffmann    fi
46402b2325ffSGerd Hoffmannfi
46412b2325ffSGerd Hoffmann
464269354a83SHans de Goede# check for usbredirparser for usb network redirection support
464369354a83SHans de Goedeif test "$usb_redir" != "no" ; then
464465d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
464569354a83SHans de Goede        usb_redir="yes"
4646ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4647ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
464869354a83SHans de Goede    else
464969354a83SHans de Goede        if test "$usb_redir" = "yes"; then
465021684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
465169354a83SHans de Goede        fi
465269354a83SHans de Goede        usb_redir="no"
465369354a83SHans de Goede    fi
465469354a83SHans de Goedefi
465569354a83SHans de Goede
4656cd4ec0b4SGerd Hoffmann##########################################
4657d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4658d9840e25STomoki Sekiyama
4659d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4660d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4661690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4662d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4663d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4664690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4665d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4666d9840e25STomoki Sekiyama	  ;;
4667690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4668d9840e25STomoki Sekiyama  esac
4669d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4670d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4671d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4672d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4673d9840e25STomoki SekiyamaEOF
4674d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4675d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4676d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4677315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4678f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4679d9840e25STomoki Sekiyama  else
4680d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4681d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4682d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4683d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4684d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4685d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4686d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4687d9840e25STomoki Sekiyama    fi
4688d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4689d9840e25STomoki Sekiyama  fi
4690d9840e25STomoki Sekiyamafi
4691d9840e25STomoki Sekiyama
4692d9840e25STomoki Sekiyama##########################################
4693d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4694d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4695d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4696d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4697d9840e25STomoki Sekiyama
4698d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4699d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4700d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4701d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4702d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4703d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4704d9840e25STomoki Sekiyama    else
4705d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4706d9840e25STomoki Sekiyama    fi
4707d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4708d9840e25STomoki Sekiyama    win_sdk=""
4709d9840e25STomoki Sekiyama  fi
4710d9840e25STomoki Sekiyamafi
4711d9840e25STomoki Sekiyama
4712d9840e25STomoki Sekiyama##########################################
471350cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
471450cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
471550cbebb9SMichael Roth  cat > $TMPC << EOF
471650cbebb9SMichael Roth#include <windows.h>
471750cbebb9SMichael Roth#include <ntddscsi.h>
471850cbebb9SMichael Rothint main(void) {
471950cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
472050cbebb9SMichael Roth#error Missing required ioctl definitions
472150cbebb9SMichael Roth#endif
472250cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
472350cbebb9SMichael Roth  return addr.Lun;
472450cbebb9SMichael Roth}
472550cbebb9SMichael RothEOF
472650cbebb9SMichael Roth  if compile_prog "" "" ; then
472750cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4728c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
472950cbebb9SMichael Roth  fi
473050cbebb9SMichael Rothfi
473150cbebb9SMichael Roth
473250cbebb9SMichael Roth##########################################
47339d9e1521SGerd Hoffmann# virgl renderer probe
47349d9e1521SGerd Hoffmann
47359d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
47369d9e1521SGerd Hoffmann  cat > $TMPC << EOF
47379d9e1521SGerd Hoffmann#include <virglrenderer.h>
47389d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
47399d9e1521SGerd HoffmannEOF
47409d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
47419d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
474247479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
47439d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
47449d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
47459d9e1521SGerd Hoffmann    virglrenderer="yes"
47469d9e1521SGerd Hoffmann  else
47479d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
47489d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
47499d9e1521SGerd Hoffmann    fi
47509d9e1521SGerd Hoffmann    virglrenderer="no"
47519d9e1521SGerd Hoffmann  fi
47529d9e1521SGerd Hoffmannfi
47539d9e1521SGerd Hoffmann
47549d9e1521SGerd Hoffmann##########################################
47558ca80760SRichard Henderson# capstone
47568ca80760SRichard Henderson
4757e219c499SRichard Hendersoncase "$capstone" in
4758e219c499SRichard Henderson  "" | yes)
47598ca80760SRichard Henderson    if $pkg_config capstone; then
4760e219c499SRichard Henderson      capstone=system
4761123ac0bbSAlexey Kardashevskiy    elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
4762e219c499SRichard Henderson      capstone=git
4763e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4764e219c499SRichard Henderson      capstone=internal
4765e219c499SRichard Henderson    elif test -z "$capstone" ; then
4766e219c499SRichard Henderson      capstone=no
4767e219c499SRichard Henderson    else
4768e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4769e219c499SRichard Henderson    fi
4770e219c499SRichard Henderson    ;;
4771e219c499SRichard Henderson
4772e219c499SRichard Henderson  system)
4773e219c499SRichard Henderson    if ! $pkg_config capstone; then
4774e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4775e219c499SRichard Henderson    fi
4776e219c499SRichard Henderson    ;;
4777e219c499SRichard Hendersonesac
4778e219c499SRichard Henderson
4779e219c499SRichard Hendersoncase "$capstone" in
4780e219c499SRichard Henderson  git | internal)
4781e219c499SRichard Henderson    if test "$capstone" = git; then
4782e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4783e219c499SRichard Henderson    fi
4784e219c499SRichard Henderson    mkdir -p capstone
4785e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4786e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4787e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4788e219c499SRichard Henderson    else
4789e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4790e219c499SRichard Henderson    fi
4791e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4792e219c499SRichard Henderson    ;;
4793e219c499SRichard Henderson
4794e219c499SRichard Henderson  system)
47958ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
47968ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4797e219c499SRichard Henderson    ;;
4798e219c499SRichard Henderson
4799e219c499SRichard Henderson  no)
4800e219c499SRichard Henderson    ;;
4801e219c499SRichard Henderson  *)
4802e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4803e219c499SRichard Henderson    ;;
4804e219c499SRichard Hendersonesac
48058ca80760SRichard Henderson
48068ca80760SRichard Henderson##########################################
48075f6b9e8fSBlue Swirl# check if we have fdatasync
48085f6b9e8fSBlue Swirl
48095f6b9e8fSBlue Swirlfdatasync=no
48105f6b9e8fSBlue Swirlcat > $TMPC << EOF
48115f6b9e8fSBlue Swirl#include <unistd.h>
4812d1722a27SAlexandre Raymondint main(void) {
4813d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4814d1722a27SAlexandre Raymondreturn fdatasync(0);
4815d1722a27SAlexandre Raymond#else
4816e172fe11SStefan Weil#error Not supported
4817d1722a27SAlexandre Raymond#endif
4818d1722a27SAlexandre Raymond}
48195f6b9e8fSBlue SwirlEOF
48205f6b9e8fSBlue Swirlif compile_prog "" "" ; then
48215f6b9e8fSBlue Swirl    fdatasync=yes
48225f6b9e8fSBlue Swirlfi
48235f6b9e8fSBlue Swirl
482494a420b1SStefan Hajnoczi##########################################
4825e78815a5SAndreas Färber# check if we have madvise
4826e78815a5SAndreas Färber
4827e78815a5SAndreas Färbermadvise=no
4828e78815a5SAndreas Färbercat > $TMPC << EOF
4829e78815a5SAndreas Färber#include <sys/types.h>
4830e78815a5SAndreas Färber#include <sys/mman.h>
4831832ce9c2SScott Wood#include <stddef.h>
4832e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4833e78815a5SAndreas FärberEOF
4834e78815a5SAndreas Färberif compile_prog "" "" ; then
4835e78815a5SAndreas Färber    madvise=yes
4836e78815a5SAndreas Färberfi
4837e78815a5SAndreas Färber
4838e78815a5SAndreas Färber##########################################
4839e78815a5SAndreas Färber# check if we have posix_madvise
4840e78815a5SAndreas Färber
4841e78815a5SAndreas Färberposix_madvise=no
4842e78815a5SAndreas Färbercat > $TMPC << EOF
4843e78815a5SAndreas Färber#include <sys/mman.h>
4844832ce9c2SScott Wood#include <stddef.h>
4845e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4846e78815a5SAndreas FärberEOF
4847e78815a5SAndreas Färberif compile_prog "" "" ; then
4848e78815a5SAndreas Färber    posix_madvise=yes
4849e78815a5SAndreas Färberfi
4850e78815a5SAndreas Färber
4851e78815a5SAndreas Färber##########################################
48529bc5a719SAndreas Gustafsson# check if we have posix_memalign()
48539bc5a719SAndreas Gustafsson
48549bc5a719SAndreas Gustafssonposix_memalign=no
48559bc5a719SAndreas Gustafssoncat > $TMPC << EOF
48569bc5a719SAndreas Gustafsson#include <stdlib.h>
48579bc5a719SAndreas Gustafssonint main(void) {
48589bc5a719SAndreas Gustafsson    void *p;
48599bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
48609bc5a719SAndreas Gustafsson}
48619bc5a719SAndreas GustafssonEOF
48629bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
48639bc5a719SAndreas Gustafsson    posix_memalign=yes
48649bc5a719SAndreas Gustafssonfi
48659bc5a719SAndreas Gustafsson
48669bc5a719SAndreas Gustafsson##########################################
48670a852417SPaul Durrant# check if we have posix_syslog
48680a852417SPaul Durrant
48690a852417SPaul Durrantposix_syslog=no
48700a852417SPaul Durrantcat > $TMPC << EOF
48710a852417SPaul Durrant#include <syslog.h>
48720a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
48730a852417SPaul DurrantEOF
48740a852417SPaul Durrantif compile_prog "" "" ; then
48750a852417SPaul Durrant    posix_syslog=yes
48760a852417SPaul Durrantfi
48770a852417SPaul Durrant
48780a852417SPaul Durrant##########################################
4879401bc051SPeter Maydell# check if we have sem_timedwait
4880401bc051SPeter Maydell
4881401bc051SPeter Maydellsem_timedwait=no
4882401bc051SPeter Maydellcat > $TMPC << EOF
4883401bc051SPeter Maydell#include <semaphore.h>
4884401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4885401bc051SPeter MaydellEOF
4886401bc051SPeter Maydellif compile_prog "" "" ; then
4887401bc051SPeter Maydell    sem_timedwait=yes
4888401bc051SPeter Maydellfi
4889401bc051SPeter Maydell
4890401bc051SPeter Maydell##########################################
48915c99fa37SKeno Fischer# check if we have strchrnul
48925c99fa37SKeno Fischer
48935c99fa37SKeno Fischerstrchrnul=no
48945c99fa37SKeno Fischercat > $TMPC << EOF
48955c99fa37SKeno Fischer#include <string.h>
48965c99fa37SKeno Fischerint main(void);
48975c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
48985c99fa37SKeno Fischerchar *haystack = (char*)&main;
48995c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
49005c99fa37SKeno FischerEOF
49015c99fa37SKeno Fischerif compile_prog "" "" ; then
49025c99fa37SKeno Fischer    strchrnul=yes
49035c99fa37SKeno Fischerfi
49045c99fa37SKeno Fischer
49055c99fa37SKeno Fischer##########################################
490694a420b1SStefan Hajnoczi# check if trace backend exists
490794a420b1SStefan Hajnoczi
49085b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
490994a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
49105b808275SLluís Vilanova  error_exit "invalid trace backends" \
49115b808275SLluís Vilanova      "Please choose supported trace backends."
491294a420b1SStefan Hajnoczifi
491394a420b1SStefan Hajnoczi
49147e24e92aSStefan Hajnoczi##########################################
49157e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
49165b808275SLluís Vilanovaif have_backend "ust"; then
49177e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4918bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
49197e24e92aSStefan Hajnocziint main(void) { return 0; }
49207e24e92aSStefan HajnocziEOF
4921c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4922bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
492389138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
49247e24e92aSStefan Hajnoczi    else
4925c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4926bf15f63cSMohamad Gebai    fi
4927bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
492889138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4929bf15f63cSMohamad Gebai    else
4930bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4931bf15f63cSMohamad Gebai    fi
4932bf15f63cSMohamad Gebai
4933bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4934bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4935bf15f63cSMohamad Gebai  else
4936bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
49377e24e92aSStefan Hajnoczi  fi
49387e24e92aSStefan Hajnoczifi
4939b3d08c02SDaniel P. Berrange
4940b3d08c02SDaniel P. Berrange##########################################
4941b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
49425b808275SLluís Vilanovaif have_backend "dtrace"; then
4943b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
494476ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4945b3d08c02SDaniel P. Berrange  fi
4946c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4947c276b17dSDaniel P. Berrange  if has 'stap' ; then
4948c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4949c276b17dSDaniel P. Berrange  fi
4950b3d08c02SDaniel P. Berrangefi
4951b3d08c02SDaniel P. Berrange
49527e24e92aSStefan Hajnoczi##########################################
4953519175a2SAlex Barcelo# check and set a backend for coroutine
4954d0e2fce5SAneesh Kumar K.V
49557c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
495633c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
495733c53c54SDaniel P. Berrange# specific one.
49587c2acc70SPeter Maydell
49597c2acc70SPeter Maydellucontext_works=no
4960d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4961d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4962d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4963cdf84806SPeter Maydell#ifdef __stub_makecontext
4964cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4965cdf84806SPeter Maydell#endif
496675cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4967d0e2fce5SAneesh Kumar K.VEOF
4968d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
49697c2acc70SPeter Maydell    ucontext_works=yes
4970d0e2fce5SAneesh Kumar K.V  fi
4971519175a2SAlex Barcelofi
49727c2acc70SPeter Maydell
49737c2acc70SPeter Maydellif test "$coroutine" = ""; then
49747c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
49757c2acc70SPeter Maydell    coroutine=win32
49767c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
49777c2acc70SPeter Maydell    coroutine=ucontext
4978519175a2SAlex Barcelo  else
49797c2acc70SPeter Maydell    coroutine=sigaltstack
49807c2acc70SPeter Maydell  fi
49817c2acc70SPeter Maydellelse
49827c2acc70SPeter Maydell  case $coroutine in
49837c2acc70SPeter Maydell  windows)
49847c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
49857c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
49867c2acc70SPeter Maydell    fi
49877c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
49887c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
49897c2acc70SPeter Maydell    coroutine=win32
49907c2acc70SPeter Maydell    ;;
49917c2acc70SPeter Maydell  ucontext)
49927c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
49937c2acc70SPeter Maydell      feature_not_found "ucontext"
49947c2acc70SPeter Maydell    fi
49957c2acc70SPeter Maydell    ;;
499633c53c54SDaniel P. Berrange  sigaltstack)
49977c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
49987c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
49997c2acc70SPeter Maydell    fi
50007c2acc70SPeter Maydell    ;;
50017c2acc70SPeter Maydell  *)
500276ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
50037c2acc70SPeter Maydell    ;;
50047c2acc70SPeter Maydell  esac
5005d0e2fce5SAneesh Kumar K.Vfi
5006d0e2fce5SAneesh Kumar K.V
500770c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
500870c60c08SStefan Hajnoczi  coroutine_pool=yes
500970c60c08SStefan Hajnoczifi
501070c60c08SStefan Hajnoczi
50117d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
50127d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
50137d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
50147d992e4dSPeter Lieven    coroutine_pool=no
50157d992e4dSPeter Lieven  fi
50167d992e4dSPeter Lievenfi
50177d992e4dSPeter Lieven
50187d992e4dSPeter Lieven
5019d0e2fce5SAneesh Kumar K.V##########################################
5020d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5021d2042378SAneesh Kumar K.V
50224e1797f9SStefan Weilopen_by_handle_at=no
5023d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5024d2042378SAneesh Kumar K.V#include <fcntl.h>
5025acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5026acc55ba8SStefan Weil# error missing definition
5027acc55ba8SStefan Weil#else
502875cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5029acc55ba8SStefan Weil#endif
5030d2042378SAneesh Kumar K.VEOF
5031d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5032d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5033d2042378SAneesh Kumar K.Vfi
5034d2042378SAneesh Kumar K.V
5035e06a765eSHarsh Prateek Bora########################################
5036e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5037e06a765eSHarsh Prateek Bora
5038e06a765eSHarsh Prateek Boralinux_magic_h=no
5039e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5040e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5041e06a765eSHarsh Prateek Boraint main(void) {
504275cafad7SStefan Weil  return 0;
5043e06a765eSHarsh Prateek Bora}
5044e06a765eSHarsh Prateek BoraEOF
5045e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5046e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5047e06a765eSHarsh Prateek Borafi
5048e06a765eSHarsh Prateek Bora
50498ab1bf12SLuiz Capitulino########################################
5050c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
5051c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
5052c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
5053c95e3080SKevin Wolf# only a warning.
5054c95e3080SKevin Wolf#
5055c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
5056c95e3080SKevin Wolf# the build doesn't fail anyway.
5057c95e3080SKevin Wolf
505806d71fa1SPeter Maydellpragma_disable_unused_but_set=no
505906d71fa1SPeter Maydellcat > $TMPC << EOF
5060e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
5061c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5062e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
5063c95e3080SKevin Wolf
506406d71fa1SPeter Maydellint main(void) {
506506d71fa1SPeter Maydell    return 0;
506606d71fa1SPeter Maydell}
506706d71fa1SPeter MaydellEOF
506806d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
5069cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
5070c95e3080SKevin Wolfelse
5071c95e3080SKevin Wolf    werror=no
507206d71fa1SPeter Maydellfi
507306d71fa1SPeter Maydell
507406d71fa1SPeter Maydell########################################
5075541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
50763f4349dcSKevin Wolf
50773f4349dcSKevin Wolfvalgrind_h=no
50783f4349dcSKevin Wolfcat > $TMPC << EOF
50793f4349dcSKevin Wolf#include <valgrind/valgrind.h>
50803f4349dcSKevin Wolfint main(void) {
50813f4349dcSKevin Wolf  return 0;
50823f4349dcSKevin Wolf}
50833f4349dcSKevin WolfEOF
50843f4349dcSKevin Wolfif compile_prog "" "" ; then
50853f4349dcSKevin Wolf    valgrind_h=yes
50863f4349dcSKevin Wolffi
50873f4349dcSKevin Wolf
50883f4349dcSKevin Wolf########################################
50898ab1bf12SLuiz Capitulino# check if environ is declared
50908ab1bf12SLuiz Capitulino
50918ab1bf12SLuiz Capitulinohas_environ=no
50928ab1bf12SLuiz Capitulinocat > $TMPC << EOF
50938ab1bf12SLuiz Capitulino#include <unistd.h>
50948ab1bf12SLuiz Capitulinoint main(void) {
5095c075a723SBlue Swirl    environ = 0;
50968ab1bf12SLuiz Capitulino    return 0;
50978ab1bf12SLuiz Capitulino}
50988ab1bf12SLuiz CapitulinoEOF
50998ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
51008ab1bf12SLuiz Capitulino    has_environ=yes
51018ab1bf12SLuiz Capitulinofi
51028ab1bf12SLuiz Capitulino
510376a347e1SRichard Henderson########################################
510476a347e1SRichard Henderson# check if cpuid.h is usable.
510576a347e1SRichard Henderson
510676a347e1SRichard Hendersoncat > $TMPC << EOF
510776a347e1SRichard Henderson#include <cpuid.h>
510876a347e1SRichard Hendersonint main(void) {
5109774d566cSPeter Maydell    unsigned a, b, c, d;
5110774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5111774d566cSPeter Maydell
5112774d566cSPeter Maydell    if (max >= 1) {
5113774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5114774d566cSPeter Maydell    }
5115774d566cSPeter Maydell
5116774d566cSPeter Maydell    if (max >= 7) {
5117774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5118774d566cSPeter Maydell    }
5119774d566cSPeter Maydell
512076a347e1SRichard Henderson    return 0;
512176a347e1SRichard Henderson}
512276a347e1SRichard HendersonEOF
512376a347e1SRichard Hendersonif compile_prog "" "" ; then
512476a347e1SRichard Henderson    cpuid_h=yes
512576a347e1SRichard Hendersonfi
512676a347e1SRichard Henderson
51275dd89908SRichard Henderson##########################################
51285dd89908SRichard Henderson# avx2 optimization requirement check
51295dd89908SRichard Henderson#
51305dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
51315dd89908SRichard Henderson# since we won't be able to select the new routines.
51325dd89908SRichard Henderson
51335dd89908SRichard Hendersonif test $cpuid_h = yes; then
51345dd89908SRichard Henderson  cat > $TMPC << EOF
51355dd89908SRichard Henderson#pragma GCC push_options
51365dd89908SRichard Henderson#pragma GCC target("avx2")
51375dd89908SRichard Henderson#include <cpuid.h>
51385dd89908SRichard Henderson#include <immintrin.h>
51395dd89908SRichard Hendersonstatic int bar(void *a) {
51405dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
51415dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
51425dd89908SRichard Henderson}
51435dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
51445dd89908SRichard HendersonEOF
51455dd89908SRichard Henderson  if compile_object "" ; then
51465dd89908SRichard Henderson    avx2_opt="yes"
51475dd89908SRichard Henderson  fi
51485dd89908SRichard Hendersonfi
51495dd89908SRichard Henderson
5150f540166bSRichard Henderson########################################
5151f540166bSRichard Henderson# check if __[u]int128_t is usable.
5152f540166bSRichard Henderson
5153f540166bSRichard Hendersonint128=no
5154f540166bSRichard Hendersoncat > $TMPC << EOF
5155a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
5156a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
5157a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
5158a00f66abSStefan Weil# endif
5159a00f66abSStefan Weil#endif
5160f540166bSRichard Henderson__int128_t a;
5161f540166bSRichard Henderson__uint128_t b;
5162f540166bSRichard Hendersonint main (void) {
5163f540166bSRichard Henderson  a = a + b;
5164f540166bSRichard Henderson  b = a * b;
5165464e3671SPeter Maydell  a = a * a;
5166f540166bSRichard Henderson  return 0;
5167f540166bSRichard Henderson}
5168f540166bSRichard HendersonEOF
5169f540166bSRichard Hendersonif compile_prog "" "" ; then
5170f540166bSRichard Henderson    int128=yes
5171f540166bSRichard Hendersonfi
517276a347e1SRichard Henderson
51737ebee43eSRichard Henderson#########################################
51747ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
51757ebee43eSRichard Henderson
51767ebee43eSRichard Hendersonatomic128=no
51777ebee43eSRichard Hendersonif test "$int128" = "yes"; then
51787ebee43eSRichard Henderson  cat > $TMPC << EOF
51797ebee43eSRichard Hendersonint main(void)
51807ebee43eSRichard Henderson{
51817ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
51827ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
51837ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
51847ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
51857ebee43eSRichard Henderson  return 0;
51867ebee43eSRichard Henderson}
51877ebee43eSRichard HendersonEOF
51887ebee43eSRichard Henderson  if compile_prog "" "" ; then
51897ebee43eSRichard Henderson    atomic128=yes
51907ebee43eSRichard Henderson  fi
51917ebee43eSRichard Hendersonfi
51927ebee43eSRichard Henderson
5193df79b996SRichard Henderson#########################################
5194df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5195df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5196df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5197df79b996SRichard Henderson
5198df79b996SRichard Hendersoncat > $TMPC << EOF
5199df79b996SRichard Henderson#include <stdint.h>
5200df79b996SRichard Hendersonint main(void)
5201df79b996SRichard Henderson{
5202df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5203df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5204df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5205df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5206df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5207df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5208df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5209df79b996SRichard Henderson#else
5210df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5211df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5212df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5213df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5214df79b996SRichard Henderson#endif
5215df79b996SRichard Henderson  return 0;
5216df79b996SRichard Henderson}
5217df79b996SRichard HendersonEOF
5218df79b996SRichard Hendersonif compile_prog "" "" ; then
5219df79b996SRichard Henderson  atomic64=yes
5220df79b996SRichard Hendersonfi
5221df79b996SRichard Henderson
52221e6e9acaSRichard Henderson########################################
5223db432672SRichard Henderson# See if 16-byte vector operations are supported.
5224db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5225db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5226db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5227db432672SRichard Henderson
5228db432672SRichard Hendersoncat > $TMPC << EOF
5229db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5230db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5231db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5232db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5233db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5234db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5235db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5236db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5237db432672SRichard Hendersonstatic U1 a1, b1;
5238db432672SRichard Hendersonstatic U2 a2, b2;
5239db432672SRichard Hendersonstatic U4 a4, b4;
5240db432672SRichard Hendersonstatic U8 a8, b8;
5241db432672SRichard Hendersonstatic S1 c1;
5242db432672SRichard Hendersonstatic S2 c2;
5243db432672SRichard Hendersonstatic S4 c4;
5244db432672SRichard Hendersonstatic S8 c8;
5245db432672SRichard Hendersonstatic int i;
524674912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
524774912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
524874912f6dSLaurent Vivier{
524974912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
525074912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
525174912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
525274912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
525374912f6dSLaurent Vivier}
5254db432672SRichard Hendersonint main(void)
5255db432672SRichard Henderson{
5256db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5257db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5258db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5259db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5260db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5261db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5262db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5263db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5264db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5265db432672SRichard Henderson  return 0;
5266db432672SRichard Henderson}
5267db432672SRichard HendersonEOF
5268db432672SRichard Henderson
5269db432672SRichard Hendersonvector16=no
5270db432672SRichard Hendersonif compile_prog "" "" ; then
5271db432672SRichard Henderson  vector16=yes
5272db432672SRichard Hendersonfi
5273db432672SRichard Henderson
5274db432672SRichard Henderson########################################
52751e6e9acaSRichard Henderson# check if getauxval is available.
52761e6e9acaSRichard Henderson
52771e6e9acaSRichard Hendersongetauxval=no
52781e6e9acaSRichard Hendersoncat > $TMPC << EOF
52791e6e9acaSRichard Henderson#include <sys/auxv.h>
52801e6e9acaSRichard Hendersonint main(void) {
52811e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
52821e6e9acaSRichard Henderson}
52831e6e9acaSRichard HendersonEOF
52841e6e9acaSRichard Hendersonif compile_prog "" "" ; then
52851e6e9acaSRichard Henderson    getauxval=yes
52861e6e9acaSRichard Hendersonfi
52871e6e9acaSRichard Henderson
5288fd0e6053SJohn Snow########################################
5289fd0e6053SJohn Snow# check if ccache is interfering with
5290fd0e6053SJohn Snow# semantic analysis of macros
5291fd0e6053SJohn Snow
52925e4dfd3dSJohn Snowunset CCACHE_CPP2
5293fd0e6053SJohn Snowccache_cpp2=no
5294fd0e6053SJohn Snowcat > $TMPC << EOF
5295fd0e6053SJohn Snowstatic const int Z = 1;
5296fd0e6053SJohn Snow#define fn() ({ Z; })
5297fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5298fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5299fd0e6053SJohn Snow#define ID(X) (X)
5300fd0e6053SJohn Snowint main(int argc, char *argv[])
5301fd0e6053SJohn Snow{
5302fd0e6053SJohn Snow    int x = 0, y = 0;
5303fd0e6053SJohn Snow    x = ID(x);
5304fd0e6053SJohn Snow    x = fn();
5305fd0e6053SJohn Snow    fn();
5306fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5307fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5308fd0e6053SJohn Snow    return 0;
5309fd0e6053SJohn Snow}
5310fd0e6053SJohn SnowEOF
5311fd0e6053SJohn Snow
5312fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5313fd0e6053SJohn Snow    ccache_cpp2=yes
5314fd0e6053SJohn Snowfi
5315fd0e6053SJohn Snow
5316b553a042SJohn Snow#################################################
5317b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5318b553a042SJohn Snow
5319b553a042SJohn Snowif test "$fortify_source" != "no"; then
5320b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5321b553a042SJohn Snow    fortify_source="no";
5322e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5323cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5324b553a042SJohn Snow    fortify_source="no";
5325b553a042SJohn Snow  else
5326b553a042SJohn Snow    fortify_source="yes"
5327b553a042SJohn Snow  fi
5328b553a042SJohn Snowfi
5329b553a042SJohn Snow
53301efad060SFam Zheng###############################################
53311efad060SFam Zheng# Check if copy_file_range is provided by glibc
53321efad060SFam Zhenghave_copy_file_range=no
53331efad060SFam Zhengcat > $TMPC << EOF
53341efad060SFam Zheng#include <unistd.h>
53351efad060SFam Zhengint main(void) {
53361efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
53371efad060SFam Zheng  return 0;
53381efad060SFam Zheng}
53391efad060SFam ZhengEOF
53401efad060SFam Zhengif compile_prog "" "" ; then
53411efad060SFam Zheng    have_copy_file_range=yes
53421efad060SFam Zhengfi
53431efad060SFam Zheng
5344d2042378SAneesh Kumar K.V##########################################
5345277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5346277abf15SJan Vesely
5347277abf15SJan Veselyhave_fsxattr=no
5348277abf15SJan Veselycat > $TMPC << EOF
5349277abf15SJan Vesely#include <linux/fs.h>
5350277abf15SJan Veselystruct fsxattr foo;
5351277abf15SJan Veselyint main(void) {
5352277abf15SJan Vesely  return 0;
5353277abf15SJan Vesely}
5354277abf15SJan VeselyEOF
5355277abf15SJan Veselyif compile_prog "" "" ; then
5356277abf15SJan Vesely    have_fsxattr=yes
5357277abf15SJan Veselyfi
5358277abf15SJan Vesely
5359b66e10e4SPeter Maydell##########################################
5360a40161cbSPaolo Bonzini# check for usable membarrier system call
5361a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5362a40161cbSPaolo Bonzini    have_membarrier=no
5363a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5364a40161cbSPaolo Bonzini        have_membarrier=yes
5365a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5366a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5367a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5368a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5369a40161cbSPaolo Bonzini    #include <unistd.h>
5370a40161cbSPaolo Bonzini    #include <stdlib.h>
5371a40161cbSPaolo Bonzini    int main(void) {
5372a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5373a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5374a40161cbSPaolo Bonzini	exit(0);
5375a40161cbSPaolo Bonzini    }
5376a40161cbSPaolo BonziniEOF
5377a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5378a40161cbSPaolo Bonzini            have_membarrier=yes
5379a40161cbSPaolo Bonzini        fi
5380a40161cbSPaolo Bonzini    fi
5381a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5382a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5383a40161cbSPaolo Bonzini    fi
5384a40161cbSPaolo Bonzinielse
5385a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5386a40161cbSPaolo Bonzini    # work on Wine.
5387a40161cbSPaolo Bonzini    membarrier=no
5388a40161cbSPaolo Bonzinifi
5389a40161cbSPaolo Bonzini
5390a40161cbSPaolo Bonzini##########################################
5391b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5392575b22b1SLaurent Vivierhave_rtnetlink=no
5393575b22b1SLaurent Viviercat > $TMPC << EOF
5394575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5395575b22b1SLaurent Vivierint main(void) {
5396575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5397575b22b1SLaurent Vivier}
5398575b22b1SLaurent VivierEOF
5399575b22b1SLaurent Vivierif compile_prog "" "" ; then
5400575b22b1SLaurent Vivier    have_rtnetlink=yes
5401575b22b1SLaurent Vivierfi
5402575b22b1SLaurent Vivier
54036a02c806SStefan Hajnoczi##########################################
54046a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
54056a02c806SStefan Hajnoczihave_af_vsock=no
54066a02c806SStefan Hajnoczicat > $TMPC << EOF
54076a02c806SStefan Hajnoczi#include <errno.h>
54086a02c806SStefan Hajnoczi#include <sys/types.h>
54096a02c806SStefan Hajnoczi#include <sys/socket.h>
54106a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
54116a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
54126a02c806SStefan Hajnoczi#endif
54136a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
54146a02c806SStefan Hajnocziint main(void) {
54156a02c806SStefan Hajnoczi    int sock, ret;
54166a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
54176a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
54186a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
54196a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
54206a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
54216a02c806SStefan Hajnoczi        return 0;
54226a02c806SStefan Hajnoczi    }
54236a02c806SStefan Hajnoczi    return -1;
54246a02c806SStefan Hajnoczi}
54256a02c806SStefan HajnocziEOF
54266a02c806SStefan Hajnocziif compile_prog "" "" ; then
54276a02c806SStefan Hajnoczi    have_af_vsock=yes
54286a02c806SStefan Hajnoczifi
54296a02c806SStefan Hajnoczi
5430f0d92b56SLongpeng(Mike)##########################################
5431f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5432f0d92b56SLongpeng(Mike)hava_afalg=no
5433f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5434f0d92b56SLongpeng(Mike)#include <errno.h>
5435f0d92b56SLongpeng(Mike)#include <sys/types.h>
5436f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5437f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5438f0d92b56SLongpeng(Mike)int main(void) {
5439f0d92b56SLongpeng(Mike)    int sock;
5440f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5441f0d92b56SLongpeng(Mike)    return sock;
5442f0d92b56SLongpeng(Mike)}
5443f0d92b56SLongpeng(Mike)EOF
5444f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5445f0d92b56SLongpeng(Mike)    have_afalg=yes
5446f0d92b56SLongpeng(Mike)fi
5447f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5448f0d92b56SLongpeng(Mike)then
5449f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5450f0d92b56SLongpeng(Mike)    then
5451f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5452f0d92b56SLongpeng(Mike)    fi
5453f0d92b56SLongpeng(Mike)fi
5454f0d92b56SLongpeng(Mike)
5455f0d92b56SLongpeng(Mike)
54566969ec6cSJames Clarke#################################################
5457c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5458d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5459c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5460c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5461c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5462c97d6d2cSSergio Andres Gomez Del RealEOF
5463c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5464c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5465c97d6d2cSSergio Andres Gomez Del Real  else
5466c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5467c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5468c97d6d2cSSergio Andres Gomez Del Real  fi
5469c97d6d2cSSergio Andres Gomez Del Realfi
5470c97d6d2cSSergio Andres Gomez Del Real
5471c97d6d2cSSergio Andres Gomez Del Real#################################################
54726969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
54736969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
54746969ec6cSJames Clarke# given. It does no harm to give it on other
54756969ec6cSJames Clarke# platforms too.
54766969ec6cSJames Clarke
54776969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
54786969ec6cSJames Clarke#       contains -Wmissing-prototypes
54796969ec6cSJames Clarkecat > $TMPC << EOF
54806969ec6cSJames Clarkeextern int foo(void);
54816969ec6cSJames Clarkeint foo(void) { return 0; }
54826969ec6cSJames ClarkeEOF
54836969ec6cSJames Clarkeif ! compile_object ""; then
54846969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
54856969ec6cSJames Clarkefi
54867ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
54877ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
54887ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
54897ecf44a5SPaolo Bonzini    break
54907ecf44a5SPaolo Bonzini  fi
54917ecf44a5SPaolo Bonzinidone
54927ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
54937ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
54946969ec6cSJames Clarkefi
54956969ec6cSJames Clarke
5496277abf15SJan Vesely##########################################
54974d04351fSChristopher Covington# check for sysmacros.h
54984d04351fSChristopher Covington
54994d04351fSChristopher Covingtonhave_sysmacros=no
55004d04351fSChristopher Covingtoncat > $TMPC << EOF
55014d04351fSChristopher Covington#include <sys/sysmacros.h>
55024d04351fSChristopher Covingtonint main(void) {
55034d04351fSChristopher Covington    return makedev(0, 0);
55044d04351fSChristopher Covington}
55054d04351fSChristopher CovingtonEOF
55064d04351fSChristopher Covingtonif compile_prog "" "" ; then
55074d04351fSChristopher Covington    have_sysmacros=yes
55084d04351fSChristopher Covingtonfi
55094d04351fSChristopher Covington
55104d04351fSChristopher Covington##########################################
5511da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5512da92c3ffSAshish Mittal# Check if libvxhs is installed
5513da92c3ffSAshish Mittal
5514da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5515da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5516da92c3ffSAshish Mittal#include <stdint.h>
5517da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5518da92c3ffSAshish Mittal
5519da92c3ffSAshish Mittalvoid *vxhs_callback;
5520da92c3ffSAshish Mittal
5521da92c3ffSAshish Mittalint main(void) {
5522da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5523da92c3ffSAshish Mittal    return 0;
5524da92c3ffSAshish Mittal}
5525da92c3ffSAshish MittalEOF
5526da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5527da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5528da92c3ffSAshish Mittal    vxhs=yes
5529da92c3ffSAshish Mittal  else
5530da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5531da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5532da92c3ffSAshish Mittal    fi
5533da92c3ffSAshish Mittal    vxhs=no
5534da92c3ffSAshish Mittal  fi
5535da92c3ffSAshish Mittalfi
5536da92c3ffSAshish Mittal
5537da92c3ffSAshish Mittal##########################################
553849e00a18SAndreas Grapentin# check for _Static_assert()
553949e00a18SAndreas Grapentin
554049e00a18SAndreas Grapentinhave_static_assert=no
554149e00a18SAndreas Grapentincat > $TMPC << EOF
554249e00a18SAndreas Grapentin_Static_assert(1, "success");
554349e00a18SAndreas Grapentinint main(void) {
554449e00a18SAndreas Grapentin    return 0;
554549e00a18SAndreas Grapentin}
554649e00a18SAndreas GrapentinEOF
554749e00a18SAndreas Grapentinif compile_prog "" "" ; then
554849e00a18SAndreas Grapentin    have_static_assert=yes
554949e00a18SAndreas Grapentinfi
555049e00a18SAndreas Grapentin
555149e00a18SAndreas Grapentin##########################################
5552e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5553e674605fSTomáš Golembiovský
5554e674605fSTomáš Golembiovskýhave_utmpx=no
5555e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5556e674605fSTomáš Golembiovský#include <utmpx.h>
5557e674605fSTomáš Golembiovskýstruct utmpx user_info;
5558e674605fSTomáš Golembiovskýint main(void) {
5559e674605fSTomáš Golembiovský    return 0;
5560e674605fSTomáš Golembiovský}
5561e674605fSTomáš GolembiovskýEOF
5562e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5563e674605fSTomáš Golembiovský    have_utmpx=yes
5564e674605fSTomáš Golembiovskýfi
5565e674605fSTomáš Golembiovský
5566e674605fSTomáš Golembiovský##########################################
5567247724cbSMarc-André Lureau# checks for sanitizers
5568247724cbSMarc-André Lureau
5569247724cbSMarc-André Lureauhave_asan=no
5570247724cbSMarc-André Lureauhave_ubsan=no
5571d83414e1SMarc-André Lureauhave_asan_iface_h=no
5572d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5573247724cbSMarc-André Lureau
5574247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5575b9f44da2SMarc-André Lureau  write_c_skeleton
5576247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5577247724cbSMarc-André Lureau      have_asan=yes
5578247724cbSMarc-André Lureau  fi
5579b9f44da2SMarc-André Lureau
5580b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5581b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5582b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5583b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5584b9f44da2SMarc-André Lureau#include <stdlib.h>
5585b9f44da2SMarc-André Lureauint main(void) {
5586b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5587b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5588b9f44da2SMarc-André Lureau}
5589b9f44da2SMarc-André LureauEOF
5590247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5591247724cbSMarc-André Lureau      have_ubsan=yes
5592247724cbSMarc-André Lureau  fi
5593d83414e1SMarc-André Lureau
5594d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5595d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5596d83414e1SMarc-André Lureau  fi
5597d83414e1SMarc-André Lureau
5598d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5599d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5600d83414e1SMarc-André Lureauint main(void) {
5601d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5602d83414e1SMarc-André Lureau  return 0;
5603d83414e1SMarc-André Lureau}
5604d83414e1SMarc-André LureauEOF
5605d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5606d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5607d83414e1SMarc-André Lureau  fi
5608247724cbSMarc-André Lureaufi
5609247724cbSMarc-André Lureau
5610247724cbSMarc-André Lureau##########################################
561151a12b51SAlex Bennée# Docker and cross-compiler support
561251a12b51SAlex Bennée#
561351a12b51SAlex Bennée# This is specifically for building test
561451a12b51SAlex Bennée# cases for foreign architectures, not
561551a12b51SAlex Bennée# cross-compiling QEMU itself.
561651a12b51SAlex Bennée
561751a12b51SAlex Bennéeif has "docker"; then
561851a12b51SAlex Bennée    docker=$($python $source_path/tests/docker/docker.py probe)
561951a12b51SAlex Bennéefi
562051a12b51SAlex Bennée
562151a12b51SAlex Bennée##########################################
562217824406SJunyan He# check for libpmem
562317824406SJunyan He
562417824406SJunyan Heif test "$libpmem" != "no"; then
562517824406SJunyan He	if $pkg_config --exists "libpmem"; then
562617824406SJunyan He		libpmem="yes"
562717824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
562817824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
562917824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
563017824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
563117824406SJunyan He	else
563217824406SJunyan He		if test "$libpmem" = "yes" ; then
563317824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
563417824406SJunyan He		fi
563517824406SJunyan He		libpmem="no"
563617824406SJunyan He	fi
563717824406SJunyan Hefi
563817824406SJunyan He
563917824406SJunyan He##########################################
5640e86ecd4bSJuan Quintela# End of CC checks
5641e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5642e86ecd4bSJuan Quintela
5643d83414e1SMarc-André Lureauwrite_c_skeleton
5644d83414e1SMarc-André Lureau
56451d728c39SBlue Swirlif test "$gcov" = "yes" ; then
56461d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
56471d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5648b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5649e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
565048e56d50SPaolo Bonzinielif test "$debug" = "no"; then
5651ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5652e86ecd4bSJuan Quintelafi
5653a316e378SJuan Quintela
5654247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5655247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
5656d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5657d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5658d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5659d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5660d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5661d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5662d83414e1SMarc-André Lureau  fi
5663247724cbSMarc-André Lureaufi
5664247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5665247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
5666247724cbSMarc-André Lureaufi
5667247724cbSMarc-André Lureau
56686542aa9cSPeter Lieven##########################################
56696542aa9cSPeter Lieven# Do we have libnfs
56706542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5671b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
56726542aa9cSPeter Lieven    libnfs="yes"
56736542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
56746542aa9cSPeter Lieven  else
56756542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
56768efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
56776542aa9cSPeter Lieven    fi
56786542aa9cSPeter Lieven    libnfs="no"
56796542aa9cSPeter Lieven  fi
56806542aa9cSPeter Lievenfi
56811d728c39SBlue Swirl
56826ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
56836ca026cbSPeter Maydellif test "$werror" = "yes"; then
56846ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
56856ca026cbSPeter Maydellfi
56866ca026cbSPeter Maydell
5687e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5688e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
56891156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5690e86ecd4bSJuan Quintela    fi
5691e86ecd4bSJuan Quintelafi
5692e86ecd4bSJuan Quintela
569394dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
569494dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
569594dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
569694dd53c5SGerd Hoffmannelse
569794dd53c5SGerd Hoffmann    POD2MAN="pod2man"
569894dd53c5SGerd Hoffmannfi
569994dd53c5SGerd Hoffmann
5700952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5701952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5702952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5703e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5704952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5705952afb71SBlue Swirl        fi
5706952afb71SBlue Swirl    done
5707952afb71SBlue Swirlfi
5708952afb71SBlue Swirl
570910ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5710e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5711528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5712834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
57135a67135aSbellard
5714e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5715e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5716e0580342SKamil Rytarowski  ivshmem=yes
5717e0580342SKamil Rytarowskifi
5718e0580342SKamil Rytarowski
57194b1c11fdSDaniel P. Berrangetools=""
57204b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5721ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
57224b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
57234b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5724b1449edbSKamil Rytarowski  fi
5725b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5726a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
57274b1c11fdSDaniel P. Berrange  fi
57284b1c11fdSDaniel P. Berrangefi
57294b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5730b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5731b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5732983eef5aSMeador Inge      virtfs=yes
573317bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5734983eef5aSMeador Inge    else
5735983eef5aSMeador Inge      if test "$virtfs" = yes; then
5736b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5737983eef5aSMeador Inge      fi
573817500370SAndreas Färber      virtfs=no
5739983eef5aSMeador Inge    fi
5740fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5741fe8fc5aeSPaolo Bonzini      mpath=yes
5742fe8fc5aeSPaolo Bonzini    else
5743fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5744fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5745fe8fc5aeSPaolo Bonzini      fi
5746fe8fc5aeSPaolo Bonzini      mpath=no
5747fe8fc5aeSPaolo Bonzini    fi
5748b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5749b855f8d1SPaolo Bonzini  else
5750b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5751b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5752b855f8d1SPaolo Bonzini    fi
5753b855f8d1SPaolo Bonzini    virtfs=no
5754fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5755fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5756fe8fc5aeSPaolo Bonzini    fi
5757fe8fc5aeSPaolo Bonzini    mpath=no
575817bff52bSM. Mohan Kumar  fi
57596a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
57606a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
57616a021536SGerd Hoffmann  fi
5762ff69fd8cSLaurent Vivierfi
57639d6bc27bSMichael Roth
57649d6bc27bSMichael Roth# Probe for guest agent support/options
57659d6bc27bSMichael Roth
5766e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5767b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5768fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5769e8ef31a3SMichael Tokarev      guest_agent=yes
5770e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5771e8ef31a3SMichael Tokarev      guest_agent=no
5772e8ef31a3SMichael Tokarev  else
5773e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5774ca35f780SPaolo Bonzini  fi
57754b1c11fdSDaniel P. Berrangefi
5776ca35f780SPaolo Bonzini
57779d6bc27bSMichael Roth# Guest agent Window MSI  package
57789d6bc27bSMichael Roth
57799d6bc27bSMichael Rothif test "$guest_agent" != yes; then
57809d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
57819d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
57829d6bc27bSMichael Roth  fi
57839d6bc27bSMichael Roth  guest_agent_msi=no
57849d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
57859d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
57869d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
57879d6bc27bSMichael Roth  fi
57889d6bc27bSMichael Roth  guest_agent_msi=no
57899d6bc27bSMichael Rothelif ! has wixl; then
57909d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
57919d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
57929d6bc27bSMichael Roth  fi
57939d6bc27bSMichael Roth  guest_agent_msi=no
57941a34904eSMichael Rothelse
57951a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
57961a34904eSMichael Roth  # disabled explicitly
57971a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
57981a34904eSMichael Roth    guest_agent_msi=yes
57991a34904eSMichael Roth  fi
58009d6bc27bSMichael Rothfi
58019d6bc27bSMichael Roth
58021a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
58039d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
58049d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
58059d6bc27bSMichael Roth  fi
58069d6bc27bSMichael Roth
58079d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
58089d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
58099d6bc27bSMichael Roth  fi
58109d6bc27bSMichael Roth
58119d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
58129d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
58139d6bc27bSMichael Roth  fi
58149d6bc27bSMichael Roth
58159d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
581689138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
58179d6bc27bSMichael Roth  fi
58189d6bc27bSMichael Roth
581989138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
58209d6bc27bSMichael Roth
58219d6bc27bSMichael Roth  case "$cpu" in
58229d6bc27bSMichael Roth  x86_64)
58239d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
58249d6bc27bSMichael Roth    ;;
58259d6bc27bSMichael Roth  i386)
58269d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
58279d6bc27bSMichael Roth    ;;
58289d6bc27bSMichael Roth  *)
58299d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
58309d6bc27bSMichael Roth    ;;
58319d6bc27bSMichael Roth  esac
58329d6bc27bSMichael Rothfi
58339d6bc27bSMichael Roth
5834ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5835ca35f780SPaolo Bonziniroms=
5836ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5837ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5838ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5839e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5840c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5841c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5842c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5843e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5844e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5845ca35f780SPaolo Bonzini            roms="optionrom"
5846e57218b6SPeter Maydell            break
5847e57218b6SPeter Maydell        fi
5848e57218b6SPeter Maydell    done
5849ca35f780SPaolo Bonzinifi
5850d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
585139ac8455SDavid Gibson  roms="$roms spapr-rtas"
585239ac8455SDavid Gibsonfi
5853ca35f780SPaolo Bonzini
58549933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
58559933c305SChristian Borntraeger  roms="$roms s390-ccw"
58569933c305SChristian Borntraegerfi
58579933c305SChristian Borntraeger
5858964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
585992fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5860964c6fa1SRichard Henderson  textseg_addr=
5861964c6fa1SRichard Henderson  case "$cpu" in
5862479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5863479eb121SRichard Henderson      # ??? Rationale for choosing this address
5864964c6fa1SRichard Henderson      textseg_addr=0x60000000
5865964c6fa1SRichard Henderson      ;;
5866964c6fa1SRichard Henderson    mips)
5867479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5868479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5869479eb121SRichard Henderson      textseg_addr=0x60000000
5870964c6fa1SRichard Henderson      ;;
5871964c6fa1SRichard Henderson  esac
5872964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5873964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5874964c6fa1SRichard Henderson    int main(void) { return 0; }
5875964c6fa1SRichard HendersonEOF
5876964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5877964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5878964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5879964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5880964c6fa1SRichard Henderson      # at least.
588192fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
588292fe2ba8SPeter Maydell        error_exit \
588392fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
588492fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
588592fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
588692fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
588792fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
588892fe2ba8SPeter Maydell            "--disable-user option to configure."
588992fe2ba8SPeter Maydell      fi
589092fe2ba8SPeter Maydell
5891964c6fa1SRichard Henderson      $ld --verbose | sed \
5892964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5893964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5894964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5895964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5896964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5897964c6fa1SRichard Henderson    fi
5898964c6fa1SRichard Henderson  fi
5899964c6fa1SRichard Hendersonfi
5900964c6fa1SRichard Henderson
590111cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
590211cde1c8SBruno 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.
590311cde1c8SBruno Dominguezif has $cxx; then
590411cde1c8SBruno Dominguez    cat > $TMPC <<EOF
590511cde1c8SBruno Dominguezint c_function(void);
590611cde1c8SBruno Dominguezint main(void) { return c_function(); }
590711cde1c8SBruno DominguezEOF
590811cde1c8SBruno Dominguez
590911cde1c8SBruno Dominguez    compile_object
591011cde1c8SBruno Dominguez
591111cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
591211cde1c8SBruno Dominguezextern "C" {
591311cde1c8SBruno Dominguez   int c_function(void);
591411cde1c8SBruno Dominguez}
591511cde1c8SBruno Dominguezint c_function(void) { return 42; }
591611cde1c8SBruno DominguezEOF
591711cde1c8SBruno Dominguez
591811cde1c8SBruno Dominguez    update_cxxflags
591911cde1c8SBruno Dominguez
592011cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
592111cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
592211cde1c8SBruno Dominguez        :
592311cde1c8SBruno Dominguez    else
592411cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
592511cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
592611cde1c8SBruno Dominguez        cxx=
592711cde1c8SBruno Dominguez    fi
592811cde1c8SBruno Dominguezelse
592911cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
593011cde1c8SBruno Dominguez    cxx=
593111cde1c8SBruno Dominguezfi
593211cde1c8SBruno Dominguez
593302d34f62SCole Robinsonecho_version() {
593402d34f62SCole Robinson    if test "$1" = "yes" ; then
593502d34f62SCole Robinson        echo "($2)"
593602d34f62SCole Robinson    fi
593702d34f62SCole Robinson}
593802d34f62SCole Robinson
593950e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
594050e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
59418a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
594250e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
59435ca9388aSGerd Hoffmann
59447d13299dSbellardecho "Install prefix    $prefix"
594589138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
59463d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
594789138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
594889138857SStefan Weilecho "library directory $(eval echo $libdir)"
594989138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
595089138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
595189138857SStefan Weilecho "include directory $(eval echo $includedir)"
595289138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
595311d9f695Sbellardif test "$mingw32" = "no" ; then
595489138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
595589138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
595643ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
59575a699bbbSLaszlo Ersekelse
59585a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5959d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
596011d9f695Sbellardfi
59615a67135aSbellardecho "Source path       $source_path"
5962cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
5963aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
59647d13299dSbellardecho "C compiler        $cc"
596583469015Sbellardecho "Host C compiler   $host_cc"
596683f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
59673c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
596845d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
59690c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5970a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
59710c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
59728a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
59737d13299dSbellardecho "make              $make"
59746a882643Spbrookecho "install           $install"
5975c886edfbSBlue Swirlecho "python            $python"
5976e2d8830eSBradif test "$slirp" = "yes" ; then
5977e2d8830eSBrad    echo "smbd              $smbd"
5978e2d8830eSBradfi
597917969268SFam Zhengecho "module support    $modules"
5980a98fd896Sbellardecho "host CPU          $cpu"
5981de83cd02Sbellardecho "host big endian   $bigendian"
598297a847bcSbellardecho "target list       $target_list"
59837d13299dSbellardecho "gprof enabled     $gprof"
598403b4fe7dSaliguoriecho "sparse enabled    $sparse"
59851625af87Saliguoriecho "strip binaries    $strip_opt"
598605c2a3e7Sbellardecho "profiler          $profiler"
598743ce4dfeSbellardecho "static build      $static"
59885b0753e0Sbellardif test "$darwin" = "yes" ; then
59895b0753e0Sbellard    echo "Cocoa support     $cocoa"
59905b0753e0Sbellardfi
599189138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
599289138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5993925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
599489138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5995a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5996ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5997b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
599891bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
599937788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
600089138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
6001fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
60029a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
60034d3b6f6eSbalrogecho "curses support    $curses"
600447479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6005769ce76dSAlexander Grafecho "curl support      $curl"
600667b915a5Sbellardecho "mingw32 support   $mingw32"
60070c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
6008b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
6009b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
6010983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
6011fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
6012821601eaSJes Sorensenecho "VNC support       $vnc"
6013821601eaSJes Sorensenif test "$vnc" = "yes" ; then
60142f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
60152f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
6016efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
6017821601eaSJes Sorensenfi
60183142255cSblueswir1if test -n "$sparc_cpu"; then
60193142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
60203142255cSblueswir1fi
6021e37630caSaliguoriecho "xen support       $xen"
60223996e85cSPaul Durrantif test "$xen" = "yes" ; then
60233996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
602464a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
60253996e85cSPaul Durrantfi
60262e4d9fb1Saurel32echo "brlapi support    $brlapi"
6027a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
6028a25dba17SJuan Quintelaecho "Documentation     $docs"
602940d6444eSAvi Kivityecho "PIE               $pie"
60308a16d273Sthsecho "vde support       $vde"
603158952137SVincenzo Maffioneecho "netmap support    $netmap"
60325c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
6033758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
603477755340Sthsecho "Install blobs     $blobs"
6035b31a0277SJuan Quintelaecho "KVM support       $kvm"
6036b0cb0a66SVincent Palatinecho "HAX support       $hax"
6037c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
6038d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
6039b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
6040b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
6041b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
60429195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
6043b3f6ea7eSPaolo Bonzinifi
60445a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
6045b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
604621ab34c9SMarcel Apfelbaumecho "PVRDMA support    $pvrdma"
6047f652e6afSaurel32echo "fdt support       $fdt"
6048a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
6049ceb42de8Saliguoriecho "preadv support    $preadv"
60505f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
6051e78815a5SAndreas Färberecho "madvise           $madvise"
6052e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
60539bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
605447e98658SCorey Bryantecho "libcap-ng support $cap_ng"
6055d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
6056042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
60575e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
6058fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
6059e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
60605b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
6061713572a7SMarc-André Lureauif have_backend "simple"; then
60629410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
6063e00e36fbSStefan Weilfi
606489138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6065f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
6066dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
60677b02f544SMarc-André Lureauecho "smartcard support $smartcard"
60682b2325ffSGerd Hoffmannecho "libusb            $libusb"
606969354a83SHans de Goedeecho "usb net redir     $usb_redir"
6070da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
6071014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
6072c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
60736542aa9cSPeter Lievenecho "libnfs support    $libnfs"
6074d138cee9SMichael Rothecho "build guest agent $guest_agent"
6075d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
607650cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
60774c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
6078f794573eSEduardo Otuboecho "seccomp support   $seccomp"
60797c2acc70SPeter Maydellecho "coroutine backend $coroutine"
608070c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
60817d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
6082ba59fb77SPaolo Bonziniecho "mutex debugging   $debug_mutex"
6083f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
6084eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
60851d728c39SBlue Swirlecho "gcov              $gcov_tool"
60861d728c39SBlue Swirlecho "gcov enabled      $gcov"
6087ab214c29SStefan Bergerecho "TPM support       $tpm"
60880a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
60893b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
6090f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
60913556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
6092ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
6093607dacd0Sqiaonuohanecho "lzo support       $lzo"
6094607dacd0Sqiaonuohanecho "snappy support    $snappy"
60956b383c08SPeter Wuecho "bzip2 support     $bzip2"
6096a99d57bbSWanlong Gaoecho "NUMA host support $numa"
6097ed279a06SKlim Kireevecho "libxml2           $libxml2"
60982847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
60997b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
610099f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
6101a6b1d4c0SChanglong Xieecho "replication support $replication"
6102da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
61038ca80760SRichard Hendersonecho "capstone          $capstone"
610451a12b51SAlex Bennéeecho "docker            $docker"
610517824406SJunyan Heecho "libpmem support   $libpmem"
610667b915a5Sbellard
61071ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
610824b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
6109e8cd23deSbellardfi
611097a847bcSbellard
6111b7715af2SDaniel P. Berrangeif test "$gtkabi" = "2.0"; then
6112b7715af2SDaniel P. Berrange    echo
6113b7715af2SDaniel P. Berrange    echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
6114b7715af2SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using GTK 3.0"
6115b7715af2SDaniel P. Berrangefi
6116b7715af2SDaniel P. Berrange
6117e52c6ba3SDaniel P. Berrangeif test "$sdlabi" = "1.2"; then
6118e52c6ba3SDaniel P. Berrange    echo
6119e52c6ba3SDaniel P. Berrange    echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
6120e52c6ba3SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using SDL 2.0"
6121e52c6ba3SDaniel P. Berrangefi
6122e52c6ba3SDaniel P. Berrange
6123898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
6124898be3e0SPeter Maydell    echo
6125898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6126898be3e0SPeter Maydell    echo
6127898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
6128898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
6129898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6130898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6131898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6132898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6133898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6134898be3e0SPeter Maydellfi
6135898be3e0SPeter Maydell
6136898be3e0SPeter Maydellif test "$supported_os" = "no"; then
6137898be3e0SPeter Maydell    echo
6138898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6139898be3e0SPeter Maydell    echo
6140c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
6141c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
6142898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6143898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6144898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6145898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6146898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6147898be3e0SPeter Maydellfi
6148898be3e0SPeter Maydell
614998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
615097a847bcSbellard
6151dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6152dbd99ae3SStefan Weil
615398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
615498ec69acSJuan Quintelaecho >> $config_host_mak
615598ec69acSJuan Quintela
6156e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
615799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
615899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
61593aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
61608bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
61610f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
616299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
616399d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
616422d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
61659afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
61663d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
61679afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6168e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
61695a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6170785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
61715a699bbbSLaszlo Ersekfi
6172f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6173834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6174f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6175cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6176aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6177f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6178804edf29SJuan Quintela
617998ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6180727e5283SPaolo Bonzini
6181f8393946Saurel32if test "$debug_tcg" = "yes" ; then
61822358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6183f8393946Saurel32fi
61841625af87Saliguoriif test "$strip_opt" = "yes" ; then
618552ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
61861625af87Saliguorifi
61877d13299dSbellardif test "$bigendian" = "yes" ; then
6188e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
618997a847bcSbellardfi
619067b915a5Sbellardif test "$mingw32" = "yes" ; then
619198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
619289138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
61939fe6de94SBlue Swirl  version_major=${rc_version%%.*}
61949fe6de94SBlue Swirl  rc_version=${rc_version#*.}
61959fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
61969fe6de94SBlue Swirl  rc_version=${rc_version#*.}
61979fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
61989fe6de94SBlue Swirl  version_micro=0
61999fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
62009fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6201d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6202d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6203f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6204d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6205d9840e25STomoki Sekiyama  fi
620650cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
620750cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
620850cbebb9SMichael Roth  fi
62091a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
62109dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
62119dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
62129dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
62139dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
62149dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
62159dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
62169dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
62179dacf32dSYossi Hindin  fi
6218210fa556Spbrookelse
621935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6220210fa556Spbrookfi
6221128ab2ffSblueswir1
6222dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6223dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6224dffcb71cSMark McLoughlinfi
6225dffcb71cSMark McLoughlin
622683fb7adfSbellardif test "$darwin" = "yes" ; then
622798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
622883fb7adfSbellardfi
6229b29fe3edSmalc
6230ec530c81Sbellardif test "$solaris" = "yes" ; then
623198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6232ec530c81Sbellardfi
6233179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6234179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6235179cf400SAndreas Färberfi
623697a847bcSbellardif test "$static" = "yes" ; then
623798ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
623897a847bcSbellardfi
62391ba16968SStefan Weilif test "$profiler" = "yes" ; then
62402358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
624105c2a3e7Sbellardfi
6242c20709aaSbellardif test "$slirp" = "yes" ; then
624398ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6244e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6245c20709aaSbellardfi
62468a16d273Sthsif test "$vde" = "yes" ; then
624798ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6248e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
62498a16d273Sthsfi
625058952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
625158952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
625258952137SVincenzo Maffionefi
6253015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6254015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6255015a33bdSGongleifi
625647e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
625747e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
625847e98658SCorey Bryantfi
62592358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
62600c58ac1cSmalcfor drv in $audio_drv_list; do
62611ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6262ce3dc033SGerd Hoffmann    case "$drv" in
6263051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6264ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6265ce3dc033SGerd Hoffmann	*)
6266ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6267ce3dc033SGerd Hoffmann    esac
62680c58ac1cSmalcdone
6269b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6270b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6271b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6272b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6273b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
627467f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
627567f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
627667f86e8eSJuan Quintelafi
6277d5631638Smalcif test "$audio_win_int" = "yes" ; then
6278d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6279d5631638Smalcfi
6280b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6281b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6282821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6283821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6284821601eaSJes Sorensenfi
62852f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
628698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
62872f9606b3Saliguorifi
6288821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
62892f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
62902f6f5c7aSCorentin Charyfi
6291821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6292efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6293efe556adSCorentin Charyfi
62946a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
62956a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
62966a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
62976a021536SGerd Hoffmannfi
629876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
62992358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
630076655d6dSaliguorifi
6301dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6302dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6303dce512deSChristoph Hellwigfi
630489138857SStefan Weilqemu_version=$(head $source_path/VERSION)
630598ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
63062358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
630798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
63082b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6309a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
631098ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6311cc8ae6deSpbrookfi
631217969268SFam Zhengif test "$modules" = "yes"; then
6313e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6314e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
631589138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
631617969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
631717969268SFam Zhengfi
63188781595bSGerd Hoffmannif test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
63198781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
63208781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
63218781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
63228781595bSGerd Hoffmannfi
63231ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
632496400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
6325a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
63268ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
63278ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
632849ecc3faSbellardfi
632949ecc3faSbellardif test "$cocoa" = "yes" ; then
633098ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
633149ecc3faSbellardfi
63324d3b6f6eSbalrogif test "$curses" = "yes" ; then
63332373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
63342373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
63352373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6336ab4e5602SJan Kiszkafi
6337099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
63382358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6339099d6b0fSRiku Voipiofi
634040ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
634140ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
634240ff6d7eSKevin Wolffi
63433ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
63442358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
63453ce34dfbSvibisreenivasanfi
6346c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6347c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6348c2882b96SRiku Voipiofi
6349751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6350751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6351751bcc39SMarc-André Lureaufi
6352d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6353d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6354d0927938SUlrich Hechtfi
63553d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
63563d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
63573d4fa43eSKusanagi Kouichifi
6358b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6359b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6360b953f075SDenis V. Lunevfi
6361ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6362ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6363ed911435SKevin Wolffi
6364c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6365c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6366c727f47dSPeter Maydellfi
6367dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6368dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6369dace20dcSPeter Maydellfi
6370d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6371d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6372d0927938SUlrich Hechtfi
63734e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
63744e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
63754e0c6529SAlex Blighfi
6376cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6377cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6378cd758dd0SAlex Blighfi
63793b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
63803b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
63813b6edd16SPeter Maydellfi
63823b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
63833b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
63843b6edd16SPeter Maydellfi
6385a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6386a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6387a8fd1abaSPeter Maydellfi
638851834341SRiku Voipioif test "$timerfd" = "yes" ; then
638951834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
639051834341SRiku Voipiofi
63919af5c906SRiku Voipioif test "$setns" = "yes" ; then
63929af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
63939af5c906SRiku Voipiofi
639438860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
639538860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
639638860a03SAleksandar Markovicfi
63975a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
63985a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
63995a03cd00SAleksandar Markovicfi
64003b3f24adSaurel32if test "$inotify" = "yes" ; then
64012358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
64023b3f24adSaurel32fi
6403c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6404c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6405c05c7a73SRiku Voipiofi
6406401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6407401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6408401bc051SPeter Maydellfi
64095c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
64105c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
64115c99fa37SKeno Fischerfi
64126ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
64136ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
64146ae9a1f4SJuan Quintelafi
64156ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
64166ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
64176ae9a1f4SJuan Quintelafi
6418769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6419d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6420b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
64216ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6422769ce76dSAlexander Graffi
64232e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
642498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
64258eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
64262e4d9fb1Saurel32fi
6427fb599c9aSbalrogif test "$bluez" = "yes" ; then
642898ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
6429ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6430fb599c9aSbalrogfi
6431d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
64329d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
64339d41401bSMichael S. Tsirkinfi
6434a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6435e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6436a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
6437a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6438014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6439925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6440925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6441925a0400SGerd Hoffmann  fi
6442bbbf9bfbSStefan Weilfi
6443a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6444ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6445ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6446ddbb0d09SDaniel P. Berrangefi
6447b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
6448b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
6449b917da4cSDaniel P. Berrangefi
645091bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
645191bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
64521f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
64531f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
64541f923c70SLongpeng(Mike)  fi
645537788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
645637788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
645737788f25SDaniel P. Berrange  fi
645862893b67SDaniel P. Berrangefi
645991bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
646091bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6461becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6462fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
6463fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6464fff2f982SDaniel P. Berrange  fi
6465ed754746SDaniel P. Berrangefi
64669a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
64679a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
64689a2fd434SDaniel P. Berrangefi
6469559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6470559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6471559607eaSDaniel P. Berrangefi
64726b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
64736b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
64746b39b063SEric Blakefi
6475277abf15SJan Vesely
6476277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6477277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6478277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6479277abf15SJan Vesely# if this macro is set.
6480277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6481277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6482277abf15SJan Veselyfi
64831efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
64841efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
64851efad060SFam Zhengfi
6486bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6487bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6488a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6489e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6490a4ccabcfSAnthony Liguorifi
64919d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
64929d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
64939d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
64949d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
64959d9e1521SGerd Hoffmannfi
6496e37630caSaliguoriif test "$xen" = "yes" ; then
64976dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6498d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
649964a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
650064a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
650164a7ad6fSIan Campbell  fi
6502e37630caSaliguorifi
65035c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
65045c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
65055c6c3a6cSChristoph Hellwigfi
6506758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6507758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6508758e8e38SVenkateswararao Jujjuri (JV)fi
65094f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
65104f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
65114f26f2b6SAvi Kivityfi
6512983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6513758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6514758e8e38SVenkateswararao Jujjuri (JV)fi
6515fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6516fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
6517*1b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
6518*1b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
6519*1b0578f5SMurilo Opsfelder Araujo  fi
6520fe8fc5aeSPaolo Bonzinifi
65215e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
65225e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
65235e9be92dSNicholas Bellingerfi
6524e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
652503ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
652603ce5744SNikolay Nikolaevfi
6527042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6528042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6529042cea27SGongleifi
6530fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6531fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6532fc0b9b0eSStefan Hajnoczifi
6533e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6534e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6535e6a74868SMarc-André Lureaufi
653677755340Sthsif test "$blobs" = "yes" ; then
653798ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
653877755340Sthsfi
6539bf9298b9Saliguoriif test "$iovec" = "yes" ; then
65402358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6541bf9298b9Saliguorifi
6542ceb42de8Saliguoriif test "$preadv" = "yes" ; then
65432358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6544ceb42de8Saliguorifi
6545e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
65463f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6547f652e6afSaurel32fi
6548a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6549a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6550a40161cbSPaolo Bonzinifi
6551dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6552dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6553dcc38d1cSMarcelo Tosattifi
6554b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6555b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
65569195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
65579195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
65589195b2c2SStefan Weil  fi
6559b3f6ea7eSPaolo Bonzinifi
65605f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
65615f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
65625f6b9e8fSBlue Swirlfi
6563e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6564e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6565e78815a5SAndreas Färberfi
6566e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6567e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6568e78815a5SAndreas Färberfi
65699bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
65709bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
65719bc5a719SAndreas Gustafssonfi
657297a847bcSbellard
6573cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6574cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6575cd4ec0b4SGerd Hoffmannfi
6576cd4ec0b4SGerd Hoffmann
65777b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
65787b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
65797b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
65807b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6581111a38b0SRobert Relyeafi
6582111a38b0SRobert Relyea
65832b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
65842b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6585b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6586b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
65872b2325ffSGerd Hoffmannfi
65882b2325ffSGerd Hoffmann
658969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
659069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6591cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6592cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
659369354a83SHans de Goedefi
659469354a83SHans de Goede
6595da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6596da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6597da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6598014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6599014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6600014cb152SGerd Hoffmann  fi
660120ff075bSMichael Wallefi
660220ff075bSMichael Walle
66035a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
66045a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
66055a22ab71SYang Zhongfi
66065a22ab71SYang Zhong
660799f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
660899f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
660999f2dbd3SLiang Lifi
661099f2dbd3SLiang Li
6611607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6612607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6613607dacd0Sqiaonuohanfi
6614607dacd0Sqiaonuohan
6615607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6616607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6617607dacd0Sqiaonuohanfi
6618607dacd0Sqiaonuohan
66196b383c08SPeter Wuif test "$bzip2" = "yes" ; then
66206b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
66216b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
66226b383c08SPeter Wufi
66236b383c08SPeter Wu
6624c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6625d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
66266ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
66276ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6628c589b249SRonnie Sahlbergfi
6629c589b249SRonnie Sahlberg
66306542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
66314be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
66324be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
66336542aa9cSPeter Lievenfi
66346542aa9cSPeter Lieven
6635f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6636f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6637c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6638c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6639f794573eSEduardo Otubofi
6640f794573eSEduardo Otubo
664183fb7adfSbellard# XXX: suppress that
66427d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
66432358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
66447d3505c5Sbellardfi
66457d3505c5Sbellard
66464d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
66474d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
66484d9310f4SDaniel P. Berrangefi
66493556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
66503556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
66513556c233SPaolo Bonzinifi
6652f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6653d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
66546ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
66556ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6656f27aaf4bSChristian Brunnerfi
665720ff6c80SAnthony Liguori
66587c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
665970c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
666070c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
666170c60c08SStefan Hajnoczielse
666270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
666370c60c08SStefan Hajnoczifi
6664d0e2fce5SAneesh Kumar K.V
66657d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
66667d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
66677d992e4dSPeter Lievenfi
66687d992e4dSPeter Lieven
6669f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6670f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6671f0d92b56SLongpeng(Mike)fi
6672f0d92b56SLongpeng(Mike)
6673d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6674d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6675d2042378SAneesh Kumar K.Vfi
6676d2042378SAneesh Kumar K.V
6677e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6678e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6679e06a765eSHarsh Prateek Borafi
6680e06a765eSHarsh Prateek Bora
6681cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6682cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
668306d71fa1SPeter Maydellfi
668406d71fa1SPeter Maydell
66853f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
66863f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
66873f4349dcSKevin Wolffi
66883f4349dcSKevin Wolf
6689d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
6690d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6691d83414e1SMarc-André Lureaufi
6692d83414e1SMarc-André Lureau
66938ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
66948ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
66958ab1bf12SLuiz Capitulinofi
66968ab1bf12SLuiz Capitulino
669776a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
669876a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
669976a347e1SRichard Hendersonfi
670076a347e1SRichard Henderson
6701f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6702f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6703f540166bSRichard Hendersonfi
6704f540166bSRichard Henderson
67057ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
67067ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
67077ebee43eSRichard Hendersonfi
67087ebee43eSRichard Henderson
6709df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6710df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6711df79b996SRichard Hendersonfi
6712df79b996SRichard Henderson
6713db432672SRichard Hendersonif test "$vector16" = "yes" ; then
6714db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
6715db432672SRichard Hendersonfi
6716db432672SRichard Henderson
67171e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
67181e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
67191e6e9acaSRichard Hendersonfi
67201e6e9acaSRichard Henderson
6721eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6722d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
67236ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
67246ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6725eb100396SBharata B Raofi
6726eb100396SBharata B Rao
6727d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6728d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6729d85fa9ebSJeff Codyfi
6730d85fa9ebSJeff Cody
67310c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
67320c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
67330c14fb47SBharata B Raofi
67340c14fb47SBharata B Rao
6735df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6736df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6737df3a429aSNiels de Vosfi
6738df3a429aSNiels de Vos
67397c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
67407c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
67417c815372SBharata B Raofi
67427c815372SBharata B Rao
67430a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6744d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
67456ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
67466ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
67470a12ec87SRichard W.M. Jonesfi
67480a12ec87SRichard W.M. Jones
6749ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6750ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6751ed1701c6SDr. David Alan Gilbertfi
6752ed1701c6SDr. David Alan Gilbert
67533b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
67543b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6755f4ede81eSAmarnath Valluri  # TPM passthrough support?
67563b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
67573b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
67583b8acc11SPaolo Bonzini  fi
6759f4ede81eSAmarnath Valluri  # TPM emulator support?
6760f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6761f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6762f4ede81eSAmarnath Valluri  fi
67633b8acc11SPaolo Bonzinifi
67643b8acc11SPaolo Bonzini
67655b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
67665b808275SLluís Vilanovaif have_backend "nop"; then
67676d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
676822890ab5SPrerna Saxenafi
67695b808275SLluís Vilanovaif have_backend "simple"; then
67706d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
67716d8a764eSLluís  # Set the appropriate trace file.
6772953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
67739410b56cSPrerna Saxenafi
6774ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6775ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
67766d8a764eSLluísfi
67775b808275SLluís Vilanovaif have_backend "ust"; then
67786d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
67796d8a764eSLluísfi
67805b808275SLluís Vilanovaif have_backend "dtrace"; then
67816d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
67826d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
67836d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
67846d8a764eSLluís  fi
6785c276b17dSDaniel P. Berrangefi
67865b808275SLluís Vilanovaif have_backend "ftrace"; then
6787781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6788781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6789781e9545SEiichi Tsukata  else
679021684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6791781e9545SEiichi Tsukata  fi
6792781e9545SEiichi Tsukatafi
67930a852417SPaul Durrantif have_backend "syslog"; then
67940a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
67950a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
67960a852417SPaul Durrant  else
67970a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
67980a852417SPaul Durrant  fi
67990a852417SPaul Durrantfi
68009410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
68019410b56cSPrerna Saxena
68022da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
68032da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6804392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
68052da776dbSMichael R. Hinesfi
68062da776dbSMichael R. Hines
680721ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
680821ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
680921ab34c9SMarcel Apfelbaumfi
681021ab34c9SMarcel Apfelbaum
6811575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6812575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6813575b22b1SLaurent Vivierfi
6814575b22b1SLaurent Vivier
6815ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6816ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6817ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6818ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6819ed279a06SKlim Kireevfi
6820ed279a06SKlim Kireev
6821a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6822a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6823a6b1d4c0SChanglong Xiefi
6824a6b1d4c0SChanglong Xie
68256a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
68266a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
68276a02c806SStefan Hajnoczifi
68286a02c806SStefan Hajnoczi
68294d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
68304d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
68314d04351fSChristopher Covingtonfi
68324d04351fSChristopher Covington
683349e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
683449e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
683549e00a18SAndreas Grapentinfi
683649e00a18SAndreas Grapentin
6837e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6838e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6839e674605fSTomáš Golembiovskýfi
6840e674605fSTomáš Golembiovský
6841e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6842e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6843e0580342SKamil Rytarowskifi
6844e219c499SRichard Hendersonif test "$capstone" != "no" ; then
68458ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
68468ca80760SRichard Hendersonfi
6847ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
6848ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6849ba59fb77SPaolo Bonzinifi
6850e0580342SKamil Rytarowski
68515c312079SDr. David Alan Gilbert# Hold two types of flag:
68525c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
68535c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
68545c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
68555c312079SDr. David Alan Gilbert#                                     platform
68565c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
68575c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
68585c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
68595c312079SDr. David Alan Gilbertfi
68605c312079SDr. David Alan Gilbert
6861da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6862da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6863da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6864da92c3ffSAshish Mittalfi
6865da92c3ffSAshish Mittal
686617824406SJunyan Heif test "$libpmem" = "yes" ; then
686717824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
686817824406SJunyan Hefi
686917824406SJunyan He
68705b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
68719edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
68725b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
68739edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
68745b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
68759edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6876c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
68779edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
687840d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
68799edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
68805b5e3037SPaolo Bonzinielse
68819edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
68825b5e3037SPaolo Bonzinifi
68839edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
68845b5e3037SPaolo Bonzini
688598ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
688698ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6887804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6888804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
68891901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
68901901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
68911901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
689221655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6893c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6894804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6895a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6896a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6897a31a8642SMichael S. Tsirkinfi
6898804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
689983f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
69003c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6901804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
690245d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6903cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
69045f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
69053dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6906804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6907804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
69089f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
69094852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
69109fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6911e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
691246eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6913a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
691411cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6915f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6916e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6917e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
691880fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
69192944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6920e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6921e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6922e39f0062SPaolo Bonzinifi
692342da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
692442da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
692542da6041SGerd Hoffmannelse
692642da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
692742da6041SGerd Hoffmannfi
6928e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
692946eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
69308a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
69316969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6932e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
693373da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
69343e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6935409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6936804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
693717969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
693817969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6939957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
694090246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
694190246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
694294dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6943cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
69441d728c39SBlue Swirlif test "$gcov" = "yes" ; then
69451d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
69461d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
69471d728c39SBlue Swirlfi
6948804edf29SJuan Quintela
694951a12b51SAlex Bennéeif test "$docker" != "no"; then
695051a12b51SAlex Bennée    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
695151a12b51SAlex Bennéefi
695251a12b51SAlex Bennée
69536efd7517SPeter Maydell# use included Linux headers
69546efd7517SPeter Maydellif test "$linux" = "yes" ; then
6955a307beb6SAndreas Färber  mkdir -p linux-headers
69566efd7517SPeter Maydell  case "$cpu" in
6957c72b26ecSRichard Henderson  i386|x86_64|x32)
695808312a63SPeter Maydell    linux_arch=x86
69596efd7517SPeter Maydell    ;;
69606efd7517SPeter Maydell  ppcemb|ppc|ppc64)
696108312a63SPeter Maydell    linux_arch=powerpc
69626efd7517SPeter Maydell    ;;
69636efd7517SPeter Maydell  s390x)
696408312a63SPeter Maydell    linux_arch=s390
696508312a63SPeter Maydell    ;;
69661f080313SClaudio Fontana  aarch64)
69671f080313SClaudio Fontana    linux_arch=arm64
69681f080313SClaudio Fontana    ;;
6969222e7d11SSanjay Lal  mips64)
6970222e7d11SSanjay Lal    linux_arch=mips
6971222e7d11SSanjay Lal    ;;
697208312a63SPeter Maydell  *)
697308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
697408312a63SPeter Maydell    linux_arch="$cpu"
69756efd7517SPeter Maydell    ;;
69766efd7517SPeter Maydell  esac
697708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
697808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
697908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
698008312a63SPeter Maydell    fi
69816efd7517SPeter Maydellfi
69826efd7517SPeter Maydell
698397a847bcSbellardfor target in $target_list; do
698497a847bcSbellardtarget_dir="$target"
698525be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
698689138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
698797a847bcSbellardtarget_bigendian="no"
69881f3d3c8fSJuan Quintela
6989c1799a84SPaolo Bonzinicase "$target_name" in
6990722dd7beSMichael Weiser  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6991ea2d6a39SJuan Quintela  target_bigendian=yes
6992ea2d6a39SJuan Quintela  ;;
6993ea2d6a39SJuan Quintelaesac
699497a847bcSbellardtarget_softmmu="no"
6995997344f3Sbellardtarget_user_only="no"
6996831b7825Sthstarget_linux_user="no"
699784778508Sblueswir1target_bsd_user="no"
69989e407a85Spbrookcase "$target" in
6999c1799a84SPaolo Bonzini  ${target_name}-softmmu)
70009e407a85Spbrook    target_softmmu="yes"
70019e407a85Spbrook    ;;
7002c1799a84SPaolo Bonzini  ${target_name}-linux-user)
70039e407a85Spbrook    target_user_only="yes"
70049e407a85Spbrook    target_linux_user="yes"
70059e407a85Spbrook    ;;
7006c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
700784778508Sblueswir1    target_user_only="yes"
700884778508Sblueswir1    target_bsd_user="yes"
700984778508Sblueswir1    ;;
70109e407a85Spbrook  *)
701176ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
70129e407a85Spbrook    exit 1
70139e407a85Spbrook    ;;
70149e407a85Spbrookesac
7015831b7825Sths
7016d75402b5SAlex Bennéetarget_compiler=""
7017d75402b5SAlex Bennéetarget_compiler_static=""
7018716a507cSAlex Bennéetarget_compiler_cflags=""
7019d75402b5SAlex Bennée
702097a847bcSbellardmkdir -p $target_dir
702125be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
702297a847bcSbellard
7023e5fe0c52Spbrookbflt="no"
7024ca759f9eSAlex Bennéemttcg="no"
702589138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
702656aebc89Spbrookgdb_xml_files=""
70277ba1e619Saliguori
7028c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
70296acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7030e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
7031e73aae67SJuan Quintela
7032c1799a84SPaolo Bonzinicase "$target_name" in
70332408a527Saurel32  i386)
7034b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
7035d75402b5SAlex Bennée    target_compiler=$cross_cc_i386
7036716a507cSAlex Bennée    target_compiler_cflags=$cross_cc_ccflags_i386
70372408a527Saurel32  ;;
70382408a527Saurel32  x86_64)
70396acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
7040b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
7041d75402b5SAlex Bennée    target_compiler=$cross_cc_x86_64
70422408a527Saurel32  ;;
70432408a527Saurel32  alpha)
70445ee4f3c2SRichard Henderson    mttcg="yes"
7045d75402b5SAlex Bennée    target_compiler=$cross_cc_alpha
70462408a527Saurel32  ;;
70472408a527Saurel32  arm|armeb)
7048b498c8a0SJuan Quintela    TARGET_ARCH=arm
7049e5fe0c52Spbrook    bflt="yes"
7050ca759f9eSAlex Bennée    mttcg="yes"
705156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7052d75402b5SAlex Bennée    target_compiler=$cross_cc_arm
7053d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
70542408a527Saurel32  ;;
7055722dd7beSMichael Weiser  aarch64|aarch64_be)
7056722dd7beSMichael Weiser    TARGET_ARCH=aarch64
70576a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
70586a49fa95SAlexander Graf    bflt="yes"
7059ca759f9eSAlex Bennée    mttcg="yes"
70608f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7061d75402b5SAlex Bennée    target_compiler=$cross_cc_aarch64
7062d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
70636a49fa95SAlexander Graf  ;;
70642408a527Saurel32  cris)
7065d75402b5SAlex Bennée    target_compiler=$cross_cc_cris
70662408a527Saurel32  ;;
706761766fe9SRichard Henderson  hppa)
70687b93dab5SRichard Henderson    mttcg="yes"
7069d75402b5SAlex Bennée    target_compiler=$cross_cc_hppa
707061766fe9SRichard Henderson  ;;
7071613a22c9SMichael Walle  lm32)
7072d75402b5SAlex Bennée    target_compiler=$cross_cc_lm32
7073613a22c9SMichael Walle  ;;
70742408a527Saurel32  m68k)
70750938cda5Saurel32    bflt="yes"
70765a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7077d75402b5SAlex Bennée    target_compiler=$cross_cc_m68k
70782408a527Saurel32  ;;
7079877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7080877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
708172b675caSEdgar E. Iglesias    bflt="yes"
7082be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
7083d75402b5SAlex Bennée    target_compiler=$cross_cc_microblaze
708472b675caSEdgar E. Iglesias  ;;
70852408a527Saurel32  mips|mipsel)
7086b498c8a0SJuan Quintela    TARGET_ARCH=mips
7087d75402b5SAlex Bennée    target_compiler=$cross_cc_mips
708825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
70892408a527Saurel32  ;;
70902408a527Saurel32  mipsn32|mipsn32el)
7091597e2cecSRichard Henderson    TARGET_ARCH=mips64
70926acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7093d75402b5SAlex Bennée    target_compiler=$cross_cc_mipsn32
709425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7095597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
70962408a527Saurel32  ;;
70972408a527Saurel32  mips64|mips64el)
7098b498c8a0SJuan Quintela    TARGET_ARCH=mips64
70996acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7100d75402b5SAlex Bennée    target_compiler=$cross_cc_mips64
710125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
71022408a527Saurel32  ;;
7103d15a9c23SAnthony Green  moxie)
7104d75402b5SAlex Bennée    target_compiler=$cross_cc_moxie
7105d15a9c23SAnthony Green  ;;
7106e671711cSMarek Vasut  nios2)
7107d75402b5SAlex Bennée    target_compiler=$cross_cc_nios2
7108e671711cSMarek Vasut  ;;
71094a09d0bbSRichard Henderson  or1k)
7110d75402b5SAlex Bennée    target_compiler=$cross_cc_or1k
7111e67db06eSJia Liu    TARGET_ARCH=openrisc
7112e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7113e67db06eSJia Liu  ;;
71142408a527Saurel32  ppc)
7115c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7116d75402b5SAlex Bennée    target_compiler=$cross_cc_powerpc
71172408a527Saurel32  ;;
71182408a527Saurel32  ppcemb)
71196acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7120e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7121c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7122d75402b5SAlex Bennée    target_compiler=$cross_cc_ppcemb
71232408a527Saurel32  ;;
71242408a527Saurel32  ppc64)
71256acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7126e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7127f0b0685dSNikunj A Dadhania    mttcg=yes
71281438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7129d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64
71302408a527Saurel32  ;;
71319c35126cSDoug Kwan  ppc64le)
71329c35126cSDoug Kwan    TARGET_ARCH=ppc64
71339c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
71349c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
7135f0b0685dSNikunj A Dadhania    mttcg=yes
71361438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7137d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64le
71389c35126cSDoug Kwan  ;;
71392408a527Saurel32  ppc64abi32)
7140b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
71416acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7142e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
714325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
71441438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7145d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64abi32
71462408a527Saurel32  ;;
714725fa194bSMichael Clark  riscv32)
714825fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
714925fa194bSMichael Clark    TARGET_ABI_DIR=riscv
715025fa194bSMichael Clark    mttcg=yes
7151d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv32
715225fa194bSMichael Clark  ;;
715325fa194bSMichael Clark  riscv64)
715425fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
715525fa194bSMichael Clark    TARGET_ABI_DIR=riscv
715625fa194bSMichael Clark    mttcg=yes
7157d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv64
715825fa194bSMichael Clark  ;;
71592408a527Saurel32  sh4|sh4eb)
7160b498c8a0SJuan Quintela    TARGET_ARCH=sh4
71614dbed897Spbrook    bflt="yes"
7162d75402b5SAlex Bennée    target_compiler=$cross_cc_sh4
71632408a527Saurel32  ;;
71642408a527Saurel32  sparc)
7165d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc
71662408a527Saurel32  ;;
71672408a527Saurel32  sparc64)
71686acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7169d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc64
71702408a527Saurel32  ;;
71712408a527Saurel32  sparc32plus)
7172b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
71736acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7174e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7175d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc32plus
717625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
71772408a527Saurel32  ;;
717824e804ecSAlexander Graf  s390x)
717963685bc4SDavid Hildenbrand    mttcg=yes
718086158a2aSChristian 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"
7181d75402b5SAlex Bennée    target_compiler=$cross_cc_s390x
718224e804ecSAlexander Graf  ;;
7183444e06b1SChen Gang  tilegx)
7184d75402b5SAlex Bennée    target_compiler=$cross_cc_tilegx
7185444e06b1SChen Gang  ;;
71865ecaa4edSPeter Crosthwaite  tricore)
7187d75402b5SAlex Bennée    target_compiler=$cross_cc_tricore
71885ecaa4edSPeter Crosthwaite  ;;
7189d2fbca94SGuan Xuetao  unicore32)
7190d75402b5SAlex Bennée    target_compiler=$cross_cc_unicore32
7191d2fbca94SGuan Xuetao  ;;
7192cfa550c6SMax Filippov  xtensa|xtensaeb)
7193cfa550c6SMax Filippov    TARGET_ARCH=xtensa
71949fb40342SMax Filippov    mttcg="yes"
7195d75402b5SAlex Bennée    target_compiler=$cross_cc_xtensa
7196cfa550c6SMax Filippov  ;;
71972408a527Saurel32  *)
719876ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
71992408a527Saurel32  ;;
72002408a527Saurel32esac
72015e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
72025e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
72035e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
72045e8861a0SPaolo Bonzinifi
72055e8861a0SPaolo Bonzini
7206d75402b5SAlex Bennée# Do we have a cross compiler for this target?
7207d75402b5SAlex Bennéeif has $target_compiler; then
7208d75402b5SAlex Bennée
7209d75402b5SAlex Bennée    write_c_skeleton
7210d75402b5SAlex Bennée
7211716a507cSAlex Bennée    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7212d75402b5SAlex Bennée        # For host systems we might get away with building without -static
7213716a507cSAlex Bennée        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7214d75402b5SAlex Bennée            target_compiler=""
7215d75402b5SAlex Bennée        else
7216d75402b5SAlex Bennée            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7217d75402b5SAlex Bennée            target_compiler_static="n"
7218d75402b5SAlex Bennée        fi
7219d75402b5SAlex Bennée    else
7220d75402b5SAlex Bennée        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7221d75402b5SAlex Bennée        target_compiler_static="y"
7222d75402b5SAlex Bennée    fi
7223d75402b5SAlex Bennéeelse
7224d75402b5SAlex Bennée    target_compiler=""
7225d75402b5SAlex Bennéefi
7226d75402b5SAlex Bennée
72275e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
72285e8861a0SPaolo Bonzini
722999afc91dSDaniel P. Berrangeupper() {
723099afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
723199afc91dSDaniel P. Berrange}
723299afc91dSDaniel P. Berrange
723389138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
723425be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7235c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
723625be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7237e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7238e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7239e6e91b9cSJuan Quintelafi
724025be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7241adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7242adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7243adfc3e91SStacey Sonfi
72443b6b7550SPaolo Bonzini
72453b6b7550SPaolo Bonziniif supported_xen_target $target; then
724625be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7247eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7248eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7249eb6fda0fSAnthony PERARD    fi
7250432d268cSJun Nakajimafi
72513b6b7550SPaolo Bonziniif supported_kvm_target $target; then
725225be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
72531ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
7254d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7255e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
7256e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7257e6a74868SMarc-André Lureau        fi
7258d5970055SMichael S. Tsirkin    fi
7259c59249f9SJuan Quintelafi
72603b6b7550SPaolo Bonziniif supported_hax_target $target; then
7261b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7262b0cb0a66SVincent Palatinfi
7263c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7264c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7265c97d6d2cSSergio Andres Gomez Del Realfi
7266d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7267d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7268d661d9a4SJustin Terry (VM)fi
7269de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
727025be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
727197a847bcSbellardfi
727297a847bcSbellardif test "$target_softmmu" = "yes" ; then
727325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7274ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7275ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7276ca759f9eSAlex Bennée  fi
7277de83cd02Sbellardfi
7278997344f3Sbellardif test "$target_user_only" = "yes" ; then
727925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7280a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7281997344f3Sbellardfi
7282831b7825Sthsif test "$target_linux_user" = "yes" ; then
728325be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7284831b7825Sthsfi
728556aebc89Spbrooklist=""
728656aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
728756aebc89Spbrook  for x in $gdb_xml_files; do
728856aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
728956aebc89Spbrook  done
729025be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
72913d0f1517SJuan Quintelafi
7292de83cd02Sbellard
7293e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
729425be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7295e5fe0c52Spbrookfi
729684778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
729725be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
729884778508Sblueswir1fi
72995b0753e0Sbellard
7300d75402b5SAlex Bennéeif test -n "$target_compiler"; then
7301d75402b5SAlex Bennée  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7302d75402b5SAlex Bennée
7303d75402b5SAlex Bennée  if test -n "$target_compiler_static"; then
7304d75402b5SAlex Bennée      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7305d75402b5SAlex Bennée  fi
7306716a507cSAlex Bennée
7307716a507cSAlex Bennée  if test -n "$target_compiler_cflags"; then
7308716a507cSAlex Bennée      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7309d75402b5SAlex Bennée  fi
7310716a507cSAlex Bennéefi
7311716a507cSAlex Bennée
7312d75402b5SAlex Bennée
73134afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7314fa282484SJuan Quintela
73154afddb55SJuan Quintelacflags=""
7316fa282484SJuan Quintelaldflags=""
73179b8e111fSJuan Quintela
7318c765fcacSPeter Crosthwaitedisas_config() {
7319c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7320c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7321c765fcacSPeter Crosthwaite}
7322c765fcacSPeter Crosthwaite
732364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
732464656024SJuan Quintela  case "$i" in
732564656024SJuan Quintela  alpha)
7326c765fcacSPeter Crosthwaite    disas_config "ALPHA"
732764656024SJuan Quintela  ;;
732882295d8aSRichard Henderson  aarch64)
732982295d8aSRichard Henderson    if test -n "${cxx}"; then
7330c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
733182295d8aSRichard Henderson    fi
733282295d8aSRichard Henderson  ;;
733364656024SJuan Quintela  arm)
7334c765fcacSPeter Crosthwaite    disas_config "ARM"
7335999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7336c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7337999b53ecSClaudio Fontana    fi
733864656024SJuan Quintela  ;;
733964656024SJuan Quintela  cris)
7340c765fcacSPeter Crosthwaite    disas_config "CRIS"
734164656024SJuan Quintela  ;;
7342429b31a2SRichard Henderson  hppa)
7343429b31a2SRichard Henderson    disas_config "HPPA"
7344429b31a2SRichard Henderson  ;;
7345c72b26ecSRichard Henderson  i386|x86_64|x32)
7346c765fcacSPeter Crosthwaite    disas_config "I386"
734764656024SJuan Quintela  ;;
734879368f49SMichael Walle  lm32)
7349c765fcacSPeter Crosthwaite    disas_config "LM32"
735079368f49SMichael Walle  ;;
735164656024SJuan Quintela  m68k)
7352c765fcacSPeter Crosthwaite    disas_config "M68K"
735364656024SJuan Quintela  ;;
7354877fdc12SEdgar E. Iglesias  microblaze*)
7355c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
735664656024SJuan Quintela  ;;
735764656024SJuan Quintela  mips*)
7358c765fcacSPeter Crosthwaite    disas_config "MIPS"
735964656024SJuan Quintela  ;;
7360d15a9c23SAnthony Green  moxie*)
7361c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7362d15a9c23SAnthony Green  ;;
7363e671711cSMarek Vasut  nios2)
7364e671711cSMarek Vasut    disas_config "NIOS2"
7365e671711cSMarek Vasut  ;;
73664a09d0bbSRichard Henderson  or1k)
7367c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7368e67db06eSJia Liu  ;;
736964656024SJuan Quintela  ppc*)
7370c765fcacSPeter Crosthwaite    disas_config "PPC"
737164656024SJuan Quintela  ;;
737225fa194bSMichael Clark  riscv)
737325fa194bSMichael Clark    disas_config "RISCV"
737425fa194bSMichael Clark  ;;
737524e804ecSAlexander Graf  s390*)
7376c765fcacSPeter Crosthwaite    disas_config "S390"
737764656024SJuan Quintela  ;;
737864656024SJuan Quintela  sh4)
7379c765fcacSPeter Crosthwaite    disas_config "SH4"
738064656024SJuan Quintela  ;;
738164656024SJuan Quintela  sparc*)
7382c765fcacSPeter Crosthwaite    disas_config "SPARC"
738364656024SJuan Quintela  ;;
7384cfa550c6SMax Filippov  xtensa*)
7385c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7386cfa550c6SMax Filippov  ;;
738764656024SJuan Quintela  esac
738864656024SJuan Quinteladone
73899195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7390c765fcacSPeter Crosthwaite  disas_config "TCI"
73919195b2c2SStefan Weilfi
739264656024SJuan Quintela
73936ee7126fSJuan Quintelacase "$ARCH" in
73946ee7126fSJuan Quintelaalpha)
73956ee7126fSJuan Quintela  # Ensure there's only a single GP
73966ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
73976ee7126fSJuan Quintela;;
73986ee7126fSJuan Quintelaesac
73996ee7126fSJuan Quintela
7400d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
740125be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
7402d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7403d02c1db3SJuan Quintela    cflags="-p $cflags"
7404d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7405d02c1db3SJuan Quintela  fi
7406d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7407d02c1db3SJuan Quintela    ldflags="-p $ldflags"
740825be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7409d02c1db3SJuan Quintela  fi
7410d02c1db3SJuan Quintelafi
7411d02c1db3SJuan Quintela
74129b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
7413964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7414fa282484SJuan Quintelafi
7415fa282484SJuan Quintela
7416e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7417e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7418e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7419e9a3591fSChristian Borntraeger# header if
7420e9a3591fSChristian Borntraeger#  - we build on s390x
7421e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7422e9a3591fSChristian Borntraeger#  - KVM is enabled
7423e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7424e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7425e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7426e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7427e9a3591fSChristian Borntraeger    fi
7428e9a3591fSChristian Borntraegerfi
7429e9a3591fSChristian Borntraeger
743025be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
743125be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7432fa282484SJuan Quintela
743397a847bcSbellarddone # for target in $targets
74347d13299dSbellard
7435d75402b5SAlex Bennéeif test -n "$enabled_cross_compilers"; then
7436d75402b5SAlex Bennée    echo
7437d75402b5SAlex Bennée    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7438d75402b5SAlex Bennéefi
7439d75402b5SAlex Bennée
7440e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
7441a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
7442a540f158SPeter Crosthwaitefi
7443e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7444e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
7445e219c499SRichard Hendersonfi
7446e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7447e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7448e219c499SRichard Hendersonfi
7449a540f158SPeter Crosthwaite
7450a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7451a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7452a99d57bbSWanlong Gaofi
7453a99d57bbSWanlong Gao
7454fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7455fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7456fd0e6053SJohn Snowfi
7457fd0e6053SJohn Snow
7458d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
7459b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
7460b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
74619933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
74622d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
7463c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
7464c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7465aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7466ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
7467446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
74689933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
74692d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
74704652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
74713a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
7472753d11f2SRichard Hendersonfor bios_file in \
7473753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7474225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
74755acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
7476753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7477753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7478e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7479753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
74804e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
7481753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7482753d11f2SRichard Hendersondo
748389138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
74847ea78b74SJan Kiszkadone
748589138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
7486c2304b52SMarcel Apfelbaumdo
748789138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
7488c2304b52SMarcel Apfelbaumdone
7489645d3cbeSSu Hangfor test_file in $(find $source_path/tests/hex-loader-check-data -type f)
7490645d3cbeSSu Hangdo
7491645d3cbeSSu Hang    FILES="$FILES tests/hex-loader-check-data$(echo $test_file | sed -e 's/.*hex-loader-check-data//')"
7492645d3cbeSSu Hangdone
7493d1807a4fSPaolo Bonzinimkdir -p $DIRS
74947d13299dSbellardfor f in $FILES ; do
7495cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7496f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7497f9245e10SPeter Maydell    fi
74987d13299dSbellarddone
74991ad2134fSPaul Brook
7500c34ebfdcSAnthony Liguori# temporary config to build submodules
75012d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
7502c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
750337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7504c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7505cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
75065f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7507c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7508c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
75093dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7510c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7511a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7512c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
75139f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7514c34ebfdcSAnthony Liguoridone
7515c34ebfdcSAnthony Liguori
7516fe31017fSMarc-André Lureau# set up tests data directory
75171b145d59SPhilippe Mathieu-Daudéfor tests_subdir in acceptance data; do
75181b145d59SPhilippe Mathieu-Daudé    if [ ! -e tests/$tests_subdir ]; then
75191b145d59SPhilippe Mathieu-Daudé        symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
7520fe31017fSMarc-André Lureau    fi
75211b145d59SPhilippe Mathieu-Daudédone
7522fe31017fSMarc-André Lureau
752376c7560aSMax Reitz# set up qemu-iotests in this build directory
752476c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
752576c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
752676c7560aSMax Reitz
752776c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
752876c7560aSMax Reitzecho >> "$iotests_common_env"
752976c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
753076c7560aSMax Reitz
753176c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
753276c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
753376c7560aSMax Reitzfi
753476c7560aSMax Reitz
7535dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7536dc655404SMichael S. Tsirkincat <<EOD >config.status
7537dc655404SMichael S. Tsirkin#!/bin/sh
7538dc655404SMichael S. Tsirkin# Generated by configure.
7539dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7540dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7541dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7542dc655404SMichael S. TsirkinEOD
7543dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7544dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
7545cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7546dc655404SMichael S. Tsirkinchmod +x config.status
7547dc655404SMichael S. Tsirkin
75488cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7549