xref: /openbmc/qemu/configure (revision d376e9de)
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 | \
198a69dc537SThomas Huth        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | \
1993b6b7550SPaolo Bonzini        s390x:s390x)
2003b6b7550SPaolo Bonzini            return 0
2013b6b7550SPaolo Bonzini        ;;
2023b6b7550SPaolo Bonzini    esac
2033b6b7550SPaolo Bonzini    return 1
2043b6b7550SPaolo Bonzini}
2053b6b7550SPaolo Bonzini
2063b6b7550SPaolo Bonzinisupported_xen_target() {
2073b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2083b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
209b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
210b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
211b5ed2e11SPaolo Bonzini        i386|x86_64)
2123b6b7550SPaolo Bonzini            return 0
2133b6b7550SPaolo Bonzini        ;;
2143b6b7550SPaolo Bonzini    esac
2153b6b7550SPaolo Bonzini    return 1
2163b6b7550SPaolo Bonzini}
2173b6b7550SPaolo Bonzini
218c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
219c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
220c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
221c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
222c97d6d2cSSergio Andres Gomez Del Real        x86_64)
223c97d6d2cSSergio Andres Gomez Del Real            return 0
224c97d6d2cSSergio Andres Gomez Del Real        ;;
225c97d6d2cSSergio Andres Gomez Del Real    esac
226c97d6d2cSSergio Andres Gomez Del Real    return 1
227c97d6d2cSSergio Andres Gomez Del Real}
228c97d6d2cSSergio Andres Gomez Del Real
229d661d9a4SJustin Terry (VM)supported_whpx_target() {
230d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
231d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
232d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
233d661d9a4SJustin Terry (VM)        i386|x86_64)
234d661d9a4SJustin Terry (VM)            return 0
235d661d9a4SJustin Terry (VM)        ;;
236d661d9a4SJustin Terry (VM)    esac
237d661d9a4SJustin Terry (VM)    return 1
238d661d9a4SJustin Terry (VM)}
239d661d9a4SJustin Terry (VM)
240d880a3baSPaolo Bonzinisupported_target() {
241d880a3baSPaolo Bonzini    case "$1" in
242d880a3baSPaolo Bonzini        *-softmmu)
243d880a3baSPaolo Bonzini            ;;
244d880a3baSPaolo Bonzini        *-linux-user)
245d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
246d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
247d880a3baSPaolo Bonzini                return 1
248d880a3baSPaolo Bonzini            fi
249d880a3baSPaolo Bonzini            ;;
250d880a3baSPaolo Bonzini        *-bsd-user)
251d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
252d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
253d880a3baSPaolo Bonzini                return 1
254d880a3baSPaolo Bonzini            fi
255d880a3baSPaolo Bonzini            ;;
256d880a3baSPaolo Bonzini        *)
257d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
258d880a3baSPaolo Bonzini            return 1
259d880a3baSPaolo Bonzini            ;;
260d880a3baSPaolo Bonzini    esac
261b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
262b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
263b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
264b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
265c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
266d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
267b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
268b3f6ea7eSPaolo Bonzini    return 1
269d880a3baSPaolo Bonzini}
270d880a3baSPaolo Bonzini
271e9a3591fSChristian Borntraeger
272e9a3591fSChristian Borntraegerld_has() {
273e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
274e9a3591fSChristian Borntraeger}
275e9a3591fSChristian Borntraeger
2767d13299dSbellard# default parameters
27789138857SStefan Weilsource_path=$(dirname "$0")
2782ff6b91eSJuan Quintelacpu=""
279a31a8642SMichael S. Tsirkiniasl="iasl"
2801e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
28143ce4dfeSbellardstatic="no"
2827d13299dSbellardcross_prefix=""
2830c58ac1cSmalcaudio_drv_list=""
284b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
285b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
286e49d021eSPeter Maydellhost_cc="cc"
28773da375eSJuan Quintelalibs_softmmu=""
2883e2e0e6bSJuan Quintelalibs_tools=""
28967f86e8eSJuan Quintelaaudio_pt_int=""
290d5631638Smalcaudio_win_int=""
291957f1f99SMichael Rothlibs_qga=""
2925bc62e01SGerd Hoffmanndebug_info="yes"
29363678e17SSteven Noonanstack_protector=""
294ac0df51dSaliguori
29592712822SDaniel P. Berrangeif test -e "$source_path/.git"
29692712822SDaniel P. Berrangethen
297f62bbee5SDaniel P. Berrange    git_update=yes
29892712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
2993ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3003ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
30192712822SDaniel P. Berrangeelse
302f62bbee5SDaniel P. Berrange    git_update=no
303aef45d51SDaniel P. Berrange    git_submodules=""
3045c0ef67aSDaniel P. Berrangé
3055c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3065c0ef67aSDaniel P. Berrangé    then
3075c0ef67aSDaniel P. Berrangé        echo
3085c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3095c0ef67aSDaniel P. Berrangé        echo
3105c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3115c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3125c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3135c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3145c0ef67aSDaniel P. Berrangé        echo
3155c0ef67aSDaniel P. Berrangé        echo "  https://www.qemu.org/download/"
3165c0ef67aSDaniel P. Berrangé        echo
3175c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3185c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3195c0ef67aSDaniel P. Berrangé        echo
3205c0ef67aSDaniel P. Berrangé        exit 1
3215c0ef67aSDaniel P. Berrangé    fi
32292712822SDaniel P. Berrangefi
323cc84d63aSDaniel P. Berrangegit="git"
324ac0df51dSaliguori
325afb63ebdSStefan Weil# Don't accept a target_list environment variable.
326afb63ebdSStefan Weilunset target_list
327377529c0SPaolo Bonzini
328377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
329377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
330377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
331377529c0SPaolo Bonzini#              unless --disable-foo is given
332377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
333377529c0SPaolo Bonzini#              feature will searched for,
334377529c0SPaolo Bonzini#              if not found, configure exits with error
335377529c0SPaolo Bonzini#
336377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
337377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
338377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
339377529c0SPaolo Bonzini
340377529c0SPaolo Bonzinibluez=""
341377529c0SPaolo Bonzinibrlapi=""
342377529c0SPaolo Bonzinicurl=""
343377529c0SPaolo Bonzinicurses=""
344377529c0SPaolo Bonzinidocs=""
345377529c0SPaolo Bonzinifdt=""
34658952137SVincenzo Maffionenetmap="no"
347377529c0SPaolo Bonzinisdl=""
348ee8466d0SCole Robinsonsdlabi=""
349983eef5aSMeador Ingevirtfs=""
350fe8fc5aeSPaolo Bonzinimpath=""
351821601eaSJes Sorensenvnc="yes"
352377529c0SPaolo Bonzinisparse="no"
353377529c0SPaolo Bonzinivde=""
354377529c0SPaolo Bonzinivnc_sasl=""
355377529c0SPaolo Bonzinivnc_jpeg=""
356377529c0SPaolo Bonzinivnc_png=""
3576a021536SGerd Hoffmannxkbcommon=""
358377529c0SPaolo Bonzinixen=""
359d5b93ddfSAnthony PERARDxen_ctrl_version=""
36064a7ad6fSIan Campbellxen_pv_domain_build="no"
361eb6fda0fSAnthony PERARDxen_pci_passthrough=""
362377529c0SPaolo Bonzinilinux_aio=""
36347e98658SCorey Bryantcap_ng=""
364377529c0SPaolo Bonziniattr=""
3654f26f2b6SAvi Kivitylibattr=""
366377529c0SPaolo Bonzinixfs=""
367b3f6ea7eSPaolo Bonzinitcg="yes"
368a40161cbSPaolo Bonzinimembarrier=""
369d41a75a2SBradvhost_net="no"
370042cea27SGongleivhost_crypto="no"
3715e9be92dSNicholas Bellingervhost_scsi="no"
372fc0b9b0eSStefan Hajnoczivhost_vsock="no"
373e6a74868SMarc-André Lureauvhost_user=""
374d41a75a2SBradkvm="no"
375b0cb0a66SVincent Palatinhax="no"
376c97d6d2cSSergio Andres Gomez Del Realhvf="no"
377d661d9a4SJustin Terry (VM)whpx="no"
3782da776dbSMichael R. Hinesrdma=""
37921ab34c9SMarcel Apfelbaumpvrdma=""
380377529c0SPaolo Bonzinigprof="no"
381377529c0SPaolo Bonzinidebug_tcg="no"
382377529c0SPaolo Bonzinidebug="no"
383247724cbSMarc-André Lureausanitizers="no"
384b553a042SJohn Snowfortify_source=""
385377529c0SPaolo Bonzinistrip_opt="yes"
3869195b2c2SStefan Weiltcg_interpreter="no"
387377529c0SPaolo Bonzinibigendian="no"
388377529c0SPaolo Bonzinimingw32="no"
3891d728c39SBlue Swirlgcov="no"
3901d728c39SBlue Swirlgcov_tool="gcov"
391377529c0SPaolo BonziniEXESUF=""
39217969268SFam ZhengDSOSUF=".so"
39317969268SFam ZhengLDFLAGS_SHARED="-shared"
39417969268SFam Zhengmodules="no"
395377529c0SPaolo Bonziniprefix="/usr/local"
396377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
397528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
3983d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
399850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
400377529c0SPaolo Bonzinibindir="\${prefix}/bin"
4013aa5d2beSAlon Levylibdir="\${prefix}/lib"
4028bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
4030f94d6daSAlon Levyincludedir="\${prefix}/include"
404377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
405785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
406377529c0SPaolo Bonziniconfsuffix="/qemu"
407377529c0SPaolo Bonzinislirp="yes"
408377529c0SPaolo Bonzinioss_lib=""
409377529c0SPaolo Bonzinibsd="no"
410377529c0SPaolo Bonzinilinux="no"
411377529c0SPaolo Bonzinisolaris="no"
412377529c0SPaolo Bonziniprofiler="no"
413377529c0SPaolo Bonzinicocoa="no"
414377529c0SPaolo Bonzinisoftmmu="yes"
415377529c0SPaolo Bonzinilinux_user="no"
416377529c0SPaolo Bonzinibsd_user="no"
417377529c0SPaolo Bonziniblobs="yes"
418377529c0SPaolo Bonzinipkgversion=""
41940d6444eSAvi Kivitypie=""
4203556c233SPaolo Bonziniqom_cast_debug="yes"
421baf86d6bSPaolo Bonzinitrace_backends="log"
422377529c0SPaolo Bonzinitrace_file="trace"
423377529c0SPaolo Bonzinispice=""
424377529c0SPaolo Bonzinirbd=""
4257b02f544SMarc-André Lureausmartcard=""
4262b2325ffSGerd Hoffmannlibusb=""
42769354a83SHans de Goedeusb_redir=""
428da076ffeSGerd Hoffmannopengl=""
429014cb152SGerd Hoffmannopengl_dmabuf="no"
4305dd89908SRichard Hendersoncpuid_h="no"
43186583a07SLiam Merwickavx2_opt=""
4321ece9905SAlon Levyzlib="yes"
4338ca80760SRichard Hendersoncapstone=""
434b25c9dffSStefan Weillzo=""
435b25c9dffSStefan Weilsnappy=""
4366b383c08SPeter Wubzip2=""
437e8ef31a3SMichael Tokarevguest_agent=""
438d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
43950cbebb9SMichael Rothguest_agent_ntddscsi="no"
4409dacf32dSYossi Hindinguest_agent_msi=""
441d9840e25STomoki Sekiyamavss_win32_sdk=""
442d9840e25STomoki Sekiyamawin_sdk="no"
4434b1c11fdSDaniel P. Berrangewant_tools="yes"
444c589b249SRonnie Sahlberglibiscsi=""
4456542aa9cSPeter Lievenlibnfs=""
446519175a2SAlex Barcelocoroutine=""
44770c60c08SStefan Hajnoczicoroutine_pool=""
4487d992e4dSPeter Lievendebug_stack_usage="no"
449f0d92b56SLongpeng(Mike)crypto_afalg="no"
450f794573eSEduardo Otuboseccomp=""
451eb100396SBharata B Raoglusterfs=""
452d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4530c14fb47SBharata B Raoglusterfs_discard="no"
454df3a429aSNiels de Vosglusterfs_fallocate="no"
4557c815372SBharata B Raoglusterfs_zerofill="no"
456a4ccabcfSAnthony Liguorigtk=""
457925a0400SGerd Hoffmanngtk_gl="no"
458a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
459ddbb0d09SDaniel P. Berrangegnutls=""
46091bfcdb0SDaniel P. Berrangenettle=""
46191bfcdb0SDaniel P. Berrangegcrypt=""
4621f923c70SLongpeng(Mike)gcrypt_hmac="no"
463bbbf9bfbSStefan Weilvte=""
4649d9e1521SGerd Hoffmannvirglrenderer=""
465e91c793cSCole Robinsontpm="yes"
4660a12ec87SRichard W.M. Joneslibssh2=""
467ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
468a99d57bbSWanlong Gaonuma=""
4692847b469SFam Zhengtcmalloc="no"
4707b01cb97SAlexandre Derumierjemalloc="no"
471a6b1d4c0SChanglong Xiereplication="yes"
472da92c3ffSAshish Mittalvxhs=""
4732f740136SJeff Codybochs="yes"
4742f740136SJeff Codycloop="yes"
4752f740136SJeff Codydmg="yes"
4762f740136SJeff Codyqcow1="yes"
4772f740136SJeff Codyvdi="yes"
4782f740136SJeff Codyvvfat="yes"
4792f740136SJeff Codyqed="yes"
4802f740136SJeff Codyparallels="yes"
4812f740136SJeff Codysheepdog="yes"
482ed279a06SKlim Kireevlibxml2=""
48351a12b51SAlex Bennéedocker="no"
484ba59fb77SPaolo Bonzinidebug_mutex="no"
48517824406SJunyan Helibpmem=""
4863efac6ebSTomáš Golembiovskýlibudev="no"
487377529c0SPaolo Bonzini
488d75402b5SAlex Bennée# cross compilers defaults, can be overridden with --cross-cc-ARCH
489d75402b5SAlex Bennéecross_cc_aarch64="aarch64-linux-gnu-gcc"
490d422b2bcSAlex Bennéecross_cc_aarch64_be="$cross_cc_aarch64"
491d422b2bcSAlex Bennéecross_cc_cflags_aarch64_be="-mbig-endian"
492d75402b5SAlex Bennéecross_cc_arm="arm-linux-gnueabihf-gcc"
493d422b2bcSAlex Bennéecross_cc_cflags_armeb="-mbig-endian"
494716a507cSAlex Bennéecross_cc_i386="i386-pc-linux-gnu-gcc"
495716a507cSAlex Bennéecross_cc_cflags_i386=""
496d75402b5SAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
497d422b2bcSAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
498d75402b5SAlex Bennée
499d75402b5SAlex Bennéeenabled_cross_compilers=""
500d75402b5SAlex Bennée
501898be3e0SPeter Maydellsupported_cpu="no"
502898be3e0SPeter Maydellsupported_os="no"
503fb59dabdSPeter Maydellbogus_os="no"
5045a22ab71SYang Zhongmalloc_trim=""
505898be3e0SPeter Maydell
506ac0df51dSaliguori# parse CC options first
507ac0df51dSaliguorifor opt do
50889138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
509ac0df51dSaliguori  case "$opt" in
510ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
511ac0df51dSaliguori  ;;
5123d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
513ac0df51dSaliguori  ;;
51483f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
51583f73fceSTomoki Sekiyama  ;;
516ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
517ca4deeb1SPaolo Bonzini  ;;
5182ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5192ff6b91eSJuan Quintela  ;;
520de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
521e2a2ed06SJuan Quintela  ;;
52211cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
52311cde1c8SBruno Dominguez  ;;
524a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
525f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
526e2a2ed06SJuan Quintela  ;;
5275bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5285bc62e01SGerd Hoffmann  ;;
5295bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
5305bc62e01SGerd Hoffmann  ;;
531d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
532d75402b5SAlex Bennée  ;;
533d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
534d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
535d422b2bcSAlex Bennée  ;;
536d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
537d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
538d75402b5SAlex Bennée  ;;
539ac0df51dSaliguori  esac
540ac0df51dSaliguoridone
541ac0df51dSaliguori# OS specific
542ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
54393148aa5SStefan Weil# we can eliminate its usage altogether.
544ac0df51dSaliguori
545e49d021eSPeter Maydell# Preferred compiler:
546e49d021eSPeter Maydell#  ${CC} (if set)
547e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
548e49d021eSPeter Maydell#  system compiler
549e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
550e49d021eSPeter Maydell  cc="$host_cc"
551e49d021eSPeter Maydellelse
552b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
553e49d021eSPeter Maydellfi
554e49d021eSPeter Maydell
55583f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
55683f73fceSTomoki Sekiyama  cxx="c++"
55783f73fceSTomoki Sekiyamaelse
55883f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
55983f73fceSTomoki Sekiyamafi
56083f73fceSTomoki Sekiyama
561b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
562cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5635f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5643dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
565b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
566b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5679f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5684852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
569b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
570b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
57117884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
57217884d7bSSergei Trofimovichquery_pkg_config() {
57317884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
57417884d7bSSergei Trofimovich}
57517884d7bSSergei Trofimovichpkg_config=query_pkg_config
576b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
57747c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
578ac0df51dSaliguori
57945d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
58045d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
58145d285abSPeter Maydell
582be17dc90SMichael S. Tsirkin# default flags for all hosts
5832d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5842d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5852d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5862d31515bSPeter Maydell# provides these semantics.)
5872d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
588f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
589c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
590be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5919edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5925bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5935bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
594be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5955bc62e01SGerd Hoffmannfi
596be17dc90SMichael S. Tsirkin
597ca4deeb1SPaolo Bonzini# make source path absolute
59889138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
599ca4deeb1SPaolo Bonzini
600cab00a5aSMichael S. Tsirkin# running configure in the source tree?
601cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
602cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
603cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
604cab00a5aSMichael S. Tsirkinelse
605cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
606cab00a5aSMichael S. Tsirkinfi
607cab00a5aSMichael S. Tsirkin
608ac0df51dSaliguoricheck_define() {
609ac0df51dSaliguoricat > $TMPC <<EOF
610ac0df51dSaliguori#if !defined($1)
611fd786e1aSPeter Maydell#error $1 not defined
612ac0df51dSaliguori#endif
613ac0df51dSaliguoriint main(void) { return 0; }
614ac0df51dSaliguoriEOF
61552166aa0SJuan Quintela  compile_object
616ac0df51dSaliguori}
617ac0df51dSaliguori
618307119e7SGerd Hoffmanncheck_include() {
619307119e7SGerd Hoffmanncat > $TMPC <<EOF
620307119e7SGerd Hoffmann#include <$1>
621307119e7SGerd Hoffmannint main(void) { return 0; }
622307119e7SGerd HoffmannEOF
623307119e7SGerd Hoffmann  compile_object
624307119e7SGerd Hoffmann}
625307119e7SGerd Hoffmann
62693b25869SJohn Snowwrite_c_skeleton() {
62793b25869SJohn Snow    cat > $TMPC <<EOF
62893b25869SJohn Snowint main(void) { return 0; }
62993b25869SJohn SnowEOF
63093b25869SJohn Snow}
63193b25869SJohn Snow
632bbea4050SPeter Maydellif check_define __linux__ ; then
633bbea4050SPeter Maydell  targetos="Linux"
634bbea4050SPeter Maydellelif check_define _WIN32 ; then
635bbea4050SPeter Maydell  targetos='MINGW32'
636bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
637bbea4050SPeter Maydell  targetos='OpenBSD'
638bbea4050SPeter Maydellelif check_define __sun__ ; then
639bbea4050SPeter Maydell  targetos='SunOS'
640bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
641bbea4050SPeter Maydell  targetos='Haiku'
642951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
643951fedfcSPeter Maydell  targetos='FreeBSD'
644951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
645951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
646951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
647951fedfcSPeter Maydell  targetos='DragonFly'
648951fedfcSPeter Maydellelif check_define __NetBSD__; then
649951fedfcSPeter Maydell  targetos='NetBSD'
650951fedfcSPeter Maydellelif check_define __APPLE__; then
651951fedfcSPeter Maydell  targetos='Darwin'
652bbea4050SPeter Maydellelse
653951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
654951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
655951fedfcSPeter Maydell  # be the result of a missing compiler.
656951fedfcSPeter Maydell  targetos='bogus'
657951fedfcSPeter Maydell  bogus_os='yes'
658bbea4050SPeter Maydellfi
659bbea4050SPeter Maydell
660bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
661bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
662bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
663bbea4050SPeter Maydell# the correct CPU with the --cpu option.
664bbea4050SPeter Maydellcase $targetos in
665bbea4050SPeter MaydellDarwin)
666bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
667bbea4050SPeter Maydell  # run 64-bit userspace code.
668bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
669bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
670bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
671bbea4050SPeter Maydell    cpu="x86_64"
672bbea4050SPeter Maydell  fi
673bbea4050SPeter Maydell  ;;
674bbea4050SPeter MaydellSunOS)
67589138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
676bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
677bbea4050SPeter Maydell    cpu="x86_64"
678bbea4050SPeter Maydell  fi
679bbea4050SPeter Maydellesac
680bbea4050SPeter Maydell
6812ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6822ff6b91eSJuan Quintela  # command line argument
6832ff6b91eSJuan Quintela  :
6842ff6b91eSJuan Quintelaelif check_define __i386__ ; then
685ac0df51dSaliguori  cpu="i386"
686ac0df51dSaliguorielif check_define __x86_64__ ; then
687c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
688c72b26ecSRichard Henderson    cpu="x32"
689c72b26ecSRichard Henderson  else
690ac0df51dSaliguori    cpu="x86_64"
691c72b26ecSRichard Henderson  fi
6923aa9bd6cSblueswir1elif check_define __sparc__ ; then
6933aa9bd6cSblueswir1  if check_define __arch64__ ; then
6943aa9bd6cSblueswir1    cpu="sparc64"
6953aa9bd6cSblueswir1  else
6963aa9bd6cSblueswir1    cpu="sparc"
6973aa9bd6cSblueswir1  fi
698fdf7ed96Smalcelif check_define _ARCH_PPC ; then
699fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
700fdf7ed96Smalc    cpu="ppc64"
701ac0df51dSaliguori  else
702fdf7ed96Smalc    cpu="ppc"
703fdf7ed96Smalc  fi
704afa05235SAurelien Jarnoelif check_define __mips__ ; then
705afa05235SAurelien Jarno  cpu="mips"
706d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
707d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
708d66ed0eaSAurelien Jarno    cpu="s390x"
709d66ed0eaSAurelien Jarno  else
710d66ed0eaSAurelien Jarno    cpu="s390"
711d66ed0eaSAurelien Jarno  fi
71221d89f84SPeter Maydellelif check_define __arm__ ; then
71321d89f84SPeter Maydell  cpu="arm"
7141f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7151f080313SClaudio Fontana  cpu="aarch64"
716fdf7ed96Smalcelse
71789138857SStefan Weil  cpu=$(uname -m)
718ac0df51dSaliguorifi
719ac0df51dSaliguori
720359bc95dSPeter MaydellARCH=
721359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
722359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7237d13299dSbellardcase "$cpu" in
7246499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
725898be3e0SPeter Maydell    cpu="$cpu"
726898be3e0SPeter Maydell    supported_cpu="yes"
727d75402b5SAlex Bennée    eval "cross_cc_${cpu}=\$host_cc"
728898be3e0SPeter Maydell  ;;
7297d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
73097a847bcSbellard    cpu="i386"
731898be3e0SPeter Maydell    supported_cpu="yes"
732d75402b5SAlex Bennée    cross_cc_i386=$host_cc
7337d13299dSbellard  ;;
734aaa5fa14Saurel32  x86_64|amd64)
735aaa5fa14Saurel32    cpu="x86_64"
736898be3e0SPeter Maydell    supported_cpu="yes"
737d75402b5SAlex Bennée    cross_cc_x86_64=$host_cc
738aaa5fa14Saurel32  ;;
73921d89f84SPeter Maydell  armv*b|armv*l|arm)
74021d89f84SPeter Maydell    cpu="arm"
741898be3e0SPeter Maydell    supported_cpu="yes"
742d75402b5SAlex Bennée    cross_cc_arm=$host_cc
7437d13299dSbellard  ;;
7441f080313SClaudio Fontana  aarch64)
7451f080313SClaudio Fontana    cpu="aarch64"
746898be3e0SPeter Maydell    supported_cpu="yes"
747d75402b5SAlex Bennée    cross_cc_aarch64=$host_cc
7481f080313SClaudio Fontana  ;;
749afa05235SAurelien Jarno  mips*)
750afa05235SAurelien Jarno    cpu="mips"
751898be3e0SPeter Maydell    supported_cpu="yes"
752d75402b5SAlex Bennée    cross_cc_mips=$host_cc
753afa05235SAurelien Jarno  ;;
7543142255cSblueswir1  sparc|sun4[cdmuv])
755ae228531Sbellard    cpu="sparc"
7566499fd15SPeter Maydell    supported_cpu="yes"
757d75402b5SAlex Bennée    cross_cc_sparc=$host_cc
758ae228531Sbellard  ;;
7597d13299dSbellard  *)
760359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
761359bc95dSPeter Maydell    ARCH=unknown
7627d13299dSbellard  ;;
7637d13299dSbellardesac
764359bc95dSPeter Maydellif test -z "$ARCH"; then
765359bc95dSPeter Maydell  ARCH="$cpu"
766359bc95dSPeter Maydellfi
767e2d52ad3SJuan Quintela
7687d13299dSbellard# OS specific
7690dbfc675SJuan Quintela
770adfc3e91SStacey Son# host *BSD for user mode
771adfc3e91SStacey SonHOST_VARIANT_DIR=""
772adfc3e91SStacey Son
7737d13299dSbellardcase $targetos in
77467b915a5SbellardMINGW32*)
77567b915a5Sbellard  mingw32="yes"
776b0cb0a66SVincent Palatin  hax="yes"
7773cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
778307119e7SGerd Hoffmann  if check_include dsound.h; then
7793cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
780307119e7SGerd Hoffmann  else
781307119e7SGerd Hoffmann    audio_drv_list=""
782307119e7SGerd Hoffmann  fi
783898be3e0SPeter Maydell  supported_os="yes"
78467b915a5Sbellard;;
7855c40d2bdSthsGNU/kFreeBSD)
786a167ba50SAurelien Jarno  bsd="yes"
7870c58ac1cSmalc  audio_drv_list="oss"
7880bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7895c40d2bdSths;;
7907d3505c5SbellardFreeBSD)
7917d3505c5Sbellard  bsd="yes"
7920db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7930c58ac1cSmalc  audio_drv_list="oss"
7940bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
795f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
796f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
797a7764f15SEd Maste  # needed for kinfo_getproc
798a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
79958952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
800adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
801898be3e0SPeter Maydell  supported_os="yes"
8027d3505c5Sbellard;;
803c5e97233Sblueswir1DragonFly)
804c5e97233Sblueswir1  bsd="yes"
8050db4a067SPaolo Bonzini  make="${MAKE-gmake}"
806c5e97233Sblueswir1  audio_drv_list="oss"
8070bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
808adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
809c5e97233Sblueswir1;;
8107d3505c5SbellardNetBSD)
8117d3505c5Sbellard  bsd="yes"
8120db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8130c58ac1cSmalc  audio_drv_list="oss"
8140bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8158ef92a88Sblueswir1  oss_lib="-lossaudio"
816adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8173c2bdbc1SKamil Rytarowski  supported_os="yes"
8187d3505c5Sbellard;;
8197d3505c5SbellardOpenBSD)
8207d3505c5Sbellard  bsd="yes"
8210db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8224f6ab397SBrad Smith  audio_drv_list="sdl"
8230bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
824adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8250a773d55SBrad Smith  supported_os="yes"
8267d3505c5Sbellard;;
82783fb7adfSbellardDarwin)
82883fb7adfSbellard  bsd="yes"
82983fb7adfSbellard  darwin="yes"
830b0cb0a66SVincent Palatin  hax="yes"
831c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
83217969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8331b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
834a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
8350c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8361b0f9cc2Saliguori  fi
837fd677642Sths  cocoa="yes"
8380c58ac1cSmalc  audio_drv_list="coreaudio"
83914382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8400c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8417973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
842a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
843a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
844a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
845adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
846898be3e0SPeter Maydell  supported_os="yes"
84783fb7adfSbellard;;
848ec530c81SbellardSunOS)
849ec530c81Sbellard  solaris="yes"
8500db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8510db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
852e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8536b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8540c58ac1cSmalc    audio_drv_list="oss"
8556b4d2ba1Sths  fi
856c2de5c91Smalc  audio_possible_drivers="oss sdl"
857d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
858d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
859d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
860d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
861a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
862560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
863560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
864560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
865ec530c81Sbellard;;
866179cf400SAndreas FärberHaiku)
867179cf400SAndreas Färber  haiku="yes"
868179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
869179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
870179cf400SAndreas Färber;;
871898be3e0SPeter MaydellLinux)
8720c58ac1cSmalc  audio_drv_list="oss"
8730bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8745327cf48Sbellard  linux="yes"
875831b7825Sths  linux_user="yes"
876af2be207SJan Kiszka  kvm="yes"
877af2be207SJan Kiszka  vhost_net="yes"
878042cea27SGonglei  vhost_crypto="yes"
8795e9be92dSNicholas Bellinger  vhost_scsi="yes"
880fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
881e8d81a61SMao Zhongyi  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
882898be3e0SPeter Maydell  supported_os="yes"
8833efac6ebSTomáš Golembiovský  libudev="yes"
884898be3e0SPeter Maydell;;
8857d13299dSbellardesac
8867d13299dSbellard
8877d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
888b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
88984778508Sblueswir1    bsd_user="yes"
8907d3505c5Sbellard  fi
89108de3949SAndreas Färberfi
8927d3505c5Sbellard
8930db4a067SPaolo Bonzini: ${make=${MAKE-make}}
8940db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
89552510f8bSStefan Weil: ${python=${PYTHON-python}}
896e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8970db4a067SPaolo Bonzini
8983c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8993c4a4d0dSPeter Maydellif has clang; then
9003c4a4d0dSPeter Maydell  objcc=clang
9013c4a4d0dSPeter Maydellelse
9023c4a4d0dSPeter Maydell  objcc="$cc"
9033c4a4d0dSPeter Maydellfi
9043c4a4d0dSPeter Maydell
9053457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
9063457a3f8SJuan Quintela  EXESUF=".exe"
90717969268SFam Zheng  DSOSUF=".dll"
908a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
909e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
910e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
91178e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
91278e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
913f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
91493b25869SJohn Snow  write_c_skeleton;
915f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
916f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
917f7cf5d5bSStefan Weil  fi
918c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
919683035deSPaolo Bonzini  mandir="\${prefix}"
920528ae5b8SEduardo Habkost  datadir="\${prefix}"
921850da188SEduardo Habkost  qemu_docdir="\${prefix}"
922683035deSPaolo Bonzini  bindir="\${prefix}"
923683035deSPaolo Bonzini  sysconfdir="\${prefix}"
9245a699bbbSLaszlo Ersek  local_statedir=
925683035deSPaolo Bonzini  confsuffix=""
926105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9273457a3f8SJuan Quintelafi
9283457a3f8SJuan Quintela
929487fefdbSAnthony Liguoriwerror=""
93085aa5189Sbellard
9317d13299dSbellardfor opt do
93289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9337d13299dSbellard  case "$opt" in
9342efc3265Sbellard  --help|-h) show_help=yes
9352efc3265Sbellard  ;;
93699123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
93799123e13SMike Frysinger  ;;
938b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9397d13299dSbellard  ;;
940b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
94132ce6337Sbellard  ;;
942ca4deeb1SPaolo Bonzini  --source-path=*)
9437d13299dSbellard  ;;
944ac0df51dSaliguori  --cross-prefix=*)
9457d13299dSbellard  ;;
946ac0df51dSaliguori  --cc=*)
9477d13299dSbellard  ;;
948b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
94983469015Sbellard  ;;
95083f73fceSTomoki Sekiyama  --cxx=*)
95183f73fceSTomoki Sekiyama  ;;
952e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
953e007dbecSMichael S. Tsirkin  ;;
9543c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9553c4a4d0dSPeter Maydell  ;;
956b1a550a0Spbrook  --make=*) make="$optarg"
9577d13299dSbellard  ;;
9586a882643Spbrook  --install=*) install="$optarg"
9596a882643Spbrook  ;;
960c886edfbSBlue Swirl  --python=*) python="$optarg"
961c886edfbSBlue Swirl  ;;
9621d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9631d728c39SBlue Swirl  ;;
964e2d8830eSBrad  --smbd=*) smbd="$optarg"
965e2d8830eSBrad  ;;
966e2a2ed06SJuan Quintela  --extra-cflags=*)
9677d13299dSbellard  ;;
96811cde1c8SBruno Dominguez  --extra-cxxflags=*)
96911cde1c8SBruno Dominguez  ;;
970e2a2ed06SJuan Quintela  --extra-ldflags=*)
9717d13299dSbellard  ;;
9725bc62e01SGerd Hoffmann  --enable-debug-info)
9735bc62e01SGerd Hoffmann  ;;
9745bc62e01SGerd Hoffmann  --disable-debug-info)
9755bc62e01SGerd Hoffmann  ;;
976d75402b5SAlex Bennée  --cross-cc-*)
977d75402b5SAlex Bennée  ;;
97817969268SFam Zheng  --enable-modules)
97917969268SFam Zheng      modules="yes"
98017969268SFam Zheng  ;;
9813aa88b31SStefan Hajnoczi  --disable-modules)
9823aa88b31SStefan Hajnoczi      modules="no"
9833aa88b31SStefan Hajnoczi  ;;
9842ff6b91eSJuan Quintela  --cpu=*)
9857d13299dSbellard  ;;
986b1a550a0Spbrook  --target-list=*) target_list="$optarg"
987de83cd02Sbellard  ;;
9885b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9895b808275SLluís Vilanova  ;;
9905b808275SLluís Vilanova  # XXX: backwards compatibility
9915b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
99294a420b1SStefan Hajnoczi  ;;
99374242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9949410b56cSPrerna Saxena  ;;
9957d13299dSbellard  --enable-gprof) gprof="yes"
9967d13299dSbellard  ;;
9971d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9981d728c39SBlue Swirl  ;;
99979427693SLoïc Minier  --static)
100079427693SLoïc Minier    static="yes"
100179427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
100217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
100343ce4dfeSbellard  ;;
10040b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
10050b24e75fSPaolo Bonzini  ;;
10060b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
10070b24e75fSPaolo Bonzini  ;;
10083aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10093aa5d2beSAlon Levy  ;;
10108bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10118bf188aaSMichael Tokarev  ;;
10120f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10130f94d6daSAlon Levy  ;;
1014528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10150b24e75fSPaolo Bonzini  ;;
1016023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1017023d3d67SEduardo Habkost  ;;
1018850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10190b24e75fSPaolo Bonzini  ;;
1020ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
102107381cc1SAnthony Liguori  ;;
1022785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1023785c23aeSLuiz Capitulino  ;;
10243d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10253d5eecabSGerd Hoffmann  ;;
1026181ce1d0SOlaf Hering  --host=*|--build=*|\
1027181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1028785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1029023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1030023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1031023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1032023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1033023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1034023ddd74SMax Filippov    # lots of directory switches by default.
1035023ddd74SMax Filippov  ;;
103697a847bcSbellard  --disable-sdl) sdl="no"
103797a847bcSbellard  ;;
1038c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1039c4198157SJuan Quintela  ;;
104047c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
104147c03744SDave Airlie  ;;
10423556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10433556c233SPaolo Bonzini  ;;
10443556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10453556c233SPaolo Bonzini  ;;
1046983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1047983eef5aSMeador Inge  ;;
1048983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1049983eef5aSMeador Inge  ;;
1050fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1051fe8fc5aeSPaolo Bonzini  ;;
1052fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1053fe8fc5aeSPaolo Bonzini  ;;
1054821601eaSJes Sorensen  --disable-vnc) vnc="no"
1055821601eaSJes Sorensen  ;;
1056821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1057821601eaSJes Sorensen  ;;
10582f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10592f6a1ab0Sblueswir1  ;;
10600c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10610c58ac1cSmalc  ;;
106289138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1063b64ec4e4SFam Zheng  ;;
106489138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1065eb852011SMarkus Armbruster  ;;
1066f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1067f8393946Saurel32  ;;
1068f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1069f8393946Saurel32  ;;
1070f3d08ee6SPaul Brook  --enable-debug)
1071f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1072f3d08ee6SPaul Brook      debug_tcg="yes"
10731fcc6d42SPeter Xu      debug_mutex="yes"
1074f3d08ee6SPaul Brook      debug="yes"
1075f3d08ee6SPaul Brook      strip_opt="no"
1076b553a042SJohn Snow      fortify_source="no"
1077f3d08ee6SPaul Brook  ;;
1078247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1079247724cbSMarc-André Lureau  ;;
1080247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1081247724cbSMarc-André Lureau  ;;
108203b4fe7dSaliguori  --enable-sparse) sparse="yes"
108303b4fe7dSaliguori  ;;
108403b4fe7dSaliguori  --disable-sparse) sparse="no"
108503b4fe7dSaliguori  ;;
10861625af87Saliguori  --disable-strip) strip_opt="no"
10871625af87Saliguori  ;;
10882f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
10892f9606b3Saliguori  ;;
1090ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1091ea784e3bSJuan Quintela  ;;
10922f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
10932f6f5c7aSCorentin Chary  ;;
10942f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
10952f6f5c7aSCorentin Chary  ;;
1096efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1097efe556adSCorentin Chary  ;;
1098efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1099efe556adSCorentin Chary  ;;
1100443f1376Sbellard  --disable-slirp) slirp="no"
1101c20709aaSbellard  ;;
1102e0e6c8c0Saliguori  --disable-vde) vde="no"
11038a16d273Sths  ;;
1104dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1105dfb278bdSJuan Quintela  ;;
110658952137SVincenzo Maffione  --disable-netmap) netmap="no"
110758952137SVincenzo Maffione  ;;
110858952137SVincenzo Maffione  --enable-netmap) netmap="yes"
110958952137SVincenzo Maffione  ;;
1110e37630caSaliguori  --disable-xen) xen="no"
1111e37630caSaliguori  ;;
1112fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1113fc321b4bSJuan Quintela  ;;
1114eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1115eb6fda0fSAnthony PERARD  ;;
1116eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1117eb6fda0fSAnthony PERARD  ;;
111864a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
111964a7ad6fSIan Campbell  ;;
112064a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
112164a7ad6fSIan Campbell  ;;
11222e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
11232e4d9fb1Saurel32  ;;
11244ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
11254ffcedb6SJuan Quintela  ;;
1126fb599c9aSbalrog  --disable-bluez) bluez="no"
1127fb599c9aSbalrog  ;;
1128a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1129a20a6f46SJuan Quintela  ;;
11307ba1e619Saliguori  --disable-kvm) kvm="no"
11317ba1e619Saliguori  ;;
1132b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1133b31a0277SJuan Quintela  ;;
1134b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1135180fb750Szhanghailiang  ;;
1136b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1137180fb750Szhanghailiang  ;;
1138c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1139c97d6d2cSSergio Andres Gomez Del Real  ;;
1140c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1141c97d6d2cSSergio Andres Gomez Del Real  ;;
1142d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1143d661d9a4SJustin Terry (VM)  ;;
1144d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1145d661d9a4SJustin Terry (VM)  ;;
11469195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11479195b2c2SStefan Weil  ;;
11489195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11499195b2c2SStefan Weil  ;;
115047e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
115147e98658SCorey Bryant  ;;
115247e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
115347e98658SCorey Bryant  ;;
1154b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1155b3f6ea7eSPaolo Bonzini  ;;
1156b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1157b3f6ea7eSPaolo Bonzini  ;;
11585a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11595a22ab71SYang Zhong  ;;
11605a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11615a22ab71SYang Zhong  ;;
1162cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1163cd4ec0b4SGerd Hoffmann  ;;
1164cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1165cd4ec0b4SGerd Hoffmann  ;;
1166c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1167c589b249SRonnie Sahlberg  ;;
1168c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1169c589b249SRonnie Sahlberg  ;;
11706542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11716542aa9cSPeter Lieven  ;;
11726542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11736542aa9cSPeter Lieven  ;;
117405c2a3e7Sbellard  --enable-profiler) profiler="yes"
117505c2a3e7Sbellard  ;;
117614821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
117714821030SPavel Borzenkov  ;;
1178c2de5c91Smalc  --enable-cocoa)
1179c2de5c91Smalc      cocoa="yes" ;
118089138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
11815b0753e0Sbellard  ;;
1182cad25d69Spbrook  --disable-system) softmmu="no"
11830a8e90f4Spbrook  ;;
1184cad25d69Spbrook  --enable-system) softmmu="yes"
11850a8e90f4Spbrook  ;;
11860953a80fSZachary Amsden  --disable-user)
11870953a80fSZachary Amsden      linux_user="no" ;
11880953a80fSZachary Amsden      bsd_user="no" ;
11890953a80fSZachary Amsden  ;;
11900953a80fSZachary Amsden  --enable-user) ;;
1191831b7825Sths  --disable-linux-user) linux_user="no"
11920a8e90f4Spbrook  ;;
1193831b7825Sths  --enable-linux-user) linux_user="yes"
1194831b7825Sths  ;;
119584778508Sblueswir1  --disable-bsd-user) bsd_user="no"
119684778508Sblueswir1  ;;
119784778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
119884778508Sblueswir1  ;;
119940d6444eSAvi Kivity  --enable-pie) pie="yes"
120034005a00SKirill A. Shutemov  ;;
120140d6444eSAvi Kivity  --disable-pie) pie="no"
120234005a00SKirill A. Shutemov  ;;
120385aa5189Sbellard  --enable-werror) werror="yes"
120485aa5189Sbellard  ;;
120585aa5189Sbellard  --disable-werror) werror="no"
120685aa5189Sbellard  ;;
120763678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
120863678e17SSteven Noonan  ;;
120963678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
121063678e17SSteven Noonan  ;;
12114d3b6f6eSbalrog  --disable-curses) curses="no"
12124d3b6f6eSbalrog  ;;
1213c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1214c584a6d0SJuan Quintela  ;;
1215769ce76dSAlexander Graf  --disable-curl) curl="no"
1216769ce76dSAlexander Graf  ;;
1217788c8196SJuan Quintela  --enable-curl) curl="yes"
1218788c8196SJuan Quintela  ;;
12192df87df7SJuan Quintela  --disable-fdt) fdt="no"
12202df87df7SJuan Quintela  ;;
12212df87df7SJuan Quintela  --enable-fdt) fdt="yes"
12222df87df7SJuan Quintela  ;;
12235c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12245c6c3a6cSChristoph Hellwig  ;;
12255c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12265c6c3a6cSChristoph Hellwig  ;;
1227758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1228758e8e38SVenkateswararao Jujjuri (JV)  ;;
1229758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1230758e8e38SVenkateswararao Jujjuri (JV)  ;;
1231a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1232a40161cbSPaolo Bonzini  ;;
1233a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1234a40161cbSPaolo Bonzini  ;;
123577755340Sths  --disable-blobs) blobs="no"
123677755340Sths  ;;
12377e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12384a19f1ecSpbrook  ;;
1239519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1240519175a2SAlex Barcelo  ;;
124170c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
124270c60c08SStefan Hajnoczi  ;;
124370c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
124470c60c08SStefan Hajnoczi  ;;
12457d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12467d992e4dSPeter Lieven  ;;
1247f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1248f0d92b56SLongpeng(Mike)  ;;
1249f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1250f0d92b56SLongpeng(Mike)  ;;
1251a25dba17SJuan Quintela  --disable-docs) docs="no"
125270ec5dc0SAnthony Liguori  ;;
1253a25dba17SJuan Quintela  --enable-docs) docs="yes"
125483a3ab8bSJuan Quintela  ;;
1255d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1256d5970055SMichael S. Tsirkin  ;;
1257d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1258d5970055SMichael S. Tsirkin  ;;
1259042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1260042cea27SGonglei  ;;
1261042cea27SGonglei  --enable-vhost-crypto)
1262042cea27SGonglei      vhost_crypto="yes"
1263042cea27SGonglei      if test "$mingw32" = "yes"; then
1264042cea27SGonglei          error_exit "vhost-crypto isn't available on win32"
1265042cea27SGonglei      fi
1266042cea27SGonglei  ;;
12675e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12685e9be92dSNicholas Bellinger  ;;
12695e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12705e9be92dSNicholas Bellinger  ;;
1271fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1272fc0b9b0eSStefan Hajnoczi  ;;
1273fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1274fc0b9b0eSStefan Hajnoczi  ;;
1275da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
127620ff075bSMichael Walle  ;;
1277da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
127820ff075bSMichael Walle  ;;
1279f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1280f27aaf4bSChristian Brunner  ;;
1281f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1282f27aaf4bSChristian Brunner  ;;
12838c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12848c84cf11SSergei Trofimovich  ;;
12858c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12868c84cf11SSergei Trofimovich  ;;
12877b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1288111a38b0SRobert Relyea  ;;
12897b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1290111a38b0SRobert Relyea  ;;
12912b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
12922b2325ffSGerd Hoffmann  ;;
12932b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
12942b2325ffSGerd Hoffmann  ;;
129569354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
129669354a83SHans de Goede  ;;
129769354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
129869354a83SHans de Goede  ;;
12991ece9905SAlon Levy  --disable-zlib-test) zlib="no"
13001ece9905SAlon Levy  ;;
1301b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1302b25c9dffSStefan Weil  ;;
1303607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1304607dacd0Sqiaonuohan  ;;
1305b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1306b25c9dffSStefan Weil  ;;
1307607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1308607dacd0Sqiaonuohan  ;;
13096b383c08SPeter Wu  --disable-bzip2) bzip2="no"
13106b383c08SPeter Wu  ;;
13116b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13126b383c08SPeter Wu  ;;
1313d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1314d138cee9SMichael Roth  ;;
1315d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1316d138cee9SMichael Roth  ;;
13179dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13189dacf32dSYossi Hindin  ;;
13199dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13209dacf32dSYossi Hindin  ;;
1321d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1322d9840e25STomoki Sekiyama  ;;
1323d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1324d9840e25STomoki Sekiyama  ;;
1325d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1326d9840e25STomoki Sekiyama  ;;
1327d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1328d9840e25STomoki Sekiyama  ;;
1329d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1330d9840e25STomoki Sekiyama  ;;
1331d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1332d9840e25STomoki Sekiyama  ;;
13334b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13344b1c11fdSDaniel P. Berrange  ;;
13354b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13364b1c11fdSDaniel P. Berrange  ;;
1337f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1338f794573eSEduardo Otubo  ;;
1339f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1340f794573eSEduardo Otubo  ;;
1341eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1342eb100396SBharata B Rao  ;;
134386583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
134486583a07SLiam Merwick  ;;
134586583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
134686583a07SLiam Merwick  ;;
1347eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1348eb100396SBharata B Rao  ;;
134952b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
135052b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1351583f6e7bSStefan Hajnoczi  ;;
1352cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1353cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1354cb6414dfSFam Zheng  ;;
1355315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1356315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1357315d3184SFam Zheng  ;;
1358a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1359a4ccabcfSAnthony Liguori  ;;
1360a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1361a4ccabcfSAnthony Liguori  ;;
1362a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1363a1c5e949SDaniel P. Berrange  ;;
1364ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1365ddbb0d09SDaniel P. Berrange  ;;
1366ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1367ddbb0d09SDaniel P. Berrange  ;;
136891bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
136991bfcdb0SDaniel P. Berrange  ;;
137091bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
137191bfcdb0SDaniel P. Berrange  ;;
137291bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
137391bfcdb0SDaniel P. Berrange  ;;
137491bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
137591bfcdb0SDaniel P. Berrange  ;;
13762da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13772da776dbSMichael R. Hines  ;;
13782da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13792da776dbSMichael R. Hines  ;;
138021ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
138121ab34c9SMarcel Apfelbaum  ;;
138221ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
138321ab34c9SMarcel Apfelbaum  ;;
1384bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1385bbbf9bfbSStefan Weil  ;;
1386bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1387bbbf9bfbSStefan Weil  ;;
13889d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
13899d9e1521SGerd Hoffmann  ;;
13909d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
13919d9e1521SGerd Hoffmann  ;;
1392e91c793cSCole Robinson  --disable-tpm) tpm="no"
1393e91c793cSCole Robinson  ;;
1394ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1395ab214c29SStefan Berger  ;;
13960a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
13970a12ec87SRichard W.M. Jones  ;;
13980a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
13990a12ec87SRichard W.M. Jones  ;;
1400ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1401ed1701c6SDr. David Alan Gilbert  ;;
1402ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1403ed1701c6SDr. David Alan Gilbert  ;;
1404a99d57bbSWanlong Gao  --disable-numa) numa="no"
1405a99d57bbSWanlong Gao  ;;
1406a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1407a99d57bbSWanlong Gao  ;;
1408ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1409ed279a06SKlim Kireev  ;;
1410ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1411ed279a06SKlim Kireev  ;;
14122847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14132847b469SFam Zheng  ;;
14142847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14152847b469SFam Zheng  ;;
14167b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14177b01cb97SAlexandre Derumier  ;;
14187b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14197b01cb97SAlexandre Derumier  ;;
1420a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1421a6b1d4c0SChanglong Xie  ;;
1422a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1423a6b1d4c0SChanglong Xie  ;;
1424da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1425da92c3ffSAshish Mittal  ;;
1426da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1427da92c3ffSAshish Mittal  ;;
14282f740136SJeff Cody  --disable-bochs) bochs="no"
14292f740136SJeff Cody  ;;
14302f740136SJeff Cody  --enable-bochs) bochs="yes"
14312f740136SJeff Cody  ;;
14322f740136SJeff Cody  --disable-cloop) cloop="no"
14332f740136SJeff Cody  ;;
14342f740136SJeff Cody  --enable-cloop) cloop="yes"
14352f740136SJeff Cody  ;;
14362f740136SJeff Cody  --disable-dmg) dmg="no"
14372f740136SJeff Cody  ;;
14382f740136SJeff Cody  --enable-dmg) dmg="yes"
14392f740136SJeff Cody  ;;
14402f740136SJeff Cody  --disable-qcow1) qcow1="no"
14412f740136SJeff Cody  ;;
14422f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14432f740136SJeff Cody  ;;
14442f740136SJeff Cody  --disable-vdi) vdi="no"
14452f740136SJeff Cody  ;;
14462f740136SJeff Cody  --enable-vdi) vdi="yes"
14472f740136SJeff Cody  ;;
14482f740136SJeff Cody  --disable-vvfat) vvfat="no"
14492f740136SJeff Cody  ;;
14502f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14512f740136SJeff Cody  ;;
14522f740136SJeff Cody  --disable-qed) qed="no"
14532f740136SJeff Cody  ;;
14542f740136SJeff Cody  --enable-qed) qed="yes"
14552f740136SJeff Cody  ;;
14562f740136SJeff Cody  --disable-parallels) parallels="no"
14572f740136SJeff Cody  ;;
14582f740136SJeff Cody  --enable-parallels) parallels="yes"
14592f740136SJeff Cody  ;;
14602f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14612f740136SJeff Cody  ;;
14622f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14632f740136SJeff Cody  ;;
1464e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1465e6a74868SMarc-André Lureau  ;;
1466e6a74868SMarc-André Lureau  --enable-vhost-user)
1467e6a74868SMarc-André Lureau      vhost_user="yes"
1468e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1469e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1470e6a74868SMarc-André Lureau      fi
1471e6a74868SMarc-André Lureau  ;;
14728ca80760SRichard Henderson  --disable-capstone) capstone="no"
14738ca80760SRichard Henderson  ;;
14748ca80760SRichard Henderson  --enable-capstone) capstone="yes"
14758ca80760SRichard Henderson  ;;
1476e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1477e219c499SRichard Henderson  ;;
1478e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1479e219c499SRichard Henderson  ;;
1480cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1481cc84d63aSDaniel P. Berrange  ;;
1482f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1483f62bbee5SDaniel P. Berrange  ;;
1484f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1485f62bbee5SDaniel P. Berrange  ;;
1486ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1487ba59fb77SPaolo Bonzini  ;;
1488ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1489ba59fb77SPaolo Bonzini  ;;
149017824406SJunyan He  --enable-libpmem) libpmem=yes
149117824406SJunyan He  ;;
149217824406SJunyan He  --disable-libpmem) libpmem=no
149317824406SJunyan He  ;;
14942d2ad6d0SFam Zheng  *)
14952d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
14962d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
14972d2ad6d0SFam Zheng      exit 1
14987f1559c6Sbalrog  ;;
14997d13299dSbellard  esac
15007d13299dSbellarddone
15017d13299dSbellard
1502e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1503e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1504e6a74868SMarc-André Lureau        vhost_user="no"
1505e6a74868SMarc-André Lureau    else
1506e6a74868SMarc-André Lureau        vhost_user="yes"
1507e6a74868SMarc-André Lureau    fi
1508e6a74868SMarc-André Lureaufi
1509e6a74868SMarc-André Lureau
151040293e58Sbellardcase "$cpu" in
1511e3608d66SRichard Henderson    ppc)
1512e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1513e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
151413a5abe2SAlex Bennée           cross_cc_powerpc=$cc
151513a5abe2SAlex Bennée           cross_cc_cflags_powerpc=$CPU_CFLAGS
1516e3608d66SRichard Henderson           ;;
1517e3608d66SRichard Henderson    ppc64)
1518e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1519e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
152013a5abe2SAlex Bennée           cross_cc_ppc64=$cc
152113a5abe2SAlex Bennée           cross_cc_cflags_ppc64=$CPU_CFLAGS
1522e3608d66SRichard Henderson           ;;
15239b9c37c3SRichard Henderson    sparc)
1524f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1525f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
152613a5abe2SAlex Bennée           cross_cc_sparc=$cc
152713a5abe2SAlex Bennée           cross_cc_cflags_sparc=$CPU_CFLAGS
15283142255cSblueswir1           ;;
1529ed968ff1SJuan Quintela    sparc64)
153079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1531f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
153213a5abe2SAlex Bennée           cross_cc_sparc64=$cc
153313a5abe2SAlex Bennée           cross_cc_cflags_sparc64=$CPU_CFLAGS
15343142255cSblueswir1           ;;
153576d83bdeSths    s390)
1536061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
153728d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
153813a5abe2SAlex Bennée           cross_cc_s390=$cc
153913a5abe2SAlex Bennée           cross_cc_cflags_s390=$CPU_CFLAGS
154028d7cc49SRichard Henderson           ;;
154128d7cc49SRichard Henderson    s390x)
1542061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
154328d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
154413a5abe2SAlex Bennée           cross_cc_s390x=$cc
154513a5abe2SAlex Bennée           cross_cc_cflags_s390x=$CPU_CFLAGS
154676d83bdeSths           ;;
154740293e58Sbellard    i386)
154879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
15490c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
1550716a507cSAlex Bennée           cross_cc_i386=$cc
1551716a507cSAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
155240293e58Sbellard           ;;
155340293e58Sbellard    x86_64)
15547ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15557ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
15567ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
15577ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
15580c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
1559716a507cSAlex Bennée           cross_cc_x86_64=$cc
1560716a507cSAlex Bennée           cross_cc_cflags_x86_64=$CPU_CFLAGS
1561379f6698SPaul Brook           ;;
1562c72b26ecSRichard Henderson    x32)
1563c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1564c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1565716a507cSAlex Bennée           cross_cc_i386=$cc
156613a5abe2SAlex Bennée           cross_cc_cflags_i386=$CPU_CFLAGS
1567c72b26ecSRichard Henderson           ;;
156830163d89SPeter Maydell    # No special flags required for other host CPUs
15693142255cSblueswir1esac
15703142255cSblueswir1
157179f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
157279f3b12fSPeter Crosthwaite
1573affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1574affc88ccSPeter Maydell# support, even if we're using TCI.
1575affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1576affc88ccSPeter Maydell  bsd_user="no"
1577affc88ccSPeter Maydell  linux_user="no"
1578affc88ccSPeter Maydellfi
1579affc88ccSPeter Maydell
158060e0df25SPeter Maydelldefault_target_list=""
158160e0df25SPeter Maydell
15826e92f823SPeter Maydellmak_wilds=""
15836e92f823SPeter Maydell
158460e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
15856e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
158660e0df25SPeter Maydellfi
158760e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
15886e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
158960e0df25SPeter Maydellfi
159060e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
15916e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
159260e0df25SPeter Maydellfi
159360e0df25SPeter Maydell
15946e92f823SPeter Maydellfor config in $mak_wilds; do
15956e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
15966e92f823SPeter Maydelldone
15976e92f823SPeter Maydell
1598c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
159964a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1600c53eeaf7SStefan Hajnoczi
1601af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1602af5db58eSpbrookcat << EOF
1603af5db58eSpbrook
1604af5db58eSpbrookUsage: configure [options]
1605af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1606af5db58eSpbrook
160708fb77edSStefan WeilStandard options:
160808fb77edSStefan Weil  --help                   print this message
160908fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
161008fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
161108fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
161208fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
161308fb77edSStefan Weil$(echo Available targets: $default_target_list | \
161408fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
161508fb77edSStefan Weil
161608fb77edSStefan WeilAdvanced options (experts only):
161708fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
161808fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
161908fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
162008fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
162108fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
162208fb77edSStefan Weil                           build time
162308fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
162408fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
162508fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
162611cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
162708fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1628d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1629d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
163008fb77edSStefan Weil  --make=MAKE              use specified make [$make]
163108fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
163208fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
163308fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1634db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
163508fb77edSStefan Weil  --static                 enable static build [$static]
163608fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
163708fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
163808fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
163908fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
164008fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1641db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
164208fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
164308fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
16443d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1645e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1646db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
164708fb77edSStefan Weil  --enable-debug           enable common debug build options
1648247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
164908fb77edSStefan Weil  --disable-strip          disable stripping binaries
165008fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
165163678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
165208fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
165308fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
165408fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
165508fb77edSStefan Weil  --block-drv-rw-whitelist=L
165608fb77edSStefan Weil                           set block driver read-write whitelist
165708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
165808fb77edSStefan Weil  --block-drv-ro-whitelist=L
165908fb77edSStefan Weil                           set block driver read-only whitelist
166008fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
16615b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1662c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
166308fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
166408fb77edSStefan Weil                           Default:trace-<pid>
1665c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1666c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
16675a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1668c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1669c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
167008fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
167133c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
167208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
167308fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1674c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1675c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1676c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1677a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1678c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1679c12d66aaSLin Ma  --enable-profiler        profiler support
1680c12d66aaSLin Ma  --enable-xen-pv-domain-build
1681c12d66aaSLin Ma                           xen pv domain builder
1682c12d66aaSLin Ma  --enable-debug-stack-usage
1683c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1684c23f23b9SMichael Tokarev
1685c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1686c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1687c23f23b9SMichael Tokarev
1688c23f23b9SMichael Tokarev  system          all system emulation targets
1689c23f23b9SMichael Tokarev  user            supported user emulation targets
1690c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1691c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1692c23f23b9SMichael Tokarev  docs            build documentation
1693c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1694c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1695c23f23b9SMichael Tokarev  pie             Position Independent Executables
1696c23f23b9SMichael Tokarev  modules         modules support
1697c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1698c23f23b9SMichael Tokarev  debug-info      debugging information
1699c23f23b9SMichael Tokarev  sparse          sparse checker
1700c23f23b9SMichael Tokarev
1701ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
170291bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
170391bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1704c23f23b9SMichael Tokarev  sdl             SDL UI
1705c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1706c23f23b9SMichael Tokarev  gtk             gtk UI
1707c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1708c23f23b9SMichael Tokarev  curses          curses UI
1709c23f23b9SMichael Tokarev  vnc             VNC UI support
1710c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1711c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1712c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1713c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1714c23f23b9SMichael Tokarev  virtfs          VirtFS
1715fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1716c23f23b9SMichael Tokarev  xen             xen backend driver support
171770c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1718c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1719c23f23b9SMichael Tokarev  curl            curl connectivity
1720a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1721c23f23b9SMichael Tokarev  fdt             fdt device tree
1722c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1723c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1724b0cb0a66SVincent Palatin  hax             HAX acceleration support
1725c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1726d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
172721ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
172821ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1729c23f23b9SMichael Tokarev  vde             support for vde network
1730c23f23b9SMichael Tokarev  netmap          support for netmap network
1731c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1732c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1733c23f23b9SMichael Tokarev  attr            attr and xattr support
1734c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1735042cea27SGonglei  vhost-crypto    vhost-crypto acceleration support
1736c23f23b9SMichael Tokarev  spice           spice
1737c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1738c23f23b9SMichael Tokarev  libiscsi        iscsi support
1739c23f23b9SMichael Tokarev  libnfs          nfs support
17407b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1741c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1742ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1743c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1744c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1745c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1746c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1747c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1748c23f23b9SMichael Tokarev  seccomp         seccomp support
1749c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1750c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1751c23f23b9SMichael Tokarev  tpm             TPM support
1752c23f23b9SMichael Tokarev  libssh2         ssh block device support
1753c23f23b9SMichael Tokarev  numa            libnuma support
1754ed279a06SKlim Kireev  libxml2         for Parallels image format
1755c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
17567b01cb97SAlexandre Derumier  jemalloc        jemalloc support
175786583a07SLiam Merwick  avx2            AVX2 optimization support
1758a6b1d4c0SChanglong Xie  replication     replication support
1759c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1760c12d66aaSLin Ma  opengl          opengl support
1761c12d66aaSLin Ma  virglrenderer   virgl rendering support
1762c12d66aaSLin Ma  xfsctl          xfsctl support
1763c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1764c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1765da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
17662f740136SJeff Cody  bochs           bochs image format support
17672f740136SJeff Cody  cloop           cloop image format support
17682f740136SJeff Cody  dmg             dmg image format support
17692f740136SJeff Cody  qcow1           qcow v1 image format support
17702f740136SJeff Cody  vdi             vdi image format support
17712f740136SJeff Cody  vvfat           vvfat image format support
17722f740136SJeff Cody  qed             qed image format support
17732f740136SJeff Cody  parallels       parallels image format support
17742f740136SJeff Cody  sheepdog        sheepdog block driver support
1775f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1776e6a74868SMarc-André Lureau  vhost-user      vhost-user support
17778ca80760SRichard Henderson  capstone        capstone disassembler support
1778ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
177917824406SJunyan He  libpmem         libpmem support
178008fb77edSStefan Weil
178108fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1782af5db58eSpbrookEOF
17832d2ad6d0SFam Zhengexit 0
1784af5db58eSpbrookfi
1785af5db58eSpbrook
1786c53eeaf7SStefan Hajnocziif ! has $python; then
1787c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1788c53eeaf7SStefan Hajnoczifi
1789c53eeaf7SStefan Hajnoczi
1790c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1791c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
17927f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
17937f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1794c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1795c53eeaf7SStefan Hajnoczifi
1796c53eeaf7SStefan Hajnoczi
1797c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1798c53eeaf7SStefan Hajnoczipython="$python -B"
1799c53eeaf7SStefan Hajnoczi
18009aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
18019aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
18029aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
18039aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
18049aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
18059aae6e54SDaniel Henrique Barbozaif compile_object ; then
18069aae6e54SDaniel Henrique Barboza  : C compiler works ok
18079aae6e54SDaniel Henrique Barbozaelse
18089aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
18099aae6e54SDaniel Henrique Barbozafi
18109aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
18119aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
18129aae6e54SDaniel Henrique Barbozafi
18139aae6e54SDaniel Henrique Barboza
1814359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1815359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1816359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1817359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1818359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1819359bc95dSPeter Maydell    else
182076ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1821359bc95dSPeter Maydell    fi
1822359bc95dSPeter Maydellfi
1823359bc95dSPeter Maydell
18249c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
18259c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
18269c83ffd8SPeter Maydellif test -z "$werror" ; then
18279c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1828e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
18299c83ffd8SPeter Maydell        werror="yes"
18309c83ffd8SPeter Maydell    else
18319c83ffd8SPeter Maydell        werror="no"
18329c83ffd8SPeter Maydell    fi
18339c83ffd8SPeter Maydellfi
18349c83ffd8SPeter Maydell
1835fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1836fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1837fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1838fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1839fb59dabdSPeter Maydell    # host OS we should stop now.
1840951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1841fb59dabdSPeter Maydellfi
1842fb59dabdSPeter Maydell
1843efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1844efc6c070SThomas Huthcat > $TMPC << EOF
1845efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1846efc6c070SThomas Huth# ifdef __apple_build_version__
1847efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1848efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
1849efc6c070SThomas Huth#  endif
1850efc6c070SThomas Huth# else
1851efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1852efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
1853efc6c070SThomas Huth#  endif
1854efc6c070SThomas Huth# endif
1855efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1856efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1857efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
1858efc6c070SThomas Huth# endif
1859efc6c070SThomas Huth#else
1860efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1861efc6c070SThomas Huth#endif
1862efc6c070SThomas Huthint main (void) { return 0; }
1863efc6c070SThomas HuthEOF
1864efc6c070SThomas Huthif ! compile_prog "" "" ; then
1865efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1866efc6c070SThomas Huthfi
1867efc6c070SThomas Huth
18688d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
18698d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1870ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1871435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1872b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
187371429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
18740e39c4aaSGerd Hoffmanngcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
18756ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
18766ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
18776ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
18786ca026cbSPeter Maydell# so it's too error prone.
187993b25869SJohn Snow
188093b25869SJohn Snowcc_has_warning_flag() {
188193b25869SJohn Snow    write_c_skeleton;
188293b25869SJohn Snow
1883a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1884a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1885a1d29d6cSPeter Maydell    # warning options).
188693b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
188793b25869SJohn Snow    compile_prog "-Werror $optflag" ""
188893b25869SJohn Snow}
188993b25869SJohn Snow
189093b25869SJohn Snowfor flag in $gcc_flags; do
189193b25869SJohn Snow    if cc_has_warning_flag $flag ; then
18928d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
18938d05095cSPaolo Bonzini    fi
18948d05095cSPaolo Bonzinidone
18958d05095cSPaolo Bonzini
189663678e17SSteven Noonanif test "$stack_protector" != "no"; then
1897fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1898fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1899fccd35a0SRodrigo Rebello{
1900fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1901fccd35a0SRodrigo Rebello    while (*c) {
1902fccd35a0SRodrigo Rebello        *p++ = *c++;
1903fccd35a0SRodrigo Rebello    }
1904fccd35a0SRodrigo Rebello    return 0;
1905fccd35a0SRodrigo Rebello}
1906fccd35a0SRodrigo RebelloEOF
190763678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
19083b463a3fSMiroslav Rezanina  sp_on=0
190963678e17SSteven Noonan  for flag in $gcc_flags; do
1910590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1911590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1912590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1913590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
191463678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19153b463a3fSMiroslav Rezanina      sp_on=1
191663678e17SSteven Noonan      break
191763678e17SSteven Noonan    fi
191863678e17SSteven Noonan  done
19193b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
19203b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
19213b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
19223b463a3fSMiroslav Rezanina    fi
19233b463a3fSMiroslav Rezanina  fi
192437746c5eSMarc-André Lureaufi
192537746c5eSMarc-André Lureau
192620bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
192720bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
192820bc94a2SPaolo Bonzinicat > $TMPC << EOF
192920bc94a2SPaolo Bonzinistruct {
193020bc94a2SPaolo Bonzini  int a[2];
193120bc94a2SPaolo Bonzini} x = {0};
193220bc94a2SPaolo BonziniEOF
193320bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
193420bc94a2SPaolo Bonzini  :
193520bc94a2SPaolo Bonzinielse
193620bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
193720bc94a2SPaolo Bonzinifi
193820bc94a2SPaolo Bonzini
1939*d376e9deSThomas Huth# Static linking is not possible with modules or PIE
194040d6444eSAvi Kivityif test "$static" = "yes" ; then
1941aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1942aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1943aa0d1f44SPaolo Bonzini  fi
194440d6444eSAvi Kivity  if test "$pie" = "yes" ; then
194576ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
194640d6444eSAvi Kivity  else
194740d6444eSAvi Kivity    pie="no"
194840d6444eSAvi Kivity  fi
194940d6444eSAvi Kivityfi
195040d6444eSAvi Kivity
1951768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1952768b7855SEmilio G. Cota  cat > $TMPC << EOF
1953768b7855SEmilio G. Cotastatic __thread int tls_var;
1954768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1955768b7855SEmilio G. CotaEOF
1956768b7855SEmilio G. Cota
1957768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1958768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1959768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1960768b7855SEmilio G. Cotafi
1961768b7855SEmilio G. Cota
196240d6444eSAvi Kivityif test "$pie" = ""; then
196340d6444eSAvi Kivity  case "$cpu-$targetos" in
1964c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
196540d6444eSAvi Kivity      ;;
196640d6444eSAvi Kivity    *)
196740d6444eSAvi Kivity      pie="no"
196840d6444eSAvi Kivity      ;;
196940d6444eSAvi Kivity  esac
197040d6444eSAvi Kivityfi
197140d6444eSAvi Kivity
197240d6444eSAvi Kivityif test "$pie" != "no" ; then
197340d6444eSAvi Kivity  cat > $TMPC << EOF
197421d4a791SAvi Kivity
197521d4a791SAvi Kivity#ifdef __linux__
197621d4a791SAvi Kivity#  define THREAD __thread
197721d4a791SAvi Kivity#else
197821d4a791SAvi Kivity#  define THREAD
197921d4a791SAvi Kivity#endif
198021d4a791SAvi Kivity
198121d4a791SAvi Kivitystatic THREAD int tls_var;
198221d4a791SAvi Kivity
198321d4a791SAvi Kivityint main(void) { return tls_var; }
198421d4a791SAvi Kivity
198540d6444eSAvi KivityEOF
198640d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
198740d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
198840d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
198940d6444eSAvi Kivity    pie="yes"
199040d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
199140d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
199240d6444eSAvi Kivity    fi
199340d6444eSAvi Kivity  else
199440d6444eSAvi Kivity    if test "$pie" = "yes"; then
199576ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
199640d6444eSAvi Kivity    else
199740d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
199840d6444eSAvi Kivity      pie="no"
199940d6444eSAvi Kivity    fi
200040d6444eSAvi Kivity  fi
200146eef33bSBrad
2002e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
200346eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
200446eef33bSBrad    LDFLAGS_NOPIE="-nopie"
200546eef33bSBrad  fi
200640d6444eSAvi Kivityfi
200740d6444eSAvi Kivity
200809dada40SPaolo Bonzini##########################################
200909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
201009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
201109dada40SPaolo Bonzini# specification is necessary
201209dada40SPaolo Bonzini
201309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
201409dada40SPaolo Bonzini  cat > $TMPC << EOF
201509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
201609dada40SPaolo Bonzini{
201709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
201809dada40SPaolo Bonzini}
201909dada40SPaolo Bonzini
202009dada40SPaolo Bonziniint main(void)
202109dada40SPaolo Bonzini{
202209dada40SPaolo Bonzini  int val = 42;
20231405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
202409dada40SPaolo Bonzini  sfaa(&val);
202509dada40SPaolo Bonzini  return val;
202609dada40SPaolo Bonzini}
202709dada40SPaolo BonziniEOF
202809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
202909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
203009dada40SPaolo Bonzini  fi
203109dada40SPaolo Bonzinifi
203209dada40SPaolo Bonzini
203309dada40SPaolo Bonzini#########################################
2034ec530c81Sbellard# Solaris specific configure tool chain decisions
203509dada40SPaolo Bonzini
2036ec530c81Sbellardif test "$solaris" = "yes" ; then
20376792aa11SLoïc Minier  if has $install; then
20386792aa11SLoïc Minier    :
20396792aa11SLoïc Minier  else
204076ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
204176ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
204276ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2043ec530c81Sbellard  fi
204489138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
204576ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
204676ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
204776ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2048ec530c81Sbellard  fi
20496792aa11SLoïc Minier  if has ar; then
20506792aa11SLoïc Minier    :
20516792aa11SLoïc Minier  else
2052ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
205376ad07a4SPeter Maydell      error_exit "No path includes ar" \
205476ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2055ec530c81Sbellard    fi
205676ad07a4SPeter Maydell    error_exit "No path includes ar"
2057ec530c81Sbellard  fi
2058ec530c81Sbellardfi
2059ec530c81Sbellard
2060afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2061d880a3baSPaolo Bonzini    for target in $default_target_list; do
2062d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2063d880a3baSPaolo Bonzini            target_list="$target_list $target"
2064d880a3baSPaolo Bonzini    done
2065d880a3baSPaolo Bonzini    target_list="${target_list# }"
2066121afa9eSAnthony Liguorielse
206789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2068d880a3baSPaolo Bonzini    for target in $target_list; do
206925b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
207025b48338SPeter Maydell        # friendly error message than if we let it fall through.
207125b48338SPeter Maydell        case " $default_target_list " in
207225b48338SPeter Maydell            *" $target "*)
207325b48338SPeter Maydell                ;;
207425b48338SPeter Maydell            *)
207525b48338SPeter Maydell                error_exit "Unknown target name '$target'"
207625b48338SPeter Maydell                ;;
207725b48338SPeter Maydell        esac
2078d880a3baSPaolo Bonzini        supported_target $target || exit 1
207925b48338SPeter Maydell    done
2080d880a3baSPaolo Bonzinifi
208125b48338SPeter Maydell
2082f55fe278SPaolo Bonzini# see if system emulation was really requested
2083f55fe278SPaolo Bonzinicase " $target_list " in
2084f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2085f55fe278SPaolo Bonzini  ;;
2086f55fe278SPaolo Bonzini  *) softmmu=no
2087f55fe278SPaolo Bonzini  ;;
2088f55fe278SPaolo Bonziniesac
20895327cf48Sbellard
2090249247c9SJuan Quintelafeature_not_found() {
2091249247c9SJuan Quintela  feature=$1
209221684af0SStewart Smith  remedy=$2
2093249247c9SJuan Quintela
209476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
209521684af0SStewart Smith      "configure was not able to find it." \
209621684af0SStewart Smith      "$remedy"
2097249247c9SJuan Quintela}
2098249247c9SJuan Quintela
20997d13299dSbellard# ---
21007d13299dSbellard# big/little endian test
21017d13299dSbellardcat > $TMPC << EOF
210261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
210361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
210461cc919fSMike Frysingerextern int foo(short *, short *);
210561cc919fSMike Frysingerint main(int argc, char *argv[]) {
210661cc919fSMike Frysinger    return foo(big_endian, little_endian);
21077d13299dSbellard}
21087d13299dSbellardEOF
21097d13299dSbellard
211061cc919fSMike Frysingerif compile_object ; then
211112f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
211261cc919fSMike Frysinger        bigendian="yes"
211312f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
211461cc919fSMike Frysinger        bigendian="no"
21157d13299dSbellard    else
21167d13299dSbellard        echo big/little test failed
21177d13299dSbellard    fi
21187d13299dSbellardelse
211961cc919fSMike Frysinger    echo big/little test failed
21207d13299dSbellardfi
21217d13299dSbellard
2122b0a47e79SJuan Quintela##########################################
2123a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2124a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2125a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2126a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2127a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2128a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2129a30878e7SPeter Maydell    fi
2130a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2131a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2132a30878e7SPeter Maydell    fi
2133a30878e7SPeter Maydell    gtk=no
2134a30878e7SPeter Maydell    sdl=no
2135a30878e7SPeter Maydellfi
2136a30878e7SPeter Maydell
21376b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
21386b39b063SEric Blakecat > $TMPC << EOF
21396b39b063SEric Blake#include <stdint.h>
21406b39b063SEric Blake#include <stdio.h>
21416b39b063SEric Blakeint main(int argc, char *argv[]) {
21426b39b063SEric Blake    return printf("%zu", SIZE_MAX);
21436b39b063SEric Blake}
21446b39b063SEric BlakeEOF
21456b39b063SEric Blakehave_broken_size_max=no
21466b39b063SEric Blakeif ! compile_object -Werror ; then
21476b39b063SEric Blake    have_broken_size_max=yes
21486b39b063SEric Blakefi
21496b39b063SEric Blake
2150a30878e7SPeter Maydell##########################################
2151015a33bdSGonglei# L2TPV3 probe
2152015a33bdSGonglei
2153015a33bdSGongleicat > $TMPC <<EOF
2154015a33bdSGonglei#include <sys/socket.h>
2155bff6cb72SMichael Tokarev#include <linux/ip.h>
2156015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2157015a33bdSGongleiEOF
2158015a33bdSGongleiif compile_prog "" "" ; then
2159015a33bdSGonglei  l2tpv3=yes
2160015a33bdSGongleielse
2161015a33bdSGonglei  l2tpv3=no
2162015a33bdSGongleifi
2163015a33bdSGonglei
2164015a33bdSGonglei##########################################
21654d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
21664d9310f4SDaniel P. Berrange
21674d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
21684d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
21694d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
21704d9310f4SDaniel P. Berrange    #
21714d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
21724d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
21734d9310f4SDaniel P. Berrange    #
21744d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
21754d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
21764d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
21774d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
21784d9310f4SDaniel P. Berrange    # that for you.
21794d9310f4SDaniel P. Berrange    #
21804d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
21814d9310f4SDaniel P. Berrange    # are not in fact redundant.
21824d9310f4SDaniel P. Berrangecat > $TMPC << EOF
21834d9310f4SDaniel P. Berrange#include <unistd.h>
21844d9310f4SDaniel P. Berrange#include <time.h>
21854d9310f4SDaniel P. Berrange#undef localtime_r
21864d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
21874d9310f4SDaniel P. BerrangeEOF
21884d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
21894d9310f4SDaniel P. Berrange        localtime_r="yes"
21904d9310f4SDaniel P. Berrange    else
21914d9310f4SDaniel P. Berrange        localtime_r="no"
21924d9310f4SDaniel P. Berrange    fi
21934d9310f4SDaniel P. Berrangefi
21944d9310f4SDaniel P. Berrange
21954d9310f4SDaniel P. Berrange##########################################
2196779ab5e3SStefan Weil# pkg-config probe
2197779ab5e3SStefan Weil
2198779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
219976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2200779ab5e3SStefan Weilfi
2201779ab5e3SStefan Weil
2202779ab5e3SStefan Weil##########################################
2203b0a47e79SJuan Quintela# NPTL probe
2204b0a47e79SJuan Quintela
220524cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2206bd0c5661Spbrook  cat > $TMPC <<EOF
2207bd0c5661Spbrook#include <sched.h>
220830813ceaSpbrook#include <linux/futex.h>
2209182eacc0SStefan Weilint main(void) {
2210bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2211bd0c5661Spbrook#error bork
2212bd0c5661Spbrook#endif
2213182eacc0SStefan Weil  return 0;
2214bd0c5661Spbrook}
2215bd0c5661SpbrookEOF
221624cb36a6SPeter Maydell  if ! compile_object ; then
221721684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2218b0a47e79SJuan Quintela  fi
2219bd0c5661Spbrookfi
2220bd0c5661Spbrook
2221ac62922eSbalrog##########################################
2222607dacd0Sqiaonuohan# lzo check
2223607dacd0Sqiaonuohan
2224607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2225607dacd0Sqiaonuohan    cat > $TMPC << EOF
2226607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2227607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2228607dacd0SqiaonuohanEOF
2229607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2230607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2231b25c9dffSStefan Weil        lzo="yes"
2232b25c9dffSStefan Weil    else
2233b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2234b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2235b25c9dffSStefan Weil        fi
2236b25c9dffSStefan Weil        lzo="no"
2237b25c9dffSStefan Weil    fi
2238607dacd0Sqiaonuohanfi
2239607dacd0Sqiaonuohan
2240607dacd0Sqiaonuohan##########################################
2241607dacd0Sqiaonuohan# snappy check
2242607dacd0Sqiaonuohan
2243607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2244607dacd0Sqiaonuohan    cat > $TMPC << EOF
2245607dacd0Sqiaonuohan#include <snappy-c.h>
2246607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2247607dacd0SqiaonuohanEOF
2248607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2249607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2250b25c9dffSStefan Weil        snappy="yes"
2251b25c9dffSStefan Weil    else
2252b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2253b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2254b25c9dffSStefan Weil        fi
2255b25c9dffSStefan Weil        snappy="no"
2256b25c9dffSStefan Weil    fi
2257607dacd0Sqiaonuohanfi
2258607dacd0Sqiaonuohan
2259607dacd0Sqiaonuohan##########################################
22606b383c08SPeter Wu# bzip2 check
22616b383c08SPeter Wu
22626b383c08SPeter Wuif test "$bzip2" != "no" ; then
22636b383c08SPeter Wu    cat > $TMPC << EOF
22646b383c08SPeter Wu#include <bzlib.h>
22656b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
22666b383c08SPeter WuEOF
22676b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
22686b383c08SPeter Wu        bzip2="yes"
22696b383c08SPeter Wu    else
22706b383c08SPeter Wu        if test "$bzip2" = "yes"; then
22716b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
22726b383c08SPeter Wu        fi
22736b383c08SPeter Wu        bzip2="no"
22746b383c08SPeter Wu    fi
22756b383c08SPeter Wufi
22766b383c08SPeter Wu
22776b383c08SPeter Wu##########################################
2278f794573eSEduardo Otubo# libseccomp check
2279f794573eSEduardo Otubo
2280d0699bd3SMarc-André Lureaulibseccomp_minver="2.2.0"
2281f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2282693e5910SAndrew Jones    case "$cpu" in
2283d0699bd3SMarc-André Lureau    i386|x86_64|mips)
22845ce43972SJames Hogan        ;;
2285693e5910SAndrew Jones    arm|aarch64)
2286693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2287693e5910SAndrew Jones        ;;
22883aa35fcfSThomas Huth    ppc|ppc64|s390x)
22893e684455SMichael Strosaker        libseccomp_minver="2.3.0"
22903e684455SMichael Strosaker        ;;
2291693e5910SAndrew Jones    *)
2292693e5910SAndrew Jones        libseccomp_minver=""
2293693e5910SAndrew Jones        ;;
2294693e5910SAndrew Jones    esac
2295693e5910SAndrew Jones
2296693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2297693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2298c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2299c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2300f794573eSEduardo Otubo        seccomp="yes"
2301f794573eSEduardo Otubo    else
2302f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2303693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2304693e5910SAndrew Jones                feature_not_found "libseccomp" \
2305693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2306693e5910SAndrew Jones            else
2307693e5910SAndrew Jones                feature_not_found "libseccomp" \
2308693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2309693e5910SAndrew Jones            fi
2310896848f0SEduardo Otubo        fi
2311e84d5956SYann E. MORIN        seccomp="no"
2312f794573eSEduardo Otubo    fi
2313f794573eSEduardo Otubofi
2314f794573eSEduardo Otubo##########################################
2315e37630caSaliguori# xen probe
2316e37630caSaliguori
2317fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2318c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2319c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2320c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2321c1cdd9d5SJuergen Gross
2322c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2323c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2324c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2325c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2326c1cdd9d5SJuergen Gross    xen=yes
2327c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2328c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
232958ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
233058ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
233158ea9a7aSAnthony PERARD    fi
2332c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2333c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2334c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2335c1cdd9d5SJuergen Gross  else
2336c1cdd9d5SJuergen Gross
2337b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2338d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2339d5b93ddfSAnthony PERARD
234050ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
234150ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
234250ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
234350ced5b3SStefan Weil
234450ced5b3SStefan Weil    # Xen (any)
234550ced5b3SStefan Weil    cat > $TMPC <<EOF
234650ced5b3SStefan Weil#include <xenctrl.h>
234750ced5b3SStefan Weilint main(void) {
234850ced5b3SStefan Weil  return 0;
234950ced5b3SStefan Weil}
235050ced5b3SStefan WeilEOF
235150ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
235250ced5b3SStefan Weil      # Xen not found
235350ced5b3SStefan Weil      if test "$xen" = "yes" ; then
235421684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
235550ced5b3SStefan Weil      fi
235650ced5b3SStefan Weil      xen=no
235750ced5b3SStefan Weil
2358d5b93ddfSAnthony PERARD    # Xen unstable
235969deef08SPeter Maydell    elif
236069deef08SPeter Maydell        cat > $TMPC <<EOF &&
23612cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
23622cbf8903SRoss Lagerwall#define __XEN_TOOLS__
23632cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2364d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
23652cbf8903SRoss Lagerwallint main(void) {
23662cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2367d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
23682cbf8903SRoss Lagerwall
23692cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
23702cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
23712cbf8903SRoss Lagerwall
2372d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2373d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2374d3c49ebbSPaul Durrant
23752cbf8903SRoss Lagerwall  return 0;
23762cbf8903SRoss Lagerwall}
23772cbf8903SRoss LagerwallEOF
23782cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
23792cbf8903SRoss Lagerwall      then
23802cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
23812cbf8903SRoss Lagerwall      xen_ctrl_version=41100
23822cbf8903SRoss Lagerwall      xen=yes
23832cbf8903SRoss Lagerwall    elif
23842cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
23855ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
23865ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
238758ea9a7aSAnthony PERARD#include <xentoolcore.h>
23885ba3d756SIgor Druzhininint main(void) {
23895ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
23905ba3d756SIgor Druzhinin
23915ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
23925ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
239358ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
23945ba3d756SIgor Druzhinin
23955ba3d756SIgor Druzhinin  return 0;
23965ba3d756SIgor Druzhinin}
23975ba3d756SIgor DruzhininEOF
239858ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
23995ba3d756SIgor Druzhinin      then
240058ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24015ba3d756SIgor Druzhinin      xen_ctrl_version=41000
24025ba3d756SIgor Druzhinin      xen=yes
24035ba3d756SIgor Druzhinin    elif
24045ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2405da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2406da8090ccSPaul Durrant#define __XEN_TOOLS__
2407da8090ccSPaul Durrant#include <xendevicemodel.h>
2408da8090ccSPaul Durrantint main(void) {
2409da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2410da8090ccSPaul Durrant
2411da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2412da8090ccSPaul Durrant  xendevicemodel_close(xd);
2413da8090ccSPaul Durrant
2414da8090ccSPaul Durrant  return 0;
2415da8090ccSPaul Durrant}
2416da8090ccSPaul DurrantEOF
2417da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2418da8090ccSPaul Durrant      then
2419da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2420f1167ee6SJuergen Gross      xen_ctrl_version=40900
2421da8090ccSPaul Durrant      xen=yes
2422da8090ccSPaul Durrant    elif
2423da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
24245eeb39c2SIan Campbell/*
24255eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
24265eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2427b6eb9b45SPaulina Szubarczyk *
2428b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2429b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2430b6eb9b45SPaulina Szubarczyk */
2431b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2432b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2433b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2434b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2435b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2436b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2437b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2438b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2439b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2440b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2441b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2442b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2443b6eb9b45SPaulina Szubarczyk#endif
2444b6eb9b45SPaulina Szubarczykint main(void) {
2445b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2446b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2447b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2448b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2449b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2450b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2451b6eb9b45SPaulina Szubarczyk
2452b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2453b6eb9b45SPaulina Szubarczyk
2454b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2455b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2456b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2457b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2458b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2459b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2460b6eb9b45SPaulina Szubarczyk
2461b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2462b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2463b6eb9b45SPaulina Szubarczyk
2464b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2465b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2466b6eb9b45SPaulina Szubarczyk
2467b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2468b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2469b6eb9b45SPaulina Szubarczyk
2470b6eb9b45SPaulina Szubarczyk  return 0;
2471b6eb9b45SPaulina Szubarczyk}
2472b6eb9b45SPaulina SzubarczykEOF
2473b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2474b6eb9b45SPaulina Szubarczyk      then
2475f1167ee6SJuergen Gross      xen_ctrl_version=40800
2476b6eb9b45SPaulina Szubarczyk      xen=yes
2477b6eb9b45SPaulina Szubarczyk    elif
2478b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2479b6eb9b45SPaulina Szubarczyk/*
2480b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2481b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
24825eeb39c2SIan Campbell */
24835eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
24845eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
24855eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
24865eeb39c2SIan Campbell#include <xenctrl.h>
24875eeb39c2SIan Campbell#include <xenstore.h>
24885eeb39c2SIan Campbell#include <xenevtchn.h>
24895eeb39c2SIan Campbell#include <xengnttab.h>
24905eeb39c2SIan Campbell#include <xenforeignmemory.h>
24915eeb39c2SIan Campbell#include <stdint.h>
24925eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
24935eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
24945eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
24955eeb39c2SIan Campbell#endif
24965eeb39c2SIan Campbellint main(void) {
24975eeb39c2SIan Campbell  xc_interface *xc = NULL;
24985eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
24995eeb39c2SIan Campbell  xenevtchn_handle *xe;
25005eeb39c2SIan Campbell  xengnttab_handle *xg;
25015eeb39c2SIan Campbell  xen_domain_handle_t handle;
25025eeb39c2SIan Campbell
25035eeb39c2SIan Campbell  xs_daemon_open();
25045eeb39c2SIan Campbell
25055eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
25065eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
25075eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25085eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25095eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
25105eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
25115eeb39c2SIan Campbell
25125eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
25135eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
25145eeb39c2SIan Campbell
25155eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
25165eeb39c2SIan Campbell  xenevtchn_fd(xe);
25175eeb39c2SIan Campbell
25185eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
25195eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
25205eeb39c2SIan Campbell
25215eeb39c2SIan Campbell  return 0;
25225eeb39c2SIan Campbell}
25235eeb39c2SIan CampbellEOF
25245eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
25255eeb39c2SIan Campbell      then
2526f1167ee6SJuergen Gross      xen_ctrl_version=40701
25275eeb39c2SIan Campbell      xen=yes
25285eeb39c2SIan Campbell    elif
25295eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2530e37630caSaliguori#include <xenctrl.h>
2531cdadde39SRoger Pau Monne#include <stdint.h>
2532cdadde39SRoger Pau Monneint main(void) {
2533cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2534cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2535cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2536cdadde39SRoger Pau Monne  return 0;
2537cdadde39SRoger Pau Monne}
2538cdadde39SRoger Pau MonneEOF
2539cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2540cdadde39SRoger Pau Monne      then
2541f1167ee6SJuergen Gross      xen_ctrl_version=40700
2542cdadde39SRoger Pau Monne      xen=yes
2543cdadde39SRoger Pau Monne
2544cdadde39SRoger Pau Monne    # Xen 4.6
2545cdadde39SRoger Pau Monne    elif
2546cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2547cdadde39SRoger Pau Monne#include <xenctrl.h>
2548e108a3c1SAnthony PERARD#include <xenstore.h>
2549d5b93ddfSAnthony PERARD#include <stdint.h>
2550d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2551d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2552d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2553d5b93ddfSAnthony PERARD#endif
2554d5b93ddfSAnthony PERARDint main(void) {
2555d5b93ddfSAnthony PERARD  xc_interface *xc;
2556d5b93ddfSAnthony PERARD  xs_daemon_open();
2557d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2558d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2559d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2560b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25618688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2562d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
256320a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2564d8b441a3SJan Beulich  return 0;
2565d8b441a3SJan Beulich}
2566d8b441a3SJan BeulichEOF
2567d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2568d8b441a3SJan Beulich      then
2569f1167ee6SJuergen Gross      xen_ctrl_version=40600
2570d8b441a3SJan Beulich      xen=yes
2571d8b441a3SJan Beulich
2572d8b441a3SJan Beulich    # Xen 4.5
2573d8b441a3SJan Beulich    elif
2574d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2575d8b441a3SJan Beulich#include <xenctrl.h>
2576d8b441a3SJan Beulich#include <xenstore.h>
2577d8b441a3SJan Beulich#include <stdint.h>
2578d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2579d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2580d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2581d8b441a3SJan Beulich#endif
2582d8b441a3SJan Beulichint main(void) {
2583d8b441a3SJan Beulich  xc_interface *xc;
2584d8b441a3SJan Beulich  xs_daemon_open();
2585d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2586d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2587d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2588d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2589d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25903996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
25913996e85cSPaul Durrant  return 0;
25923996e85cSPaul Durrant}
25933996e85cSPaul DurrantEOF
25943996e85cSPaul Durrant        compile_prog "" "$xen_libs"
25953996e85cSPaul Durrant      then
2596f1167ee6SJuergen Gross      xen_ctrl_version=40500
25973996e85cSPaul Durrant      xen=yes
25983996e85cSPaul Durrant
25993996e85cSPaul Durrant    elif
26003996e85cSPaul Durrant        cat > $TMPC <<EOF &&
26013996e85cSPaul Durrant#include <xenctrl.h>
26023996e85cSPaul Durrant#include <xenstore.h>
26033996e85cSPaul Durrant#include <stdint.h>
26043996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
26053996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
26063996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
26073996e85cSPaul Durrant#endif
26083996e85cSPaul Durrantint main(void) {
26093996e85cSPaul Durrant  xc_interface *xc;
26103996e85cSPaul Durrant  xs_daemon_open();
26113996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
26123996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26133996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
26143996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26153996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26168688e065SStefano Stabellini  return 0;
26178688e065SStefano Stabellini}
26188688e065SStefano StabelliniEOF
26198688e065SStefano Stabellini        compile_prog "" "$xen_libs"
262069deef08SPeter Maydell      then
2621f1167ee6SJuergen Gross      xen_ctrl_version=40200
26228688e065SStefano Stabellini      xen=yes
26238688e065SStefano Stabellini
2624e37630caSaliguori    else
2625fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2626edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2627edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2628fc321b4bSJuan Quintela      fi
2629fc321b4bSJuan Quintela      xen=no
2630e37630caSaliguori    fi
2631d5b93ddfSAnthony PERARD
2632d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2633f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
26345eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
26355eeb39c2SIan Campbell      fi
2636d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2637d5b93ddfSAnthony PERARD    fi
2638e37630caSaliguori  fi
2639c1cdd9d5SJuergen Grossfi
2640e37630caSaliguori
2641eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2642edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2643eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2644eb6fda0fSAnthony PERARD  else
2645eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
264676ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
264776ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2648eb6fda0fSAnthony PERARD    fi
2649eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2650eb6fda0fSAnthony PERARD  fi
2651eb6fda0fSAnthony PERARDfi
2652eb6fda0fSAnthony PERARD
265364a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
265464a7ad6fSIan Campbell   test "$xen" != "yes"; then
265564a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
265664a7ad6fSIan Campbell	       "which requires Xen support."
265764a7ad6fSIan Campbellfi
265864a7ad6fSIan Campbell
2659e37630caSaliguori##########################################
2660d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2661d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2662327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2663d661d9a4SJustin Terry (VM)        whpx="yes"
2664d661d9a4SJustin Terry (VM)    else
2665d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
266653537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2667d661d9a4SJustin Terry (VM)        fi
2668d661d9a4SJustin Terry (VM)        whpx="no"
2669d661d9a4SJustin Terry (VM)    fi
2670d661d9a4SJustin Terry (VM)fi
2671d661d9a4SJustin Terry (VM)
2672d661d9a4SJustin Terry (VM)##########################################
2673dfffc653SJuan Quintela# Sparse probe
2674dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
26750dba6195SLoïc Minier  if has cgcc; then
2676dfffc653SJuan Quintela    sparse=yes
2677dfffc653SJuan Quintela  else
2678dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
267921684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2680dfffc653SJuan Quintela    fi
2681dfffc653SJuan Quintela    sparse=no
2682dfffc653SJuan Quintela  fi
2683dfffc653SJuan Quintelafi
2684dfffc653SJuan Quintela
2685dfffc653SJuan Quintela##########################################
2686f676c67eSJeremy White# X11 probe
2687f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
26888781595bSGerd Hoffmann    have_x11=yes
268989138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
269089138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2691f676c67eSJeremy Whitefi
2692f676c67eSJeremy White
2693f676c67eSJeremy White##########################################
2694a4ccabcfSAnthony Liguori# GTK probe
2695a4ccabcfSAnthony Liguori
26965a464e6cSPeter Xuif test "$gtk" != "no"; then
269789d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
269889d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
269958296cb6SDaniel P. Berrangé    gtkversion="3.14.0"
2700bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
270189138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
270289138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
270389138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
27040a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
27058781595bSGerd Hoffmann            need_x11=yes
2706f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2707f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
27080a337ed0SGerd Hoffmann        fi
2709bbbf9bfbSStefan Weil        gtk="yes"
2710bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
27115fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2712bbbf9bfbSStefan Weil    else
2713bbbf9bfbSStefan Weil        gtk="no"
2714bbbf9bfbSStefan Weil    fi
2715bbbf9bfbSStefan Weilfi
2716bbbf9bfbSStefan Weil
2717ddbb0d09SDaniel P. Berrange
2718ddbb0d09SDaniel P. Berrange##########################################
2719ddbb0d09SDaniel P. Berrange# GNUTLS probe
2720ddbb0d09SDaniel P. Berrange
2721ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2722a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
272389138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
272489138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2725ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2726ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2727ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2728ddbb0d09SDaniel P. Berrange        gnutls="yes"
2729ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2730a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2731ddbb0d09SDaniel P. Berrange    else
2732ddbb0d09SDaniel P. Berrange        gnutls="no"
2733ddbb0d09SDaniel P. Berrange    fi
2734ddbb0d09SDaniel P. Berrangefi
2735ddbb0d09SDaniel P. Berrange
273691bfcdb0SDaniel P. Berrange
273791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
273891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2739a0722409SDaniel P. Berrangé# explicitly
274091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
274191bfcdb0SDaniel P. Berrangethen
2742a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
274391bfcdb0SDaniel P. Berrange    then
274491bfcdb0SDaniel P. Berrange        gcrypt="no"
274591bfcdb0SDaniel P. Berrange    fi
274691bfcdb0SDaniel P. Berrangefi
274791bfcdb0SDaniel P. Berrange
274891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
274991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2750a0722409SDaniel P. Berrangé# explicitly
275191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
275291bfcdb0SDaniel P. Berrangethen
2753a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
275491bfcdb0SDaniel P. Berrange    then
275591bfcdb0SDaniel P. Berrange        nettle="no"
275691bfcdb0SDaniel P. Berrange    fi
275791bfcdb0SDaniel P. Berrangefi
275891bfcdb0SDaniel P. Berrange
2759dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
276091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
276191bfcdb0SDaniel P. Berrange    then
276291bfcdb0SDaniel P. Berrange	return 1
276391bfcdb0SDaniel P. Berrange    fi
276491bfcdb0SDaniel P. Berrange
276591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
276691bfcdb0SDaniel P. Berrange    then
276789138857SStefan Weil	host=$(libgcrypt-config --host)
276891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
276991bfcdb0SDaniel P. Berrange	then
277091bfcdb0SDaniel P. Berrange	    return 1
277191bfcdb0SDaniel P. Berrange	fi
277291bfcdb0SDaniel P. Berrange    fi
277391bfcdb0SDaniel P. Berrange
2774dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2775dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2776dea7a64eSDaniel P. Berrangé
2777dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2778dea7a64eSDaniel P. Berrangé    then
2779dea7a64eSDaniel P. Berrangé       return 1
2780dea7a64eSDaniel P. Berrangé    fi
2781dea7a64eSDaniel P. Berrangé
278291bfcdb0SDaniel P. Berrange    return 0
278391bfcdb0SDaniel P. Berrange}
278491bfcdb0SDaniel P. Berrange
2785a0722409SDaniel P. Berrangé
2786a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
278764dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2788a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2789a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2790a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2791a0722409SDaniel P. Berrangé        libs_softmmu="$nettle_libs $libs_softmmu"
2792a0722409SDaniel P. Berrangé        libs_tools="$nettle_libs $libs_tools"
2793a0722409SDaniel P. Berrangé        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2794a0722409SDaniel P. Berrangé        nettle="yes"
2795a0722409SDaniel P. Berrangé
2796a0722409SDaniel P. Berrangé        if test -z "$gcrypt"; then
2797a0722409SDaniel P. Berrangé           gcrypt="no"
2798a0722409SDaniel P. Berrangé        fi
2799a0722409SDaniel P. Berrangé    else
2800a0722409SDaniel P. Berrangé        if test "$nettle" = "yes"; then
280164dd2f3bSDaniel P. Berrangé            feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2802a0722409SDaniel P. Berrangé        else
2803a0722409SDaniel P. Berrangé            nettle="no"
2804a0722409SDaniel P. Berrangé        fi
2805a0722409SDaniel P. Berrangé    fi
2806a0722409SDaniel P. Berrangéfi
2807a0722409SDaniel P. Berrangé
280891bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2809dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
281089138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
281189138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
281291bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
281391bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
281491bfcdb0SDaniel P. Berrange        # turn breaks static builds...
281591bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
281691bfcdb0SDaniel P. Berrange        then
281791bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
281891bfcdb0SDaniel P. Berrange        fi
281962893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
282062893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
282162893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
282291bfcdb0SDaniel P. Berrange        gcrypt="yes"
28231f923c70SLongpeng(Mike)
28241f923c70SLongpeng(Mike)        cat > $TMPC << EOF
28251f923c70SLongpeng(Mike)#include <gcrypt.h>
28261f923c70SLongpeng(Mike)int main(void) {
28271f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
28281f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
28291f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
28301f923c70SLongpeng(Mike)  return 0;
28311f923c70SLongpeng(Mike)}
28321f923c70SLongpeng(Mike)EOF
28331f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
28341f923c70SLongpeng(Mike)            gcrypt_hmac=yes
28351f923c70SLongpeng(Mike)        fi
283662893b67SDaniel P. Berrange    else
283791bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
2838dea7a64eSDaniel P. Berrangé            feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
283991bfcdb0SDaniel P. Berrange        else
284091bfcdb0SDaniel P. Berrange            gcrypt="no"
284191bfcdb0SDaniel P. Berrange        fi
284262893b67SDaniel P. Berrange    fi
284362893b67SDaniel P. Berrangefi
284462893b67SDaniel P. Berrange
2845ddbb0d09SDaniel P. Berrange
284691bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
284791bfcdb0SDaniel P. Berrangethen
284891bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
284991bfcdb0SDaniel P. Berrangefi
2850ed754746SDaniel P. Berrange
28519a2fd434SDaniel P. Berrange##########################################
28529a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
28539a2fd434SDaniel P. Berrange
28549a2fd434SDaniel P. Berrangetasn1=yes
285590246037SDaniel P. Berrangetasn1_cflags=""
285690246037SDaniel P. Berrangetasn1_libs=""
28579a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
285889138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
285989138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
28609a2fd434SDaniel P. Berrangeelse
28619a2fd434SDaniel P. Berrange    tasn1=no
28629a2fd434SDaniel P. Berrangefi
28639a2fd434SDaniel P. Berrange
2864ed754746SDaniel P. Berrange
2865bbbf9bfbSStefan Weil##########################################
2866559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2867559607eaSDaniel P. Berrange
2868559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2869559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2870559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2871559607eaSDaniel P. Berrangefi
2872559607eaSDaniel P. Berrange
2873559607eaSDaniel P. Berrange##########################################
2874bbbf9bfbSStefan Weil# VTE probe
2875bbbf9bfbSStefan Weil
2876bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2877c6feff9eSCole Robinson    vteminversion="0.32.0"
2878c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
2879c6feff9eSCole Robinson      vtepackage="vte-2.91"
2880c6feff9eSCole Robinson    else
2881528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
2882c6feff9eSCole Robinson    fi
2883c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
288489138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
288589138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
288689138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2887bbbf9bfbSStefan Weil        vte="yes"
2888bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
2889c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
28909e04c683SStefan Weil    else
2891bbbf9bfbSStefan Weil        vte="no"
2892a4ccabcfSAnthony Liguori    fi
2893a4ccabcfSAnthony Liguorifi
2894a4ccabcfSAnthony Liguori
2895a4ccabcfSAnthony Liguori##########################################
289611d9f695Sbellard# SDL probe
289711d9f695Sbellard
28983ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
28993ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
290047c03744SDave Airlie
2901c6093a05SPeter Xusdl_probe ()
2902c6093a05SPeter Xu{
2903c6093a05SPeter Xu  sdl_too_old=no
2904ee8466d0SCole Robinson  if test "$sdlabi" = ""; then
29058f4ea9cdSGerd Hoffmann      if $pkg_config --exists "sdl2"; then
2906ee8466d0SCole Robinson          sdlabi=2.0
29078f4ea9cdSGerd Hoffmann      elif $pkg_config --exists "sdl"; then
2908ee8466d0SCole Robinson          sdlabi=1.2
29098f4ea9cdSGerd Hoffmann      else
29108f4ea9cdSGerd Hoffmann          sdlabi=2.0
2911ee8466d0SCole Robinson      fi
2912ee8466d0SCole Robinson  fi
2913ee8466d0SCole Robinson
291447c03744SDave Airlie  if test $sdlabi = "2.0"; then
291547c03744SDave Airlie      sdl_config=$sdl2_config
291647c03744SDave Airlie      sdlname=sdl2
291747c03744SDave Airlie      sdlconfigname=sdl2_config
2918e07047cfSCole Robinson  elif test $sdlabi = "1.2"; then
291947c03744SDave Airlie      sdlname=sdl
292047c03744SDave Airlie      sdlconfigname=sdl_config
2921e07047cfSCole Robinson  else
2922e07047cfSCole Robinson      error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
29233ec87ffeSPaolo Bonzini  fi
29243ec87ffeSPaolo Bonzini
292589138857SStefan Weil  if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
292647c03744SDave Airlie    sdl_config=$sdlconfigname
292747c03744SDave Airlie  fi
292847c03744SDave Airlie
292947c03744SDave Airlie  if $pkg_config $sdlname --exists; then
293047c03744SDave Airlie    sdlconfig="$pkg_config $sdlname"
293189138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
29323ec87ffeSPaolo Bonzini  elif has ${sdl_config}; then
29333ec87ffeSPaolo Bonzini    sdlconfig="$sdl_config"
293489138857SStefan Weil    sdlversion=$($sdlconfig --version)
2935a0dfd8a4SLoïc Minier  else
2936a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
29378f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
2938a0dfd8a4SLoïc Minier    fi
2939a0dfd8a4SLoïc Minier    sdl=no
2940c6093a05SPeter Xu    # no need to do the rest
2941c6093a05SPeter Xu    return
29429316f803SPaolo Bonzini  fi
294329e5badaSScott Wood  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
29443ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
29453ec87ffeSPaolo Bonzini  fi
294611d9f695Sbellard
294711d9f695Sbellard  cat > $TMPC << EOF
294811d9f695Sbellard#include <SDL.h>
294911d9f695Sbellard#undef main /* We don't want SDL to override our main() */
295011d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
295111d9f695SbellardEOF
295289138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
29532ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
295474f42e18STeLeMan  if test "$static" = "yes" ; then
29555f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
29565f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
29575f37e6d4SThomas Huth    else
295889138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
29595f37e6d4SThomas Huth    fi
296074f42e18STeLeMan  else
296189138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
296274f42e18STeLeMan  fi
296352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
296489138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
296511d9f695Sbellard      sdl_too_old=yes
296611d9f695Sbellard    else
296711d9f695Sbellard      sdl=yes
296811d9f695Sbellard    fi
29697c1f25b4Sbellard
297067c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
29711ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
297267c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
297389138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
297489138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
297511d9f695Sbellard      fi
297652166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
29771ac88f28SJuan Quintela	:
29781ac88f28SJuan Quintela      else
29791ac88f28SJuan Quintela        sdl=no
29807c1f25b4Sbellard      fi
29817c1f25b4Sbellard    fi # static link
2982c4198157SJuan Quintela  else # sdl not found
2983c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
298421684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2985c4198157SJuan Quintela    fi
2986c4198157SJuan Quintela    sdl=no
29877c1f25b4Sbellard  fi # sdl compile test
2988c6093a05SPeter Xu}
2989c6093a05SPeter Xu
2990c6093a05SPeter Xuif test "$sdl" != "no" ; then
2991c6093a05SPeter Xu  sdl_probe
2992fd677642Sthsfi
299311d9f695Sbellard
29945368a422Saliguoriif test "$sdl" = "yes" ; then
29955368a422Saliguori  cat > $TMPC <<EOF
29965368a422Saliguori#include <SDL.h>
29975368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
29985368a422Saliguori#include <X11/XKBlib.h>
29995368a422Saliguori#else
30005368a422Saliguori#error No x11 support
30015368a422Saliguori#endif
30025368a422Saliguoriint main(void) { return 0; }
30035368a422SaliguoriEOF
3004f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
30058781595bSGerd Hoffmann    need_x11=yes
3006f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3007f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
30085368a422Saliguori  fi
30095368a422Saliguorifi
30105368a422Saliguori
30118f28f3fbSths##########################################
30122da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
30132da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
30142da776dbSMichael R. Hines  cat > $TMPC <<EOF
30152da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
30162da776dbSMichael R. Hinesint main(void) { return 0; }
30172da776dbSMichael R. HinesEOF
3018ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
30192da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
30202da776dbSMichael R. Hines    rdma="yes"
3021ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
30222da776dbSMichael R. Hines  else
30232da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
30242da776dbSMichael R. Hines        error_exit \
3025ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
30262da776dbSMichael R. Hines            " Your options:" \
3027ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
30282da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
30292da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
30302da776dbSMichael R. Hines    fi
30312da776dbSMichael R. Hines    rdma="no"
30322da776dbSMichael R. Hines  fi
30332da776dbSMichael R. Hinesfi
30342da776dbSMichael R. Hines
303521ab34c9SMarcel Apfelbaum##########################################
303621ab34c9SMarcel Apfelbaum# PVRDMA detection
303721ab34c9SMarcel Apfelbaum
303821ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
303921ab34c9SMarcel Apfelbaum#include <sys/mman.h>
304021ab34c9SMarcel Apfelbaum
304121ab34c9SMarcel Apfelbaumint
304221ab34c9SMarcel Apfelbaummain(void)
304321ab34c9SMarcel Apfelbaum{
304421ab34c9SMarcel Apfelbaum    char buf = 0;
304521ab34c9SMarcel Apfelbaum    void *addr = &buf;
304621ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
304721ab34c9SMarcel Apfelbaum
304821ab34c9SMarcel Apfelbaum    return 0;
304921ab34c9SMarcel Apfelbaum}
305021ab34c9SMarcel ApfelbaumEOF
305121ab34c9SMarcel Apfelbaum
305221ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
305321ab34c9SMarcel Apfelbaum    case "$pvrdma" in
305421ab34c9SMarcel Apfelbaum    "")
305521ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
305621ab34c9SMarcel Apfelbaum            pvrdma="yes"
305721ab34c9SMarcel Apfelbaum        else
305821ab34c9SMarcel Apfelbaum            pvrdma="no"
305921ab34c9SMarcel Apfelbaum        fi
306021ab34c9SMarcel Apfelbaum        ;;
306121ab34c9SMarcel Apfelbaum    "yes")
306221ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
306321ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
306421ab34c9SMarcel Apfelbaum        fi
306521ab34c9SMarcel Apfelbaum        pvrdma="yes"
306621ab34c9SMarcel Apfelbaum        ;;
306721ab34c9SMarcel Apfelbaum    "no")
306821ab34c9SMarcel Apfelbaum        pvrdma="no"
306921ab34c9SMarcel Apfelbaum        ;;
307021ab34c9SMarcel Apfelbaum    esac
307121ab34c9SMarcel Apfelbaumelse
307221ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
307321ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
307421ab34c9SMarcel Apfelbaum    fi
307521ab34c9SMarcel Apfelbaum    pvrdma="no"
307621ab34c9SMarcel Apfelbaumfi
307795c6bff3SBenoît Canet
307895c6bff3SBenoît Canet##########################################
30792f9606b3Saliguori# VNC SASL detection
3080821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
30812f9606b3Saliguori  cat > $TMPC <<EOF
30822f9606b3Saliguori#include <sasl/sasl.h>
30832f9606b3Saliguori#include <stdio.h>
30842f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
30852f9606b3SaliguoriEOF
30862f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
30872f9606b3Saliguori  vnc_sasl_cflags=""
30882f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
308952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3090ea784e3bSJuan Quintela    vnc_sasl=yes
3091fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3092ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
30932f9606b3Saliguori  else
3094ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
309521684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3096ea784e3bSJuan Quintela    fi
3097ea784e3bSJuan Quintela    vnc_sasl=no
30982f9606b3Saliguori  fi
30992f9606b3Saliguorifi
31002f9606b3Saliguori
31012f9606b3Saliguori##########################################
31022f6f5c7aSCorentin Chary# VNC JPEG detection
3103821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
31042f6f5c7aSCorentin Charycat > $TMPC <<EOF
31052f6f5c7aSCorentin Chary#include <stdio.h>
31062f6f5c7aSCorentin Chary#include <jpeglib.h>
31072f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
31082f6f5c7aSCorentin CharyEOF
31092f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
31102f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
31112f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
31122f6f5c7aSCorentin Chary    vnc_jpeg=yes
31132f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3114ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
31152f6f5c7aSCorentin Chary  else
31162f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
311721684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
31182f6f5c7aSCorentin Chary    fi
31192f6f5c7aSCorentin Chary    vnc_jpeg=no
31202f6f5c7aSCorentin Chary  fi
31212f6f5c7aSCorentin Charyfi
31222f6f5c7aSCorentin Chary
31232f6f5c7aSCorentin Chary##########################################
3124efe556adSCorentin Chary# VNC PNG detection
3125821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
3126efe556adSCorentin Charycat > $TMPC <<EOF
3127efe556adSCorentin Chary//#include <stdio.h>
3128efe556adSCorentin Chary#include <png.h>
3129832ce9c2SScott Wood#include <stddef.h>
3130efe556adSCorentin Charyint main(void) {
3131efe556adSCorentin Chary    png_structp png_ptr;
3132efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
31337edc3fedSPeter Maydell    return png_ptr != 0;
3134efe556adSCorentin Chary}
3135efe556adSCorentin CharyEOF
313665d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
313789138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
313889138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
31399af8025eSBrad  else
3140efe556adSCorentin Chary    vnc_png_cflags=""
3141efe556adSCorentin Chary    vnc_png_libs="-lpng"
31429af8025eSBrad  fi
3143efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3144efe556adSCorentin Chary    vnc_png=yes
3145efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
31469af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3147efe556adSCorentin Chary  else
3148efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
314921684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3150efe556adSCorentin Chary    fi
3151efe556adSCorentin Chary    vnc_png=no
3152efe556adSCorentin Chary  fi
3153efe556adSCorentin Charyfi
3154efe556adSCorentin Chary
3155efe556adSCorentin Chary##########################################
31566a021536SGerd Hoffmann# xkbcommon probe
31576a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
31586a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
31596a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
31606a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
31616a021536SGerd Hoffmann    xkbcommon=yes
31626a021536SGerd Hoffmann  else
31636a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
31646a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
31656a021536SGerd Hoffmann    fi
31666a021536SGerd Hoffmann    xkbcommon=no
31676a021536SGerd Hoffmann  fi
31686a021536SGerd Hoffmannfi
31696a021536SGerd Hoffmann
31706a021536SGerd Hoffmann##########################################
317176655d6dSaliguori# fnmatch() probe, used for ACL routines
317276655d6dSaliguorifnmatch="no"
317376655d6dSaliguoricat > $TMPC << EOF
317476655d6dSaliguori#include <fnmatch.h>
317576655d6dSaliguoriint main(void)
317676655d6dSaliguori{
317776655d6dSaliguori    fnmatch("foo", "foo", 0);
317876655d6dSaliguori    return 0;
317976655d6dSaliguori}
318076655d6dSaliguoriEOF
318152166aa0SJuan Quintelaif compile_prog "" "" ; then
318276655d6dSaliguori   fnmatch="yes"
318376655d6dSaliguorifi
318476655d6dSaliguori
318576655d6dSaliguori##########################################
3186c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3187dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3188dce512deSChristoph Hellwig  cat > $TMPC << EOF
3189ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3190dce512deSChristoph Hellwig#include <xfs/xfs.h>
3191dce512deSChristoph Hellwigint main(void)
3192dce512deSChristoph Hellwig{
3193dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3194dce512deSChristoph Hellwig    return 0;
3195dce512deSChristoph Hellwig}
3196dce512deSChristoph HellwigEOF
3197dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3198dce512deSChristoph Hellwig    xfs="yes"
3199dce512deSChristoph Hellwig  else
3200dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
320121684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3202dce512deSChristoph Hellwig    fi
3203dce512deSChristoph Hellwig    xfs=no
3204dce512deSChristoph Hellwig  fi
3205dce512deSChristoph Hellwigfi
3206dce512deSChristoph Hellwig
3207dce512deSChristoph Hellwig##########################################
32088a16d273Sths# vde libraries probe
3209dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
32104baae0acSJuan Quintela  vde_libs="-lvdeplug"
32118a16d273Sths  cat > $TMPC << EOF
32128a16d273Sths#include <libvdeplug.h>
32134a7f0e06Spbrookint main(void)
32144a7f0e06Spbrook{
32154a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3216fea08e08SPeter Maydell    char s[] = "";
3217fea08e08SPeter Maydell    vde_open(s, s, &a);
32184a7f0e06Spbrook    return 0;
32194a7f0e06Spbrook}
32208a16d273SthsEOF
322152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
32224baae0acSJuan Quintela    vde=yes
3223dfb278bdSJuan Quintela  else
3224dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
322521684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3226dfb278bdSJuan Quintela    fi
3227dfb278bdSJuan Quintela    vde=no
32288a16d273Sths  fi
32298a16d273Sthsfi
32308a16d273Sths
32318a16d273Sths##########################################
32320a985b37SVincenzo Maffione# netmap support probe
32330a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
32340a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
32350a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
32360a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
32370a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
323858952137SVincenzo Maffioneif test "$netmap" != "no" ; then
323958952137SVincenzo Maffione  cat > $TMPC << EOF
324058952137SVincenzo Maffione#include <inttypes.h>
324158952137SVincenzo Maffione#include <net/if.h>
324258952137SVincenzo Maffione#include <net/netmap.h>
324358952137SVincenzo Maffione#include <net/netmap_user.h>
32440a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
32450a985b37SVincenzo Maffione#error
32460a985b37SVincenzo Maffione#endif
324758952137SVincenzo Maffioneint main(void) { return 0; }
324858952137SVincenzo MaffioneEOF
324958952137SVincenzo Maffione  if compile_prog "" "" ; then
325058952137SVincenzo Maffione    netmap=yes
325158952137SVincenzo Maffione  else
325258952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
325358952137SVincenzo Maffione      feature_not_found "netmap"
325458952137SVincenzo Maffione    fi
325558952137SVincenzo Maffione    netmap=no
325658952137SVincenzo Maffione  fi
325758952137SVincenzo Maffionefi
325858952137SVincenzo Maffione
325958952137SVincenzo Maffione##########################################
326047e98658SCorey Bryant# libcap-ng library probe
326147e98658SCorey Bryantif test "$cap_ng" != "no" ; then
326247e98658SCorey Bryant  cap_libs="-lcap-ng"
326347e98658SCorey Bryant  cat > $TMPC << EOF
326447e98658SCorey Bryant#include <cap-ng.h>
326547e98658SCorey Bryantint main(void)
326647e98658SCorey Bryant{
326747e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
326847e98658SCorey Bryant    return 0;
326947e98658SCorey Bryant}
327047e98658SCorey BryantEOF
327147e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
327247e98658SCorey Bryant    cap_ng=yes
327347e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
327447e98658SCorey Bryant  else
327547e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
327621684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
327747e98658SCorey Bryant    fi
327847e98658SCorey Bryant    cap_ng=no
327947e98658SCorey Bryant  fi
328047e98658SCorey Bryantfi
328147e98658SCorey Bryant
328247e98658SCorey Bryant##########################################
3283c2de5c91Smalc# Sound support libraries probe
32848f28f3fbSths
3285c2de5c91Smalcaudio_drv_probe()
3286c2de5c91Smalc{
3287c2de5c91Smalc    drv=$1
3288c2de5c91Smalc    hdr=$2
3289c2de5c91Smalc    lib=$3
3290c2de5c91Smalc    exp=$4
3291c2de5c91Smalc    cfl=$5
32928f28f3fbSths        cat > $TMPC << EOF
3293c2de5c91Smalc#include <$hdr>
3294c2de5c91Smalcint main(void) { $exp }
32958f28f3fbSthsEOF
329652166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
32978f28f3fbSths        :
32988f28f3fbSths    else
329976ad07a4SPeter Maydell        error_exit "$drv check failed" \
330076ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
33018f28f3fbSths    fi
3302c2de5c91Smalc}
3303c2de5c91Smalc
330489138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3305c2de5c91Smalcfor drv in $audio_drv_list; do
3306c2de5c91Smalc    case $drv in
3307c2de5c91Smalc    alsa)
3308c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3309e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3310b1149911SFam Zheng    alsa_libs="-lasound"
3311c2de5c91Smalc    ;;
3312c2de5c91Smalc
3313b8e59f18Smalc    pa)
3314e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3315e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3316b1149911SFam Zheng    pulse_libs="-lpulse"
331767f86e8eSJuan Quintela    audio_pt_int="yes"
3318b8e59f18Smalc    ;;
3319b8e59f18Smalc
3320373967b2SGerd Hoffmann    sdl)
3321373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3322373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3323373967b2SGerd Hoffmann    fi
3324373967b2SGerd Hoffmann    ;;
3325373967b2SGerd Hoffmann
3326997e690aSJuan Quintela    coreaudio)
3327b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3328997e690aSJuan Quintela    ;;
3329997e690aSJuan Quintela
3330a4bf6780SJuan Quintela    dsound)
3331b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3332d5631638Smalc      audio_win_int="yes"
3333a4bf6780SJuan Quintela    ;;
3334a4bf6780SJuan Quintela
3335a4bf6780SJuan Quintela    oss)
3336b1149911SFam Zheng      oss_libs="$oss_lib"
3337a4bf6780SJuan Quintela    ;;
3338a4bf6780SJuan Quintela
3339373967b2SGerd Hoffmann    wav)
3340373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
33412f6a1ab0Sblueswir1    ;;
33422f6a1ab0Sblueswir1
3343e4c63a6aSmalc    *)
33441c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
334576ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
334676ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3347e4c63a6aSmalc    }
3348e4c63a6aSmalc    ;;
3349c2de5c91Smalc    esac
3350c2de5c91Smalcdone
33518f28f3fbSths
33524d3b6f6eSbalrog##########################################
33532e4d9fb1Saurel32# BrlAPI probe
33542e4d9fb1Saurel32
33554ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3356eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
33572e4d9fb1Saurel32  cat > $TMPC << EOF
33582e4d9fb1Saurel32#include <brlapi.h>
3359832ce9c2SScott Wood#include <stddef.h>
33602e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
33612e4d9fb1Saurel32EOF
336252166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
33632e4d9fb1Saurel32    brlapi=yes
33644ffcedb6SJuan Quintela  else
33654ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
336621684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
33674ffcedb6SJuan Quintela    fi
33684ffcedb6SJuan Quintela    brlapi=no
3369eb82284fSJuan Quintela  fi
3370eb82284fSJuan Quintelafi
33712e4d9fb1Saurel32
33722e4d9fb1Saurel32##########################################
33734d3b6f6eSbalrog# curses probe
3374a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3375e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
33768ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
33778ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3378e095e2f3SStefan Weil  else
33797c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
33808ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3381e095e2f3SStefan Weil  fi
3382c584a6d0SJuan Quintela  curses_found=no
33834d3b6f6eSbalrog  cat > $TMPC << EOF
33848ddc5bf9SSamuel Thibault#include <locale.h>
33854d3b6f6eSbalrog#include <curses.h>
33868ddc5bf9SSamuel Thibault#include <wchar.h>
3387ef9a2524SStefan Weilint main(void) {
33888ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
33898ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3390ef9a2524SStefan Weil  resize_term(0, 0);
33918ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
33928ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
33937c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3394271f37abSKamil Rytarowski  return 0;
3395ef9a2524SStefan Weil}
33964d3b6f6eSbalrogEOF
3397ecbe251fSVadim Evard  IFS=:
33988ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3399b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3400b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
34017c703002SSamuel Thibault    IFS=:
34028ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3403ecbe251fSVadim Evard      unset IFS
34048ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3405c584a6d0SJuan Quintela        curses_found=yes
34064f78ef9aSJuan Quintela        break
34074d3b6f6eSbalrog      fi
34084f78ef9aSJuan Quintela    done
34097c703002SSamuel Thibault    if test "$curses_found" = yes ; then
34107c703002SSamuel Thibault      break
34117c703002SSamuel Thibault    fi
34128ddc5bf9SSamuel Thibault  done
3413ecbe251fSVadim Evard  unset IFS
3414c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3415c584a6d0SJuan Quintela    curses=yes
3416c584a6d0SJuan Quintela  else
3417c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
341821684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3419c584a6d0SJuan Quintela    fi
3420c584a6d0SJuan Quintela    curses=no
3421c584a6d0SJuan Quintela  fi
34224f78ef9aSJuan Quintelafi
34234d3b6f6eSbalrog
3424414f0dabSblueswir1##########################################
3425769ce76dSAlexander Graf# curl probe
3426a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
342765d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3428a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
34294e2b0658SPaolo Bonzini  else
34304e2b0658SPaolo Bonzini    curlconfig=curl-config
34314e2b0658SPaolo Bonzini  fi
3432769ce76dSAlexander Graf  cat > $TMPC << EOF
3433769ce76dSAlexander Graf#include <curl/curl.h>
34340b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3435769ce76dSAlexander GrafEOF
343689138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
343789138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3438b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3439769ce76dSAlexander Graf    curl=yes
3440788c8196SJuan Quintela  else
3441788c8196SJuan Quintela    if test "$curl" = "yes" ; then
344221684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3443788c8196SJuan Quintela    fi
3444788c8196SJuan Quintela    curl=no
3445769ce76dSAlexander Graf  fi
3446769ce76dSAlexander Graffi # test "$curl"
3447769ce76dSAlexander Graf
3448769ce76dSAlexander Graf##########################################
3449fb599c9aSbalrog# bluez support probe
3450a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3451e820e3f4Sbalrog  cat > $TMPC << EOF
3452e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3453e820e3f4Sbalrogint main(void) { return bt_error(0); }
3454e820e3f4SbalrogEOF
345589138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
345689138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
345752166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3458a20a6f46SJuan Quintela    bluez=yes
3459e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3460e820e3f4Sbalrog  else
3461a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
346221684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3463a20a6f46SJuan Quintela    fi
3464e820e3f4Sbalrog    bluez="no"
3465e820e3f4Sbalrog  fi
3466fb599c9aSbalrogfi
3467fb599c9aSbalrog
3468fb599c9aSbalrog##########################################
3469e18df141SAnthony Liguori# glib support probe
3470a52d28afSPaolo Bonzini
3471e7b3af81SDaniel P. Berrangéglib_req_ver=2.40
3472aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3473aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3474a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3475aa0d1f44SPaolo Bonzinifi
3476e26110cfSFam Zheng
34774eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
34784eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
34794eaf7202SSameeh Jubran
34804eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
34814eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
34824eaf7202SSameeh Jubranfi
34834eaf7202SSameeh Jubran
3484aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3485e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
348689138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
348789138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
34884a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
348914015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3490957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3491e18df141SAnthony Liguori    else
3492e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3493e26110cfSFam Zheng    fi
3494e26110cfSFam Zhengdone
3495e26110cfSFam Zheng
3496977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3497977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3498977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3499977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3500977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3501977a82abSDaniel P. Berrange#include <glib.h>
3502977a82abSDaniel P. Berrange#include <unistd.h>
3503977a82abSDaniel P. Berrange
3504977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3505977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3506977a82abSDaniel P. Berrange
3507977a82abSDaniel P. Berrangeint main(void) {
3508977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3509977a82abSDaniel P. Berrange   return 0;
3510977a82abSDaniel P. Berrange}
3511977a82abSDaniel P. BerrangeEOF
3512977a82abSDaniel P. Berrange
35135919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3514977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3515977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3516977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3517977a82abSDaniel P. Berrange	       "build target"
3518977a82abSDaniel P. Berrangefi
3519977a82abSDaniel P. Berrange
3520bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3521bbbf2e04SJohn Snowcat > $TMPC << EOF
3522bbbf2e04SJohn Snow#include <glib.h>
3523bbbf2e04SJohn Snowint main(void) { return 0; }
3524bbbf2e04SJohn SnowEOF
3525bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3526bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3527bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3528bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3529bbbf2e04SJohn Snow    fi
3530bbbf2e04SJohn Snowfi
3531bbbf2e04SJohn Snow
35326a1f42bdSStefan Weil#########################################
35336a1f42bdSStefan Weil# zlib check
35346a1f42bdSStefan Weil
35356a1f42bdSStefan Weilif test "$zlib" != "no" ; then
35366a1f42bdSStefan Weil    if $pkg_config --exists zlib; then
35376a1f42bdSStefan Weil        zlib_cflags=$($pkg_config --cflags zlib)
35386a1f42bdSStefan Weil        zlib_libs=$($pkg_config --libs zlib)
35396a1f42bdSStefan Weil        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
35406a1f42bdSStefan Weil        LIBS="$zlib_libs $LIBS"
35416a1f42bdSStefan Weil    else
35426a1f42bdSStefan Weil        cat > $TMPC << EOF
35436a1f42bdSStefan Weil#include <zlib.h>
35446a1f42bdSStefan Weilint main(void) { zlibVersion(); return 0; }
35456a1f42bdSStefan WeilEOF
35466a1f42bdSStefan Weil        if compile_prog "" "-lz" ; then
35476a1f42bdSStefan Weil            LIBS="$LIBS -lz"
35486a1f42bdSStefan Weil        else
35496a1f42bdSStefan Weil            error_exit "zlib check failed" \
35506a1f42bdSStefan Weil                "Make sure to have the zlib libs and headers installed."
35516a1f42bdSStefan Weil        fi
35526a1f42bdSStefan Weil    fi
35536a1f42bdSStefan Weilfi
35546a1f42bdSStefan Weil
3555e26110cfSFam Zheng##########################################
3556e26110cfSFam Zheng# SHA command probe for modules
3557e26110cfSFam Zhengif test "$modules" = yes; then
3558e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3559e26110cfSFam Zheng    for c in $shacmd_probe; do
35608ccefb91SFam Zheng        if has $c; then
3561e26110cfSFam Zheng            shacmd="$c"
3562e26110cfSFam Zheng            break
3563e26110cfSFam Zheng        fi
3564e26110cfSFam Zheng    done
3565e26110cfSFam Zheng    if test "$shacmd" = ""; then
3566e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3567e26110cfSFam Zheng    fi
3568e18df141SAnthony Liguorifi
3569e18df141SAnthony Liguori
3570e18df141SAnthony Liguori##########################################
3571e2134eb9SGerd Hoffmann# pixman support probe
3572e2134eb9SGerd Hoffmann
357374880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
357474880fe2SRobert Schiele  pixman_cflags=
357574880fe2SRobert Schiele  pixman_libs=
357635c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
357789138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
357889138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3579e2134eb9SGerd Hoffmannelse
3580c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3581c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3582e2134eb9SGerd Hoffmannfi
3583e2134eb9SGerd Hoffmann
3584e2134eb9SGerd Hoffmann##########################################
3585fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3586fe8fc5aeSPaolo Bonzini
3587fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
35881b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3589fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3590fe8fc5aeSPaolo Bonzini#include <libudev.h>
3591fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3592fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3593fe8fc5aeSPaolo Bonziniint logsink;
3594b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3595b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3596b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3597b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3598b3f1c8c4SPaolo Bonzinistruct udev *udev;
3599b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3600b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3601b3f1c8c4SPaolo Bonzini
3602fe8fc5aeSPaolo Bonziniint main(void) {
3603b3f1c8c4SPaolo Bonzini    udev = udev_new();
3604b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3605fe8fc5aeSPaolo Bonzini    return 0;
3606fe8fc5aeSPaolo Bonzini}
3607fe8fc5aeSPaolo BonziniEOF
3608fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3609fe8fc5aeSPaolo Bonzini    mpathpersist=yes
36101b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
36111b0578f5SMurilo Opsfelder Araujo  else
36121b0578f5SMurilo Opsfelder Araujo    # probe for the old API
36131b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
36141b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
36151b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
36161b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
36171b0578f5SMurilo Opsfelder Araujoint logsink;
36181b0578f5SMurilo Opsfelder Araujoint main(void) {
36191b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
36201b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
36211b0578f5SMurilo Opsfelder Araujo    return 0;
36221b0578f5SMurilo Opsfelder Araujo}
36231b0578f5SMurilo Opsfelder AraujoEOF
36241b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
36251b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
36261b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3627fe8fc5aeSPaolo Bonzini    else
3628fe8fc5aeSPaolo Bonzini      mpathpersist=no
3629fe8fc5aeSPaolo Bonzini    fi
36301b0578f5SMurilo Opsfelder Araujo  fi
3631fe8fc5aeSPaolo Bonzinielse
3632fe8fc5aeSPaolo Bonzini  mpathpersist=no
3633fe8fc5aeSPaolo Bonzinifi
3634fe8fc5aeSPaolo Bonzini
3635fe8fc5aeSPaolo Bonzini##########################################
363617bff52bSM. Mohan Kumar# libcap probe
363717bff52bSM. Mohan Kumar
363817bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
363917bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
364017bff52bSM. Mohan Kumar#include <stdio.h>
364117bff52bSM. Mohan Kumar#include <sys/capability.h>
3642cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
364317bff52bSM. Mohan KumarEOF
364417bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
364517bff52bSM. Mohan Kumar    cap=yes
364617bff52bSM. Mohan Kumar  else
364717bff52bSM. Mohan Kumar    cap=no
364817bff52bSM. Mohan Kumar  fi
364917bff52bSM. Mohan Kumarfi
365017bff52bSM. Mohan Kumar
365117bff52bSM. Mohan Kumar##########################################
3652e5d355d1Saliguori# pthread probe
36534b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
36543c529d93Saliguori
3655e5d355d1Saliguoripthread=no
3656414f0dabSblueswir1cat > $TMPC << EOF
36573c529d93Saliguori#include <pthread.h>
36587a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
36597a42bbe4SStefan Weilint main(void) {
36607a42bbe4SStefan Weil  pthread_t thread;
36617a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
36627a42bbe4SStefan Weil  return 0;
36637a42bbe4SStefan Weil}
3664414f0dabSblueswir1EOF
3665bd00d539SAndreas Färberif compile_prog "" "" ; then
3666bd00d539SAndreas Färber  pthread=yes
3667bd00d539SAndreas Färberelse
3668de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
366952166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3670e5d355d1Saliguori      pthread=yes
3671e3c56761SPeter Portante      found=no
3672e3c56761SPeter Portante      for lib_entry in $LIBS; do
3673e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3674e3c56761SPeter Portante          found=yes
3675e3c56761SPeter Portante          break
3676e3c56761SPeter Portante        fi
3677e3c56761SPeter Portante      done
3678e3c56761SPeter Portante      if test "$found" = "no"; then
36795572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
368014ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3681e3c56761SPeter Portante      fi
3682409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3683de65fe0fSSebastian Herbszt      break
3684414f0dabSblueswir1    fi
3685de65fe0fSSebastian Herbszt  done
3686bd00d539SAndreas Färberfi
3687414f0dabSblueswir1
36884617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
368976ad07a4SPeter Maydell  error_exit "pthread check failed" \
369076ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3691e5d355d1Saliguorifi
3692e5d355d1Saliguori
36935c312079SDr. David Alan Gilbert# check for pthread_setname_np
36945c312079SDr. David Alan Gilbertpthread_setname_np=no
36955c312079SDr. David Alan Gilbertcat > $TMPC << EOF
36965c312079SDr. David Alan Gilbert#include <pthread.h>
36975c312079SDr. David Alan Gilbert
36985c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
36995c312079SDr. David Alan Gilbertint main(void)
37005c312079SDr. David Alan Gilbert{
37015c312079SDr. David Alan Gilbert    pthread_t thread;
37025c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
37035c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
37045c312079SDr. David Alan Gilbert    return 0;
37055c312079SDr. David Alan Gilbert}
37065c312079SDr. David Alan GilbertEOF
37075c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
37085c312079SDr. David Alan Gilbert  pthread_setname_np=yes
37095c312079SDr. David Alan Gilbertfi
37105c312079SDr. David Alan Gilbert
3711bf9298b9Saliguori##########################################
3712f27aaf4bSChristian Brunner# rbd probe
3713f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3714f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3715f27aaf4bSChristian Brunner#include <stdio.h>
3716ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3717f27aaf4bSChristian Brunnerint main(void) {
3718ad32e9c0SJosh Durgin    rados_t cluster;
3719ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3720f27aaf4bSChristian Brunner    return 0;
3721f27aaf4bSChristian Brunner}
3722f27aaf4bSChristian BrunnerEOF
3723ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3724f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3725f27aaf4bSChristian Brunner    rbd=yes
3726f27aaf4bSChristian Brunner  else
3727f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
372821684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3729f27aaf4bSChristian Brunner    fi
3730f27aaf4bSChristian Brunner    rbd=no
3731f27aaf4bSChristian Brunner  fi
3732f27aaf4bSChristian Brunnerfi
3733f27aaf4bSChristian Brunner
3734f27aaf4bSChristian Brunner##########################################
37350a12ec87SRichard W.M. Jones# libssh2 probe
37364fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
37370a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
373865d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
373989138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
374089138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
37410a12ec87SRichard W.M. Jones    libssh2=yes
37420a12ec87SRichard W.M. Jones  else
37430a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
37444fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
37450a12ec87SRichard W.M. Jones    fi
37460a12ec87SRichard W.M. Jones    libssh2=no
37470a12ec87SRichard W.M. Jones  fi
37480a12ec87SRichard W.M. Jonesfi
37490a12ec87SRichard W.M. Jones
37500a12ec87SRichard W.M. Jones##########################################
37519a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
37529a2d462eSRichard W.M. Jones
37539a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
37549a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
37559a2d462eSRichard W.M. Jones#include <stdio.h>
37569a2d462eSRichard W.M. Jones#include <libssh2.h>
37579a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
37589a2d462eSRichard W.M. Jonesint main(void) {
37599a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
37609a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
37619a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
37629a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
37639a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
37649a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
37659a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
37669a2d462eSRichard W.M. Jones    return 0;
37679a2d462eSRichard W.M. Jones}
37689a2d462eSRichard W.M. JonesEOF
37699a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
37709a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
37719a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
37729a2d462eSRichard W.M. Jones  fi
37739a2d462eSRichard W.M. Jonesfi
37749a2d462eSRichard W.M. Jones
37759a2d462eSRichard W.M. Jones##########################################
37765c6c3a6cSChristoph Hellwig# linux-aio probe
37775c6c3a6cSChristoph Hellwig
37785c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
37795c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
37805c6c3a6cSChristoph Hellwig#include <libaio.h>
37815c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3782832ce9c2SScott Wood#include <stddef.h>
37835c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
37845c6c3a6cSChristoph HellwigEOF
37855c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
37865c6c3a6cSChristoph Hellwig    linux_aio=yes
37875c6c3a6cSChristoph Hellwig  else
37885c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
378921684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
37905c6c3a6cSChristoph Hellwig    fi
37913cfcae3cSLuiz Capitulino    linux_aio=no
37925c6c3a6cSChristoph Hellwig  fi
37935c6c3a6cSChristoph Hellwigfi
37945c6c3a6cSChristoph Hellwig
37955c6c3a6cSChristoph Hellwig##########################################
37963b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
37973b8acc11SPaolo Bonzini
37983b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
37993b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
38003b8acc11SPaolo Bonzinielse
38013b8acc11SPaolo Bonzini  tpm_passthrough=no
38023b8acc11SPaolo Bonzinifi
38033b8acc11SPaolo Bonzini
3804f4ede81eSAmarnath Valluri# TPM emulator is for all posix systems
3805f4ede81eSAmarnath Valluriif test "$mingw32" != "yes"; then
3806f4ede81eSAmarnath Valluri  tpm_emulator=$tpm
3807f4ede81eSAmarnath Vallurielse
3808f4ede81eSAmarnath Valluri  tpm_emulator=no
3809f4ede81eSAmarnath Vallurifi
38103b8acc11SPaolo Bonzini##########################################
3811758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3812758e8e38SVenkateswararao Jujjuri (JV)
3813758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3814758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3815758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3816758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3817f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3818f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3819f2338fb4SPavel Borzenkov#else
38204f26f2b6SAvi Kivity#include <sys/xattr.h>
3821f2338fb4SPavel Borzenkov#endif
3822758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3823758e8e38SVenkateswararao Jujjuri (JV)EOF
38244f26f2b6SAvi Kivity  if compile_prog "" "" ; then
38254f26f2b6SAvi Kivity    attr=yes
38264f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3827f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3828758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3829758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
38304f26f2b6SAvi Kivity    libattr=yes
3831758e8e38SVenkateswararao Jujjuri (JV)  else
3832758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
383321684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3834758e8e38SVenkateswararao Jujjuri (JV)    fi
3835758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3836758e8e38SVenkateswararao Jujjuri (JV)  fi
3837758e8e38SVenkateswararao Jujjuri (JV)fi
3838758e8e38SVenkateswararao Jujjuri (JV)
3839758e8e38SVenkateswararao Jujjuri (JV)##########################################
3840bf9298b9Saliguori# iovec probe
3841bf9298b9Saliguoricat > $TMPC <<EOF
3842db34f0b3Sblueswir1#include <sys/types.h>
3843bf9298b9Saliguori#include <sys/uio.h>
3844db34f0b3Sblueswir1#include <unistd.h>
3845f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3846bf9298b9SaliguoriEOF
3847bf9298b9Saliguoriiovec=no
384852166aa0SJuan Quintelaif compile_prog "" "" ; then
3849bf9298b9Saliguori  iovec=yes
3850bf9298b9Saliguorifi
3851bf9298b9Saliguori
3852f652e6afSaurel32##########################################
3853ceb42de8Saliguori# preadv probe
3854ceb42de8Saliguoricat > $TMPC <<EOF
3855ceb42de8Saliguori#include <sys/types.h>
3856ceb42de8Saliguori#include <sys/uio.h>
3857ceb42de8Saliguori#include <unistd.h>
3858c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3859ceb42de8SaliguoriEOF
3860ceb42de8Saliguoripreadv=no
386152166aa0SJuan Quintelaif compile_prog "" "" ; then
3862ceb42de8Saliguori  preadv=yes
3863ceb42de8Saliguorifi
3864ceb42de8Saliguori
3865ceb42de8Saliguori##########################################
3866f652e6afSaurel32# fdt probe
3867e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3868e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3869e169e1e1SPeter Maydellfdt_required=no
3870e169e1e1SPeter Maydellfor target in $target_list; do
3871e169e1e1SPeter Maydell  case $target in
3872a666409fSKONRAD Frederic    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3873e169e1e1SPeter Maydell      fdt_required=yes
3874e169e1e1SPeter Maydell    ;;
3875e169e1e1SPeter Maydell  esac
3876e169e1e1SPeter Maydelldone
3877e169e1e1SPeter Maydell
3878e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3879e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3880e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3881e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3882e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3883e169e1e1SPeter Maydell  fi
3884e169e1e1SPeter Maydell  fdt=yes
3885e169e1e1SPeter Maydellfi
3886e169e1e1SPeter Maydell
38872df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3888b41af4baSJuan Quintela  fdt_libs="-lfdt"
388996ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
38906e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3891f652e6afSaurel32  cat > $TMPC << EOF
389231ce0adbSThomas Huth#include <libfdt.h>
389396ce6545SPeter Crosthwaite#include <libfdt_env.h>
38946e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3895f652e6afSaurel32EOF
389652166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3897a540f158SPeter Crosthwaite    # system DTC is good - use it
3898e3971d61SPhilippe Mathieu-Daudé    fdt=system
3899aef45d51SDaniel P. Berrange  else
3900aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3901aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3902aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3903aef45d51SDaniel P. Berrange      fi
3904aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3905e3971d61SPhilippe Mathieu-Daudé          fdt=git
3906a540f158SPeter Crosthwaite          mkdir -p dtc
3907cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3908a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3909a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
39102df87df7SJuan Quintela          fi
3911a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
39128a99e9a3SPhilippe Mathieu-Daudé          fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
39138a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
3914a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
3915aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
3916aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3917aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
3918a540f158SPeter Crosthwaite      else
3919a540f158SPeter Crosthwaite          # don't have and don't want
3920de3a354aSMichael Walle          fdt_libs=
39212df87df7SJuan Quintela          fdt=no
3922f652e6afSaurel32      fi
3923f652e6afSaurel32  fi
3924aef45d51SDaniel P. Berrangefi
3925f652e6afSaurel32
3926a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3927a540f158SPeter Crosthwaite
392820ff075bSMichael Walle##########################################
3929fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3930b1546f32SGerd Hoffmann
3931da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
39324939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
39335f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
39345f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
39355f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3936da076ffeSGerd Hoffmann    opengl=yes
3937925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3938925a0400SGerd Hoffmann        gtk_gl="yes"
3939925a0400SGerd Hoffmann    fi
3940cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
394120ff075bSMichael Walle  else
3942da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3943dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
394420ff075bSMichael Walle    fi
3945f676c67eSJeremy White    opengl_cflags=""
3946da076ffeSGerd Hoffmann    opengl_libs=""
3947da076ffeSGerd Hoffmann    opengl=no
394820ff075bSMichael Walle  fi
394920ff075bSMichael Wallefi
395020ff075bSMichael Walle
3951014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3952014cb152SGerd Hoffmann  cat > $TMPC << EOF
3953014cb152SGerd Hoffmann#include <epoxy/egl.h>
3954014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3955014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3956014cb152SGerd Hoffmann#endif
3957014cb152SGerd Hoffmannint main(void) { return 0; }
3958014cb152SGerd HoffmannEOF
3959014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3960014cb152SGerd Hoffmann    opengl_dmabuf=yes
3961014cb152SGerd Hoffmann  fi
3962014cb152SGerd Hoffmannfi
3963c9a12e75SChrysostomos Nanakos
3964ed279a06SKlim Kireev##########################################
3965ed279a06SKlim Kireev# libxml2 probe
3966ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3967ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3968ed279a06SKlim Kireev        libxml2="yes"
3969ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3970ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3971ed279a06SKlim Kireev    else
3972ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3973ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3974ed279a06SKlim Kireev        fi
3975ed279a06SKlim Kireev        libxml2="no"
3976ed279a06SKlim Kireev    fi
3977ed279a06SKlim Kireevfi
3978c9a12e75SChrysostomos Nanakos
3979eb100396SBharata B Rao##########################################
3980eb100396SBharata B Rao# glusterfs probe
3981eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
398265d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3983e01bee08SBharata B Rao    glusterfs="yes"
398489138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
398589138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3986d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3987d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3988d85fa9ebSJeff Cody    fi
398965d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
39900c14fb47SBharata B Rao      glusterfs_discard="yes"
39910c14fb47SBharata B Rao    fi
39927c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3993df3a429aSNiels de Vos      glusterfs_fallocate="yes"
39947c815372SBharata B Rao      glusterfs_zerofill="yes"
39957c815372SBharata B Rao    fi
3996eb100396SBharata B Rao  else
3997eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
39988efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
39998efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4000eb100396SBharata B Rao    fi
4001e01bee08SBharata B Rao    glusterfs="no"
4002eb100396SBharata B Rao  fi
4003eb100396SBharata B Raofi
4004eb100396SBharata B Rao
400539386ac7Saurel32# Check for inotify functions when we are building linux-user
40063b3f24adSaurel32# emulator.  This is done because older glibc versions don't
40073b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
40083b3f24adSaurel32# don't provide them even if kernel supports them.
40093b3f24adSaurel32#
40103b3f24adSaurel32inotify=no
40113b3f24adSaurel32cat > $TMPC << EOF
40123b3f24adSaurel32#include <sys/inotify.h>
40133b3f24adSaurel32
40143b3f24adSaurel32int
40153b3f24adSaurel32main(void)
40163b3f24adSaurel32{
40173b3f24adSaurel32	/* try to start inotify */
40188690e420Saurel32	return inotify_init();
40193b3f24adSaurel32}
40203b3f24adSaurel32EOF
402152166aa0SJuan Quintelaif compile_prog "" "" ; then
40223b3f24adSaurel32  inotify=yes
40233b3f24adSaurel32fi
40243b3f24adSaurel32
4025c05c7a73SRiku Voipioinotify1=no
4026c05c7a73SRiku Voipiocat > $TMPC << EOF
4027c05c7a73SRiku Voipio#include <sys/inotify.h>
4028c05c7a73SRiku Voipio
4029c05c7a73SRiku Voipioint
4030c05c7a73SRiku Voipiomain(void)
4031c05c7a73SRiku Voipio{
4032c05c7a73SRiku Voipio    /* try to start inotify */
4033c05c7a73SRiku Voipio    return inotify_init1(0);
4034c05c7a73SRiku Voipio}
4035c05c7a73SRiku VoipioEOF
4036c05c7a73SRiku Voipioif compile_prog "" "" ; then
4037c05c7a73SRiku Voipio  inotify1=yes
4038c05c7a73SRiku Voipiofi
4039c05c7a73SRiku Voipio
4040099d6b0fSRiku Voipio# check if pipe2 is there
4041099d6b0fSRiku Voipiopipe2=no
4042099d6b0fSRiku Voipiocat > $TMPC << EOF
4043099d6b0fSRiku Voipio#include <unistd.h>
4044099d6b0fSRiku Voipio#include <fcntl.h>
4045099d6b0fSRiku Voipio
4046099d6b0fSRiku Voipioint main(void)
4047099d6b0fSRiku Voipio{
4048099d6b0fSRiku Voipio    int pipefd[2];
40499bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4050099d6b0fSRiku Voipio}
4051099d6b0fSRiku VoipioEOF
405252166aa0SJuan Quintelaif compile_prog "" "" ; then
4053099d6b0fSRiku Voipio  pipe2=yes
4054099d6b0fSRiku Voipiofi
4055099d6b0fSRiku Voipio
405640ff6d7eSKevin Wolf# check if accept4 is there
405740ff6d7eSKevin Wolfaccept4=no
405840ff6d7eSKevin Wolfcat > $TMPC << EOF
405940ff6d7eSKevin Wolf#include <sys/socket.h>
406040ff6d7eSKevin Wolf#include <stddef.h>
406140ff6d7eSKevin Wolf
406240ff6d7eSKevin Wolfint main(void)
406340ff6d7eSKevin Wolf{
406440ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
406540ff6d7eSKevin Wolf    return 0;
406640ff6d7eSKevin Wolf}
406740ff6d7eSKevin WolfEOF
406840ff6d7eSKevin Wolfif compile_prog "" "" ; then
406940ff6d7eSKevin Wolf  accept4=yes
407040ff6d7eSKevin Wolffi
407140ff6d7eSKevin Wolf
40723ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
40733ce34dfbSvibisreenivasansplice=no
40743ce34dfbSvibisreenivasancat > $TMPC << EOF
40753ce34dfbSvibisreenivasan#include <unistd.h>
40763ce34dfbSvibisreenivasan#include <fcntl.h>
40773ce34dfbSvibisreenivasan#include <limits.h>
40783ce34dfbSvibisreenivasan
40793ce34dfbSvibisreenivasanint main(void)
40803ce34dfbSvibisreenivasan{
408166ea0f22SStefan Weil    int len, fd = 0;
40823ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
40833ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
40843ce34dfbSvibisreenivasan    return 0;
40853ce34dfbSvibisreenivasan}
40863ce34dfbSvibisreenivasanEOF
408752166aa0SJuan Quintelaif compile_prog "" "" ; then
40883ce34dfbSvibisreenivasan  splice=yes
40893ce34dfbSvibisreenivasanfi
40903ce34dfbSvibisreenivasan
4091dcc38d1cSMarcelo Tosatti##########################################
4092a99d57bbSWanlong Gao# libnuma probe
4093a99d57bbSWanlong Gao
4094a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4095a99d57bbSWanlong Gao  cat > $TMPC << EOF
4096a99d57bbSWanlong Gao#include <numa.h>
4097a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4098a99d57bbSWanlong GaoEOF
4099a99d57bbSWanlong Gao
4100a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4101a99d57bbSWanlong Gao    numa=yes
4102a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4103a99d57bbSWanlong Gao  else
4104a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4105a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4106a99d57bbSWanlong Gao    fi
4107a99d57bbSWanlong Gao    numa=no
4108a99d57bbSWanlong Gao  fi
4109a99d57bbSWanlong Gaofi
4110a99d57bbSWanlong Gao
41117b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
41127b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
41137b01cb97SAlexandre Derumier    exit 1
41147b01cb97SAlexandre Derumierfi
41157b01cb97SAlexandre Derumier
41165a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
41175a22ab71SYang Zhong# do not support it.
41185a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
41195a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
41205a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
41215a22ab71SYang Zhong    fi
41225a22ab71SYang Zhong    malloc_trim="no"
41235a22ab71SYang Zhongfi
41245a22ab71SYang Zhong
41255a22ab71SYang Zhong#######################################
41265a22ab71SYang Zhong# malloc_trim
41275a22ab71SYang Zhong
41285a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
41295a22ab71SYang Zhong    cat > $TMPC << EOF
41305a22ab71SYang Zhong#include <malloc.h>
41315a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
41325a22ab71SYang ZhongEOF
41335a22ab71SYang Zhong    if compile_prog "" "" ; then
41345a22ab71SYang Zhong        malloc_trim="yes"
41355a22ab71SYang Zhong    else
41365a22ab71SYang Zhong        malloc_trim="no"
41375a22ab71SYang Zhong    fi
41385a22ab71SYang Zhongfi
41395a22ab71SYang Zhong
4140a99d57bbSWanlong Gao##########################################
41412847b469SFam Zheng# tcmalloc probe
41422847b469SFam Zheng
41432847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
41442847b469SFam Zheng  cat > $TMPC << EOF
41452847b469SFam Zheng#include <stdlib.h>
41462847b469SFam Zhengint main(void) { malloc(1); return 0; }
41472847b469SFam ZhengEOF
41482847b469SFam Zheng
41492847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
41502847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
41512847b469SFam Zheng  else
41522847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
41532847b469SFam Zheng  fi
41542847b469SFam Zhengfi
41552847b469SFam Zheng
41562847b469SFam Zheng##########################################
41577b01cb97SAlexandre Derumier# jemalloc probe
41587b01cb97SAlexandre Derumier
41597b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
41607b01cb97SAlexandre Derumier  cat > $TMPC << EOF
41617b01cb97SAlexandre Derumier#include <stdlib.h>
41627b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
41637b01cb97SAlexandre DerumierEOF
41647b01cb97SAlexandre Derumier
41657b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
41667b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
41677b01cb97SAlexandre Derumier  else
41687b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
41697b01cb97SAlexandre Derumier  fi
41707b01cb97SAlexandre Derumierfi
41717b01cb97SAlexandre Derumier
41727b01cb97SAlexandre Derumier##########################################
4173dcc38d1cSMarcelo Tosatti# signalfd probe
4174dcc38d1cSMarcelo Tosattisignalfd="no"
4175dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4176dcc38d1cSMarcelo Tosatti#include <unistd.h>
4177dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4178dcc38d1cSMarcelo Tosatti#include <signal.h>
4179dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4180dcc38d1cSMarcelo TosattiEOF
4181dcc38d1cSMarcelo Tosatti
4182dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4183dcc38d1cSMarcelo Tosatti  signalfd=yes
4184dcc38d1cSMarcelo Tosattifi
4185dcc38d1cSMarcelo Tosatti
4186c2882b96SRiku Voipio# check if eventfd is supported
4187c2882b96SRiku Voipioeventfd=no
4188c2882b96SRiku Voipiocat > $TMPC << EOF
4189c2882b96SRiku Voipio#include <sys/eventfd.h>
4190c2882b96SRiku Voipio
4191c2882b96SRiku Voipioint main(void)
4192c2882b96SRiku Voipio{
419355cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4194c2882b96SRiku Voipio}
4195c2882b96SRiku VoipioEOF
4196c2882b96SRiku Voipioif compile_prog "" "" ; then
4197c2882b96SRiku Voipio  eventfd=yes
4198c2882b96SRiku Voipiofi
4199c2882b96SRiku Voipio
4200751bcc39SMarc-André Lureau# check if memfd is supported
4201751bcc39SMarc-André Lureaumemfd=no
4202751bcc39SMarc-André Lureaucat > $TMPC << EOF
420375e5b70eSPaolo Bonzini#include <sys/mman.h>
4204751bcc39SMarc-André Lureau
4205751bcc39SMarc-André Lureauint main(void)
4206751bcc39SMarc-André Lureau{
4207751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4208751bcc39SMarc-André Lureau}
4209751bcc39SMarc-André LureauEOF
4210751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4211751bcc39SMarc-André Lureau  memfd=yes
4212751bcc39SMarc-André Lureaufi
4213751bcc39SMarc-André Lureau
4214955727d2SCortland Tölva# check for usbfs
4215955727d2SCortland Tölvahave_usbfs=no
4216955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
4217955727d2SCortland Tölva  if check_include linux/usbdevice_fs.h; then
4218955727d2SCortland Tölva    have_usbfs=yes
4219955727d2SCortland Tölva  fi
4220955727d2SCortland Tölva  have_usbfs=yes
4221955727d2SCortland Tölvafi
4222751bcc39SMarc-André Lureau
4223d0927938SUlrich Hecht# check for fallocate
4224d0927938SUlrich Hechtfallocate=no
4225d0927938SUlrich Hechtcat > $TMPC << EOF
4226d0927938SUlrich Hecht#include <fcntl.h>
4227d0927938SUlrich Hecht
4228d0927938SUlrich Hechtint main(void)
4229d0927938SUlrich Hecht{
4230d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4231d0927938SUlrich Hecht    return 0;
4232d0927938SUlrich Hecht}
4233d0927938SUlrich HechtEOF
42348fb03151SPeter Maydellif compile_prog "" "" ; then
4235d0927938SUlrich Hecht  fallocate=yes
4236d0927938SUlrich Hechtfi
4237d0927938SUlrich Hecht
42383d4fa43eSKusanagi Kouichi# check for fallocate hole punching
42393d4fa43eSKusanagi Kouichifallocate_punch_hole=no
42403d4fa43eSKusanagi Kouichicat > $TMPC << EOF
42413d4fa43eSKusanagi Kouichi#include <fcntl.h>
42423d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
42433d4fa43eSKusanagi Kouichi
42443d4fa43eSKusanagi Kouichiint main(void)
42453d4fa43eSKusanagi Kouichi{
42463d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
42473d4fa43eSKusanagi Kouichi    return 0;
42483d4fa43eSKusanagi Kouichi}
42493d4fa43eSKusanagi KouichiEOF
42503d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
42513d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
42523d4fa43eSKusanagi Kouichifi
42533d4fa43eSKusanagi Kouichi
4254b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4255b953f075SDenis V. Lunevfallocate_zero_range=no
4256b953f075SDenis V. Lunevcat > $TMPC << EOF
4257b953f075SDenis V. Lunev#include <fcntl.h>
4258b953f075SDenis V. Lunev#include <linux/falloc.h>
4259b953f075SDenis V. Lunev
4260b953f075SDenis V. Lunevint main(void)
4261b953f075SDenis V. Lunev{
4262b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4263b953f075SDenis V. Lunev    return 0;
4264b953f075SDenis V. Lunev}
4265b953f075SDenis V. LunevEOF
4266b953f075SDenis V. Lunevif compile_prog "" "" ; then
4267b953f075SDenis V. Lunev  fallocate_zero_range=yes
4268b953f075SDenis V. Lunevfi
4269b953f075SDenis V. Lunev
4270ed911435SKevin Wolf# check for posix_fallocate
4271ed911435SKevin Wolfposix_fallocate=no
4272ed911435SKevin Wolfcat > $TMPC << EOF
4273ed911435SKevin Wolf#include <fcntl.h>
4274ed911435SKevin Wolf
4275ed911435SKevin Wolfint main(void)
4276ed911435SKevin Wolf{
4277ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4278ed911435SKevin Wolf    return 0;
4279ed911435SKevin Wolf}
4280ed911435SKevin WolfEOF
4281ed911435SKevin Wolfif compile_prog "" "" ; then
4282ed911435SKevin Wolf    posix_fallocate=yes
4283ed911435SKevin Wolffi
4284ed911435SKevin Wolf
4285c727f47dSPeter Maydell# check for sync_file_range
4286c727f47dSPeter Maydellsync_file_range=no
4287c727f47dSPeter Maydellcat > $TMPC << EOF
4288c727f47dSPeter Maydell#include <fcntl.h>
4289c727f47dSPeter Maydell
4290c727f47dSPeter Maydellint main(void)
4291c727f47dSPeter Maydell{
4292c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4293c727f47dSPeter Maydell    return 0;
4294c727f47dSPeter Maydell}
4295c727f47dSPeter MaydellEOF
42968fb03151SPeter Maydellif compile_prog "" "" ; then
4297c727f47dSPeter Maydell  sync_file_range=yes
4298c727f47dSPeter Maydellfi
4299c727f47dSPeter Maydell
4300dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4301dace20dcSPeter Maydellfiemap=no
4302dace20dcSPeter Maydellcat > $TMPC << EOF
4303dace20dcSPeter Maydell#include <sys/ioctl.h>
4304dace20dcSPeter Maydell#include <linux/fs.h>
4305dace20dcSPeter Maydell#include <linux/fiemap.h>
4306dace20dcSPeter Maydell
4307dace20dcSPeter Maydellint main(void)
4308dace20dcSPeter Maydell{
4309dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4310dace20dcSPeter Maydell    return 0;
4311dace20dcSPeter Maydell}
4312dace20dcSPeter MaydellEOF
43138fb03151SPeter Maydellif compile_prog "" "" ; then
4314dace20dcSPeter Maydell  fiemap=yes
4315dace20dcSPeter Maydellfi
4316dace20dcSPeter Maydell
4317d0927938SUlrich Hecht# check for dup3
4318d0927938SUlrich Hechtdup3=no
4319d0927938SUlrich Hechtcat > $TMPC << EOF
4320d0927938SUlrich Hecht#include <unistd.h>
4321d0927938SUlrich Hecht
4322d0927938SUlrich Hechtint main(void)
4323d0927938SUlrich Hecht{
4324d0927938SUlrich Hecht    dup3(0, 0, 0);
4325d0927938SUlrich Hecht    return 0;
4326d0927938SUlrich Hecht}
4327d0927938SUlrich HechtEOF
432878f5d726SJan Kiszkaif compile_prog "" "" ; then
4329d0927938SUlrich Hecht  dup3=yes
4330d0927938SUlrich Hechtfi
4331d0927938SUlrich Hecht
43324e0c6529SAlex Bligh# check for ppoll support
43334e0c6529SAlex Blighppoll=no
43344e0c6529SAlex Blighcat > $TMPC << EOF
43354e0c6529SAlex Bligh#include <poll.h>
43364e0c6529SAlex Bligh
43374e0c6529SAlex Blighint main(void)
43384e0c6529SAlex Bligh{
43394e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
43404e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
43414e0c6529SAlex Bligh    return 0;
43424e0c6529SAlex Bligh}
43434e0c6529SAlex BlighEOF
43444e0c6529SAlex Blighif compile_prog "" "" ; then
43454e0c6529SAlex Bligh  ppoll=yes
43464e0c6529SAlex Blighfi
43474e0c6529SAlex Bligh
4348cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4349cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4350cd758dd0SAlex Blighcat > $TMPC << EOF
4351cd758dd0SAlex Bligh#include <sys/prctl.h>
4352cd758dd0SAlex Bligh
4353cd758dd0SAlex Blighint main(void)
4354cd758dd0SAlex Bligh{
4355cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4356cd758dd0SAlex Bligh    return 0;
4357cd758dd0SAlex Bligh}
4358cd758dd0SAlex BlighEOF
4359cd758dd0SAlex Blighif compile_prog "" "" ; then
4360cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4361cd758dd0SAlex Blighfi
4362cd758dd0SAlex Bligh
43633b6edd16SPeter Maydell# check for epoll support
43643b6edd16SPeter Maydellepoll=no
43653b6edd16SPeter Maydellcat > $TMPC << EOF
43663b6edd16SPeter Maydell#include <sys/epoll.h>
43673b6edd16SPeter Maydell
43683b6edd16SPeter Maydellint main(void)
43693b6edd16SPeter Maydell{
43703b6edd16SPeter Maydell    epoll_create(0);
43713b6edd16SPeter Maydell    return 0;
43723b6edd16SPeter Maydell}
43733b6edd16SPeter MaydellEOF
43748fb03151SPeter Maydellif compile_prog "" "" ; then
43753b6edd16SPeter Maydell  epoll=yes
43763b6edd16SPeter Maydellfi
43773b6edd16SPeter Maydell
4378227f0214SPeter Maydell# epoll_create1 is a later addition
4379227f0214SPeter Maydell# so we must check separately for its presence
43803b6edd16SPeter Maydellepoll_create1=no
43813b6edd16SPeter Maydellcat > $TMPC << EOF
43823b6edd16SPeter Maydell#include <sys/epoll.h>
43833b6edd16SPeter Maydell
43843b6edd16SPeter Maydellint main(void)
43853b6edd16SPeter Maydell{
438619e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
438719e83f6bSPeter Maydell     * a function being called. This is necessary so that on
438819e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
438919e83f6bSPeter Maydell     * the library but not declared in the header file we will
439019e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
439119e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
439219e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
439319e83f6bSPeter Maydell     */
4394c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
43953b6edd16SPeter Maydell}
43963b6edd16SPeter MaydellEOF
43978fb03151SPeter Maydellif compile_prog "" "" ; then
43983b6edd16SPeter Maydell  epoll_create1=yes
43993b6edd16SPeter Maydellfi
44003b6edd16SPeter Maydell
4401a8fd1abaSPeter Maydell# check for sendfile support
4402a8fd1abaSPeter Maydellsendfile=no
4403a8fd1abaSPeter Maydellcat > $TMPC << EOF
4404a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4405a8fd1abaSPeter Maydell
4406a8fd1abaSPeter Maydellint main(void)
4407a8fd1abaSPeter Maydell{
4408a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4409a8fd1abaSPeter Maydell}
4410a8fd1abaSPeter MaydellEOF
4411a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4412a8fd1abaSPeter Maydell  sendfile=yes
4413a8fd1abaSPeter Maydellfi
4414a8fd1abaSPeter Maydell
441551834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
441651834341SRiku Voipiotimerfd=no
441751834341SRiku Voipiocat > $TMPC << EOF
441851834341SRiku Voipio#include <sys/timerfd.h>
441951834341SRiku Voipio
442051834341SRiku Voipioint main(void)
442151834341SRiku Voipio{
442251834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
442351834341SRiku Voipio}
442451834341SRiku VoipioEOF
442551834341SRiku Voipioif compile_prog "" "" ; then
442651834341SRiku Voipio  timerfd=yes
442751834341SRiku Voipiofi
442851834341SRiku Voipio
44299af5c906SRiku Voipio# check for setns and unshare support
44309af5c906SRiku Voipiosetns=no
44319af5c906SRiku Voipiocat > $TMPC << EOF
44329af5c906SRiku Voipio#include <sched.h>
44339af5c906SRiku Voipio
44349af5c906SRiku Voipioint main(void)
44359af5c906SRiku Voipio{
44369af5c906SRiku Voipio    int ret;
44379af5c906SRiku Voipio    ret = setns(0, 0);
44389af5c906SRiku Voipio    ret = unshare(0);
44399af5c906SRiku Voipio    return ret;
44409af5c906SRiku Voipio}
44419af5c906SRiku VoipioEOF
44429af5c906SRiku Voipioif compile_prog "" "" ; then
44439af5c906SRiku Voipio  setns=yes
44449af5c906SRiku Voipiofi
44459af5c906SRiku Voipio
444638860a03SAleksandar Markovic# clock_adjtime probe
444738860a03SAleksandar Markovicclock_adjtime=no
444838860a03SAleksandar Markoviccat > $TMPC <<EOF
444938860a03SAleksandar Markovic#include <time.h>
445038860a03SAleksandar Markovic
445138860a03SAleksandar Markovicint main(void)
445238860a03SAleksandar Markovic{
445338860a03SAleksandar Markovic    return clock_adjtime(0, 0);
445438860a03SAleksandar Markovic}
445538860a03SAleksandar MarkovicEOF
445638860a03SAleksandar Markovicclock_adjtime=no
445738860a03SAleksandar Markovicif compile_prog "" "" ; then
445838860a03SAleksandar Markovic  clock_adjtime=yes
445938860a03SAleksandar Markovicfi
446038860a03SAleksandar Markovic
44615a03cd00SAleksandar Markovic# syncfs probe
44625a03cd00SAleksandar Markovicsyncfs=no
44635a03cd00SAleksandar Markoviccat > $TMPC <<EOF
44645a03cd00SAleksandar Markovic#include <unistd.h>
44655a03cd00SAleksandar Markovic
44665a03cd00SAleksandar Markovicint main(void)
44675a03cd00SAleksandar Markovic{
44685a03cd00SAleksandar Markovic    return syncfs(0);
44695a03cd00SAleksandar Markovic}
44705a03cd00SAleksandar MarkovicEOF
44715a03cd00SAleksandar Markovicsyncfs=no
44725a03cd00SAleksandar Markovicif compile_prog "" "" ; then
44735a03cd00SAleksandar Markovic  syncfs=yes
44745a03cd00SAleksandar Markovicfi
44755a03cd00SAleksandar Markovic
4476cc8ae6deSpbrook# Check if tools are available to build documentation.
4477a25dba17SJuan Quintelaif test "$docs" != "no" ; then
447801668d98SStefan Weil  if has makeinfo && has pod2man; then
4479a25dba17SJuan Quintela    docs=yes
448083a3ab8bSJuan Quintela  else
4481a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
448221684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
448383a3ab8bSJuan Quintela    fi
4484a25dba17SJuan Quintela    docs=no
448583a3ab8bSJuan Quintela  fi
4486cc8ae6deSpbrookfi
4487cc8ae6deSpbrook
4488f514f41cSStefan Weil# Search for bswap_32 function
44896ae9a1f4SJuan Quintelabyteswap_h=no
44906ae9a1f4SJuan Quintelacat > $TMPC << EOF
44916ae9a1f4SJuan Quintela#include <byteswap.h>
44926ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
44936ae9a1f4SJuan QuintelaEOF
449452166aa0SJuan Quintelaif compile_prog "" "" ; then
44956ae9a1f4SJuan Quintela  byteswap_h=yes
44966ae9a1f4SJuan Quintelafi
44976ae9a1f4SJuan Quintela
449875f13596SStefan Weil# Search for bswap32 function
44996ae9a1f4SJuan Quintelabswap_h=no
45006ae9a1f4SJuan Quintelacat > $TMPC << EOF
45016ae9a1f4SJuan Quintela#include <sys/endian.h>
45026ae9a1f4SJuan Quintela#include <sys/types.h>
45036ae9a1f4SJuan Quintela#include <machine/bswap.h>
45046ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
45056ae9a1f4SJuan QuintelaEOF
450652166aa0SJuan Quintelaif compile_prog "" "" ; then
45076ae9a1f4SJuan Quintela  bswap_h=yes
45086ae9a1f4SJuan Quintelafi
45096ae9a1f4SJuan Quintela
4510da93a1fdSaliguori##########################################
4511e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4512c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4513e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
45143c33ea96SPaolo Bonzini    libiscsi="yes"
4515ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4516ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4517c589b249SRonnie Sahlberg  else
4518c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4519e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4520c589b249SRonnie Sahlberg    fi
4521c589b249SRonnie Sahlberg    libiscsi="no"
4522c589b249SRonnie Sahlberg  fi
4523c589b249SRonnie Sahlbergfi
4524c589b249SRonnie Sahlberg
4525c589b249SRonnie Sahlberg##########################################
45268bacde8dSNatanael Copa# Do we need libm
45278bacde8dSNatanael Copacat > $TMPC << EOF
45288bacde8dSNatanael Copa#include <math.h>
4529f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
45308bacde8dSNatanael CopaEOF
45318bacde8dSNatanael Copaif compile_prog "" "" ; then
45328bacde8dSNatanael Copa  :
45338bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
45348bacde8dSNatanael Copa  LIBS="-lm $LIBS"
45358bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
45368bacde8dSNatanael Copaelse
453776ad07a4SPeter Maydell  error_exit "libm check failed"
45388bacde8dSNatanael Copafi
45398bacde8dSNatanael Copa
45408bacde8dSNatanael Copa##########################################
4541da93a1fdSaliguori# Do we need librt
45428bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
45438bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
45448bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
45458bacde8dSNatanael Copa# function in addition.
4546da93a1fdSaliguoricat > $TMPC <<EOF
4547da93a1fdSaliguori#include <signal.h>
4548da93a1fdSaliguori#include <time.h>
45498bacde8dSNatanael Copaint main(void) {
45508bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
45518bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
45528bacde8dSNatanael Copa}
4553da93a1fdSaliguoriEOF
4554da93a1fdSaliguori
455552166aa0SJuan Quintelaif compile_prog "" "" ; then
455607ffa4bdSJuan Quintela  :
45578bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
455818e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
455918e588b1SRick Liu  LIBS="$LIBS -lrt"
456018e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4561da93a1fdSaliguorifi
4562da93a1fdSaliguori
456331ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
456478723752SPeter Maydell        "$haiku" != "yes" ; then
45656362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
45666362a53fSJuan Quintelafi
45676362a53fSJuan Quintela
4568de5071c5SBlue Swirl##########################################
4569cd4ec0b4SGerd Hoffmann# spice probe
4570cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4571cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4572cd4ec0b4SGerd Hoffmann#include <spice.h>
4573cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4574cd4ec0b4SGerd HoffmannEOF
4575710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4576710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
457765d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
457865d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4579cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4580cd4ec0b4SGerd Hoffmann    spice="yes"
4581cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4582cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
45832e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
45842e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4585cd4ec0b4SGerd Hoffmann  else
4586cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
45878efc9363SHu Tao      feature_not_found "spice" \
45888efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4589cd4ec0b4SGerd Hoffmann    fi
4590cd4ec0b4SGerd Hoffmann    spice="no"
4591cd4ec0b4SGerd Hoffmann  fi
4592cd4ec0b4SGerd Hoffmannfi
4593cd4ec0b4SGerd Hoffmann
45947b02f544SMarc-André Lureau# check for smartcard support
45957b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
45960f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
45977b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
45987b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
45997b02f544SMarc-André Lureau        smartcard="yes"
4600111a38b0SRobert Relyea    else
46017b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
46027b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4603111a38b0SRobert Relyea        fi
46047b02f544SMarc-André Lureau        smartcard="no"
4605111a38b0SRobert Relyea    fi
4606111a38b0SRobert Relyeafi
4607111a38b0SRobert Relyea
46082b2325ffSGerd Hoffmann# check for libusb
46092b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
461065d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
46112b2325ffSGerd Hoffmann        libusb="yes"
4612ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4613ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
46142b2325ffSGerd Hoffmann    else
46152b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
46168efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
46172b2325ffSGerd Hoffmann        fi
46182b2325ffSGerd Hoffmann        libusb="no"
46192b2325ffSGerd Hoffmann    fi
46202b2325ffSGerd Hoffmannfi
46212b2325ffSGerd Hoffmann
462269354a83SHans de Goede# check for usbredirparser for usb network redirection support
462369354a83SHans de Goedeif test "$usb_redir" != "no" ; then
462465d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
462569354a83SHans de Goede        usb_redir="yes"
4626ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4627ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
462869354a83SHans de Goede    else
462969354a83SHans de Goede        if test "$usb_redir" = "yes"; then
463021684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
463169354a83SHans de Goede        fi
463269354a83SHans de Goede        usb_redir="no"
463369354a83SHans de Goede    fi
463469354a83SHans de Goedefi
463569354a83SHans de Goede
4636cd4ec0b4SGerd Hoffmann##########################################
4637d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4638d9840e25STomoki Sekiyama
4639d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4640d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4641690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4642d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4643d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4644690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4645d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4646d9840e25STomoki Sekiyama	  ;;
4647690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4648d9840e25STomoki Sekiyama  esac
4649d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4650d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4651d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4652d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4653d9840e25STomoki SekiyamaEOF
4654d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4655d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4656d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4657315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4658f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4659d9840e25STomoki Sekiyama  else
4660d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4661d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4662d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4663d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4664d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4665d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4666d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4667d9840e25STomoki Sekiyama    fi
4668d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4669d9840e25STomoki Sekiyama  fi
4670d9840e25STomoki Sekiyamafi
4671d9840e25STomoki Sekiyama
4672d9840e25STomoki Sekiyama##########################################
4673d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4674d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4675d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4676d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4677d9840e25STomoki Sekiyama
4678d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4679d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4680d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4681d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4682d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4683d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4684d9840e25STomoki Sekiyama    else
4685d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4686d9840e25STomoki Sekiyama    fi
4687d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4688d9840e25STomoki Sekiyama    win_sdk=""
4689d9840e25STomoki Sekiyama  fi
4690d9840e25STomoki Sekiyamafi
4691d9840e25STomoki Sekiyama
4692d9840e25STomoki Sekiyama##########################################
469350cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
469450cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
469550cbebb9SMichael Roth  cat > $TMPC << EOF
469650cbebb9SMichael Roth#include <windows.h>
469750cbebb9SMichael Roth#include <ntddscsi.h>
469850cbebb9SMichael Rothint main(void) {
469950cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
470050cbebb9SMichael Roth#error Missing required ioctl definitions
470150cbebb9SMichael Roth#endif
470250cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
470350cbebb9SMichael Roth  return addr.Lun;
470450cbebb9SMichael Roth}
470550cbebb9SMichael RothEOF
470650cbebb9SMichael Roth  if compile_prog "" "" ; then
470750cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4708c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
470950cbebb9SMichael Roth  fi
471050cbebb9SMichael Rothfi
471150cbebb9SMichael Roth
471250cbebb9SMichael Roth##########################################
47139d9e1521SGerd Hoffmann# virgl renderer probe
47149d9e1521SGerd Hoffmann
47159d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
47169d9e1521SGerd Hoffmann  cat > $TMPC << EOF
47179d9e1521SGerd Hoffmann#include <virglrenderer.h>
47189d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
47199d9e1521SGerd HoffmannEOF
47209d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
47219d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
472247479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
47239d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
47249d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
47259d9e1521SGerd Hoffmann    virglrenderer="yes"
47269d9e1521SGerd Hoffmann  else
47279d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
47289d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
47299d9e1521SGerd Hoffmann    fi
47309d9e1521SGerd Hoffmann    virglrenderer="no"
47319d9e1521SGerd Hoffmann  fi
47329d9e1521SGerd Hoffmannfi
47339d9e1521SGerd Hoffmann
47349d9e1521SGerd Hoffmann##########################################
47358ca80760SRichard Henderson# capstone
47368ca80760SRichard Henderson
4737e219c499SRichard Hendersoncase "$capstone" in
4738e219c499SRichard Henderson  "" | yes)
47398ca80760SRichard Henderson    if $pkg_config capstone; then
4740e219c499SRichard Henderson      capstone=system
4741123ac0bbSAlexey Kardashevskiy    elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
4742e219c499SRichard Henderson      capstone=git
4743e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4744e219c499SRichard Henderson      capstone=internal
4745e219c499SRichard Henderson    elif test -z "$capstone" ; then
4746e219c499SRichard Henderson      capstone=no
4747e219c499SRichard Henderson    else
4748e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4749e219c499SRichard Henderson    fi
4750e219c499SRichard Henderson    ;;
4751e219c499SRichard Henderson
4752e219c499SRichard Henderson  system)
4753e219c499SRichard Henderson    if ! $pkg_config capstone; then
4754e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4755e219c499SRichard Henderson    fi
4756e219c499SRichard Henderson    ;;
4757e219c499SRichard Hendersonesac
4758e219c499SRichard Henderson
4759e219c499SRichard Hendersoncase "$capstone" in
4760e219c499SRichard Henderson  git | internal)
4761e219c499SRichard Henderson    if test "$capstone" = git; then
4762e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4763e219c499SRichard Henderson    fi
4764e219c499SRichard Henderson    mkdir -p capstone
4765e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4766e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4767e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4768e219c499SRichard Henderson    else
4769e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4770e219c499SRichard Henderson    fi
4771e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4772e219c499SRichard Henderson    ;;
4773e219c499SRichard Henderson
4774e219c499SRichard Henderson  system)
47758ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
47768ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4777e219c499SRichard Henderson    ;;
4778e219c499SRichard Henderson
4779e219c499SRichard Henderson  no)
4780e219c499SRichard Henderson    ;;
4781e219c499SRichard Henderson  *)
4782e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4783e219c499SRichard Henderson    ;;
4784e219c499SRichard Hendersonesac
47858ca80760SRichard Henderson
47868ca80760SRichard Henderson##########################################
47875f6b9e8fSBlue Swirl# check if we have fdatasync
47885f6b9e8fSBlue Swirl
47895f6b9e8fSBlue Swirlfdatasync=no
47905f6b9e8fSBlue Swirlcat > $TMPC << EOF
47915f6b9e8fSBlue Swirl#include <unistd.h>
4792d1722a27SAlexandre Raymondint main(void) {
4793d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4794d1722a27SAlexandre Raymondreturn fdatasync(0);
4795d1722a27SAlexandre Raymond#else
4796e172fe11SStefan Weil#error Not supported
4797d1722a27SAlexandre Raymond#endif
4798d1722a27SAlexandre Raymond}
47995f6b9e8fSBlue SwirlEOF
48005f6b9e8fSBlue Swirlif compile_prog "" "" ; then
48015f6b9e8fSBlue Swirl    fdatasync=yes
48025f6b9e8fSBlue Swirlfi
48035f6b9e8fSBlue Swirl
480494a420b1SStefan Hajnoczi##########################################
4805e78815a5SAndreas Färber# check if we have madvise
4806e78815a5SAndreas Färber
4807e78815a5SAndreas Färbermadvise=no
4808e78815a5SAndreas Färbercat > $TMPC << EOF
4809e78815a5SAndreas Färber#include <sys/types.h>
4810e78815a5SAndreas Färber#include <sys/mman.h>
4811832ce9c2SScott Wood#include <stddef.h>
4812e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4813e78815a5SAndreas FärberEOF
4814e78815a5SAndreas Färberif compile_prog "" "" ; then
4815e78815a5SAndreas Färber    madvise=yes
4816e78815a5SAndreas Färberfi
4817e78815a5SAndreas Färber
4818e78815a5SAndreas Färber##########################################
4819e78815a5SAndreas Färber# check if we have posix_madvise
4820e78815a5SAndreas Färber
4821e78815a5SAndreas Färberposix_madvise=no
4822e78815a5SAndreas Färbercat > $TMPC << EOF
4823e78815a5SAndreas Färber#include <sys/mman.h>
4824832ce9c2SScott Wood#include <stddef.h>
4825e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4826e78815a5SAndreas FärberEOF
4827e78815a5SAndreas Färberif compile_prog "" "" ; then
4828e78815a5SAndreas Färber    posix_madvise=yes
4829e78815a5SAndreas Färberfi
4830e78815a5SAndreas Färber
4831e78815a5SAndreas Färber##########################################
48329bc5a719SAndreas Gustafsson# check if we have posix_memalign()
48339bc5a719SAndreas Gustafsson
48349bc5a719SAndreas Gustafssonposix_memalign=no
48359bc5a719SAndreas Gustafssoncat > $TMPC << EOF
48369bc5a719SAndreas Gustafsson#include <stdlib.h>
48379bc5a719SAndreas Gustafssonint main(void) {
48389bc5a719SAndreas Gustafsson    void *p;
48399bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
48409bc5a719SAndreas Gustafsson}
48419bc5a719SAndreas GustafssonEOF
48429bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
48439bc5a719SAndreas Gustafsson    posix_memalign=yes
48449bc5a719SAndreas Gustafssonfi
48459bc5a719SAndreas Gustafsson
48469bc5a719SAndreas Gustafsson##########################################
48470a852417SPaul Durrant# check if we have posix_syslog
48480a852417SPaul Durrant
48490a852417SPaul Durrantposix_syslog=no
48500a852417SPaul Durrantcat > $TMPC << EOF
48510a852417SPaul Durrant#include <syslog.h>
48520a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
48530a852417SPaul DurrantEOF
48540a852417SPaul Durrantif compile_prog "" "" ; then
48550a852417SPaul Durrant    posix_syslog=yes
48560a852417SPaul Durrantfi
48570a852417SPaul Durrant
48580a852417SPaul Durrant##########################################
4859401bc051SPeter Maydell# check if we have sem_timedwait
4860401bc051SPeter Maydell
4861401bc051SPeter Maydellsem_timedwait=no
4862401bc051SPeter Maydellcat > $TMPC << EOF
4863401bc051SPeter Maydell#include <semaphore.h>
4864401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4865401bc051SPeter MaydellEOF
4866401bc051SPeter Maydellif compile_prog "" "" ; then
4867401bc051SPeter Maydell    sem_timedwait=yes
4868401bc051SPeter Maydellfi
4869401bc051SPeter Maydell
4870401bc051SPeter Maydell##########################################
48715c99fa37SKeno Fischer# check if we have strchrnul
48725c99fa37SKeno Fischer
48735c99fa37SKeno Fischerstrchrnul=no
48745c99fa37SKeno Fischercat > $TMPC << EOF
48755c99fa37SKeno Fischer#include <string.h>
48765c99fa37SKeno Fischerint main(void);
48775c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
48785c99fa37SKeno Fischerchar *haystack = (char*)&main;
48795c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
48805c99fa37SKeno FischerEOF
48815c99fa37SKeno Fischerif compile_prog "" "" ; then
48825c99fa37SKeno Fischer    strchrnul=yes
48835c99fa37SKeno Fischerfi
48845c99fa37SKeno Fischer
48855c99fa37SKeno Fischer##########################################
488694a420b1SStefan Hajnoczi# check if trace backend exists
488794a420b1SStefan Hajnoczi
48885b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
488994a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
48905b808275SLluís Vilanova  error_exit "invalid trace backends" \
48915b808275SLluís Vilanova      "Please choose supported trace backends."
489294a420b1SStefan Hajnoczifi
489394a420b1SStefan Hajnoczi
48947e24e92aSStefan Hajnoczi##########################################
48957e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
48965b808275SLluís Vilanovaif have_backend "ust"; then
48977e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4898bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
48997e24e92aSStefan Hajnocziint main(void) { return 0; }
49007e24e92aSStefan HajnocziEOF
4901c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4902bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
490389138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
49047e24e92aSStefan Hajnoczi    else
4905c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4906bf15f63cSMohamad Gebai    fi
4907bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
490889138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4909bf15f63cSMohamad Gebai    else
4910bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4911bf15f63cSMohamad Gebai    fi
4912bf15f63cSMohamad Gebai
4913bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4914bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4915bf15f63cSMohamad Gebai  else
4916bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
49177e24e92aSStefan Hajnoczi  fi
49187e24e92aSStefan Hajnoczifi
4919b3d08c02SDaniel P. Berrange
4920b3d08c02SDaniel P. Berrange##########################################
4921b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
49225b808275SLluís Vilanovaif have_backend "dtrace"; then
4923b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
492476ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4925b3d08c02SDaniel P. Berrange  fi
4926c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4927c276b17dSDaniel P. Berrange  if has 'stap' ; then
4928c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4929c276b17dSDaniel P. Berrange  fi
4930b3d08c02SDaniel P. Berrangefi
4931b3d08c02SDaniel P. Berrange
49327e24e92aSStefan Hajnoczi##########################################
4933519175a2SAlex Barcelo# check and set a backend for coroutine
4934d0e2fce5SAneesh Kumar K.V
49357c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
493633c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
493733c53c54SDaniel P. Berrange# specific one.
49387c2acc70SPeter Maydell
49397c2acc70SPeter Maydellucontext_works=no
4940d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4941d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4942d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4943cdf84806SPeter Maydell#ifdef __stub_makecontext
4944cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4945cdf84806SPeter Maydell#endif
494675cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4947d0e2fce5SAneesh Kumar K.VEOF
4948d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
49497c2acc70SPeter Maydell    ucontext_works=yes
4950d0e2fce5SAneesh Kumar K.V  fi
4951519175a2SAlex Barcelofi
49527c2acc70SPeter Maydell
49537c2acc70SPeter Maydellif test "$coroutine" = ""; then
49547c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
49557c2acc70SPeter Maydell    coroutine=win32
49567c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
49577c2acc70SPeter Maydell    coroutine=ucontext
4958519175a2SAlex Barcelo  else
49597c2acc70SPeter Maydell    coroutine=sigaltstack
49607c2acc70SPeter Maydell  fi
49617c2acc70SPeter Maydellelse
49627c2acc70SPeter Maydell  case $coroutine in
49637c2acc70SPeter Maydell  windows)
49647c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
49657c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
49667c2acc70SPeter Maydell    fi
49677c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
49687c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
49697c2acc70SPeter Maydell    coroutine=win32
49707c2acc70SPeter Maydell    ;;
49717c2acc70SPeter Maydell  ucontext)
49727c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
49737c2acc70SPeter Maydell      feature_not_found "ucontext"
49747c2acc70SPeter Maydell    fi
49757c2acc70SPeter Maydell    ;;
497633c53c54SDaniel P. Berrange  sigaltstack)
49777c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
49787c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
49797c2acc70SPeter Maydell    fi
49807c2acc70SPeter Maydell    ;;
49817c2acc70SPeter Maydell  *)
498276ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
49837c2acc70SPeter Maydell    ;;
49847c2acc70SPeter Maydell  esac
4985d0e2fce5SAneesh Kumar K.Vfi
4986d0e2fce5SAneesh Kumar K.V
498770c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
498870c60c08SStefan Hajnoczi  coroutine_pool=yes
498970c60c08SStefan Hajnoczifi
499070c60c08SStefan Hajnoczi
49917d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
49927d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
49937d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
49947d992e4dSPeter Lieven    coroutine_pool=no
49957d992e4dSPeter Lieven  fi
49967d992e4dSPeter Lievenfi
49977d992e4dSPeter Lieven
49987d992e4dSPeter Lieven
4999d0e2fce5SAneesh Kumar K.V##########################################
5000d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5001d2042378SAneesh Kumar K.V
50024e1797f9SStefan Weilopen_by_handle_at=no
5003d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5004d2042378SAneesh Kumar K.V#include <fcntl.h>
5005acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5006acc55ba8SStefan Weil# error missing definition
5007acc55ba8SStefan Weil#else
500875cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5009acc55ba8SStefan Weil#endif
5010d2042378SAneesh Kumar K.VEOF
5011d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5012d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5013d2042378SAneesh Kumar K.Vfi
5014d2042378SAneesh Kumar K.V
5015e06a765eSHarsh Prateek Bora########################################
5016e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5017e06a765eSHarsh Prateek Bora
5018e06a765eSHarsh Prateek Boralinux_magic_h=no
5019e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5020e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5021e06a765eSHarsh Prateek Boraint main(void) {
502275cafad7SStefan Weil  return 0;
5023e06a765eSHarsh Prateek Bora}
5024e06a765eSHarsh Prateek BoraEOF
5025e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5026e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5027e06a765eSHarsh Prateek Borafi
5028e06a765eSHarsh Prateek Bora
50298ab1bf12SLuiz Capitulino########################################
5030c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
5031c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
5032c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
5033c95e3080SKevin Wolf# only a warning.
5034c95e3080SKevin Wolf#
5035c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
5036c95e3080SKevin Wolf# the build doesn't fail anyway.
5037c95e3080SKevin Wolf
503806d71fa1SPeter Maydellpragma_disable_unused_but_set=no
503906d71fa1SPeter Maydellcat > $TMPC << EOF
5040e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
5041c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5042e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
5043c95e3080SKevin Wolf
504406d71fa1SPeter Maydellint main(void) {
504506d71fa1SPeter Maydell    return 0;
504606d71fa1SPeter Maydell}
504706d71fa1SPeter MaydellEOF
504806d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
5049cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
5050c95e3080SKevin Wolfelse
5051c95e3080SKevin Wolf    werror=no
505206d71fa1SPeter Maydellfi
505306d71fa1SPeter Maydell
505406d71fa1SPeter Maydell########################################
5055541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
50563f4349dcSKevin Wolf
50573f4349dcSKevin Wolfvalgrind_h=no
50583f4349dcSKevin Wolfcat > $TMPC << EOF
50593f4349dcSKevin Wolf#include <valgrind/valgrind.h>
50603f4349dcSKevin Wolfint main(void) {
50613f4349dcSKevin Wolf  return 0;
50623f4349dcSKevin Wolf}
50633f4349dcSKevin WolfEOF
50643f4349dcSKevin Wolfif compile_prog "" "" ; then
50653f4349dcSKevin Wolf    valgrind_h=yes
50663f4349dcSKevin Wolffi
50673f4349dcSKevin Wolf
50683f4349dcSKevin Wolf########################################
50698ab1bf12SLuiz Capitulino# check if environ is declared
50708ab1bf12SLuiz Capitulino
50718ab1bf12SLuiz Capitulinohas_environ=no
50728ab1bf12SLuiz Capitulinocat > $TMPC << EOF
50738ab1bf12SLuiz Capitulino#include <unistd.h>
50748ab1bf12SLuiz Capitulinoint main(void) {
5075c075a723SBlue Swirl    environ = 0;
50768ab1bf12SLuiz Capitulino    return 0;
50778ab1bf12SLuiz Capitulino}
50788ab1bf12SLuiz CapitulinoEOF
50798ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
50808ab1bf12SLuiz Capitulino    has_environ=yes
50818ab1bf12SLuiz Capitulinofi
50828ab1bf12SLuiz Capitulino
508376a347e1SRichard Henderson########################################
508476a347e1SRichard Henderson# check if cpuid.h is usable.
508576a347e1SRichard Henderson
508676a347e1SRichard Hendersoncat > $TMPC << EOF
508776a347e1SRichard Henderson#include <cpuid.h>
508876a347e1SRichard Hendersonint main(void) {
5089774d566cSPeter Maydell    unsigned a, b, c, d;
5090774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5091774d566cSPeter Maydell
5092774d566cSPeter Maydell    if (max >= 1) {
5093774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5094774d566cSPeter Maydell    }
5095774d566cSPeter Maydell
5096774d566cSPeter Maydell    if (max >= 7) {
5097774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5098774d566cSPeter Maydell    }
5099774d566cSPeter Maydell
510076a347e1SRichard Henderson    return 0;
510176a347e1SRichard Henderson}
510276a347e1SRichard HendersonEOF
510376a347e1SRichard Hendersonif compile_prog "" "" ; then
510476a347e1SRichard Henderson    cpuid_h=yes
510576a347e1SRichard Hendersonfi
510676a347e1SRichard Henderson
51075dd89908SRichard Henderson##########################################
51085dd89908SRichard Henderson# avx2 optimization requirement check
51095dd89908SRichard Henderson#
51105dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
51115dd89908SRichard Henderson# since we won't be able to select the new routines.
51125dd89908SRichard Henderson
511386583a07SLiam Merwickif test "$cpuid_h" = "yes" -a "$avx2_opt" != "no"; then
51145dd89908SRichard Henderson  cat > $TMPC << EOF
51155dd89908SRichard Henderson#pragma GCC push_options
51165dd89908SRichard Henderson#pragma GCC target("avx2")
51175dd89908SRichard Henderson#include <cpuid.h>
51185dd89908SRichard Henderson#include <immintrin.h>
51195dd89908SRichard Hendersonstatic int bar(void *a) {
51205dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
51215dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
51225dd89908SRichard Henderson}
51235dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
51245dd89908SRichard HendersonEOF
51255dd89908SRichard Henderson  if compile_object "" ; then
51265dd89908SRichard Henderson    avx2_opt="yes"
512786583a07SLiam Merwick  else
512886583a07SLiam Merwick    avx2_opt="no"
51295dd89908SRichard Henderson  fi
51305dd89908SRichard Hendersonfi
51315dd89908SRichard Henderson
5132f540166bSRichard Henderson########################################
5133f540166bSRichard Henderson# check if __[u]int128_t is usable.
5134f540166bSRichard Henderson
5135f540166bSRichard Hendersonint128=no
5136f540166bSRichard Hendersoncat > $TMPC << EOF
5137f540166bSRichard Henderson__int128_t a;
5138f540166bSRichard Henderson__uint128_t b;
5139f540166bSRichard Hendersonint main (void) {
5140f540166bSRichard Henderson  a = a + b;
5141f540166bSRichard Henderson  b = a * b;
5142464e3671SPeter Maydell  a = a * a;
5143f540166bSRichard Henderson  return 0;
5144f540166bSRichard Henderson}
5145f540166bSRichard HendersonEOF
5146f540166bSRichard Hendersonif compile_prog "" "" ; then
5147f540166bSRichard Henderson    int128=yes
5148f540166bSRichard Hendersonfi
514976a347e1SRichard Henderson
51507ebee43eSRichard Henderson#########################################
51517ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
51527ebee43eSRichard Henderson
51537ebee43eSRichard Hendersonatomic128=no
51547ebee43eSRichard Hendersonif test "$int128" = "yes"; then
51557ebee43eSRichard Henderson  cat > $TMPC << EOF
51567ebee43eSRichard Hendersonint main(void)
51577ebee43eSRichard Henderson{
51587ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
51597ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
51607ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
51617ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
51627ebee43eSRichard Henderson  return 0;
51637ebee43eSRichard Henderson}
51647ebee43eSRichard HendersonEOF
51657ebee43eSRichard Henderson  if compile_prog "" "" ; then
51667ebee43eSRichard Henderson    atomic128=yes
51677ebee43eSRichard Henderson  fi
51687ebee43eSRichard Hendersonfi
51697ebee43eSRichard Henderson
5170e6cd4bb5SRichard Hendersoncmpxchg128=no
5171e6cd4bb5SRichard Hendersonif test "$int128" = yes -a "$atomic128" = no; then
5172e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5173e6cd4bb5SRichard Hendersonint main(void)
5174e6cd4bb5SRichard Henderson{
5175e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5176e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5177e6cd4bb5SRichard Henderson  return 0;
5178e6cd4bb5SRichard Henderson}
5179e6cd4bb5SRichard HendersonEOF
5180e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5181e6cd4bb5SRichard Henderson    cmpxchg128=yes
5182e6cd4bb5SRichard Henderson  fi
5183e6cd4bb5SRichard Hendersonfi
5184e6cd4bb5SRichard Henderson
5185df79b996SRichard Henderson#########################################
5186df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5187df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5188df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5189df79b996SRichard Henderson
5190df79b996SRichard Hendersoncat > $TMPC << EOF
5191df79b996SRichard Henderson#include <stdint.h>
5192df79b996SRichard Hendersonint main(void)
5193df79b996SRichard Henderson{
5194df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5195df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5196df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5197df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5198df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5199df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5200df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5201df79b996SRichard Henderson#else
5202df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5203df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5204df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5205df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5206df79b996SRichard Henderson#endif
5207df79b996SRichard Henderson  return 0;
5208df79b996SRichard Henderson}
5209df79b996SRichard HendersonEOF
5210df79b996SRichard Hendersonif compile_prog "" "" ; then
5211df79b996SRichard Henderson  atomic64=yes
5212df79b996SRichard Hendersonfi
5213df79b996SRichard Henderson
52141e6e9acaSRichard Henderson########################################
5215db432672SRichard Henderson# See if 16-byte vector operations are supported.
5216db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5217db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5218db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5219db432672SRichard Henderson
5220db432672SRichard Hendersoncat > $TMPC << EOF
5221db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5222db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5223db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5224db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5225db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5226db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5227db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5228db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5229db432672SRichard Hendersonstatic U1 a1, b1;
5230db432672SRichard Hendersonstatic U2 a2, b2;
5231db432672SRichard Hendersonstatic U4 a4, b4;
5232db432672SRichard Hendersonstatic U8 a8, b8;
5233db432672SRichard Hendersonstatic S1 c1;
5234db432672SRichard Hendersonstatic S2 c2;
5235db432672SRichard Hendersonstatic S4 c4;
5236db432672SRichard Hendersonstatic S8 c8;
5237db432672SRichard Hendersonstatic int i;
523874912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
523974912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
524074912f6dSLaurent Vivier{
524174912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
524274912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
524374912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
524474912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
524574912f6dSLaurent Vivier}
5246db432672SRichard Hendersonint main(void)
5247db432672SRichard Henderson{
5248db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5249db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5250db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5251db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5252db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5253db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5254db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5255db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5256db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5257db432672SRichard Henderson  return 0;
5258db432672SRichard Henderson}
5259db432672SRichard HendersonEOF
5260db432672SRichard Henderson
5261db432672SRichard Hendersonvector16=no
5262db432672SRichard Hendersonif compile_prog "" "" ; then
5263db432672SRichard Henderson  vector16=yes
5264db432672SRichard Hendersonfi
5265db432672SRichard Henderson
5266db432672SRichard Henderson########################################
52671e6e9acaSRichard Henderson# check if getauxval is available.
52681e6e9acaSRichard Henderson
52691e6e9acaSRichard Hendersongetauxval=no
52701e6e9acaSRichard Hendersoncat > $TMPC << EOF
52711e6e9acaSRichard Henderson#include <sys/auxv.h>
52721e6e9acaSRichard Hendersonint main(void) {
52731e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
52741e6e9acaSRichard Henderson}
52751e6e9acaSRichard HendersonEOF
52761e6e9acaSRichard Hendersonif compile_prog "" "" ; then
52771e6e9acaSRichard Henderson    getauxval=yes
52781e6e9acaSRichard Hendersonfi
52791e6e9acaSRichard Henderson
5280fd0e6053SJohn Snow########################################
5281fd0e6053SJohn Snow# check if ccache is interfering with
5282fd0e6053SJohn Snow# semantic analysis of macros
5283fd0e6053SJohn Snow
52845e4dfd3dSJohn Snowunset CCACHE_CPP2
5285fd0e6053SJohn Snowccache_cpp2=no
5286fd0e6053SJohn Snowcat > $TMPC << EOF
5287fd0e6053SJohn Snowstatic const int Z = 1;
5288fd0e6053SJohn Snow#define fn() ({ Z; })
5289fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5290fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5291fd0e6053SJohn Snow#define ID(X) (X)
5292fd0e6053SJohn Snowint main(int argc, char *argv[])
5293fd0e6053SJohn Snow{
5294fd0e6053SJohn Snow    int x = 0, y = 0;
5295fd0e6053SJohn Snow    x = ID(x);
5296fd0e6053SJohn Snow    x = fn();
5297fd0e6053SJohn Snow    fn();
5298fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5299fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5300fd0e6053SJohn Snow    return 0;
5301fd0e6053SJohn Snow}
5302fd0e6053SJohn SnowEOF
5303fd0e6053SJohn Snow
5304fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5305fd0e6053SJohn Snow    ccache_cpp2=yes
5306fd0e6053SJohn Snowfi
5307fd0e6053SJohn Snow
5308b553a042SJohn Snow#################################################
5309b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5310b553a042SJohn Snow
5311b553a042SJohn Snowif test "$fortify_source" != "no"; then
5312b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5313b553a042SJohn Snow    fortify_source="no";
5314e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5315cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5316b553a042SJohn Snow    fortify_source="no";
5317b553a042SJohn Snow  else
5318b553a042SJohn Snow    fortify_source="yes"
5319b553a042SJohn Snow  fi
5320b553a042SJohn Snowfi
5321b553a042SJohn Snow
53221efad060SFam Zheng###############################################
53231efad060SFam Zheng# Check if copy_file_range is provided by glibc
53241efad060SFam Zhenghave_copy_file_range=no
53251efad060SFam Zhengcat > $TMPC << EOF
53261efad060SFam Zheng#include <unistd.h>
53271efad060SFam Zhengint main(void) {
53281efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
53291efad060SFam Zheng  return 0;
53301efad060SFam Zheng}
53311efad060SFam ZhengEOF
53321efad060SFam Zhengif compile_prog "" "" ; then
53331efad060SFam Zheng    have_copy_file_range=yes
53341efad060SFam Zhengfi
53351efad060SFam Zheng
5336d2042378SAneesh Kumar K.V##########################################
5337277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5338277abf15SJan Vesely
5339277abf15SJan Veselyhave_fsxattr=no
5340277abf15SJan Veselycat > $TMPC << EOF
5341277abf15SJan Vesely#include <linux/fs.h>
5342277abf15SJan Veselystruct fsxattr foo;
5343277abf15SJan Veselyint main(void) {
5344277abf15SJan Vesely  return 0;
5345277abf15SJan Vesely}
5346277abf15SJan VeselyEOF
5347277abf15SJan Veselyif compile_prog "" "" ; then
5348277abf15SJan Vesely    have_fsxattr=yes
5349277abf15SJan Veselyfi
5350277abf15SJan Vesely
5351b66e10e4SPeter Maydell##########################################
5352a40161cbSPaolo Bonzini# check for usable membarrier system call
5353a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5354a40161cbSPaolo Bonzini    have_membarrier=no
5355a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5356a40161cbSPaolo Bonzini        have_membarrier=yes
5357a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5358a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5359a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5360a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5361a40161cbSPaolo Bonzini    #include <unistd.h>
5362a40161cbSPaolo Bonzini    #include <stdlib.h>
5363a40161cbSPaolo Bonzini    int main(void) {
5364a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5365a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5366a40161cbSPaolo Bonzini	exit(0);
5367a40161cbSPaolo Bonzini    }
5368a40161cbSPaolo BonziniEOF
5369a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5370a40161cbSPaolo Bonzini            have_membarrier=yes
5371a40161cbSPaolo Bonzini        fi
5372a40161cbSPaolo Bonzini    fi
5373a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5374a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5375a40161cbSPaolo Bonzini    fi
5376a40161cbSPaolo Bonzinielse
5377a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5378a40161cbSPaolo Bonzini    # work on Wine.
5379a40161cbSPaolo Bonzini    membarrier=no
5380a40161cbSPaolo Bonzinifi
5381a40161cbSPaolo Bonzini
5382a40161cbSPaolo Bonzini##########################################
5383b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5384575b22b1SLaurent Vivierhave_rtnetlink=no
5385575b22b1SLaurent Viviercat > $TMPC << EOF
5386575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5387575b22b1SLaurent Vivierint main(void) {
5388575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5389575b22b1SLaurent Vivier}
5390575b22b1SLaurent VivierEOF
5391575b22b1SLaurent Vivierif compile_prog "" "" ; then
5392575b22b1SLaurent Vivier    have_rtnetlink=yes
5393575b22b1SLaurent Vivierfi
5394575b22b1SLaurent Vivier
53956a02c806SStefan Hajnoczi##########################################
53966a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
53976a02c806SStefan Hajnoczihave_af_vsock=no
53986a02c806SStefan Hajnoczicat > $TMPC << EOF
53996a02c806SStefan Hajnoczi#include <errno.h>
54006a02c806SStefan Hajnoczi#include <sys/types.h>
54016a02c806SStefan Hajnoczi#include <sys/socket.h>
54026a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
54036a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
54046a02c806SStefan Hajnoczi#endif
54056a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
54066a02c806SStefan Hajnocziint main(void) {
54076a02c806SStefan Hajnoczi    int sock, ret;
54086a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
54096a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
54106a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
54116a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
54126a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
54136a02c806SStefan Hajnoczi        return 0;
54146a02c806SStefan Hajnoczi    }
54156a02c806SStefan Hajnoczi    return -1;
54166a02c806SStefan Hajnoczi}
54176a02c806SStefan HajnocziEOF
54186a02c806SStefan Hajnocziif compile_prog "" "" ; then
54196a02c806SStefan Hajnoczi    have_af_vsock=yes
54206a02c806SStefan Hajnoczifi
54216a02c806SStefan Hajnoczi
5422f0d92b56SLongpeng(Mike)##########################################
5423f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5424f0d92b56SLongpeng(Mike)hava_afalg=no
5425f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5426f0d92b56SLongpeng(Mike)#include <errno.h>
5427f0d92b56SLongpeng(Mike)#include <sys/types.h>
5428f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5429f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5430f0d92b56SLongpeng(Mike)int main(void) {
5431f0d92b56SLongpeng(Mike)    int sock;
5432f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5433f0d92b56SLongpeng(Mike)    return sock;
5434f0d92b56SLongpeng(Mike)}
5435f0d92b56SLongpeng(Mike)EOF
5436f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5437f0d92b56SLongpeng(Mike)    have_afalg=yes
5438f0d92b56SLongpeng(Mike)fi
5439f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5440f0d92b56SLongpeng(Mike)then
5441f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5442f0d92b56SLongpeng(Mike)    then
5443f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5444f0d92b56SLongpeng(Mike)    fi
5445f0d92b56SLongpeng(Mike)fi
5446f0d92b56SLongpeng(Mike)
5447f0d92b56SLongpeng(Mike)
54486969ec6cSJames Clarke#################################################
5449c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5450d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5451c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5452c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5453c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5454c97d6d2cSSergio Andres Gomez Del RealEOF
5455c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5456c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5457c97d6d2cSSergio Andres Gomez Del Real  else
5458c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5459c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5460c97d6d2cSSergio Andres Gomez Del Real  fi
5461c97d6d2cSSergio Andres Gomez Del Realfi
5462c97d6d2cSSergio Andres Gomez Del Real
5463c97d6d2cSSergio Andres Gomez Del Real#################################################
54646969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
54656969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
54666969ec6cSJames Clarke# given. It does no harm to give it on other
54676969ec6cSJames Clarke# platforms too.
54686969ec6cSJames Clarke
54696969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
54706969ec6cSJames Clarke#       contains -Wmissing-prototypes
54716969ec6cSJames Clarkecat > $TMPC << EOF
54726969ec6cSJames Clarkeextern int foo(void);
54736969ec6cSJames Clarkeint foo(void) { return 0; }
54746969ec6cSJames ClarkeEOF
54756969ec6cSJames Clarkeif ! compile_object ""; then
54766969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
54776969ec6cSJames Clarkefi
54787ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
54797ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
54807ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
54817ecf44a5SPaolo Bonzini    break
54827ecf44a5SPaolo Bonzini  fi
54837ecf44a5SPaolo Bonzinidone
54847ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
54857ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
54866969ec6cSJames Clarkefi
54876969ec6cSJames Clarke
5488277abf15SJan Vesely##########################################
54894d04351fSChristopher Covington# check for sysmacros.h
54904d04351fSChristopher Covington
54914d04351fSChristopher Covingtonhave_sysmacros=no
54924d04351fSChristopher Covingtoncat > $TMPC << EOF
54934d04351fSChristopher Covington#include <sys/sysmacros.h>
54944d04351fSChristopher Covingtonint main(void) {
54954d04351fSChristopher Covington    return makedev(0, 0);
54964d04351fSChristopher Covington}
54974d04351fSChristopher CovingtonEOF
54984d04351fSChristopher Covingtonif compile_prog "" "" ; then
54994d04351fSChristopher Covington    have_sysmacros=yes
55004d04351fSChristopher Covingtonfi
55014d04351fSChristopher Covington
55024d04351fSChristopher Covington##########################################
5503da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5504da92c3ffSAshish Mittal# Check if libvxhs is installed
5505da92c3ffSAshish Mittal
5506da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5507da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5508da92c3ffSAshish Mittal#include <stdint.h>
5509da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5510da92c3ffSAshish Mittal
5511da92c3ffSAshish Mittalvoid *vxhs_callback;
5512da92c3ffSAshish Mittal
5513da92c3ffSAshish Mittalint main(void) {
5514da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5515da92c3ffSAshish Mittal    return 0;
5516da92c3ffSAshish Mittal}
5517da92c3ffSAshish MittalEOF
5518da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5519da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5520da92c3ffSAshish Mittal    vxhs=yes
5521da92c3ffSAshish Mittal  else
5522da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5523da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5524da92c3ffSAshish Mittal    fi
5525da92c3ffSAshish Mittal    vxhs=no
5526da92c3ffSAshish Mittal  fi
5527da92c3ffSAshish Mittalfi
5528da92c3ffSAshish Mittal
5529da92c3ffSAshish Mittal##########################################
553049e00a18SAndreas Grapentin# check for _Static_assert()
553149e00a18SAndreas Grapentin
553249e00a18SAndreas Grapentinhave_static_assert=no
553349e00a18SAndreas Grapentincat > $TMPC << EOF
553449e00a18SAndreas Grapentin_Static_assert(1, "success");
553549e00a18SAndreas Grapentinint main(void) {
553649e00a18SAndreas Grapentin    return 0;
553749e00a18SAndreas Grapentin}
553849e00a18SAndreas GrapentinEOF
553949e00a18SAndreas Grapentinif compile_prog "" "" ; then
554049e00a18SAndreas Grapentin    have_static_assert=yes
554149e00a18SAndreas Grapentinfi
554249e00a18SAndreas Grapentin
554349e00a18SAndreas Grapentin##########################################
5544e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5545e674605fSTomáš Golembiovský
5546e674605fSTomáš Golembiovskýhave_utmpx=no
5547e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5548e674605fSTomáš Golembiovský#include <utmpx.h>
5549e674605fSTomáš Golembiovskýstruct utmpx user_info;
5550e674605fSTomáš Golembiovskýint main(void) {
5551e674605fSTomáš Golembiovský    return 0;
5552e674605fSTomáš Golembiovský}
5553e674605fSTomáš GolembiovskýEOF
5554e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5555e674605fSTomáš Golembiovský    have_utmpx=yes
5556e674605fSTomáš Golembiovskýfi
5557e674605fSTomáš Golembiovský
5558e674605fSTomáš Golembiovský##########################################
5559247724cbSMarc-André Lureau# checks for sanitizers
5560247724cbSMarc-André Lureau
5561247724cbSMarc-André Lureauhave_asan=no
5562247724cbSMarc-André Lureauhave_ubsan=no
5563d83414e1SMarc-André Lureauhave_asan_iface_h=no
5564d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5565247724cbSMarc-André Lureau
5566247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5567b9f44da2SMarc-André Lureau  write_c_skeleton
5568247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5569247724cbSMarc-André Lureau      have_asan=yes
5570247724cbSMarc-André Lureau  fi
5571b9f44da2SMarc-André Lureau
5572b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5573b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5574b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5575b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5576b9f44da2SMarc-André Lureau#include <stdlib.h>
5577b9f44da2SMarc-André Lureauint main(void) {
5578b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5579b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5580b9f44da2SMarc-André Lureau}
5581b9f44da2SMarc-André LureauEOF
5582247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5583247724cbSMarc-André Lureau      have_ubsan=yes
5584247724cbSMarc-André Lureau  fi
5585d83414e1SMarc-André Lureau
5586d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5587d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5588d83414e1SMarc-André Lureau  fi
5589d83414e1SMarc-André Lureau
5590d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5591d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5592d83414e1SMarc-André Lureauint main(void) {
5593d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5594d83414e1SMarc-André Lureau  return 0;
5595d83414e1SMarc-André Lureau}
5596d83414e1SMarc-André LureauEOF
5597d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5598d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5599d83414e1SMarc-André Lureau  fi
5600247724cbSMarc-André Lureaufi
5601247724cbSMarc-André Lureau
5602247724cbSMarc-André Lureau##########################################
560351a12b51SAlex Bennée# Docker and cross-compiler support
560451a12b51SAlex Bennée#
560551a12b51SAlex Bennée# This is specifically for building test
560651a12b51SAlex Bennée# cases for foreign architectures, not
560751a12b51SAlex Bennée# cross-compiling QEMU itself.
560851a12b51SAlex Bennée
560951a12b51SAlex Bennéeif has "docker"; then
561051a12b51SAlex Bennée    docker=$($python $source_path/tests/docker/docker.py probe)
561151a12b51SAlex Bennéefi
561251a12b51SAlex Bennée
561351a12b51SAlex Bennée##########################################
561417824406SJunyan He# check for libpmem
561517824406SJunyan He
561617824406SJunyan Heif test "$libpmem" != "no"; then
561717824406SJunyan He	if $pkg_config --exists "libpmem"; then
561817824406SJunyan He		libpmem="yes"
561917824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
562017824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
562117824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
562217824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
562317824406SJunyan He	else
562417824406SJunyan He		if test "$libpmem" = "yes" ; then
562517824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
562617824406SJunyan He		fi
562717824406SJunyan He		libpmem="no"
562817824406SJunyan He	fi
562917824406SJunyan Hefi
563017824406SJunyan He
563117824406SJunyan He##########################################
5632e86ecd4bSJuan Quintela# End of CC checks
5633e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5634e86ecd4bSJuan Quintela
5635d83414e1SMarc-André Lureauwrite_c_skeleton
5636d83414e1SMarc-André Lureau
56371d728c39SBlue Swirlif test "$gcov" = "yes" ; then
56381d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
56391d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5640b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5641e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
564248e56d50SPaolo Bonzinielif test "$debug" = "no"; then
5643ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5644e86ecd4bSJuan Quintelafi
5645a316e378SJuan Quintela
5646247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5647247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
5648d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5649d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5650d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5651d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5652d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5653d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5654d83414e1SMarc-André Lureau  fi
5655247724cbSMarc-André Lureaufi
5656247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5657247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
5658247724cbSMarc-André Lureaufi
5659247724cbSMarc-André Lureau
56606542aa9cSPeter Lieven##########################################
56616542aa9cSPeter Lieven# Do we have libnfs
56626542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5663b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
56646542aa9cSPeter Lieven    libnfs="yes"
56656542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
56666542aa9cSPeter Lieven  else
56676542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
56688efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
56696542aa9cSPeter Lieven    fi
56706542aa9cSPeter Lieven    libnfs="no"
56716542aa9cSPeter Lieven  fi
56726542aa9cSPeter Lievenfi
56731d728c39SBlue Swirl
56743efac6ebSTomáš Golembiovský##########################################
56753efac6ebSTomáš Golembiovský# Do we have libudev
56763efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
56773efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
56783efac6ebSTomáš Golembiovský    libudev="yes"
56793efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
56803efac6ebSTomáš Golembiovský  else
56813efac6ebSTomáš Golembiovský    libudev="no"
56823efac6ebSTomáš Golembiovský  fi
56833efac6ebSTomáš Golembiovskýfi
56843efac6ebSTomáš Golembiovský
56856ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
56866ca026cbSPeter Maydellif test "$werror" = "yes"; then
56876ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
56886ca026cbSPeter Maydellfi
56896ca026cbSPeter Maydell
5690e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5691e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
56921156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5693e86ecd4bSJuan Quintela    fi
5694e86ecd4bSJuan Quintelafi
5695e86ecd4bSJuan Quintela
569694dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
569794dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
569894dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
569994dd53c5SGerd Hoffmannelse
570094dd53c5SGerd Hoffmann    POD2MAN="pod2man"
570194dd53c5SGerd Hoffmannfi
570294dd53c5SGerd Hoffmann
5703952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5704952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5705952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5706e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5707952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5708952afb71SBlue Swirl        fi
5709952afb71SBlue Swirl    done
5710952afb71SBlue Swirlfi
5711952afb71SBlue Swirl
571210ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5713e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5714528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5715834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
57165a67135aSbellard
5717e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5718e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5719e0580342SKamil Rytarowski  ivshmem=yes
5720e0580342SKamil Rytarowskifi
5721e0580342SKamil Rytarowski
57224b1c11fdSDaniel P. Berrangetools=""
57234b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
572472d277a7SGerd Hoffmann  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
57254b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
57264b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5727b1449edbSKamil Rytarowski  fi
5728b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5729a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
57304b1c11fdSDaniel P. Berrange  fi
57313fa2d384SViktor Prutyanov  if [ "$posix" = "yes" ] && [ "$curl" = "yes" ]; then
57323fa2d384SViktor Prutyanov    tools="elf2dmp $tools"
57333fa2d384SViktor Prutyanov  fi
57344b1c11fdSDaniel P. Berrangefi
57354b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5736b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5737b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5738983eef5aSMeador Inge      virtfs=yes
573917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5740983eef5aSMeador Inge    else
5741983eef5aSMeador Inge      if test "$virtfs" = yes; then
5742b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5743983eef5aSMeador Inge      fi
574417500370SAndreas Färber      virtfs=no
5745983eef5aSMeador Inge    fi
5746fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5747fe8fc5aeSPaolo Bonzini      mpath=yes
5748fe8fc5aeSPaolo Bonzini    else
5749fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5750fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5751fe8fc5aeSPaolo Bonzini      fi
5752fe8fc5aeSPaolo Bonzini      mpath=no
5753fe8fc5aeSPaolo Bonzini    fi
5754b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5755b855f8d1SPaolo Bonzini  else
5756b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5757b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5758b855f8d1SPaolo Bonzini    fi
5759b855f8d1SPaolo Bonzini    virtfs=no
5760fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5761fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5762fe8fc5aeSPaolo Bonzini    fi
5763fe8fc5aeSPaolo Bonzini    mpath=no
576417bff52bSM. Mohan Kumar  fi
57656a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
57666a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
57676a021536SGerd Hoffmann  fi
5768ff69fd8cSLaurent Vivierfi
57699d6bc27bSMichael Roth
57709d6bc27bSMichael Roth# Probe for guest agent support/options
57719d6bc27bSMichael Roth
5772e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5773b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5774fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5775e8ef31a3SMichael Tokarev      guest_agent=yes
5776e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5777e8ef31a3SMichael Tokarev      guest_agent=no
5778e8ef31a3SMichael Tokarev  else
5779e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5780ca35f780SPaolo Bonzini  fi
57814b1c11fdSDaniel P. Berrangefi
5782ca35f780SPaolo Bonzini
57839d6bc27bSMichael Roth# Guest agent Window MSI  package
57849d6bc27bSMichael Roth
57859d6bc27bSMichael Rothif test "$guest_agent" != yes; then
57869d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
57879d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
57889d6bc27bSMichael Roth  fi
57899d6bc27bSMichael Roth  guest_agent_msi=no
57909d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
57919d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
57929d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
57939d6bc27bSMichael Roth  fi
57949d6bc27bSMichael Roth  guest_agent_msi=no
57959d6bc27bSMichael Rothelif ! has wixl; then
57969d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
57979d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
57989d6bc27bSMichael Roth  fi
57999d6bc27bSMichael Roth  guest_agent_msi=no
58001a34904eSMichael Rothelse
58011a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
58021a34904eSMichael Roth  # disabled explicitly
58031a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
58041a34904eSMichael Roth    guest_agent_msi=yes
58051a34904eSMichael Roth  fi
58069d6bc27bSMichael Rothfi
58079d6bc27bSMichael Roth
58081a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
58099d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
58109d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
58119d6bc27bSMichael Roth  fi
58129d6bc27bSMichael Roth
58139d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
58149d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
58159d6bc27bSMichael Roth  fi
58169d6bc27bSMichael Roth
58179d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
58189d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
58199d6bc27bSMichael Roth  fi
58209d6bc27bSMichael Roth
58219d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
582289138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
58239d6bc27bSMichael Roth  fi
58249d6bc27bSMichael Roth
582589138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
58269d6bc27bSMichael Roth
58279d6bc27bSMichael Roth  case "$cpu" in
58289d6bc27bSMichael Roth  x86_64)
58299d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
58309d6bc27bSMichael Roth    ;;
58319d6bc27bSMichael Roth  i386)
58329d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
58339d6bc27bSMichael Roth    ;;
58349d6bc27bSMichael Roth  *)
58359d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
58369d6bc27bSMichael Roth    ;;
58379d6bc27bSMichael Roth  esac
58389d6bc27bSMichael Rothfi
58399d6bc27bSMichael Roth
5840ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5841ca35f780SPaolo Bonziniroms=
5842ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5843ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5844ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5845e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5846c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5847c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5848c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5849e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5850e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5851ca35f780SPaolo Bonzini            roms="optionrom"
5852e57218b6SPeter Maydell            break
5853e57218b6SPeter Maydell        fi
5854e57218b6SPeter Maydell    done
5855ca35f780SPaolo Bonzinifi
5856d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
585739ac8455SDavid Gibson  roms="$roms spapr-rtas"
585839ac8455SDavid Gibsonfi
5859ca35f780SPaolo Bonzini
58609933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
58619933c305SChristian Borntraeger  roms="$roms s390-ccw"
58629933c305SChristian Borntraegerfi
58639933c305SChristian Borntraeger
5864964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
586592fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5866964c6fa1SRichard Henderson  textseg_addr=
5867964c6fa1SRichard Henderson  case "$cpu" in
5868479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5869479eb121SRichard Henderson      # ??? Rationale for choosing this address
5870964c6fa1SRichard Henderson      textseg_addr=0x60000000
5871964c6fa1SRichard Henderson      ;;
5872964c6fa1SRichard Henderson    mips)
5873479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5874479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5875479eb121SRichard Henderson      textseg_addr=0x60000000
5876964c6fa1SRichard Henderson      ;;
5877964c6fa1SRichard Henderson  esac
5878964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5879964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5880964c6fa1SRichard Henderson    int main(void) { return 0; }
5881964c6fa1SRichard HendersonEOF
5882964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5883964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5884964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5885964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5886964c6fa1SRichard Henderson      # at least.
588792fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
588892fe2ba8SPeter Maydell        error_exit \
588992fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
589092fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
589192fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
589292fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
589392fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
589492fe2ba8SPeter Maydell            "--disable-user option to configure."
589592fe2ba8SPeter Maydell      fi
589692fe2ba8SPeter Maydell
5897964c6fa1SRichard Henderson      $ld --verbose | sed \
5898964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5899964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5900964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5901964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5902964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5903964c6fa1SRichard Henderson    fi
5904964c6fa1SRichard Henderson  fi
5905964c6fa1SRichard Hendersonfi
5906964c6fa1SRichard Henderson
590711cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
590811cde1c8SBruno 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.
590911cde1c8SBruno Dominguezif has $cxx; then
591011cde1c8SBruno Dominguez    cat > $TMPC <<EOF
591111cde1c8SBruno Dominguezint c_function(void);
591211cde1c8SBruno Dominguezint main(void) { return c_function(); }
591311cde1c8SBruno DominguezEOF
591411cde1c8SBruno Dominguez
591511cde1c8SBruno Dominguez    compile_object
591611cde1c8SBruno Dominguez
591711cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
591811cde1c8SBruno Dominguezextern "C" {
591911cde1c8SBruno Dominguez   int c_function(void);
592011cde1c8SBruno Dominguez}
592111cde1c8SBruno Dominguezint c_function(void) { return 42; }
592211cde1c8SBruno DominguezEOF
592311cde1c8SBruno Dominguez
592411cde1c8SBruno Dominguez    update_cxxflags
592511cde1c8SBruno Dominguez
592611cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
592711cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
592811cde1c8SBruno Dominguez        :
592911cde1c8SBruno Dominguez    else
593011cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
593111cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
593211cde1c8SBruno Dominguez        cxx=
593311cde1c8SBruno Dominguez    fi
593411cde1c8SBruno Dominguezelse
593511cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
593611cde1c8SBruno Dominguez    cxx=
593711cde1c8SBruno Dominguezfi
593811cde1c8SBruno Dominguez
593902d34f62SCole Robinsonecho_version() {
594002d34f62SCole Robinson    if test "$1" = "yes" ; then
594102d34f62SCole Robinson        echo "($2)"
594202d34f62SCole Robinson    fi
594302d34f62SCole Robinson}
594402d34f62SCole Robinson
594550e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
594650e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
59478a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
594850e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
59495ca9388aSGerd Hoffmann
59507d13299dSbellardecho "Install prefix    $prefix"
595189138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
59523d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
595389138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
595489138857SStefan Weilecho "library directory $(eval echo $libdir)"
595589138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
595689138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
595789138857SStefan Weilecho "include directory $(eval echo $includedir)"
595889138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
595911d9f695Sbellardif test "$mingw32" = "no" ; then
596089138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
596189138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
596243ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
59635a699bbbSLaszlo Ersekelse
59645a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5965d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
596611d9f695Sbellardfi
59675a67135aSbellardecho "Source path       $source_path"
5968cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
5969aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
59707d13299dSbellardecho "C compiler        $cc"
597183469015Sbellardecho "Host C compiler   $host_cc"
597283f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
59733c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
597445d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
59750c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5976a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
59770c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
59788a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
59797d13299dSbellardecho "make              $make"
59806a882643Spbrookecho "install           $install"
5981c886edfbSBlue Swirlecho "python            $python"
5982e2d8830eSBradif test "$slirp" = "yes" ; then
5983e2d8830eSBrad    echo "smbd              $smbd"
5984e2d8830eSBradfi
598517969268SFam Zhengecho "module support    $modules"
5986a98fd896Sbellardecho "host CPU          $cpu"
5987de83cd02Sbellardecho "host big endian   $bigendian"
598897a847bcSbellardecho "target list       $target_list"
59897d13299dSbellardecho "gprof enabled     $gprof"
599003b4fe7dSaliguoriecho "sparse enabled    $sparse"
59911625af87Saliguoriecho "strip binaries    $strip_opt"
599205c2a3e7Sbellardecho "profiler          $profiler"
599343ce4dfeSbellardecho "static build      $static"
59945b0753e0Sbellardif test "$darwin" = "yes" ; then
59955b0753e0Sbellard    echo "Cocoa support     $cocoa"
59965b0753e0Sbellardfi
599789138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
599889138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5999925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
600089138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
6001a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
6002ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
600391bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
600489138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
60059a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
60064d3b6f6eSbalrogecho "curses support    $curses"
600747479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6008769ce76dSAlexander Grafecho "curl support      $curl"
600967b915a5Sbellardecho "mingw32 support   $mingw32"
60100c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
6011b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
6012b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
6013983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
6014fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
6015821601eaSJes Sorensenecho "VNC support       $vnc"
6016821601eaSJes Sorensenif test "$vnc" = "yes" ; then
60172f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
60182f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
6019efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
6020821601eaSJes Sorensenfi
60213142255cSblueswir1if test -n "$sparc_cpu"; then
60223142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
60233142255cSblueswir1fi
6024e37630caSaliguoriecho "xen support       $xen"
60253996e85cSPaul Durrantif test "$xen" = "yes" ; then
60263996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
602764a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
60283996e85cSPaul Durrantfi
60292e4d9fb1Saurel32echo "brlapi support    $brlapi"
6030a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
6031a25dba17SJuan Quintelaecho "Documentation     $docs"
603240d6444eSAvi Kivityecho "PIE               $pie"
60338a16d273Sthsecho "vde support       $vde"
603458952137SVincenzo Maffioneecho "netmap support    $netmap"
60355c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
6036758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
603777755340Sthsecho "Install blobs     $blobs"
6038b31a0277SJuan Quintelaecho "KVM support       $kvm"
6039b0cb0a66SVincent Palatinecho "HAX support       $hax"
6040c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
6041d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
6042b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
6043b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
6044b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
60459195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
6046b3f6ea7eSPaolo Bonzinifi
60475a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
6048b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
604921ab34c9SMarcel Apfelbaumecho "PVRDMA support    $pvrdma"
6050f652e6afSaurel32echo "fdt support       $fdt"
6051a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
6052ceb42de8Saliguoriecho "preadv support    $preadv"
60535f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
6054e78815a5SAndreas Färberecho "madvise           $madvise"
6055e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
60569bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
605747e98658SCorey Bryantecho "libcap-ng support $cap_ng"
6058d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
6059042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
60605e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
6061fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
6062e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
60635b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
6064713572a7SMarc-André Lureauif have_backend "simple"; then
60659410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
6066e00e36fbSStefan Weilfi
606789138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6068f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
6069dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
60707b02f544SMarc-André Lureauecho "smartcard support $smartcard"
60712b2325ffSGerd Hoffmannecho "libusb            $libusb"
607269354a83SHans de Goedeecho "usb net redir     $usb_redir"
6073da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
6074014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
6075c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
60766542aa9cSPeter Lievenecho "libnfs support    $libnfs"
6077d138cee9SMichael Rothecho "build guest agent $guest_agent"
6078d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
607950cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
60804c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
6081f794573eSEduardo Otuboecho "seccomp support   $seccomp"
60827c2acc70SPeter Maydellecho "coroutine backend $coroutine"
608370c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
60847d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
6085ba59fb77SPaolo Bonziniecho "mutex debugging   $debug_mutex"
6086f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
6087eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
60881d728c39SBlue Swirlecho "gcov              $gcov_tool"
60891d728c39SBlue Swirlecho "gcov enabled      $gcov"
6090ab214c29SStefan Bergerecho "TPM support       $tpm"
60910a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
60923b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
6093f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
60943556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
6095ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
6096607dacd0Sqiaonuohanecho "lzo support       $lzo"
6097607dacd0Sqiaonuohanecho "snappy support    $snappy"
60986b383c08SPeter Wuecho "bzip2 support     $bzip2"
6099a99d57bbSWanlong Gaoecho "NUMA host support $numa"
6100ed279a06SKlim Kireevecho "libxml2           $libxml2"
61012847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
61027b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
610399f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
6104a6b1d4c0SChanglong Xieecho "replication support $replication"
6105da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
61062f740136SJeff Codyecho "bochs support     $bochs"
61072f740136SJeff Codyecho "cloop support     $cloop"
61082f740136SJeff Codyecho "dmg support       $dmg"
61092f740136SJeff Codyecho "qcow v1 support   $qcow1"
61102f740136SJeff Codyecho "vdi support       $vdi"
61112f740136SJeff Codyecho "vvfat support     $vvfat"
61122f740136SJeff Codyecho "qed support       $qed"
61132f740136SJeff Codyecho "parallels support $parallels"
61142f740136SJeff Codyecho "sheepdog support  $sheepdog"
61158ca80760SRichard Hendersonecho "capstone          $capstone"
611651a12b51SAlex Bennéeecho "docker            $docker"
611717824406SJunyan Heecho "libpmem support   $libpmem"
61183efac6ebSTomáš Golembiovskýecho "libudev           $libudev"
611967b915a5Sbellard
61201ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
612124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
6122e8cd23deSbellardfi
612397a847bcSbellard
6124e52c6ba3SDaniel P. Berrangeif test "$sdlabi" = "1.2"; then
6125e52c6ba3SDaniel P. Berrange    echo
6126e52c6ba3SDaniel P. Berrange    echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
6127e52c6ba3SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using SDL 2.0"
6128e52c6ba3SDaniel P. Berrangefi
6129e52c6ba3SDaniel P. Berrange
6130898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
6131898be3e0SPeter Maydell    echo
6132898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6133898be3e0SPeter Maydell    echo
6134898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
6135898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
6136898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6137898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6138898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6139898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6140898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6141898be3e0SPeter Maydellfi
6142898be3e0SPeter Maydell
6143898be3e0SPeter Maydellif test "$supported_os" = "no"; then
6144898be3e0SPeter Maydell    echo
6145898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6146898be3e0SPeter Maydell    echo
6147c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
6148c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
6149898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6150898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6151898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6152898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6153898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6154898be3e0SPeter Maydellfi
6155898be3e0SPeter Maydell
615698ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
615797a847bcSbellard
6158dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6159dbd99ae3SStefan Weil
616098ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
616198ec69acSJuan Quintelaecho >> $config_host_mak
616298ec69acSJuan Quintela
6163e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
616499d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
616599d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
61663aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
61678bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
61680f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
616999d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
617099d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
617122d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
61729afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
61733d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
61749afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6175e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
61765a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6177785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
61785a699bbbSLaszlo Ersekfi
6179f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6180834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6181f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6182cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6183aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6184f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6185804edf29SJuan Quintela
618698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6187727e5283SPaolo Bonzini
6188f8393946Saurel32if test "$debug_tcg" = "yes" ; then
61892358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6190f8393946Saurel32fi
61911625af87Saliguoriif test "$strip_opt" = "yes" ; then
619252ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
61931625af87Saliguorifi
61947d13299dSbellardif test "$bigendian" = "yes" ; then
6195e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
619697a847bcSbellardfi
619767b915a5Sbellardif test "$mingw32" = "yes" ; then
619898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
619989138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
62009fe6de94SBlue Swirl  version_major=${rc_version%%.*}
62019fe6de94SBlue Swirl  rc_version=${rc_version#*.}
62029fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
62039fe6de94SBlue Swirl  rc_version=${rc_version#*.}
62049fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
62059fe6de94SBlue Swirl  version_micro=0
62069fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
62079fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6208d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6209d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6210f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6211d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6212d9840e25STomoki Sekiyama  fi
621350cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
621476dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
621550cbebb9SMichael Roth  fi
62161a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
62179dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
62189dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
62199dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
62209dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
62219dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
62229dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
62239dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
62249dacf32dSYossi Hindin  fi
6225210fa556Spbrookelse
622635f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6227210fa556Spbrookfi
6228128ab2ffSblueswir1
6229dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6230dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6231dffcb71cSMark McLoughlinfi
6232dffcb71cSMark McLoughlin
623383fb7adfSbellardif test "$darwin" = "yes" ; then
623498ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
623583fb7adfSbellardfi
6236b29fe3edSmalc
6237ec530c81Sbellardif test "$solaris" = "yes" ; then
623898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6239ec530c81Sbellardfi
6240179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6241179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6242179cf400SAndreas Färberfi
624397a847bcSbellardif test "$static" = "yes" ; then
624498ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
624597a847bcSbellardfi
62461ba16968SStefan Weilif test "$profiler" = "yes" ; then
62472358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
624805c2a3e7Sbellardfi
6249c20709aaSbellardif test "$slirp" = "yes" ; then
625098ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6251e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6252c20709aaSbellardfi
62538a16d273Sthsif test "$vde" = "yes" ; then
625498ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6255e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
62568a16d273Sthsfi
625758952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
625858952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
625958952137SVincenzo Maffionefi
6260015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6261015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6262015a33bdSGongleifi
626347e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
626447e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
626547e98658SCorey Bryantfi
62662358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
62670c58ac1cSmalcfor drv in $audio_drv_list; do
62681ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6269ce3dc033SGerd Hoffmann    case "$drv" in
6270051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6271ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6272ce3dc033SGerd Hoffmann	*)
6273ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6274ce3dc033SGerd Hoffmann    esac
62750c58ac1cSmalcdone
6276b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6277b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6278b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6279b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6280b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
628167f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
628267f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
628367f86e8eSJuan Quintelafi
6284d5631638Smalcif test "$audio_win_int" = "yes" ; then
6285d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6286d5631638Smalcfi
6287b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6288b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6289821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6290821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6291821601eaSJes Sorensenfi
62922f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
629398ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
62942f9606b3Saliguorifi
6295821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
62962f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
62972f6f5c7aSCorentin Charyfi
6298821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6299efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6300efe556adSCorentin Charyfi
63016a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
63026a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
63036a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
63046a021536SGerd Hoffmannfi
630576655d6dSaliguoriif test "$fnmatch" = "yes" ; then
63062358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
630776655d6dSaliguorifi
6308dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6309dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6310dce512deSChristoph Hellwigfi
631189138857SStefan Weilqemu_version=$(head $source_path/VERSION)
631298ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
63132358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
631498ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
63152b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6316a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
631798ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6318cc8ae6deSpbrookfi
631917969268SFam Zhengif test "$modules" = "yes"; then
6320e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6321e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
632289138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
632317969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
632417969268SFam Zhengfi
63258781595bSGerd Hoffmannif test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
63268781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
63278781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
63288781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
63298781595bSGerd Hoffmannfi
63301ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
633196400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
6332a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
63338ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
63348ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
633549ecc3faSbellardfi
633649ecc3faSbellardif test "$cocoa" = "yes" ; then
633798ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
633849ecc3faSbellardfi
63394d3b6f6eSbalrogif test "$curses" = "yes" ; then
63402373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
63412373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
63422373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6343ab4e5602SJan Kiszkafi
6344099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
63452358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6346099d6b0fSRiku Voipiofi
634740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
634840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
634940ff6d7eSKevin Wolffi
63503ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
63512358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
63523ce34dfbSvibisreenivasanfi
6353c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6354c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6355c2882b96SRiku Voipiofi
6356751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6357751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6358751bcc39SMarc-André Lureaufi
6359955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6360955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6361955727d2SCortland Tölvafi
6362d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6363d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6364d0927938SUlrich Hechtfi
63653d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
63663d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
63673d4fa43eSKusanagi Kouichifi
6368b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6369b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6370b953f075SDenis V. Lunevfi
6371ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6372ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6373ed911435SKevin Wolffi
6374c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6375c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6376c727f47dSPeter Maydellfi
6377dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6378dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6379dace20dcSPeter Maydellfi
6380d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6381d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6382d0927938SUlrich Hechtfi
63834e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
63844e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
63854e0c6529SAlex Blighfi
6386cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6387cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6388cd758dd0SAlex Blighfi
63893b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
63903b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
63913b6edd16SPeter Maydellfi
63923b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
63933b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
63943b6edd16SPeter Maydellfi
6395a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6396a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6397a8fd1abaSPeter Maydellfi
639851834341SRiku Voipioif test "$timerfd" = "yes" ; then
639951834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
640051834341SRiku Voipiofi
64019af5c906SRiku Voipioif test "$setns" = "yes" ; then
64029af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
64039af5c906SRiku Voipiofi
640438860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
640538860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
640638860a03SAleksandar Markovicfi
64075a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
64085a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
64095a03cd00SAleksandar Markovicfi
64103b3f24adSaurel32if test "$inotify" = "yes" ; then
64112358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
64123b3f24adSaurel32fi
6413c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6414c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6415c05c7a73SRiku Voipiofi
6416401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6417401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6418401bc051SPeter Maydellfi
64195c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
64205c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
64215c99fa37SKeno Fischerfi
64226ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
64236ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
64246ae9a1f4SJuan Quintelafi
64256ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
64266ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
64276ae9a1f4SJuan Quintelafi
6428769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6429d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6430b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
64316ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6432769ce76dSAlexander Graffi
64332e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
643498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
64358eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
64362e4d9fb1Saurel32fi
6437fb599c9aSbalrogif test "$bluez" = "yes" ; then
643898ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
6439ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6440fb599c9aSbalrogfi
6441a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6442e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6443a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6444014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6445925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6446925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6447925a0400SGerd Hoffmann  fi
6448bbbf9bfbSStefan Weilfi
6449a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6450ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6451ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6452ddbb0d09SDaniel P. Berrangefi
645391bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
645491bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
64551f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
64561f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
64571f923c70SLongpeng(Mike)  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
6462ed754746SDaniel P. Berrangefi
64639a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
64649a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
64659a2fd434SDaniel P. Berrangefi
6466559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6467559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6468559607eaSDaniel P. Berrangefi
64696b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
64706b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
64716b39b063SEric Blakefi
6472277abf15SJan Vesely
6473277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6474277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6475277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6476277abf15SJan Vesely# if this macro is set.
6477277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6478277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6479277abf15SJan Veselyfi
64801efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
64811efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
64821efad060SFam Zhengfi
6483bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6484bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6485a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6486e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6487a4ccabcfSAnthony Liguorifi
64889d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
64899d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
64909d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
64919d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
64929d9e1521SGerd Hoffmannfi
6493e37630caSaliguoriif test "$xen" = "yes" ; then
64946dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6495d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
649664a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
649764a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
649864a7ad6fSIan Campbell  fi
6499e37630caSaliguorifi
65005c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
65015c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
65025c6c3a6cSChristoph Hellwigfi
6503758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6504758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6505758e8e38SVenkateswararao Jujjuri (JV)fi
65064f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
65074f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
65084f26f2b6SAvi Kivityfi
6509983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6510758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6511758e8e38SVenkateswararao Jujjuri (JV)fi
6512fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6513fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
65141b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
65151b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
65161b0578f5SMurilo Opsfelder Araujo  fi
6517fe8fc5aeSPaolo Bonzinifi
65185e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
65195e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
65205e9be92dSNicholas Bellingerfi
6521e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
652203ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
652303ce5744SNikolay Nikolaevfi
6524042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6525042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6526042cea27SGongleifi
6527fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6528fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6529fc0b9b0eSStefan Hajnoczifi
6530e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6531e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6532e6a74868SMarc-André Lureaufi
653377755340Sthsif test "$blobs" = "yes" ; then
653498ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
653577755340Sthsfi
6536bf9298b9Saliguoriif test "$iovec" = "yes" ; then
65372358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6538bf9298b9Saliguorifi
6539ceb42de8Saliguoriif test "$preadv" = "yes" ; then
65402358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6541ceb42de8Saliguorifi
6542e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
65433f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6544f652e6afSaurel32fi
6545a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6546a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6547a40161cbSPaolo Bonzinifi
6548dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6549dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6550dcc38d1cSMarcelo Tosattifi
6551b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6552b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
65539195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
65549195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
65559195b2c2SStefan Weil  fi
6556b3f6ea7eSPaolo Bonzinifi
65575f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
65585f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
65595f6b9e8fSBlue Swirlfi
6560e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6561e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6562e78815a5SAndreas Färberfi
6563e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6564e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6565e78815a5SAndreas Färberfi
65669bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
65679bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
65689bc5a719SAndreas Gustafssonfi
656997a847bcSbellard
6570cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6571cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6572cd4ec0b4SGerd Hoffmannfi
6573cd4ec0b4SGerd Hoffmann
65747b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
65757b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
65767b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
65777b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6578111a38b0SRobert Relyeafi
6579111a38b0SRobert Relyea
65802b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
65812b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6582b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6583b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
65842b2325ffSGerd Hoffmannfi
65852b2325ffSGerd Hoffmann
658669354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
658769354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6588cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6589cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
659069354a83SHans de Goedefi
659169354a83SHans de Goede
6592da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6593da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6594da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6595014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6596014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6597014cb152SGerd Hoffmann  fi
659820ff075bSMichael Wallefi
659920ff075bSMichael Walle
66005a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
66015a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
66025a22ab71SYang Zhongfi
66035a22ab71SYang Zhong
660499f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
660599f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
660699f2dbd3SLiang Lifi
660799f2dbd3SLiang Li
6608607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6609607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6610607dacd0Sqiaonuohanfi
6611607dacd0Sqiaonuohan
6612607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6613607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6614607dacd0Sqiaonuohanfi
6615607dacd0Sqiaonuohan
66166b383c08SPeter Wuif test "$bzip2" = "yes" ; then
66176b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
66186b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
66196b383c08SPeter Wufi
66206b383c08SPeter Wu
6621c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6622d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
66236ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
66246ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6625c589b249SRonnie Sahlbergfi
6626c589b249SRonnie Sahlberg
66276542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
66284be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
66294be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
66306542aa9cSPeter Lievenfi
66316542aa9cSPeter Lieven
6632f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6633f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6634c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6635c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6636f794573eSEduardo Otubofi
6637f794573eSEduardo Otubo
663883fb7adfSbellard# XXX: suppress that
66397d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
66402358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
66417d3505c5Sbellardfi
66427d3505c5Sbellard
66434d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
66444d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
66454d9310f4SDaniel P. Berrangefi
66463556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
66473556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
66483556c233SPaolo Bonzinifi
6649f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6650d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
66516ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
66526ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6653f27aaf4bSChristian Brunnerfi
665420ff6c80SAnthony Liguori
66557c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
665670c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
665770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
665870c60c08SStefan Hajnoczielse
665970c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
666070c60c08SStefan Hajnoczifi
6661d0e2fce5SAneesh Kumar K.V
66627d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
66637d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
66647d992e4dSPeter Lievenfi
66657d992e4dSPeter Lieven
6666f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6667f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6668f0d92b56SLongpeng(Mike)fi
6669f0d92b56SLongpeng(Mike)
6670d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6671d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6672d2042378SAneesh Kumar K.Vfi
6673d2042378SAneesh Kumar K.V
6674e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6675e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6676e06a765eSHarsh Prateek Borafi
6677e06a765eSHarsh Prateek Bora
6678cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6679cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
668006d71fa1SPeter Maydellfi
668106d71fa1SPeter Maydell
66823f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
66833f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
66843f4349dcSKevin Wolffi
66853f4349dcSKevin Wolf
6686d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
6687d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6688d83414e1SMarc-André Lureaufi
6689d83414e1SMarc-André Lureau
66908ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
66918ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
66928ab1bf12SLuiz Capitulinofi
66938ab1bf12SLuiz Capitulino
669476a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
669576a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
669676a347e1SRichard Hendersonfi
669776a347e1SRichard Henderson
6698f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6699f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6700f540166bSRichard Hendersonfi
6701f540166bSRichard Henderson
67027ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
67037ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
67047ebee43eSRichard Hendersonfi
67057ebee43eSRichard Henderson
6706e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
6707e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
6708e6cd4bb5SRichard Hendersonfi
6709e6cd4bb5SRichard Henderson
6710df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6711df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6712df79b996SRichard Hendersonfi
6713df79b996SRichard Henderson
6714db432672SRichard Hendersonif test "$vector16" = "yes" ; then
6715db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
6716db432672SRichard Hendersonfi
6717db432672SRichard Henderson
67181e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
67191e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
67201e6e9acaSRichard Hendersonfi
67211e6e9acaSRichard Henderson
6722eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6723d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
67246ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
67256ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6726eb100396SBharata B Raofi
6727eb100396SBharata B Rao
6728d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6729d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6730d85fa9ebSJeff Codyfi
6731d85fa9ebSJeff Cody
67320c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
67330c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
67340c14fb47SBharata B Raofi
67350c14fb47SBharata B Rao
6736df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6737df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6738df3a429aSNiels de Vosfi
6739df3a429aSNiels de Vos
67407c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
67417c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
67427c815372SBharata B Raofi
67437c815372SBharata B Rao
67440a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6745d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
67466ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
67476ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
67480a12ec87SRichard W.M. Jonesfi
67490a12ec87SRichard W.M. Jones
6750ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6751ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6752ed1701c6SDr. David Alan Gilbertfi
6753ed1701c6SDr. David Alan Gilbert
67543b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
67553b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6756f4ede81eSAmarnath Valluri  # TPM passthrough support?
67573b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
67583b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
67593b8acc11SPaolo Bonzini  fi
6760f4ede81eSAmarnath Valluri  # TPM emulator support?
6761f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6762f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6763f4ede81eSAmarnath Valluri  fi
67643b8acc11SPaolo Bonzinifi
67653b8acc11SPaolo Bonzini
67665b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
67675b808275SLluís Vilanovaif have_backend "nop"; then
67686d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
676922890ab5SPrerna Saxenafi
67705b808275SLluís Vilanovaif have_backend "simple"; then
67716d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
67726d8a764eSLluís  # Set the appropriate trace file.
6773953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
67749410b56cSPrerna Saxenafi
6775ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6776ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
67776d8a764eSLluísfi
67785b808275SLluís Vilanovaif have_backend "ust"; then
67796d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
67806d8a764eSLluísfi
67815b808275SLluís Vilanovaif have_backend "dtrace"; then
67826d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
67836d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
67846d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
67856d8a764eSLluís  fi
6786c276b17dSDaniel P. Berrangefi
67875b808275SLluís Vilanovaif have_backend "ftrace"; then
6788781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6789781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6790781e9545SEiichi Tsukata  else
679121684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6792781e9545SEiichi Tsukata  fi
6793781e9545SEiichi Tsukatafi
67940a852417SPaul Durrantif have_backend "syslog"; then
67950a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
67960a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
67970a852417SPaul Durrant  else
67980a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
67990a852417SPaul Durrant  fi
68000a852417SPaul Durrantfi
68019410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
68029410b56cSPrerna Saxena
68032da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
68042da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6805392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
68062da776dbSMichael R. Hinesfi
68072da776dbSMichael R. Hines
680821ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
680921ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
681021ab34c9SMarcel Apfelbaumfi
681121ab34c9SMarcel Apfelbaum
6812575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6813575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6814575b22b1SLaurent Vivierfi
6815575b22b1SLaurent Vivier
6816ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6817ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6818ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6819ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6820ed279a06SKlim Kireevfi
6821ed279a06SKlim Kireev
6822a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6823a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6824a6b1d4c0SChanglong Xiefi
6825a6b1d4c0SChanglong Xie
68266a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
68276a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
68286a02c806SStefan Hajnoczifi
68296a02c806SStefan Hajnoczi
68304d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
68314d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
68324d04351fSChristopher Covingtonfi
68334d04351fSChristopher Covington
683449e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
683549e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
683649e00a18SAndreas Grapentinfi
683749e00a18SAndreas Grapentin
6838e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6839e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6840e674605fSTomáš Golembiovskýfi
6841e674605fSTomáš Golembiovský
6842e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6843e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6844e0580342SKamil Rytarowskifi
6845e219c499SRichard Hendersonif test "$capstone" != "no" ; then
68468ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
68478ca80760SRichard Hendersonfi
6848ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
6849ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6850ba59fb77SPaolo Bonzinifi
6851e0580342SKamil Rytarowski
68525c312079SDr. David Alan Gilbert# Hold two types of flag:
68535c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
68545c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
68555c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
68565c312079SDr. David Alan Gilbert#                                     platform
68575c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
68585c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
68595c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
68605c312079SDr. David Alan Gilbertfi
68615c312079SDr. David Alan Gilbert
6862da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6863da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6864da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6865da92c3ffSAshish Mittalfi
6866da92c3ffSAshish Mittal
686717824406SJunyan Heif test "$libpmem" = "yes" ; then
686817824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
686917824406SJunyan Hefi
687017824406SJunyan He
68712f740136SJeff Codyif test "$bochs" = "yes" ; then
68722f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
68732f740136SJeff Codyfi
68742f740136SJeff Codyif test "$cloop" = "yes" ; then
68752f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
68762f740136SJeff Codyfi
68772f740136SJeff Codyif test "$dmg" = "yes" ; then
68782f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
68792f740136SJeff Codyfi
68802f740136SJeff Codyif test "$qcow1" = "yes" ; then
68812f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
68822f740136SJeff Codyfi
68832f740136SJeff Codyif test "$vdi" = "yes" ; then
68842f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
68852f740136SJeff Codyfi
68862f740136SJeff Codyif test "$vvfat" = "yes" ; then
68872f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
68882f740136SJeff Codyfi
68892f740136SJeff Codyif test "$qed" = "yes" ; then
68902f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
68912f740136SJeff Codyfi
68922f740136SJeff Codyif test "$parallels" = "yes" ; then
68932f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
68942f740136SJeff Codyfi
68952f740136SJeff Codyif test "$sheepdog" = "yes" ; then
68962f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
68972f740136SJeff Codyfi
68982f740136SJeff Cody
68995b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
69009edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
69015b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
69029edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
69035b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
69049edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6905c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
69069edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
690740d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
69089edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
69095b5e3037SPaolo Bonzinielse
69109edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
69115b5e3037SPaolo Bonzinifi
69129edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
69135b5e3037SPaolo Bonzini
691498ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
691598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6916804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6917804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
69181901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
69191901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
69201901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
692121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6922c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6923804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6924a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6925a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6926a31a8642SMichael S. Tsirkinfi
6927804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
692883f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
69293c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6930804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
693145d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6932cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
69335f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
69343dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6935804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6936804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
69379f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
69384852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
69399fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6940e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
694146eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6942a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
694311cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6944f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6945e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6946e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
694780fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
69482944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6949e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6950e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6951e39f0062SPaolo Bonzinifi
695242da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
695342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
695442da6041SGerd Hoffmannelse
695542da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
695642da6041SGerd Hoffmannfi
6957e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
695846eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
69598a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
69606969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6961e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
696273da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
69633e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6964409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6965804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
696617969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
696717969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6968957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
696990246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
697090246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
697194dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
69721d728c39SBlue Swirlif test "$gcov" = "yes" ; then
69731d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
69741d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
69751d728c39SBlue Swirlfi
6976804edf29SJuan Quintela
697751a12b51SAlex Bennéeif test "$docker" != "no"; then
697851a12b51SAlex Bennée    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
697951a12b51SAlex Bennéefi
698051a12b51SAlex Bennée
69813efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
69823efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
69833efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
69843efac6ebSTomáš Golembiovskýfi
69853efac6ebSTomáš Golembiovský
69866efd7517SPeter Maydell# use included Linux headers
69876efd7517SPeter Maydellif test "$linux" = "yes" ; then
6988a307beb6SAndreas Färber  mkdir -p linux-headers
69896efd7517SPeter Maydell  case "$cpu" in
6990c72b26ecSRichard Henderson  i386|x86_64|x32)
699108312a63SPeter Maydell    linux_arch=x86
69926efd7517SPeter Maydell    ;;
6993a69dc537SThomas Huth  ppc|ppc64)
699408312a63SPeter Maydell    linux_arch=powerpc
69956efd7517SPeter Maydell    ;;
69966efd7517SPeter Maydell  s390x)
699708312a63SPeter Maydell    linux_arch=s390
699808312a63SPeter Maydell    ;;
69991f080313SClaudio Fontana  aarch64)
70001f080313SClaudio Fontana    linux_arch=arm64
70011f080313SClaudio Fontana    ;;
7002222e7d11SSanjay Lal  mips64)
7003222e7d11SSanjay Lal    linux_arch=mips
7004222e7d11SSanjay Lal    ;;
700508312a63SPeter Maydell  *)
700608312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
700708312a63SPeter Maydell    linux_arch="$cpu"
70086efd7517SPeter Maydell    ;;
70096efd7517SPeter Maydell  esac
701008312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
701108312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
701208312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
701308312a63SPeter Maydell    fi
70146efd7517SPeter Maydellfi
70156efd7517SPeter Maydell
701697a847bcSbellardfor target in $target_list; do
701797a847bcSbellardtarget_dir="$target"
701825be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
701989138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
702097a847bcSbellardtarget_bigendian="no"
70211f3d3c8fSJuan Quintela
7022c1799a84SPaolo Bonzinicase "$target_name" in
7023a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7024ea2d6a39SJuan Quintela  target_bigendian=yes
7025ea2d6a39SJuan Quintela  ;;
7026ea2d6a39SJuan Quintelaesac
702797a847bcSbellardtarget_softmmu="no"
7028997344f3Sbellardtarget_user_only="no"
7029831b7825Sthstarget_linux_user="no"
703084778508Sblueswir1target_bsd_user="no"
70319e407a85Spbrookcase "$target" in
7032c1799a84SPaolo Bonzini  ${target_name}-softmmu)
70339e407a85Spbrook    target_softmmu="yes"
70349e407a85Spbrook    ;;
7035c1799a84SPaolo Bonzini  ${target_name}-linux-user)
70369e407a85Spbrook    target_user_only="yes"
70379e407a85Spbrook    target_linux_user="yes"
70389e407a85Spbrook    ;;
7039c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
704084778508Sblueswir1    target_user_only="yes"
704184778508Sblueswir1    target_bsd_user="yes"
704284778508Sblueswir1    ;;
70439e407a85Spbrook  *)
704476ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
70459e407a85Spbrook    exit 1
70469e407a85Spbrook    ;;
70479e407a85Spbrookesac
7048831b7825Sths
7049d75402b5SAlex Bennéetarget_compiler=""
7050d75402b5SAlex Bennéetarget_compiler_static=""
7051716a507cSAlex Bennéetarget_compiler_cflags=""
7052d75402b5SAlex Bennée
705397a847bcSbellardmkdir -p $target_dir
705425be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
705597a847bcSbellard
7056e5fe0c52Spbrookbflt="no"
7057ca759f9eSAlex Bennéemttcg="no"
705889138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
705956aebc89Spbrookgdb_xml_files=""
70607ba1e619Saliguori
7061c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
70626acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7063e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
7064e73aae67SJuan Quintela
7065c1799a84SPaolo Bonzinicase "$target_name" in
70662408a527Saurel32  i386)
70670a7fa00aSEmilio G. Cota    mttcg="yes"
7068b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
7069d75402b5SAlex Bennée    target_compiler=$cross_cc_i386
7070716a507cSAlex Bennée    target_compiler_cflags=$cross_cc_ccflags_i386
70712408a527Saurel32  ;;
70722408a527Saurel32  x86_64)
70736acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
70740a7fa00aSEmilio G. Cota    mttcg="yes"
7075b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
7076d75402b5SAlex Bennée    target_compiler=$cross_cc_x86_64
70772408a527Saurel32  ;;
70782408a527Saurel32  alpha)
70795ee4f3c2SRichard Henderson    mttcg="yes"
7080d75402b5SAlex Bennée    target_compiler=$cross_cc_alpha
70812408a527Saurel32  ;;
70822408a527Saurel32  arm|armeb)
7083b498c8a0SJuan Quintela    TARGET_ARCH=arm
7084e5fe0c52Spbrook    bflt="yes"
7085ca759f9eSAlex Bennée    mttcg="yes"
708656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7087d75402b5SAlex Bennée    target_compiler=$cross_cc_arm
7088d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
70892408a527Saurel32  ;;
7090722dd7beSMichael Weiser  aarch64|aarch64_be)
7091722dd7beSMichael Weiser    TARGET_ARCH=aarch64
70926a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
70936a49fa95SAlexander Graf    bflt="yes"
7094ca759f9eSAlex Bennée    mttcg="yes"
70958f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7096d75402b5SAlex Bennée    target_compiler=$cross_cc_aarch64
7097d422b2bcSAlex Bennée    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
70986a49fa95SAlexander Graf  ;;
70992408a527Saurel32  cris)
7100d75402b5SAlex Bennée    target_compiler=$cross_cc_cris
71012408a527Saurel32  ;;
710261766fe9SRichard Henderson  hppa)
71037b93dab5SRichard Henderson    mttcg="yes"
7104d75402b5SAlex Bennée    target_compiler=$cross_cc_hppa
710561766fe9SRichard Henderson  ;;
7106613a22c9SMichael Walle  lm32)
7107d75402b5SAlex Bennée    target_compiler=$cross_cc_lm32
7108613a22c9SMichael Walle  ;;
71092408a527Saurel32  m68k)
71100938cda5Saurel32    bflt="yes"
71115a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7112d75402b5SAlex Bennée    target_compiler=$cross_cc_m68k
71132408a527Saurel32  ;;
7114877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7115877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
711672b675caSEdgar E. Iglesias    bflt="yes"
7117be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
7118d75402b5SAlex Bennée    target_compiler=$cross_cc_microblaze
711972b675caSEdgar E. Iglesias  ;;
71202408a527Saurel32  mips|mipsel)
7121b498c8a0SJuan Quintela    TARGET_ARCH=mips
7122d75402b5SAlex Bennée    target_compiler=$cross_cc_mips
712325be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
71242408a527Saurel32  ;;
71252408a527Saurel32  mipsn32|mipsn32el)
7126597e2cecSRichard Henderson    TARGET_ARCH=mips64
71276acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7128d75402b5SAlex Bennée    target_compiler=$cross_cc_mipsn32
712925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7130597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
71312408a527Saurel32  ;;
71322408a527Saurel32  mips64|mips64el)
7133b498c8a0SJuan Quintela    TARGET_ARCH=mips64
71346acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
7135d75402b5SAlex Bennée    target_compiler=$cross_cc_mips64
713625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
71372408a527Saurel32  ;;
7138d15a9c23SAnthony Green  moxie)
7139d75402b5SAlex Bennée    target_compiler=$cross_cc_moxie
7140d15a9c23SAnthony Green  ;;
7141e671711cSMarek Vasut  nios2)
7142d75402b5SAlex Bennée    target_compiler=$cross_cc_nios2
7143e671711cSMarek Vasut  ;;
71444a09d0bbSRichard Henderson  or1k)
7145d75402b5SAlex Bennée    target_compiler=$cross_cc_or1k
7146e67db06eSJia Liu    TARGET_ARCH=openrisc
7147e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7148e67db06eSJia Liu  ;;
71492408a527Saurel32  ppc)
7150c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7151d75402b5SAlex Bennée    target_compiler=$cross_cc_powerpc
71522408a527Saurel32  ;;
71532408a527Saurel32  ppc64)
71546acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7155e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7156f0b0685dSNikunj A Dadhania    mttcg=yes
71571438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7158d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64
71592408a527Saurel32  ;;
71609c35126cSDoug Kwan  ppc64le)
71619c35126cSDoug Kwan    TARGET_ARCH=ppc64
71629c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
71639c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
7164f0b0685dSNikunj A Dadhania    mttcg=yes
71651438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7166d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64le
71679c35126cSDoug Kwan  ;;
71682408a527Saurel32  ppc64abi32)
7169b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
71706acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7171e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
717225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
71731438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7174d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64abi32
71752408a527Saurel32  ;;
717625fa194bSMichael Clark  riscv32)
717725fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
717825fa194bSMichael Clark    TARGET_ABI_DIR=riscv
717925fa194bSMichael Clark    mttcg=yes
7180d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv32
718125fa194bSMichael Clark  ;;
718225fa194bSMichael Clark  riscv64)
718325fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
718425fa194bSMichael Clark    TARGET_ABI_DIR=riscv
718525fa194bSMichael Clark    mttcg=yes
7186d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv64
718725fa194bSMichael Clark  ;;
71882408a527Saurel32  sh4|sh4eb)
7189b498c8a0SJuan Quintela    TARGET_ARCH=sh4
71904dbed897Spbrook    bflt="yes"
7191d75402b5SAlex Bennée    target_compiler=$cross_cc_sh4
71922408a527Saurel32  ;;
71932408a527Saurel32  sparc)
7194d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc
71952408a527Saurel32  ;;
71962408a527Saurel32  sparc64)
71976acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7198d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc64
71992408a527Saurel32  ;;
72002408a527Saurel32  sparc32plus)
7201b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
72026acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7203e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7204d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc32plus
720525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
72062408a527Saurel32  ;;
720724e804ecSAlexander Graf  s390x)
720863685bc4SDavid Hildenbrand    mttcg=yes
720986158a2aSChristian 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"
7210d75402b5SAlex Bennée    target_compiler=$cross_cc_s390x
721124e804ecSAlexander Graf  ;;
7212444e06b1SChen Gang  tilegx)
7213d75402b5SAlex Bennée    target_compiler=$cross_cc_tilegx
7214444e06b1SChen Gang  ;;
72155ecaa4edSPeter Crosthwaite  tricore)
7216d75402b5SAlex Bennée    target_compiler=$cross_cc_tricore
72175ecaa4edSPeter Crosthwaite  ;;
7218d2fbca94SGuan Xuetao  unicore32)
7219d75402b5SAlex Bennée    target_compiler=$cross_cc_unicore32
7220d2fbca94SGuan Xuetao  ;;
7221cfa550c6SMax Filippov  xtensa|xtensaeb)
7222cfa550c6SMax Filippov    TARGET_ARCH=xtensa
722302e33e9fSMax Filippov    bflt="yes"
72249fb40342SMax Filippov    mttcg="yes"
7225d75402b5SAlex Bennée    target_compiler=$cross_cc_xtensa
7226cfa550c6SMax Filippov  ;;
72272408a527Saurel32  *)
722876ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
72292408a527Saurel32  ;;
72302408a527Saurel32esac
72315e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
72325e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
72335e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
72345e8861a0SPaolo Bonzinifi
72355e8861a0SPaolo Bonzini
7236d75402b5SAlex Bennée# Do we have a cross compiler for this target?
7237d75402b5SAlex Bennéeif has $target_compiler; then
7238d75402b5SAlex Bennée
7239d75402b5SAlex Bennée    write_c_skeleton
7240d75402b5SAlex Bennée
7241716a507cSAlex Bennée    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7242d75402b5SAlex Bennée        # For host systems we might get away with building without -static
7243716a507cSAlex Bennée        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7244d75402b5SAlex Bennée            target_compiler=""
7245d75402b5SAlex Bennée        else
7246d75402b5SAlex Bennée            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7247d75402b5SAlex Bennée            target_compiler_static="n"
7248d75402b5SAlex Bennée        fi
7249d75402b5SAlex Bennée    else
7250d75402b5SAlex Bennée        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7251d75402b5SAlex Bennée        target_compiler_static="y"
7252d75402b5SAlex Bennée    fi
7253d75402b5SAlex Bennéeelse
7254d75402b5SAlex Bennée    target_compiler=""
7255d75402b5SAlex Bennéefi
7256d75402b5SAlex Bennée
72575e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
72585e8861a0SPaolo Bonzini
725999afc91dSDaniel P. Berrangeupper() {
726099afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
726199afc91dSDaniel P. Berrange}
726299afc91dSDaniel P. Berrange
726389138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
726425be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7265c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
726625be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7267e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7268e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7269e6e91b9cSJuan Quintelafi
727025be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7271adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7272adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7273adfc3e91SStacey Sonfi
72743b6b7550SPaolo Bonzini
72753b6b7550SPaolo Bonziniif supported_xen_target $target; then
727625be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7277eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7278eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7279eb6fda0fSAnthony PERARD    fi
7280432d268cSJun Nakajimafi
72813b6b7550SPaolo Bonziniif supported_kvm_target $target; then
728225be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
72831ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
7284d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7285e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
7286e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7287e6a74868SMarc-André Lureau        fi
7288d5970055SMichael S. Tsirkin    fi
7289c59249f9SJuan Quintelafi
72903b6b7550SPaolo Bonziniif supported_hax_target $target; then
7291b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7292b0cb0a66SVincent Palatinfi
7293c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7294c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7295c97d6d2cSSergio Andres Gomez Del Realfi
7296d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7297d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7298d661d9a4SJustin Terry (VM)fi
7299de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
730025be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
730197a847bcSbellardfi
730297a847bcSbellardif test "$target_softmmu" = "yes" ; then
730325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7304ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7305ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7306ca759f9eSAlex Bennée  fi
7307de83cd02Sbellardfi
7308997344f3Sbellardif test "$target_user_only" = "yes" ; then
730925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7310a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7311997344f3Sbellardfi
7312831b7825Sthsif test "$target_linux_user" = "yes" ; then
731325be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7314831b7825Sthsfi
731556aebc89Spbrooklist=""
731656aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
731756aebc89Spbrook  for x in $gdb_xml_files; do
731856aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
731956aebc89Spbrook  done
732025be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
73213d0f1517SJuan Quintelafi
7322de83cd02Sbellard
7323e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
732425be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7325e5fe0c52Spbrookfi
732684778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
732725be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
732884778508Sblueswir1fi
73295b0753e0Sbellard
7330d75402b5SAlex Bennéeif test -n "$target_compiler"; then
7331d75402b5SAlex Bennée  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7332d75402b5SAlex Bennée
7333d75402b5SAlex Bennée  if test -n "$target_compiler_static"; then
7334d75402b5SAlex Bennée      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7335d75402b5SAlex Bennée  fi
7336716a507cSAlex Bennée
7337716a507cSAlex Bennée  if test -n "$target_compiler_cflags"; then
7338716a507cSAlex Bennée      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7339d75402b5SAlex Bennée  fi
7340716a507cSAlex Bennéefi
7341716a507cSAlex Bennée
7342d75402b5SAlex Bennée
73434afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7344fa282484SJuan Quintela
73454afddb55SJuan Quintelacflags=""
7346fa282484SJuan Quintelaldflags=""
73479b8e111fSJuan Quintela
7348c765fcacSPeter Crosthwaitedisas_config() {
7349c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7350c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7351c765fcacSPeter Crosthwaite}
7352c765fcacSPeter Crosthwaite
735364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
735464656024SJuan Quintela  case "$i" in
735564656024SJuan Quintela  alpha)
7356c765fcacSPeter Crosthwaite    disas_config "ALPHA"
735764656024SJuan Quintela  ;;
735882295d8aSRichard Henderson  aarch64)
735982295d8aSRichard Henderson    if test -n "${cxx}"; then
7360c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
736182295d8aSRichard Henderson    fi
736282295d8aSRichard Henderson  ;;
736364656024SJuan Quintela  arm)
7364c765fcacSPeter Crosthwaite    disas_config "ARM"
7365999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7366c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7367999b53ecSClaudio Fontana    fi
736864656024SJuan Quintela  ;;
736964656024SJuan Quintela  cris)
7370c765fcacSPeter Crosthwaite    disas_config "CRIS"
737164656024SJuan Quintela  ;;
7372429b31a2SRichard Henderson  hppa)
7373429b31a2SRichard Henderson    disas_config "HPPA"
7374429b31a2SRichard Henderson  ;;
7375c72b26ecSRichard Henderson  i386|x86_64|x32)
7376c765fcacSPeter Crosthwaite    disas_config "I386"
737764656024SJuan Quintela  ;;
737879368f49SMichael Walle  lm32)
7379c765fcacSPeter Crosthwaite    disas_config "LM32"
738079368f49SMichael Walle  ;;
738164656024SJuan Quintela  m68k)
7382c765fcacSPeter Crosthwaite    disas_config "M68K"
738364656024SJuan Quintela  ;;
7384877fdc12SEdgar E. Iglesias  microblaze*)
7385c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
738664656024SJuan Quintela  ;;
738764656024SJuan Quintela  mips*)
7388c765fcacSPeter Crosthwaite    disas_config "MIPS"
738989a955e8SAleksandar Markovic    if test -n "${cxx}"; then
739089a955e8SAleksandar Markovic      disas_config "NANOMIPS"
739189a955e8SAleksandar Markovic    fi
739264656024SJuan Quintela  ;;
7393d15a9c23SAnthony Green  moxie*)
7394c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7395d15a9c23SAnthony Green  ;;
7396e671711cSMarek Vasut  nios2)
7397e671711cSMarek Vasut    disas_config "NIOS2"
7398e671711cSMarek Vasut  ;;
73994a09d0bbSRichard Henderson  or1k)
7400c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7401e67db06eSJia Liu  ;;
740264656024SJuan Quintela  ppc*)
7403c765fcacSPeter Crosthwaite    disas_config "PPC"
740464656024SJuan Quintela  ;;
740525fa194bSMichael Clark  riscv)
740625fa194bSMichael Clark    disas_config "RISCV"
740725fa194bSMichael Clark  ;;
740824e804ecSAlexander Graf  s390*)
7409c765fcacSPeter Crosthwaite    disas_config "S390"
741064656024SJuan Quintela  ;;
741164656024SJuan Quintela  sh4)
7412c765fcacSPeter Crosthwaite    disas_config "SH4"
741364656024SJuan Quintela  ;;
741464656024SJuan Quintela  sparc*)
7415c765fcacSPeter Crosthwaite    disas_config "SPARC"
741664656024SJuan Quintela  ;;
7417cfa550c6SMax Filippov  xtensa*)
7418c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7419cfa550c6SMax Filippov  ;;
742064656024SJuan Quintela  esac
742164656024SJuan Quinteladone
74229195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7423c765fcacSPeter Crosthwaite  disas_config "TCI"
74249195b2c2SStefan Weilfi
742564656024SJuan Quintela
74266ee7126fSJuan Quintelacase "$ARCH" in
74276ee7126fSJuan Quintelaalpha)
74286ee7126fSJuan Quintela  # Ensure there's only a single GP
74296ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
74306ee7126fSJuan Quintela;;
74316ee7126fSJuan Quintelaesac
74326ee7126fSJuan Quintela
7433d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
743425be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
7435d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7436d02c1db3SJuan Quintela    cflags="-p $cflags"
7437d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7438d02c1db3SJuan Quintela  fi
7439d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7440d02c1db3SJuan Quintela    ldflags="-p $ldflags"
744125be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7442d02c1db3SJuan Quintela  fi
7443d02c1db3SJuan Quintelafi
7444d02c1db3SJuan Quintela
74459b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
7446964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7447fa282484SJuan Quintelafi
7448fa282484SJuan Quintela
7449e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7450e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7451e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7452e9a3591fSChristian Borntraeger# header if
7453e9a3591fSChristian Borntraeger#  - we build on s390x
7454e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7455e9a3591fSChristian Borntraeger#  - KVM is enabled
7456e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7457e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7458e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7459e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7460e9a3591fSChristian Borntraeger    fi
7461e9a3591fSChristian Borntraegerfi
7462e9a3591fSChristian Borntraeger
746325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
746425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7465fa282484SJuan Quintela
746697a847bcSbellarddone # for target in $targets
74677d13299dSbellard
7468d75402b5SAlex Bennéeif test -n "$enabled_cross_compilers"; then
7469d75402b5SAlex Bennée    echo
7470d75402b5SAlex Bennée    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7471d75402b5SAlex Bennéefi
7472d75402b5SAlex Bennée
7473e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
7474a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
7475a540f158SPeter Crosthwaitefi
7476e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7477e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
7478e219c499SRichard Hendersonfi
7479e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7480e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7481e219c499SRichard Hendersonfi
7482a540f158SPeter Crosthwaite
7483a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7484a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7485a99d57bbSWanlong Gaofi
7486a99d57bbSWanlong Gao
7487fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7488fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7489fd0e6053SJohn Snowfi
7490fd0e6053SJohn Snow
7491e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
7492e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
7493e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
7494e29e5c6eSPeter Maydell# (these can be both files and directories).
7495e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
7496e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
7497e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
7498e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
7499e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
7500e29e5c6eSPeter Maydell# directory and symlink the directory instead.
7501b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
75023ac1f813SEmilio G. CotaDIRS="$DIRS tests/fp"
7503b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
75049933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
75052d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
7506e29e5c6eSPeter MaydellLINKS="Makefile tests/tcg/Makefile qdict-test-data.txt"
7507e29e5c6eSPeter MaydellLINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7508e29e5c6eSPeter MaydellLINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7509e29e5c6eSPeter MaydellLINKS="$LINKS tests/fp/Makefile"
7510e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7511e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/spapr-rtas/Makefile"
7512e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
7513e29e5c6eSPeter MaydellLINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7514e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
7515e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
751639950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
751739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
7518753d11f2SRichard Hendersonfor bios_file in \
7519753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7520225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
75215acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
7522753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7523753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7524e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7525753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
75264e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
7527753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7528753d11f2SRichard Hendersondo
7529e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
75307ea78b74SJan Kiszkadone
7531d1807a4fSPaolo Bonzinimkdir -p $DIRS
7532e29e5c6eSPeter Maydellfor f in $LINKS ; do
7533cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7534f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7535f9245e10SPeter Maydell    fi
75367d13299dSbellarddone
75371ad2134fSPaul Brook
7538c34ebfdcSAnthony Liguori# temporary config to build submodules
75392d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
7540c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
754137116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7542c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7543cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
75445f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7545c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7546c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
75473dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7548c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7549a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7550c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
75519f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7552c34ebfdcSAnthony Liguoridone
7553c34ebfdcSAnthony Liguori
755476c7560aSMax Reitz# set up qemu-iotests in this build directory
755576c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
755676c7560aSMax Reitz
755776c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
755876c7560aSMax Reitzecho >> "$iotests_common_env"
755976c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
756076c7560aSMax Reitz
7561dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7562dc655404SMichael S. Tsirkincat <<EOD >config.status
7563dc655404SMichael S. Tsirkin#!/bin/sh
7564dc655404SMichael S. Tsirkin# Generated by configure.
7565dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7566dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7567dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7568dc655404SMichael S. TsirkinEOD
7569e811da7fSDaniel P. Berrangé
7570e811da7fSDaniel P. Berrangépreserve_env() {
7571e811da7fSDaniel P. Berrangé    envname=$1
7572e811da7fSDaniel P. Berrangé
7573e811da7fSDaniel P. Berrangé    eval envval=\$$envname
7574e811da7fSDaniel P. Berrangé
7575e811da7fSDaniel P. Berrangé    if test -n "$envval"
7576e811da7fSDaniel P. Berrangé    then
7577e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
7578e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
7579e811da7fSDaniel P. Berrangé    else
7580e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
7581e811da7fSDaniel P. Berrangé    fi
7582e811da7fSDaniel P. Berrangé}
7583e811da7fSDaniel P. Berrangé
7584e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
7585e811da7fSDaniel P. Berrangé# features/build target configure will detect
7586e811da7fSDaniel P. Berrangépreserve_env AR
7587e811da7fSDaniel P. Berrangépreserve_env AS
7588e811da7fSDaniel P. Berrangépreserve_env CC
7589e811da7fSDaniel P. Berrangépreserve_env CPP
7590e811da7fSDaniel P. Berrangépreserve_env CXX
7591e811da7fSDaniel P. Berrangépreserve_env INSTALL
7592e811da7fSDaniel P. Berrangépreserve_env LD
7593e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
7594e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
7595e811da7fSDaniel P. Berrangépreserve_env MAKE
7596e811da7fSDaniel P. Berrangépreserve_env NM
7597e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
7598e811da7fSDaniel P. Berrangépreserve_env PATH
7599e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
7600e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
7601e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
7602e811da7fSDaniel P. Berrangépreserve_env PYTHON
7603e811da7fSDaniel P. Berrangépreserve_env SDL_CONFIG
7604e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
7605e811da7fSDaniel P. Berrangépreserve_env SMBD
7606e811da7fSDaniel P. Berrangépreserve_env STRIP
7607e811da7fSDaniel P. Berrangépreserve_env WINDRES
7608e811da7fSDaniel P. Berrangé
7609dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7610dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
7611cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7612dc655404SMichael S. Tsirkinchmod +x config.status
7613dc655404SMichael S. Tsirkin
76148cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7615