xref: /openbmc/qemu/configure (revision 98fc1ada)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
148cd05ab6SPeter Maydell# Temporary directory used for files created while
158cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
168cd05ab6SPeter Maydell# we can safely blow away any previous version of it
178cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
188cd05ab6SPeter Maydell# it when configure exits.)
198cd05ab6SPeter MaydellTMPDIR1="config-temp"
208cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
218cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
228cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
238cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
248cd05ab6SPeter Maydell    exit 1
257d13299dSbellardfi
267d13299dSbellard
278cd05ab6SPeter MaydellTMPB="qemu-conf"
288cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
2966518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
309c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
318cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
326969ec6cSJames ClarkeTMPMO="${TMPDIR1}/${TMPB}.mo"
337d13299dSbellard
34da1d85e3SGerd Hoffmannrm -f config.log
359ac81bbbSmalc
36b48e3611SPeter Maydell# Print a helpful header at the top of config.log
37b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
38979ae168SPeter Maydellprintf "# Configured with:" >> config.log
39979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
40979ae168SPeter Maydellecho >> config.log
41b48e3611SPeter Maydellecho "#" >> config.log
42b48e3611SPeter Maydell
43d880a3baSPaolo Bonziniprint_error() {
44d880a3baSPaolo Bonzini    (echo
4576ad07a4SPeter Maydell    echo "ERROR: $1"
4676ad07a4SPeter Maydell    while test -n "$2"; do
4776ad07a4SPeter Maydell        echo "       $2"
4876ad07a4SPeter Maydell        shift
4976ad07a4SPeter Maydell    done
50d880a3baSPaolo Bonzini    echo) >&2
51d880a3baSPaolo Bonzini}
52d880a3baSPaolo Bonzini
53d880a3baSPaolo Bonzinierror_exit() {
54d880a3baSPaolo Bonzini    print_error "$@"
5576ad07a4SPeter Maydell    exit 1
5676ad07a4SPeter Maydell}
5776ad07a4SPeter Maydell
589c83ffd8SPeter Maydelldo_compiler() {
599c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
609c83ffd8SPeter Maydell    # is compiler binary to execute.
619c83ffd8SPeter Maydell    local compiler="$1"
629c83ffd8SPeter Maydell    shift
638bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
648bbe05d7SIan Jackson        echo >>config.log "
658bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
668bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
678bbe05d7SIan Jackson    '; fi
689c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
699c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
708dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
718dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
728dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
738dc38a78SPeter Maydell    # obvious to developers.
748dc38a78SPeter Maydell    if test "$werror" != "yes"; then
758dc38a78SPeter Maydell        return 0
768dc38a78SPeter Maydell    fi
778dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
788dc38a78SPeter Maydell    case "$*" in
798dc38a78SPeter Maydell        *-Werror*)
808dc38a78SPeter Maydell           return 0
818dc38a78SPeter Maydell        ;;
828dc38a78SPeter Maydell    esac
839c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
849c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
8576ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
8676ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8776ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8876ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
898dc38a78SPeter Maydell}
908dc38a78SPeter Maydell
919c83ffd8SPeter Maydelldo_cc() {
929c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
939c83ffd8SPeter Maydell}
949c83ffd8SPeter Maydell
959c83ffd8SPeter Maydelldo_cxx() {
969c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
979c83ffd8SPeter Maydell}
989c83ffd8SPeter Maydell
999c83ffd8SPeter Maydellupdate_cxxflags() {
1009c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1019c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1029c83ffd8SPeter Maydell    # because they only make sense for C programs.
10311cde1c8SBruno Dominguez    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
10411cde1c8SBruno Dominguez
1059c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1069c83ffd8SPeter Maydell        case $arg in
1079c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1089c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1099c83ffd8SPeter Maydell                ;;
1107be41675SThomas Huth            -std=gnu99)
1117be41675SThomas Huth                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
1127be41675SThomas Huth                ;;
1139c83ffd8SPeter Maydell            *)
1149c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1159c83ffd8SPeter Maydell                ;;
1169c83ffd8SPeter Maydell        esac
1179c83ffd8SPeter Maydell    done
1189c83ffd8SPeter Maydell}
1199c83ffd8SPeter Maydell
12052166aa0SJuan Quintelacompile_object() {
121fd0e6053SJohn Snow  local_cflags="$1"
122fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
12352166aa0SJuan Quintela}
12452166aa0SJuan Quintela
12552166aa0SJuan Quintelacompile_prog() {
12652166aa0SJuan Quintela  local_cflags="$1"
12752166aa0SJuan Quintela  local_ldflags="$2"
1288dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
12952166aa0SJuan Quintela}
13052166aa0SJuan Quintela
13111568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
13211568d6dSPaolo Bonzinisymlink() {
13372b8b5a1SStefan Weil  rm -rf "$2"
134ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
13572b8b5a1SStefan Weil  ln -s "$1" "$2"
13611568d6dSPaolo Bonzini}
13711568d6dSPaolo Bonzini
1380dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1390dba6195SLoïc Minier# executable or a builtin)
1400dba6195SLoïc Minierhas() {
1410dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1420dba6195SLoïc Minier}
1430dba6195SLoïc Minier
1440dba6195SLoïc Minier# search for an executable in PATH
1450dba6195SLoïc Minierpath_of() {
1460dba6195SLoïc Minier    local_command="$1"
1470dba6195SLoïc Minier    local_ifs="$IFS"
1480dba6195SLoïc Minier    local_dir=""
1490dba6195SLoïc Minier
1500dba6195SLoïc Minier    # pathname has a dir component?
1510dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1520dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1530dba6195SLoïc Minier            echo "$local_command"
1540dba6195SLoïc Minier            return 0
1550dba6195SLoïc Minier        fi
1560dba6195SLoïc Minier    fi
1570dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1580dba6195SLoïc Minier        return 1
1590dba6195SLoïc Minier    fi
1600dba6195SLoïc Minier
1610dba6195SLoïc Minier    IFS=:
1620dba6195SLoïc Minier    for local_dir in $PATH; do
1630dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1640dba6195SLoïc Minier            echo "$local_dir/$local_command"
1650dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1660dba6195SLoïc Minier            return 0
1670dba6195SLoïc Minier        fi
1680dba6195SLoïc Minier    done
1690dba6195SLoïc Minier    # not found
1700dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1710dba6195SLoïc Minier    return 1
1720dba6195SLoïc Minier}
1730dba6195SLoïc Minier
1745b808275SLluís Vilanovahave_backend () {
1755b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1765b808275SLluís Vilanova}
1775b808275SLluís Vilanova
1783b6b7550SPaolo Bonziniglob() {
1793b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1803b6b7550SPaolo Bonzini}
1813b6b7550SPaolo Bonzini
1823b6b7550SPaolo Bonzinisupported_hax_target() {
1833b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1843b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1853b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1863b6b7550SPaolo Bonzini        i386|x86_64)
1873b6b7550SPaolo Bonzini            return 0
1883b6b7550SPaolo Bonzini        ;;
1893b6b7550SPaolo Bonzini    esac
1903b6b7550SPaolo Bonzini    return 1
1913b6b7550SPaolo Bonzini}
1923b6b7550SPaolo Bonzini
1933b6b7550SPaolo Bonzinisupported_kvm_target() {
1943b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1953b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1963b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1973b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1983b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
1993b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
2003b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
201f8378accSRichard Henderson        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
2023b6b7550SPaolo Bonzini        s390x:s390x)
2033b6b7550SPaolo Bonzini            return 0
2043b6b7550SPaolo Bonzini        ;;
2053b6b7550SPaolo Bonzini    esac
2063b6b7550SPaolo Bonzini    return 1
2073b6b7550SPaolo Bonzini}
2083b6b7550SPaolo Bonzini
2093b6b7550SPaolo Bonzinisupported_xen_target() {
2103b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2113b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
212b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
213b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
214b5ed2e11SPaolo Bonzini        i386|x86_64)
2153b6b7550SPaolo Bonzini            return 0
2163b6b7550SPaolo Bonzini        ;;
2173b6b7550SPaolo Bonzini    esac
2183b6b7550SPaolo Bonzini    return 1
2193b6b7550SPaolo Bonzini}
2203b6b7550SPaolo Bonzini
221c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
222c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
223c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
224c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
225c97d6d2cSSergio Andres Gomez Del Real        x86_64)
226c97d6d2cSSergio Andres Gomez Del Real            return 0
227c97d6d2cSSergio Andres Gomez Del Real        ;;
228c97d6d2cSSergio Andres Gomez Del Real    esac
229c97d6d2cSSergio Andres Gomez Del Real    return 1
230c97d6d2cSSergio Andres Gomez Del Real}
231c97d6d2cSSergio Andres Gomez Del Real
232d661d9a4SJustin Terry (VM)supported_whpx_target() {
233d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
234d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
235d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
236d661d9a4SJustin Terry (VM)        i386|x86_64)
237d661d9a4SJustin Terry (VM)            return 0
238d661d9a4SJustin Terry (VM)        ;;
239d661d9a4SJustin Terry (VM)    esac
240d661d9a4SJustin Terry (VM)    return 1
241d661d9a4SJustin Terry (VM)}
242d661d9a4SJustin Terry (VM)
243d880a3baSPaolo Bonzinisupported_target() {
244d880a3baSPaolo Bonzini    case "$1" in
245d880a3baSPaolo Bonzini        *-softmmu)
246d880a3baSPaolo Bonzini            ;;
247d880a3baSPaolo Bonzini        *-linux-user)
248d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
249d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
250d880a3baSPaolo Bonzini                return 1
251d880a3baSPaolo Bonzini            fi
252d880a3baSPaolo Bonzini            ;;
253d880a3baSPaolo Bonzini        *-bsd-user)
254d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
255d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
256d880a3baSPaolo Bonzini                return 1
257d880a3baSPaolo Bonzini            fi
258d880a3baSPaolo Bonzini            ;;
259d880a3baSPaolo Bonzini        *)
260d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
261d880a3baSPaolo Bonzini            return 1
262d880a3baSPaolo Bonzini            ;;
263d880a3baSPaolo Bonzini    esac
264b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
265b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
266b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
267b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
268c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
269d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
270b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
271b3f6ea7eSPaolo Bonzini    return 1
272d880a3baSPaolo Bonzini}
273d880a3baSPaolo Bonzini
274e9a3591fSChristian Borntraeger
275e9a3591fSChristian Borntraegerld_has() {
276e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
277e9a3591fSChristian Borntraeger}
278e9a3591fSChristian Borntraeger
27979d77bcdSPeter Maydell# make source path absolute
28014211825SAntonio Ospitesource_path=$(cd "$(dirname -- "$0")"; pwd)
28114211825SAntonio Ospite
2824ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2834ace32e2SAntonio Ospitethen
2844ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2854ace32e2SAntonio Ospitefi
2864ace32e2SAntonio Ospite
28714211825SAntonio Ospite# default parameters
2882ff6b91eSJuan Quintelacpu=""
289a31a8642SMichael S. Tsirkiniasl="iasl"
2901e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
29143ce4dfeSbellardstatic="no"
2927d13299dSbellardcross_prefix=""
2930c58ac1cSmalcaudio_drv_list=""
294b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
295b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
296e49d021eSPeter Maydellhost_cc="cc"
29702f9135bSDaniel P. Berrangélibs_cpu=""
29873da375eSJuan Quintelalibs_softmmu=""
2993e2e0e6bSJuan Quintelalibs_tools=""
300d5631638Smalcaudio_win_int=""
301957f1f99SMichael Rothlibs_qga=""
3025bc62e01SGerd Hoffmanndebug_info="yes"
30363678e17SSteven Noonanstack_protector=""
304ac0df51dSaliguori
30592712822SDaniel P. Berrangeif test -e "$source_path/.git"
30692712822SDaniel P. Berrangethen
307f62bbee5SDaniel P. Berrange    git_update=yes
30892712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
3093ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3103ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
31192712822SDaniel P. Berrangeelse
312f62bbee5SDaniel P. Berrange    git_update=no
313aef45d51SDaniel P. Berrange    git_submodules=""
3145c0ef67aSDaniel P. Berrangé
3155c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3165c0ef67aSDaniel P. Berrangé    then
3175c0ef67aSDaniel P. Berrangé        echo
3185c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3195c0ef67aSDaniel P. Berrangé        echo
3205c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3215c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3225c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3235c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3245c0ef67aSDaniel P. Berrangé        echo
325a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
3265c0ef67aSDaniel P. Berrangé        echo
3275c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3285c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3295c0ef67aSDaniel P. Berrangé        echo
3305c0ef67aSDaniel P. Berrangé        exit 1
3315c0ef67aSDaniel P. Berrangé    fi
33292712822SDaniel P. Berrangefi
333cc84d63aSDaniel P. Berrangegit="git"
334ac0df51dSaliguori
335afb63ebdSStefan Weil# Don't accept a target_list environment variable.
336afb63ebdSStefan Weilunset target_list
337447e133fSAlex Bennéeunset target_list_exclude
338377529c0SPaolo Bonzini
339377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
340377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
341377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
342377529c0SPaolo Bonzini#              unless --disable-foo is given
343377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
344377529c0SPaolo Bonzini#              feature will searched for,
345377529c0SPaolo Bonzini#              if not found, configure exits with error
346377529c0SPaolo Bonzini#
347377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
348377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
349377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
350377529c0SPaolo Bonzini
351377529c0SPaolo Bonzinibluez=""
352377529c0SPaolo Bonzinibrlapi=""
353377529c0SPaolo Bonzinicurl=""
354377529c0SPaolo Bonzinicurses=""
355377529c0SPaolo Bonzinidocs=""
356377529c0SPaolo Bonzinifdt=""
35758952137SVincenzo Maffionenetmap="no"
358377529c0SPaolo Bonzinisdl=""
359a442fe2fSDaniel P. Berrangésdl_image=""
360983eef5aSMeador Ingevirtfs=""
361fe8fc5aeSPaolo Bonzinimpath=""
362821601eaSJes Sorensenvnc="yes"
363377529c0SPaolo Bonzinisparse="no"
364377529c0SPaolo Bonzinivde=""
365377529c0SPaolo Bonzinivnc_sasl=""
366377529c0SPaolo Bonzinivnc_jpeg=""
367377529c0SPaolo Bonzinivnc_png=""
3686a021536SGerd Hoffmannxkbcommon=""
369377529c0SPaolo Bonzinixen=""
370d5b93ddfSAnthony PERARDxen_ctrl_version=""
371eb6fda0fSAnthony PERARDxen_pci_passthrough=""
372377529c0SPaolo Bonzinilinux_aio=""
37347e98658SCorey Bryantcap_ng=""
374377529c0SPaolo Bonziniattr=""
3754f26f2b6SAvi Kivitylibattr=""
376377529c0SPaolo Bonzinixfs=""
377b3f6ea7eSPaolo Bonzinitcg="yes"
378a40161cbSPaolo Bonzinimembarrier=""
379299e6f19SPaolo Bonzinivhost_net=""
380299e6f19SPaolo Bonzinivhost_crypto=""
381299e6f19SPaolo Bonzinivhost_scsi=""
382299e6f19SPaolo Bonzinivhost_vsock=""
383e6a74868SMarc-André Lureauvhost_user=""
384*98fc1adaSDr. David Alan Gilbertvhost_user_fs=""
385d41a75a2SBradkvm="no"
386b0cb0a66SVincent Palatinhax="no"
387c97d6d2cSSergio Andres Gomez Del Realhvf="no"
388d661d9a4SJustin Terry (VM)whpx="no"
3892da776dbSMichael R. Hinesrdma=""
39021ab34c9SMarcel Apfelbaumpvrdma=""
391377529c0SPaolo Bonzinigprof="no"
392377529c0SPaolo Bonzinidebug_tcg="no"
393377529c0SPaolo Bonzinidebug="no"
394247724cbSMarc-André Lureausanitizers="no"
395b553a042SJohn Snowfortify_source=""
396377529c0SPaolo Bonzinistrip_opt="yes"
3979195b2c2SStefan Weiltcg_interpreter="no"
398377529c0SPaolo Bonzinibigendian="no"
399377529c0SPaolo Bonzinimingw32="no"
4001d728c39SBlue Swirlgcov="no"
4011d728c39SBlue Swirlgcov_tool="gcov"
402377529c0SPaolo BonziniEXESUF=""
40317969268SFam ZhengDSOSUF=".so"
40417969268SFam ZhengLDFLAGS_SHARED="-shared"
40517969268SFam Zhengmodules="no"
406377529c0SPaolo Bonziniprefix="/usr/local"
407377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
408528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
4093d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
410850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
411377529c0SPaolo Bonzinibindir="\${prefix}/bin"
4123aa5d2beSAlon Levylibdir="\${prefix}/lib"
4138bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
4140f94d6daSAlon Levyincludedir="\${prefix}/include"
415377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
416785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
417377529c0SPaolo Bonziniconfsuffix="/qemu"
418675b9b53SMarc-André Lureauslirp=""
419377529c0SPaolo Bonzinioss_lib=""
420377529c0SPaolo Bonzinibsd="no"
421377529c0SPaolo Bonzinilinux="no"
422377529c0SPaolo Bonzinisolaris="no"
423377529c0SPaolo Bonziniprofiler="no"
424377529c0SPaolo Bonzinicocoa="no"
425377529c0SPaolo Bonzinisoftmmu="yes"
426377529c0SPaolo Bonzinilinux_user="no"
427377529c0SPaolo Bonzinibsd_user="no"
428377529c0SPaolo Bonziniblobs="yes"
429377529c0SPaolo Bonzinipkgversion=""
43040d6444eSAvi Kivitypie=""
4313556c233SPaolo Bonziniqom_cast_debug="yes"
432baf86d6bSPaolo Bonzinitrace_backends="log"
433377529c0SPaolo Bonzinitrace_file="trace"
434377529c0SPaolo Bonzinispice=""
435377529c0SPaolo Bonzinirbd=""
4367b02f544SMarc-André Lureausmartcard=""
4372b2325ffSGerd Hoffmannlibusb=""
43869354a83SHans de Goedeusb_redir=""
439da076ffeSGerd Hoffmannopengl=""
440014cb152SGerd Hoffmannopengl_dmabuf="no"
4415dd89908SRichard Hendersoncpuid_h="no"
44286583a07SLiam Merwickavx2_opt=""
4431ece9905SAlon Levyzlib="yes"
4448ca80760SRichard Hendersoncapstone=""
445b25c9dffSStefan Weillzo=""
446b25c9dffSStefan Weilsnappy=""
4476b383c08SPeter Wubzip2=""
44883bc1f97SJulio Faraccolzfse=""
449e8ef31a3SMichael Tokarevguest_agent=""
450d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
45150cbebb9SMichael Rothguest_agent_ntddscsi="no"
4529dacf32dSYossi Hindinguest_agent_msi=""
453d9840e25STomoki Sekiyamavss_win32_sdk=""
454d9840e25STomoki Sekiyamawin_sdk="no"
4554b1c11fdSDaniel P. Berrangewant_tools="yes"
456c589b249SRonnie Sahlberglibiscsi=""
4576542aa9cSPeter Lievenlibnfs=""
458519175a2SAlex Barcelocoroutine=""
45970c60c08SStefan Hajnoczicoroutine_pool=""
4607d992e4dSPeter Lievendebug_stack_usage="no"
461f0d92b56SLongpeng(Mike)crypto_afalg="no"
462f794573eSEduardo Otuboseccomp=""
463eb100396SBharata B Raoglusterfs=""
464d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4650c14fb47SBharata B Raoglusterfs_discard="no"
466df3a429aSNiels de Vosglusterfs_fallocate="no"
4677c815372SBharata B Raoglusterfs_zerofill="no"
468e014dbe7SPrasanna Kumar Kaleverglusterfs_ftruncate_has_stat="no"
4690e3b891fSNiels de Vosglusterfs_iocb_has_stat="no"
470a4ccabcfSAnthony Liguorigtk=""
471925a0400SGerd Hoffmanngtk_gl="no"
472a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
473ddbb0d09SDaniel P. Berrangegnutls=""
47491bfcdb0SDaniel P. Berrangenettle=""
47591bfcdb0SDaniel P. Berrangegcrypt=""
4761f923c70SLongpeng(Mike)gcrypt_hmac="no"
4778953caf3SDaniel P. Berrangeauth_pam=""
478bbbf9bfbSStefan Weilvte=""
4799d9e1521SGerd Hoffmannvirglrenderer=""
4807aaa6a16SPaolo Bonzinitpm=""
481b10d49d7SPino Toscanolibssh=""
482ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
483a99d57bbSWanlong Gaonuma=""
4842847b469SFam Zhengtcmalloc="no"
4857b01cb97SAlexandre Derumierjemalloc="no"
486a6b1d4c0SChanglong Xiereplication="yes"
487da92c3ffSAshish Mittalvxhs=""
4882f740136SJeff Codybochs="yes"
4892f740136SJeff Codycloop="yes"
4902f740136SJeff Codydmg="yes"
4912f740136SJeff Codyqcow1="yes"
4922f740136SJeff Codyvdi="yes"
4932f740136SJeff Codyvvfat="yes"
4942f740136SJeff Codyqed="yes"
4952f740136SJeff Codyparallels="yes"
4962f740136SJeff Codysheepdog="yes"
497ed279a06SKlim Kireevlibxml2=""
498ba59fb77SPaolo Bonzinidebug_mutex="no"
49917824406SJunyan Helibpmem=""
500f3494749SPaolo Bonzinidefault_devices="yes"
501377529c0SPaolo Bonzini
502898be3e0SPeter Maydellsupported_cpu="no"
503898be3e0SPeter Maydellsupported_os="no"
504fb59dabdSPeter Maydellbogus_os="no"
5055a22ab71SYang Zhongmalloc_trim=""
506898be3e0SPeter Maydell
507ac0df51dSaliguori# parse CC options first
508ac0df51dSaliguorifor opt do
50989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
510ac0df51dSaliguori  case "$opt" in
511ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
512ac0df51dSaliguori  ;;
5133d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
514ac0df51dSaliguori  ;;
51583f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
51683f73fceSTomoki Sekiyama  ;;
5172ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5182ff6b91eSJuan Quintela  ;;
519de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
520e2a2ed06SJuan Quintela  ;;
52111cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
52211cde1c8SBruno Dominguez  ;;
523a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
524f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
525e2a2ed06SJuan Quintela  ;;
5265bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5275bc62e01SGerd Hoffmann  ;;
5285bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
5295bc62e01SGerd Hoffmann  ;;
530d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
531d75402b5SAlex Bennée  ;;
532d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
533d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
5342038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
535d422b2bcSAlex Bennée  ;;
536d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
5372038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
538d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
5392038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
540d75402b5SAlex Bennée  ;;
541ac0df51dSaliguori  esac
542ac0df51dSaliguoridone
543ac0df51dSaliguori# OS specific
544ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
54593148aa5SStefan Weil# we can eliminate its usage altogether.
546ac0df51dSaliguori
547e49d021eSPeter Maydell# Preferred compiler:
548e49d021eSPeter Maydell#  ${CC} (if set)
549e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
550e49d021eSPeter Maydell#  system compiler
551e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
552e49d021eSPeter Maydell  cc="$host_cc"
553e49d021eSPeter Maydellelse
554b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
555e49d021eSPeter Maydellfi
556e49d021eSPeter Maydell
55783f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
55883f73fceSTomoki Sekiyama  cxx="c++"
55983f73fceSTomoki Sekiyamaelse
56083f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
56183f73fceSTomoki Sekiyamafi
56283f73fceSTomoki Sekiyama
563b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
564cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5655f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5663dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
567b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
568b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5699f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5704852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
571b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
572b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
57317884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
57417884d7bSSergei Trofimovichquery_pkg_config() {
57517884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
57617884d7bSSergei Trofimovich}
57717884d7bSSergei Trofimovichpkg_config=query_pkg_config
57847c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
579ac0df51dSaliguori
58045d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
58145d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
58245d285abSPeter Maydell
583be17dc90SMichael S. Tsirkin# default flags for all hosts
5842d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5852d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5862d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5872d31515bSPeter Maydell# provides these semantics.)
5887be41675SThomas HuthQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
589f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
590c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
591be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5929edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5935bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5945bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
595be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5965bc62e01SGerd Hoffmannfi
597be17dc90SMichael S. Tsirkin
598cab00a5aSMichael S. Tsirkin# running configure in the source tree?
599cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
600cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
601cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
602cab00a5aSMichael S. Tsirkinelse
603cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
604cab00a5aSMichael S. Tsirkinfi
605cab00a5aSMichael S. Tsirkin
606ac0df51dSaliguoricheck_define() {
607ac0df51dSaliguoricat > $TMPC <<EOF
608ac0df51dSaliguori#if !defined($1)
609fd786e1aSPeter Maydell#error $1 not defined
610ac0df51dSaliguori#endif
611ac0df51dSaliguoriint main(void) { return 0; }
612ac0df51dSaliguoriEOF
61352166aa0SJuan Quintela  compile_object
614ac0df51dSaliguori}
615ac0df51dSaliguori
616307119e7SGerd Hoffmanncheck_include() {
617307119e7SGerd Hoffmanncat > $TMPC <<EOF
618307119e7SGerd Hoffmann#include <$1>
619307119e7SGerd Hoffmannint main(void) { return 0; }
620307119e7SGerd HoffmannEOF
621307119e7SGerd Hoffmann  compile_object
622307119e7SGerd Hoffmann}
623307119e7SGerd Hoffmann
62493b25869SJohn Snowwrite_c_skeleton() {
62593b25869SJohn Snow    cat > $TMPC <<EOF
62693b25869SJohn Snowint main(void) { return 0; }
62793b25869SJohn SnowEOF
62893b25869SJohn Snow}
62993b25869SJohn Snow
630bbea4050SPeter Maydellif check_define __linux__ ; then
631bbea4050SPeter Maydell  targetos="Linux"
632bbea4050SPeter Maydellelif check_define _WIN32 ; then
633bbea4050SPeter Maydell  targetos='MINGW32'
634bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
635bbea4050SPeter Maydell  targetos='OpenBSD'
636bbea4050SPeter Maydellelif check_define __sun__ ; then
637bbea4050SPeter Maydell  targetos='SunOS'
638bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
639bbea4050SPeter Maydell  targetos='Haiku'
640951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
641951fedfcSPeter Maydell  targetos='FreeBSD'
642951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
643951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
644951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
645951fedfcSPeter Maydell  targetos='DragonFly'
646951fedfcSPeter Maydellelif check_define __NetBSD__; then
647951fedfcSPeter Maydell  targetos='NetBSD'
648951fedfcSPeter Maydellelif check_define __APPLE__; then
649951fedfcSPeter Maydell  targetos='Darwin'
650bbea4050SPeter Maydellelse
651951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
652951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
653951fedfcSPeter Maydell  # be the result of a missing compiler.
654951fedfcSPeter Maydell  targetos='bogus'
655951fedfcSPeter Maydell  bogus_os='yes'
656bbea4050SPeter Maydellfi
657bbea4050SPeter Maydell
658bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
659bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
660bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
661bbea4050SPeter Maydell# the correct CPU with the --cpu option.
662bbea4050SPeter Maydellcase $targetos in
663bbea4050SPeter MaydellDarwin)
664bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
665bbea4050SPeter Maydell  # run 64-bit userspace code.
666bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
667bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
668bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
669bbea4050SPeter Maydell    cpu="x86_64"
670bbea4050SPeter Maydell  fi
671bbea4050SPeter Maydell  ;;
672bbea4050SPeter MaydellSunOS)
67389138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
674bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
675bbea4050SPeter Maydell    cpu="x86_64"
676bbea4050SPeter Maydell  fi
677bbea4050SPeter Maydellesac
678bbea4050SPeter Maydell
6792ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6802ff6b91eSJuan Quintela  # command line argument
6812ff6b91eSJuan Quintela  :
6822ff6b91eSJuan Quintelaelif check_define __i386__ ; then
683ac0df51dSaliguori  cpu="i386"
684ac0df51dSaliguorielif check_define __x86_64__ ; then
685c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
686c72b26ecSRichard Henderson    cpu="x32"
687c72b26ecSRichard Henderson  else
688ac0df51dSaliguori    cpu="x86_64"
689c72b26ecSRichard Henderson  fi
6903aa9bd6cSblueswir1elif check_define __sparc__ ; then
6913aa9bd6cSblueswir1  if check_define __arch64__ ; then
6923aa9bd6cSblueswir1    cpu="sparc64"
6933aa9bd6cSblueswir1  else
6943aa9bd6cSblueswir1    cpu="sparc"
6953aa9bd6cSblueswir1  fi
696fdf7ed96Smalcelif check_define _ARCH_PPC ; then
697fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
698f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
699f8378accSRichard Henderson      cpu="ppc64le"
700f8378accSRichard Henderson    else
701fdf7ed96Smalc      cpu="ppc64"
702f8378accSRichard Henderson    fi
703ac0df51dSaliguori  else
704fdf7ed96Smalc    cpu="ppc"
705fdf7ed96Smalc  fi
706afa05235SAurelien Jarnoelif check_define __mips__ ; then
707afa05235SAurelien Jarno  cpu="mips"
708d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
709d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
710d66ed0eaSAurelien Jarno    cpu="s390x"
711d66ed0eaSAurelien Jarno  else
712d66ed0eaSAurelien Jarno    cpu="s390"
713d66ed0eaSAurelien Jarno  fi
714c4f80543SAlistair Franciselif check_define __riscv ; then
715c4f80543SAlistair Francis  if check_define _LP64 ; then
716c4f80543SAlistair Francis    cpu="riscv64"
717c4f80543SAlistair Francis  else
718c4f80543SAlistair Francis    cpu="riscv32"
719c4f80543SAlistair Francis  fi
72021d89f84SPeter Maydellelif check_define __arm__ ; then
72121d89f84SPeter Maydell  cpu="arm"
7221f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7231f080313SClaudio Fontana  cpu="aarch64"
724fdf7ed96Smalcelse
72589138857SStefan Weil  cpu=$(uname -m)
726ac0df51dSaliguorifi
727ac0df51dSaliguori
728359bc95dSPeter MaydellARCH=
729359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
730359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7317d13299dSbellardcase "$cpu" in
732ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
733898be3e0SPeter Maydell    supported_cpu="yes"
734898be3e0SPeter Maydell  ;;
735f8378accSRichard Henderson  ppc64le)
736f8378accSRichard Henderson    ARCH="ppc64"
737f8378accSRichard Henderson    supported_cpu="yes"
738f8378accSRichard Henderson  ;;
7397d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
74097a847bcSbellard    cpu="i386"
741898be3e0SPeter Maydell    supported_cpu="yes"
7427d13299dSbellard  ;;
743aaa5fa14Saurel32  x86_64|amd64)
744aaa5fa14Saurel32    cpu="x86_64"
745898be3e0SPeter Maydell    supported_cpu="yes"
746aaa5fa14Saurel32  ;;
74721d89f84SPeter Maydell  armv*b|armv*l|arm)
74821d89f84SPeter Maydell    cpu="arm"
749898be3e0SPeter Maydell    supported_cpu="yes"
7507d13299dSbellard  ;;
7511f080313SClaudio Fontana  aarch64)
7521f080313SClaudio Fontana    cpu="aarch64"
753898be3e0SPeter Maydell    supported_cpu="yes"
7541f080313SClaudio Fontana  ;;
755afa05235SAurelien Jarno  mips*)
756afa05235SAurelien Jarno    cpu="mips"
757898be3e0SPeter Maydell    supported_cpu="yes"
758afa05235SAurelien Jarno  ;;
7593142255cSblueswir1  sparc|sun4[cdmuv])
760ae228531Sbellard    cpu="sparc"
7616499fd15SPeter Maydell    supported_cpu="yes"
762ae228531Sbellard  ;;
7637d13299dSbellard  *)
764359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
765359bc95dSPeter Maydell    ARCH=unknown
7667d13299dSbellard  ;;
7677d13299dSbellardesac
768359bc95dSPeter Maydellif test -z "$ARCH"; then
769359bc95dSPeter Maydell  ARCH="$cpu"
770359bc95dSPeter Maydellfi
771e2d52ad3SJuan Quintela
7727d13299dSbellard# OS specific
7730dbfc675SJuan Quintela
774adfc3e91SStacey Son# host *BSD for user mode
775adfc3e91SStacey SonHOST_VARIANT_DIR=""
776adfc3e91SStacey Son
7777d13299dSbellardcase $targetos in
77867b915a5SbellardMINGW32*)
77967b915a5Sbellard  mingw32="yes"
780b0cb0a66SVincent Palatin  hax="yes"
781299e6f19SPaolo Bonzini  vhost_user="no"
7823cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
783307119e7SGerd Hoffmann  if check_include dsound.h; then
7843cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
785307119e7SGerd Hoffmann  else
786307119e7SGerd Hoffmann    audio_drv_list=""
787307119e7SGerd Hoffmann  fi
788898be3e0SPeter Maydell  supported_os="yes"
78967b915a5Sbellard;;
7905c40d2bdSthsGNU/kFreeBSD)
791a167ba50SAurelien Jarno  bsd="yes"
7926a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7930bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7945c40d2bdSths;;
7957d3505c5SbellardFreeBSD)
7967d3505c5Sbellard  bsd="yes"
7970db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7986a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7990bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
800f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
801f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
802a7764f15SEd Maste  # needed for kinfo_getproc
803a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
80458952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
805adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
806898be3e0SPeter Maydell  supported_os="yes"
8077d3505c5Sbellard;;
808c5e97233Sblueswir1DragonFly)
809c5e97233Sblueswir1  bsd="yes"
8100db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8116a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8120bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
813adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
814c5e97233Sblueswir1;;
8157d3505c5SbellardNetBSD)
8167d3505c5Sbellard  bsd="yes"
817604a5b99SKamil Rytarowski  hax="yes"
8180db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8196a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8200bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8218ef92a88Sblueswir1  oss_lib="-lossaudio"
822adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8233c2bdbc1SKamil Rytarowski  supported_os="yes"
8247d3505c5Sbellard;;
8257d3505c5SbellardOpenBSD)
8267d3505c5Sbellard  bsd="yes"
8270db4a067SPaolo Bonzini  make="${MAKE-gmake}"
828f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8290bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
830adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8310a773d55SBrad Smith  supported_os="yes"
8327d3505c5Sbellard;;
83383fb7adfSbellardDarwin)
83483fb7adfSbellard  bsd="yes"
83583fb7adfSbellard  darwin="yes"
836b0cb0a66SVincent Palatin  hax="yes"
837c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
83817969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8391b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
840a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
8410c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8421b0f9cc2Saliguori  fi
843fd677642Sths  cocoa="yes"
8446a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
84514382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8460c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8477973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
848a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
849a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
850a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
851adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
852898be3e0SPeter Maydell  supported_os="yes"
85383fb7adfSbellard;;
854ec530c81SbellardSunOS)
855ec530c81Sbellard  solaris="yes"
8560db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8570db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
858e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8596b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8606a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
8616b4d2ba1Sths  fi
862c2de5c91Smalc  audio_possible_drivers="oss sdl"
863d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
864d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
865d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
866d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
867a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
868560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
869560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
870560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
871ec530c81Sbellard;;
872179cf400SAndreas FärberHaiku)
873179cf400SAndreas Färber  haiku="yes"
874179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
875179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
876179cf400SAndreas Färber;;
877898be3e0SPeter MaydellLinux)
8787183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
8790bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8805327cf48Sbellard  linux="yes"
881831b7825Sths  linux_user="yes"
882af2be207SJan Kiszka  kvm="yes"
883e8d81a61SMao Zhongyi  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
884898be3e0SPeter Maydell  supported_os="yes"
8853efac6ebSTomáš Golembiovský  libudev="yes"
886898be3e0SPeter Maydell;;
8877d13299dSbellardesac
8887d13299dSbellard
8897d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
890b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
89184778508Sblueswir1    bsd_user="yes"
8927d3505c5Sbellard  fi
89308de3949SAndreas Färberfi
8947d3505c5Sbellard
8950db4a067SPaolo Bonzini: ${make=${MAKE-make}}
8960db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
897faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
898faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
899faf44142SDaniel P. Berrangé# we check that before python2
900faf44142SDaniel P. Berrangépython=
901faf44142SDaniel P. Berrangéfor binary in "${PYTHON-python3}" python python2
902faf44142SDaniel P. Berrangédo
903faf44142SDaniel P. Berrangé    if has "$binary"
904faf44142SDaniel P. Berrangé    then
905faf44142SDaniel P. Berrangé        python="$binary"
906faf44142SDaniel P. Berrangé        break
907faf44142SDaniel P. Berrangé    fi
908faf44142SDaniel P. Berrangédone
909e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9100db4a067SPaolo Bonzini
9113c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9123c4a4d0dSPeter Maydellif has clang; then
9133c4a4d0dSPeter Maydell  objcc=clang
9143c4a4d0dSPeter Maydellelse
9153c4a4d0dSPeter Maydell  objcc="$cc"
9163c4a4d0dSPeter Maydellfi
9173c4a4d0dSPeter Maydell
9183457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
9193457a3f8SJuan Quintela  EXESUF=".exe"
92017969268SFam Zheng  DSOSUF=".dll"
92178e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
92278e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
923f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
92493b25869SJohn Snow  write_c_skeleton;
925f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
926f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
927f7cf5d5bSStefan Weil  fi
928c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
929683035deSPaolo Bonzini  mandir="\${prefix}"
930528ae5b8SEduardo Habkost  datadir="\${prefix}"
931850da188SEduardo Habkost  qemu_docdir="\${prefix}"
932683035deSPaolo Bonzini  bindir="\${prefix}"
933683035deSPaolo Bonzini  sysconfdir="\${prefix}"
9345a699bbbSLaszlo Ersek  local_statedir=
935683035deSPaolo Bonzini  confsuffix=""
936105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9373457a3f8SJuan Quintelafi
9383457a3f8SJuan Quintela
939487fefdbSAnthony Liguoriwerror=""
94085aa5189Sbellard
9417d13299dSbellardfor opt do
94289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9437d13299dSbellard  case "$opt" in
9442efc3265Sbellard  --help|-h) show_help=yes
9452efc3265Sbellard  ;;
94699123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
94799123e13SMike Frysinger  ;;
948b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9497d13299dSbellard  ;;
950b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
95132ce6337Sbellard  ;;
952ac0df51dSaliguori  --cross-prefix=*)
9537d13299dSbellard  ;;
954ac0df51dSaliguori  --cc=*)
9557d13299dSbellard  ;;
956b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
95783469015Sbellard  ;;
95883f73fceSTomoki Sekiyama  --cxx=*)
95983f73fceSTomoki Sekiyama  ;;
960e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
961e007dbecSMichael S. Tsirkin  ;;
9623c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9633c4a4d0dSPeter Maydell  ;;
964b1a550a0Spbrook  --make=*) make="$optarg"
9657d13299dSbellard  ;;
9666a882643Spbrook  --install=*) install="$optarg"
9676a882643Spbrook  ;;
968c886edfbSBlue Swirl  --python=*) python="$optarg"
969c886edfbSBlue Swirl  ;;
9701d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9711d728c39SBlue Swirl  ;;
972e2d8830eSBrad  --smbd=*) smbd="$optarg"
973e2d8830eSBrad  ;;
974e2a2ed06SJuan Quintela  --extra-cflags=*)
9757d13299dSbellard  ;;
97611cde1c8SBruno Dominguez  --extra-cxxflags=*)
97711cde1c8SBruno Dominguez  ;;
978e2a2ed06SJuan Quintela  --extra-ldflags=*)
9797d13299dSbellard  ;;
9805bc62e01SGerd Hoffmann  --enable-debug-info)
9815bc62e01SGerd Hoffmann  ;;
9825bc62e01SGerd Hoffmann  --disable-debug-info)
9835bc62e01SGerd Hoffmann  ;;
984d75402b5SAlex Bennée  --cross-cc-*)
985d75402b5SAlex Bennée  ;;
98617969268SFam Zheng  --enable-modules)
98717969268SFam Zheng      modules="yes"
98817969268SFam Zheng  ;;
9893aa88b31SStefan Hajnoczi  --disable-modules)
9903aa88b31SStefan Hajnoczi      modules="no"
9913aa88b31SStefan Hajnoczi  ;;
9922ff6b91eSJuan Quintela  --cpu=*)
9937d13299dSbellard  ;;
994b1a550a0Spbrook  --target-list=*) target_list="$optarg"
995447e133fSAlex Bennée                   if test "$target_list_exclude"; then
996447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
997447e133fSAlex Bennée                   fi
998447e133fSAlex Bennée  ;;
999447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
1000447e133fSAlex Bennée                   if test "$target_list"; then
1001447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
1002447e133fSAlex Bennée                   fi
1003de83cd02Sbellard  ;;
10045b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
10055b808275SLluís Vilanova  ;;
10065b808275SLluís Vilanova  # XXX: backwards compatibility
10075b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
100894a420b1SStefan Hajnoczi  ;;
100974242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
10109410b56cSPrerna Saxena  ;;
1011f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1012f3494749SPaolo Bonzini  ;;
1013f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1014f3494749SPaolo Bonzini  ;;
10157d13299dSbellard  --enable-gprof) gprof="yes"
10167d13299dSbellard  ;;
10171d728c39SBlue Swirl  --enable-gcov) gcov="yes"
10181d728c39SBlue Swirl  ;;
101979427693SLoïc Minier  --static)
102079427693SLoïc Minier    static="yes"
102179427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
102217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
102343ce4dfeSbellard  ;;
10240b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
10250b24e75fSPaolo Bonzini  ;;
10260b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
10270b24e75fSPaolo Bonzini  ;;
10283aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10293aa5d2beSAlon Levy  ;;
10308bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10318bf188aaSMichael Tokarev  ;;
10320f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10330f94d6daSAlon Levy  ;;
1034528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10350b24e75fSPaolo Bonzini  ;;
1036023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1037023d3d67SEduardo Habkost  ;;
1038850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10390b24e75fSPaolo Bonzini  ;;
1040ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
104107381cc1SAnthony Liguori  ;;
1042785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1043785c23aeSLuiz Capitulino  ;;
10443d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10453d5eecabSGerd Hoffmann  ;;
1046181ce1d0SOlaf Hering  --host=*|--build=*|\
1047181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1048785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1049023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1050023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1051023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1052023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1053023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1054023ddd74SMax Filippov    # lots of directory switches by default.
1055023ddd74SMax Filippov  ;;
105697a847bcSbellard  --disable-sdl) sdl="no"
105797a847bcSbellard  ;;
1058c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1059c4198157SJuan Quintela  ;;
1060a442fe2fSDaniel P. Berrangé  --disable-sdl-image) sdl_image="no"
1061a442fe2fSDaniel P. Berrangé  ;;
1062a442fe2fSDaniel P. Berrangé  --enable-sdl-image) sdl_image="yes"
1063a442fe2fSDaniel P. Berrangé  ;;
10643556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10653556c233SPaolo Bonzini  ;;
10663556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10673556c233SPaolo Bonzini  ;;
1068983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1069983eef5aSMeador Inge  ;;
1070983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1071983eef5aSMeador Inge  ;;
1072fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1073fe8fc5aeSPaolo Bonzini  ;;
1074fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1075fe8fc5aeSPaolo Bonzini  ;;
1076821601eaSJes Sorensen  --disable-vnc) vnc="no"
1077821601eaSJes Sorensen  ;;
1078821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1079821601eaSJes Sorensen  ;;
10802f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10812f6a1ab0Sblueswir1  ;;
10820c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10830c58ac1cSmalc  ;;
108489138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1085b64ec4e4SFam Zheng  ;;
108689138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1087eb852011SMarkus Armbruster  ;;
1088f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1089f8393946Saurel32  ;;
1090f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1091f8393946Saurel32  ;;
1092f3d08ee6SPaul Brook  --enable-debug)
1093f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1094f3d08ee6SPaul Brook      debug_tcg="yes"
10951fcc6d42SPeter Xu      debug_mutex="yes"
1096f3d08ee6SPaul Brook      debug="yes"
1097f3d08ee6SPaul Brook      strip_opt="no"
1098b553a042SJohn Snow      fortify_source="no"
1099f3d08ee6SPaul Brook  ;;
1100247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1101247724cbSMarc-André Lureau  ;;
1102247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1103247724cbSMarc-André Lureau  ;;
110403b4fe7dSaliguori  --enable-sparse) sparse="yes"
110503b4fe7dSaliguori  ;;
110603b4fe7dSaliguori  --disable-sparse) sparse="no"
110703b4fe7dSaliguori  ;;
11081625af87Saliguori  --disable-strip) strip_opt="no"
11091625af87Saliguori  ;;
11102f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
11112f9606b3Saliguori  ;;
1112ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1113ea784e3bSJuan Quintela  ;;
11142f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
11152f6f5c7aSCorentin Chary  ;;
11162f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
11172f6f5c7aSCorentin Chary  ;;
1118efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1119efe556adSCorentin Chary  ;;
1120efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1121efe556adSCorentin Chary  ;;
1122443f1376Sbellard  --disable-slirp) slirp="no"
1123c20709aaSbellard  ;;
11247c57bdd8SMarc-André Lureau  --enable-slirp=git) slirp="git"
11257c57bdd8SMarc-André Lureau  ;;
1126675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1127675b9b53SMarc-André Lureau  ;;
1128e0e6c8c0Saliguori  --disable-vde) vde="no"
11298a16d273Sths  ;;
1130dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1131dfb278bdSJuan Quintela  ;;
113258952137SVincenzo Maffione  --disable-netmap) netmap="no"
113358952137SVincenzo Maffione  ;;
113458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
113558952137SVincenzo Maffione  ;;
1136e37630caSaliguori  --disable-xen) xen="no"
1137e37630caSaliguori  ;;
1138fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1139fc321b4bSJuan Quintela  ;;
1140eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1141eb6fda0fSAnthony PERARD  ;;
1142eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1143eb6fda0fSAnthony PERARD  ;;
11442e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
11452e4d9fb1Saurel32  ;;
11464ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
11474ffcedb6SJuan Quintela  ;;
1148fb599c9aSbalrog  --disable-bluez) bluez="no"
1149fb599c9aSbalrog  ;;
1150a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1151a20a6f46SJuan Quintela  ;;
11527ba1e619Saliguori  --disable-kvm) kvm="no"
11537ba1e619Saliguori  ;;
1154b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1155b31a0277SJuan Quintela  ;;
1156b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1157180fb750Szhanghailiang  ;;
1158b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1159180fb750Szhanghailiang  ;;
1160c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1161c97d6d2cSSergio Andres Gomez Del Real  ;;
1162c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1163c97d6d2cSSergio Andres Gomez Del Real  ;;
1164d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1165d661d9a4SJustin Terry (VM)  ;;
1166d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1167d661d9a4SJustin Terry (VM)  ;;
11689195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11699195b2c2SStefan Weil  ;;
11709195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11719195b2c2SStefan Weil  ;;
117247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
117347e98658SCorey Bryant  ;;
117447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
117547e98658SCorey Bryant  ;;
1176b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1177b3f6ea7eSPaolo Bonzini  ;;
1178b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1179b3f6ea7eSPaolo Bonzini  ;;
11805a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11815a22ab71SYang Zhong  ;;
11825a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11835a22ab71SYang Zhong  ;;
1184cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1185cd4ec0b4SGerd Hoffmann  ;;
1186cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1187cd4ec0b4SGerd Hoffmann  ;;
1188c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1189c589b249SRonnie Sahlberg  ;;
1190c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1191c589b249SRonnie Sahlberg  ;;
11926542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11936542aa9cSPeter Lieven  ;;
11946542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11956542aa9cSPeter Lieven  ;;
119605c2a3e7Sbellard  --enable-profiler) profiler="yes"
119705c2a3e7Sbellard  ;;
119814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
119914821030SPavel Borzenkov  ;;
1200c2de5c91Smalc  --enable-cocoa)
1201c2de5c91Smalc      cocoa="yes" ;
120289138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
12035b0753e0Sbellard  ;;
1204cad25d69Spbrook  --disable-system) softmmu="no"
12050a8e90f4Spbrook  ;;
1206cad25d69Spbrook  --enable-system) softmmu="yes"
12070a8e90f4Spbrook  ;;
12080953a80fSZachary Amsden  --disable-user)
12090953a80fSZachary Amsden      linux_user="no" ;
12100953a80fSZachary Amsden      bsd_user="no" ;
12110953a80fSZachary Amsden  ;;
12120953a80fSZachary Amsden  --enable-user) ;;
1213831b7825Sths  --disable-linux-user) linux_user="no"
12140a8e90f4Spbrook  ;;
1215831b7825Sths  --enable-linux-user) linux_user="yes"
1216831b7825Sths  ;;
121784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
121884778508Sblueswir1  ;;
121984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
122084778508Sblueswir1  ;;
122140d6444eSAvi Kivity  --enable-pie) pie="yes"
122234005a00SKirill A. Shutemov  ;;
122340d6444eSAvi Kivity  --disable-pie) pie="no"
122434005a00SKirill A. Shutemov  ;;
122585aa5189Sbellard  --enable-werror) werror="yes"
122685aa5189Sbellard  ;;
122785aa5189Sbellard  --disable-werror) werror="no"
122885aa5189Sbellard  ;;
122963678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
123063678e17SSteven Noonan  ;;
123163678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
123263678e17SSteven Noonan  ;;
12334d3b6f6eSbalrog  --disable-curses) curses="no"
12344d3b6f6eSbalrog  ;;
1235c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1236c584a6d0SJuan Quintela  ;;
1237e08bb301SSamuel Thibault  --disable-iconv) iconv="no"
1238e08bb301SSamuel Thibault  ;;
1239e08bb301SSamuel Thibault  --enable-iconv) iconv="yes"
1240e08bb301SSamuel Thibault  ;;
1241769ce76dSAlexander Graf  --disable-curl) curl="no"
1242769ce76dSAlexander Graf  ;;
1243788c8196SJuan Quintela  --enable-curl) curl="yes"
1244788c8196SJuan Quintela  ;;
12452df87df7SJuan Quintela  --disable-fdt) fdt="no"
12462df87df7SJuan Quintela  ;;
12472df87df7SJuan Quintela  --enable-fdt) fdt="yes"
12482df87df7SJuan Quintela  ;;
12495c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12505c6c3a6cSChristoph Hellwig  ;;
12515c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12525c6c3a6cSChristoph Hellwig  ;;
1253758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1254758e8e38SVenkateswararao Jujjuri (JV)  ;;
1255758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1256758e8e38SVenkateswararao Jujjuri (JV)  ;;
1257a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1258a40161cbSPaolo Bonzini  ;;
1259a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1260a40161cbSPaolo Bonzini  ;;
126177755340Sths  --disable-blobs) blobs="no"
126277755340Sths  ;;
12637e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12644a19f1ecSpbrook  ;;
1265519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1266519175a2SAlex Barcelo  ;;
126770c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
126870c60c08SStefan Hajnoczi  ;;
126970c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
127070c60c08SStefan Hajnoczi  ;;
12717d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12727d992e4dSPeter Lieven  ;;
1273f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1274f0d92b56SLongpeng(Mike)  ;;
1275f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1276f0d92b56SLongpeng(Mike)  ;;
1277a25dba17SJuan Quintela  --disable-docs) docs="no"
127870ec5dc0SAnthony Liguori  ;;
1279a25dba17SJuan Quintela  --enable-docs) docs="yes"
128083a3ab8bSJuan Quintela  ;;
1281d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1282d5970055SMichael S. Tsirkin  ;;
1283d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1284d5970055SMichael S. Tsirkin  ;;
1285042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1286042cea27SGonglei  ;;
1287299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1288042cea27SGonglei  ;;
12895e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12905e9be92dSNicholas Bellinger  ;;
12915e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12925e9be92dSNicholas Bellinger  ;;
1293fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1294fc0b9b0eSStefan Hajnoczi  ;;
1295fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1296fc0b9b0eSStefan Hajnoczi  ;;
1297*98fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
1298*98fc1adaSDr. David Alan Gilbert  ;;
1299*98fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
1300*98fc1adaSDr. David Alan Gilbert  ;;
1301da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
130220ff075bSMichael Walle  ;;
1303da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
130420ff075bSMichael Walle  ;;
1305f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1306f27aaf4bSChristian Brunner  ;;
1307f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1308f27aaf4bSChristian Brunner  ;;
13098c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
13108c84cf11SSergei Trofimovich  ;;
13118c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
13128c84cf11SSergei Trofimovich  ;;
13137b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1314111a38b0SRobert Relyea  ;;
13157b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1316111a38b0SRobert Relyea  ;;
13172b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
13182b2325ffSGerd Hoffmann  ;;
13192b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
13202b2325ffSGerd Hoffmann  ;;
132169354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
132269354a83SHans de Goede  ;;
132369354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
132469354a83SHans de Goede  ;;
13251ece9905SAlon Levy  --disable-zlib-test) zlib="no"
13261ece9905SAlon Levy  ;;
1327b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1328b25c9dffSStefan Weil  ;;
1329607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1330607dacd0Sqiaonuohan  ;;
1331b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1332b25c9dffSStefan Weil  ;;
1333607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1334607dacd0Sqiaonuohan  ;;
13356b383c08SPeter Wu  --disable-bzip2) bzip2="no"
13366b383c08SPeter Wu  ;;
13376b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13386b383c08SPeter Wu  ;;
133983bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
134083bc1f97SJulio Faracco  ;;
134183bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
134283bc1f97SJulio Faracco  ;;
1343d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1344d138cee9SMichael Roth  ;;
1345d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1346d138cee9SMichael Roth  ;;
13479dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13489dacf32dSYossi Hindin  ;;
13499dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13509dacf32dSYossi Hindin  ;;
1351d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1352d9840e25STomoki Sekiyama  ;;
1353d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1354d9840e25STomoki Sekiyama  ;;
1355d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1356d9840e25STomoki Sekiyama  ;;
1357d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1358d9840e25STomoki Sekiyama  ;;
1359d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1360d9840e25STomoki Sekiyama  ;;
1361d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1362d9840e25STomoki Sekiyama  ;;
13634b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13644b1c11fdSDaniel P. Berrange  ;;
13654b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13664b1c11fdSDaniel P. Berrange  ;;
1367f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1368f794573eSEduardo Otubo  ;;
1369f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1370f794573eSEduardo Otubo  ;;
1371eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1372eb100396SBharata B Rao  ;;
137386583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
137486583a07SLiam Merwick  ;;
137586583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
137686583a07SLiam Merwick  ;;
1377eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1378eb100396SBharata B Rao  ;;
137952b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
138052b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1381583f6e7bSStefan Hajnoczi  ;;
1382cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1383cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1384cb6414dfSFam Zheng  ;;
1385315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1386315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1387315d3184SFam Zheng  ;;
1388a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1389a4ccabcfSAnthony Liguori  ;;
1390a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1391a4ccabcfSAnthony Liguori  ;;
1392a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1393a1c5e949SDaniel P. Berrange  ;;
1394ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1395ddbb0d09SDaniel P. Berrange  ;;
1396ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1397ddbb0d09SDaniel P. Berrange  ;;
139891bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
139991bfcdb0SDaniel P. Berrange  ;;
140091bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
140191bfcdb0SDaniel P. Berrange  ;;
140291bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
140391bfcdb0SDaniel P. Berrange  ;;
140491bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
140591bfcdb0SDaniel P. Berrange  ;;
14068953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
14078953caf3SDaniel P. Berrange  ;;
14088953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
14098953caf3SDaniel P. Berrange  ;;
14102da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14112da776dbSMichael R. Hines  ;;
14122da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14132da776dbSMichael R. Hines  ;;
141421ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
141521ab34c9SMarcel Apfelbaum  ;;
141621ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
141721ab34c9SMarcel Apfelbaum  ;;
1418bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1419bbbf9bfbSStefan Weil  ;;
1420bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1421bbbf9bfbSStefan Weil  ;;
14229d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14239d9e1521SGerd Hoffmann  ;;
14249d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
14259d9e1521SGerd Hoffmann  ;;
1426e91c793cSCole Robinson  --disable-tpm) tpm="no"
1427e91c793cSCole Robinson  ;;
1428ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1429ab214c29SStefan Berger  ;;
1430b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14310a12ec87SRichard W.M. Jones  ;;
1432b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14330a12ec87SRichard W.M. Jones  ;;
1434ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1435ed1701c6SDr. David Alan Gilbert  ;;
1436ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1437ed1701c6SDr. David Alan Gilbert  ;;
1438a99d57bbSWanlong Gao  --disable-numa) numa="no"
1439a99d57bbSWanlong Gao  ;;
1440a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1441a99d57bbSWanlong Gao  ;;
1442ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1443ed279a06SKlim Kireev  ;;
1444ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1445ed279a06SKlim Kireev  ;;
14462847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14472847b469SFam Zheng  ;;
14482847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14492847b469SFam Zheng  ;;
14507b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14517b01cb97SAlexandre Derumier  ;;
14527b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14537b01cb97SAlexandre Derumier  ;;
1454a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1455a6b1d4c0SChanglong Xie  ;;
1456a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1457a6b1d4c0SChanglong Xie  ;;
1458da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1459da92c3ffSAshish Mittal  ;;
1460da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1461da92c3ffSAshish Mittal  ;;
14622f740136SJeff Cody  --disable-bochs) bochs="no"
14632f740136SJeff Cody  ;;
14642f740136SJeff Cody  --enable-bochs) bochs="yes"
14652f740136SJeff Cody  ;;
14662f740136SJeff Cody  --disable-cloop) cloop="no"
14672f740136SJeff Cody  ;;
14682f740136SJeff Cody  --enable-cloop) cloop="yes"
14692f740136SJeff Cody  ;;
14702f740136SJeff Cody  --disable-dmg) dmg="no"
14712f740136SJeff Cody  ;;
14722f740136SJeff Cody  --enable-dmg) dmg="yes"
14732f740136SJeff Cody  ;;
14742f740136SJeff Cody  --disable-qcow1) qcow1="no"
14752f740136SJeff Cody  ;;
14762f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14772f740136SJeff Cody  ;;
14782f740136SJeff Cody  --disable-vdi) vdi="no"
14792f740136SJeff Cody  ;;
14802f740136SJeff Cody  --enable-vdi) vdi="yes"
14812f740136SJeff Cody  ;;
14822f740136SJeff Cody  --disable-vvfat) vvfat="no"
14832f740136SJeff Cody  ;;
14842f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14852f740136SJeff Cody  ;;
14862f740136SJeff Cody  --disable-qed) qed="no"
14872f740136SJeff Cody  ;;
14882f740136SJeff Cody  --enable-qed) qed="yes"
14892f740136SJeff Cody  ;;
14902f740136SJeff Cody  --disable-parallels) parallels="no"
14912f740136SJeff Cody  ;;
14922f740136SJeff Cody  --enable-parallels) parallels="yes"
14932f740136SJeff Cody  ;;
14942f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14952f740136SJeff Cody  ;;
14962f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14972f740136SJeff Cody  ;;
1498e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1499e6a74868SMarc-André Lureau  ;;
1500299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1501299e6f19SPaolo Bonzini  ;;
1502299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1503299e6f19SPaolo Bonzini  ;;
1504299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1505e6a74868SMarc-André Lureau  ;;
15068ca80760SRichard Henderson  --disable-capstone) capstone="no"
15078ca80760SRichard Henderson  ;;
15088ca80760SRichard Henderson  --enable-capstone) capstone="yes"
15098ca80760SRichard Henderson  ;;
1510e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1511e219c499SRichard Henderson  ;;
1512e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1513e219c499SRichard Henderson  ;;
1514cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1515cc84d63aSDaniel P. Berrange  ;;
1516f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1517f62bbee5SDaniel P. Berrange  ;;
1518f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1519f62bbee5SDaniel P. Berrange  ;;
1520ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1521ba59fb77SPaolo Bonzini  ;;
1522ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1523ba59fb77SPaolo Bonzini  ;;
152417824406SJunyan He  --enable-libpmem) libpmem=yes
152517824406SJunyan He  ;;
152617824406SJunyan He  --disable-libpmem) libpmem=no
152717824406SJunyan He  ;;
152875411919SJames Le Cuirot  --enable-xkbcommon) xkbcommon=yes
152975411919SJames Le Cuirot  ;;
153075411919SJames Le Cuirot  --disable-xkbcommon) xkbcommon=no
153175411919SJames Le Cuirot  ;;
15322d2ad6d0SFam Zheng  *)
15332d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15342d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15352d2ad6d0SFam Zheng      exit 1
15367f1559c6Sbalrog  ;;
15377d13299dSbellard  esac
15387d13299dSbellarddone
15397d13299dSbellard
154040293e58Sbellardcase "$cpu" in
1541e3608d66SRichard Henderson    ppc)
1542e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1543e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1544e3608d66SRichard Henderson           ;;
1545e3608d66SRichard Henderson    ppc64)
1546e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1547e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1548e3608d66SRichard Henderson           ;;
15499b9c37c3SRichard Henderson    sparc)
1550f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1551f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
15523142255cSblueswir1           ;;
1553ed968ff1SJuan Quintela    sparc64)
155479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1555f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
15563142255cSblueswir1           ;;
155776d83bdeSths    s390)
1558061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
155928d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
156028d7cc49SRichard Henderson           ;;
156128d7cc49SRichard Henderson    s390x)
1562061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
156328d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
156476d83bdeSths           ;;
156540293e58Sbellard    i386)
156679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
15670c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
156840293e58Sbellard           ;;
156940293e58Sbellard    x86_64)
15707ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15717ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
15727ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
15737ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
15740c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
1575379f6698SPaul Brook           ;;
1576c72b26ecSRichard Henderson    x32)
1577c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1578c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1579c72b26ecSRichard Henderson           ;;
158030163d89SPeter Maydell    # No special flags required for other host CPUs
15813142255cSblueswir1esac
15823142255cSblueswir1
15832038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
15842038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
158579f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
158679f3b12fSPeter Crosthwaite
1587affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1588affc88ccSPeter Maydell# support, even if we're using TCI.
1589affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1590affc88ccSPeter Maydell  bsd_user="no"
1591affc88ccSPeter Maydell  linux_user="no"
1592affc88ccSPeter Maydellfi
1593affc88ccSPeter Maydell
159460e0df25SPeter Maydelldefault_target_list=""
159560e0df25SPeter Maydell
15966e92f823SPeter Maydellmak_wilds=""
15976e92f823SPeter Maydell
159860e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
15996e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
160060e0df25SPeter Maydellfi
160160e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
16026e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
160360e0df25SPeter Maydellfi
160460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
16056e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
160660e0df25SPeter Maydellfi
160760e0df25SPeter Maydell
1608447e133fSAlex Bennéeif test -z "$target_list_exclude"; then
16096e92f823SPeter Maydell    for config in $mak_wilds; do
16106e92f823SPeter Maydell        default_target_list="${default_target_list} $(basename "$config" .mak)"
16116e92f823SPeter Maydell    done
1612447e133fSAlex Bennéeelse
1613447e133fSAlex Bennée    exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1614447e133fSAlex Bennée    for config in $mak_wilds; do
1615447e133fSAlex Bennée        target="$(basename "$config" .mak)"
1616447e133fSAlex Bennée        exclude="no"
1617447e133fSAlex Bennée        for excl in $exclude_list; do
1618447e133fSAlex Bennée            if test "$excl" = "$target"; then
1619447e133fSAlex Bennée                exclude="yes"
1620447e133fSAlex Bennée                break;
1621447e133fSAlex Bennée            fi
1622447e133fSAlex Bennée        done
1623447e133fSAlex Bennée        if test "$exclude" = "no"; then
1624447e133fSAlex Bennée            default_target_list="${default_target_list} $target"
1625447e133fSAlex Bennée        fi
1626447e133fSAlex Bennée    done
1627447e133fSAlex Bennéefi
16286e92f823SPeter Maydell
1629c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
163064a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1631c53eeaf7SStefan Hajnoczi
1632af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1633af5db58eSpbrookcat << EOF
1634af5db58eSpbrook
1635af5db58eSpbrookUsage: configure [options]
1636af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1637af5db58eSpbrook
163808fb77edSStefan WeilStandard options:
163908fb77edSStefan Weil  --help                   print this message
164008fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
164108fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
164208fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
164308fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
164408fb77edSStefan Weil$(echo Available targets: $default_target_list | \
164508fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1646447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
164708fb77edSStefan Weil
164808fb77edSStefan WeilAdvanced options (experts only):
164908fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
165008fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
165108fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
165208fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
165308fb77edSStefan Weil                           build time
165408fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
165508fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
165608fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
165711cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
165808fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1659d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1660d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
166108fb77edSStefan Weil  --make=MAKE              use specified make [$make]
166208fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
166308fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
166408fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1665db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
166608fb77edSStefan Weil  --static                 enable static build [$static]
166708fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
166808fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
166908fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
167008fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
167108fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1672db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
167308fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
167408fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
16753d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1676e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1677db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
167808fb77edSStefan Weil  --enable-debug           enable common debug build options
1679247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
168008fb77edSStefan Weil  --disable-strip          disable stripping binaries
168108fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
168263678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
168308fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
168408fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
168508fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
168608fb77edSStefan Weil  --block-drv-rw-whitelist=L
168708fb77edSStefan Weil                           set block driver read-write whitelist
168808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
168908fb77edSStefan Weil  --block-drv-ro-whitelist=L
169008fb77edSStefan Weil                           set block driver read-only whitelist
169108fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
16925b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1693c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
169408fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
169508fb77edSStefan Weil                           Default:trace-<pid>
1696c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1697c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
16985a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1699c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1700c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
170108fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
170233c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
170308fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
170408fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1705c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1706c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1707c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1708a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1709c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1710c12d66aaSLin Ma  --enable-profiler        profiler support
1711c12d66aaSLin Ma  --enable-debug-stack-usage
1712c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1713c23f23b9SMichael Tokarev
1714c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1715c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1716c23f23b9SMichael Tokarev
1717c23f23b9SMichael Tokarev  system          all system emulation targets
1718c23f23b9SMichael Tokarev  user            supported user emulation targets
1719c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1720c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1721c23f23b9SMichael Tokarev  docs            build documentation
1722c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1723c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1724c23f23b9SMichael Tokarev  pie             Position Independent Executables
172521e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1726c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1727c23f23b9SMichael Tokarev  debug-info      debugging information
1728c23f23b9SMichael Tokarev  sparse          sparse checker
1729c23f23b9SMichael Tokarev
1730ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
173191bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
173291bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
17338953caf3SDaniel P. Berrange  auth-pam        PAM access control
1734c23f23b9SMichael Tokarev  sdl             SDL UI
173504c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1736c23f23b9SMichael Tokarev  gtk             gtk UI
1737c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1738c23f23b9SMichael Tokarev  curses          curses UI
1739e08bb301SSamuel Thibault  iconv           font glyph conversion support
1740c23f23b9SMichael Tokarev  vnc             VNC UI support
1741c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1742c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1743c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1744c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1745c23f23b9SMichael Tokarev  virtfs          VirtFS
1746fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1747c23f23b9SMichael Tokarev  xen             xen backend driver support
174870c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1749c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1750c23f23b9SMichael Tokarev  curl            curl connectivity
1751a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1752c23f23b9SMichael Tokarev  fdt             fdt device tree
1753c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1754c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1755b0cb0a66SVincent Palatin  hax             HAX acceleration support
1756c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1757d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
175821ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
175921ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1760c23f23b9SMichael Tokarev  vde             support for vde network
1761c23f23b9SMichael Tokarev  netmap          support for netmap network
1762c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1763c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1764c23f23b9SMichael Tokarev  attr            attr and xattr support
1765299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1766299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1767299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1768299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1769299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1770299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1771c23f23b9SMichael Tokarev  spice           spice
1772c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1773c23f23b9SMichael Tokarev  libiscsi        iscsi support
1774c23f23b9SMichael Tokarev  libnfs          nfs support
17757b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1776c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1777ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1778c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1779c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1780c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1781c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1782c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
178383bc1f97SJulio Faracco  lzfse           support of lzfse compression library
178483bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
1785c23f23b9SMichael Tokarev  seccomp         seccomp support
1786c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1787c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1788c23f23b9SMichael Tokarev  tpm             TPM support
1789b10d49d7SPino Toscano  libssh          ssh block device support
1790c23f23b9SMichael Tokarev  numa            libnuma support
1791ed279a06SKlim Kireev  libxml2         for Parallels image format
1792c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
17937b01cb97SAlexandre Derumier  jemalloc        jemalloc support
179486583a07SLiam Merwick  avx2            AVX2 optimization support
1795a6b1d4c0SChanglong Xie  replication     replication support
1796c12d66aaSLin Ma  opengl          opengl support
1797c12d66aaSLin Ma  virglrenderer   virgl rendering support
1798c12d66aaSLin Ma  xfsctl          xfsctl support
1799c12d66aaSLin Ma  qom-cast-debug  cast debugging support
18008de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
1801da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
18022f740136SJeff Cody  bochs           bochs image format support
18032f740136SJeff Cody  cloop           cloop image format support
18042f740136SJeff Cody  dmg             dmg image format support
18052f740136SJeff Cody  qcow1           qcow v1 image format support
18062f740136SJeff Cody  vdi             vdi image format support
18072f740136SJeff Cody  vvfat           vvfat image format support
18082f740136SJeff Cody  qed             qed image format support
18092f740136SJeff Cody  parallels       parallels image format support
18102f740136SJeff Cody  sheepdog        sheepdog block driver support
1811f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
18128ca80760SRichard Henderson  capstone        capstone disassembler support
1813ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
181417824406SJunyan He  libpmem         libpmem support
181575411919SJames Le Cuirot  xkbcommon       xkbcommon support
181608fb77edSStefan Weil
181708fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1818af5db58eSpbrookEOF
18192d2ad6d0SFam Zhengexit 0
1820af5db58eSpbrookfi
1821af5db58eSpbrook
18229c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1823bb768f71SThomas Huthrm -f */config-devices.mak.d
18249c790242SThomas Huth
1825faf44142SDaniel P. Berrangéif test -z "$python"
1826faf44142SDaniel P. Berrangéthen
1827c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1828c53eeaf7SStefan Hajnoczifi
1829c53eeaf7SStefan Hajnoczi
1830c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1831c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
18327f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
18337f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1834c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1835c53eeaf7SStefan Hajnoczifi
1836c53eeaf7SStefan Hajnoczi
1837755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1838406ab2f3SCleber Rosapython_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
1839755ee70fSCleber Rosa
1840c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1841c53eeaf7SStefan Hajnoczipython="$python -B"
1842c53eeaf7SStefan Hajnoczi
18439aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
18449aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
18459aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
18469aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
18479aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
18489aae6e54SDaniel Henrique Barbozaif compile_object ; then
18499aae6e54SDaniel Henrique Barboza  : C compiler works ok
18509aae6e54SDaniel Henrique Barbozaelse
18519aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
18529aae6e54SDaniel Henrique Barbozafi
18539aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
18549aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
18559aae6e54SDaniel Henrique Barbozafi
18569aae6e54SDaniel Henrique Barboza
1857359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1858359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1859359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1860359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1861359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1862359bc95dSPeter Maydell    else
186376ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1864359bc95dSPeter Maydell    fi
1865359bc95dSPeter Maydellfi
1866359bc95dSPeter Maydell
18679c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
18689c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
18699c83ffd8SPeter Maydellif test -z "$werror" ; then
1870fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
1871e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
18729c83ffd8SPeter Maydell        werror="yes"
18739c83ffd8SPeter Maydell    else
18749c83ffd8SPeter Maydell        werror="no"
18759c83ffd8SPeter Maydell    fi
18769c83ffd8SPeter Maydellfi
18779c83ffd8SPeter Maydell
1878fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1879fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1880fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1881fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1882fb59dabdSPeter Maydell    # host OS we should stop now.
1883951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1884fb59dabdSPeter Maydellfi
1885fb59dabdSPeter Maydell
1886efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1887efc6c070SThomas Huthcat > $TMPC << EOF
1888efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1889efc6c070SThomas Huth# ifdef __apple_build_version__
1890efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1891efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
1892efc6c070SThomas Huth#  endif
1893efc6c070SThomas Huth# else
1894efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1895efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
1896efc6c070SThomas Huth#  endif
1897efc6c070SThomas Huth# endif
1898efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1899efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1900efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
1901efc6c070SThomas Huth# endif
1902efc6c070SThomas Huth#else
1903efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1904efc6c070SThomas Huth#endif
1905efc6c070SThomas Huthint main (void) { return 0; }
1906efc6c070SThomas HuthEOF
1907efc6c070SThomas Huthif ! compile_prog "" "" ; then
1908efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1909efc6c070SThomas Huthfi
1910efc6c070SThomas Huth
19118d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
19128d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1913ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1914435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1915b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1916e6e90feeSThomas Huthgcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
19176ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
19186ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
19196ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
19206ca026cbSPeter Maydell# so it's too error prone.
192193b25869SJohn Snow
192293b25869SJohn Snowcc_has_warning_flag() {
192393b25869SJohn Snow    write_c_skeleton;
192493b25869SJohn Snow
1925a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1926a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1927a1d29d6cSPeter Maydell    # warning options).
192893b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
192993b25869SJohn Snow    compile_prog "-Werror $optflag" ""
193093b25869SJohn Snow}
193193b25869SJohn Snow
193293b25869SJohn Snowfor flag in $gcc_flags; do
193393b25869SJohn Snow    if cc_has_warning_flag $flag ; then
19348d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19358d05095cSPaolo Bonzini    fi
19368d05095cSPaolo Bonzinidone
19378d05095cSPaolo Bonzini
193863678e17SSteven Noonanif test "$stack_protector" != "no"; then
1939fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1940fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1941fccd35a0SRodrigo Rebello{
1942fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1943fccd35a0SRodrigo Rebello    while (*c) {
1944fccd35a0SRodrigo Rebello        *p++ = *c++;
1945fccd35a0SRodrigo Rebello    }
1946fccd35a0SRodrigo Rebello    return 0;
1947fccd35a0SRodrigo Rebello}
1948fccd35a0SRodrigo RebelloEOF
194963678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
19503b463a3fSMiroslav Rezanina  sp_on=0
195163678e17SSteven Noonan  for flag in $gcc_flags; do
1952590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1953590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1954590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1955590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
195663678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
19573b463a3fSMiroslav Rezanina      sp_on=1
195863678e17SSteven Noonan      break
195963678e17SSteven Noonan    fi
196063678e17SSteven Noonan  done
19613b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
19623b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
19633b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
19643b463a3fSMiroslav Rezanina    fi
19653b463a3fSMiroslav Rezanina  fi
196637746c5eSMarc-André Lureaufi
196737746c5eSMarc-André Lureau
196820bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
196920bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
197020bc94a2SPaolo Bonzinicat > $TMPC << EOF
197120bc94a2SPaolo Bonzinistruct {
197220bc94a2SPaolo Bonzini  int a[2];
197320bc94a2SPaolo Bonzini} x = {0};
197420bc94a2SPaolo BonziniEOF
197520bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
197620bc94a2SPaolo Bonzini  :
197720bc94a2SPaolo Bonzinielse
197820bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
197920bc94a2SPaolo Bonzinifi
198020bc94a2SPaolo Bonzini
198121e709aaSMarc-André Lureau# Our module code doesn't support Windows
198221e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
198321e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
198421e709aaSMarc-André Lureaufi
198521e709aaSMarc-André Lureau
1986d376e9deSThomas Huth# Static linking is not possible with modules or PIE
198740d6444eSAvi Kivityif test "$static" = "yes" ; then
1988aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1989aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1990aa0d1f44SPaolo Bonzini  fi
199140d6444eSAvi Kivity  if test "$pie" = "yes" ; then
199276ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
199340d6444eSAvi Kivity  else
199440d6444eSAvi Kivity    pie="no"
199540d6444eSAvi Kivity  fi
199640d6444eSAvi Kivityfi
199740d6444eSAvi Kivity
1998768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1999768b7855SEmilio G. Cota  cat > $TMPC << EOF
2000768b7855SEmilio G. Cotastatic __thread int tls_var;
2001768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2002768b7855SEmilio G. CotaEOF
2003768b7855SEmilio G. Cota
2004768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2005768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2006768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2007768b7855SEmilio G. Cotafi
2008768b7855SEmilio G. Cota
200940d6444eSAvi Kivityif test "$pie" = ""; then
201040d6444eSAvi Kivity  case "$cpu-$targetos" in
2011c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
201240d6444eSAvi Kivity      ;;
201340d6444eSAvi Kivity    *)
201440d6444eSAvi Kivity      pie="no"
201540d6444eSAvi Kivity      ;;
201640d6444eSAvi Kivity  esac
201740d6444eSAvi Kivityfi
201840d6444eSAvi Kivity
201940d6444eSAvi Kivityif test "$pie" != "no" ; then
202040d6444eSAvi Kivity  cat > $TMPC << EOF
202121d4a791SAvi Kivity
202221d4a791SAvi Kivity#ifdef __linux__
202321d4a791SAvi Kivity#  define THREAD __thread
202421d4a791SAvi Kivity#else
202521d4a791SAvi Kivity#  define THREAD
202621d4a791SAvi Kivity#endif
202721d4a791SAvi Kivity
202821d4a791SAvi Kivitystatic THREAD int tls_var;
202921d4a791SAvi Kivity
203021d4a791SAvi Kivityint main(void) { return tls_var; }
203121d4a791SAvi Kivity
203240d6444eSAvi KivityEOF
2033412aeacdSAlex Bennée  # check we support --no-pie first...
2034412aeacdSAlex Bennée  if compile_prog "-Werror -fno-pie" "-no-pie"; then
2035412aeacdSAlex Bennée    CFLAGS_NOPIE="-fno-pie"
2036412aeacdSAlex Bennée    LDFLAGS_NOPIE="-nopie"
2037412aeacdSAlex Bennée  fi
2038412aeacdSAlex Bennée
203940d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
204040d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
204140d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
204240d6444eSAvi Kivity    pie="yes"
204340d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
204440d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
204540d6444eSAvi Kivity    fi
204640d6444eSAvi Kivity  else
204740d6444eSAvi Kivity    if test "$pie" = "yes"; then
204876ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
204940d6444eSAvi Kivity    else
205040d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
205140d6444eSAvi Kivity      pie="no"
205240d6444eSAvi Kivity    fi
205340d6444eSAvi Kivity  fi
205440d6444eSAvi Kivityfi
205540d6444eSAvi Kivity
205609dada40SPaolo Bonzini##########################################
205709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
205809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
205909dada40SPaolo Bonzini# specification is necessary
206009dada40SPaolo Bonzini
206109dada40SPaolo Bonziniif test "$cpu" = "i386"; then
206209dada40SPaolo Bonzini  cat > $TMPC << EOF
206309dada40SPaolo Bonzinistatic int sfaa(int *ptr)
206409dada40SPaolo Bonzini{
206509dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
206609dada40SPaolo Bonzini}
206709dada40SPaolo Bonzini
206809dada40SPaolo Bonziniint main(void)
206909dada40SPaolo Bonzini{
207009dada40SPaolo Bonzini  int val = 42;
20711405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
207209dada40SPaolo Bonzini  sfaa(&val);
207309dada40SPaolo Bonzini  return val;
207409dada40SPaolo Bonzini}
207509dada40SPaolo BonziniEOF
207609dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
207709dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
207809dada40SPaolo Bonzini  fi
207909dada40SPaolo Bonzinifi
208009dada40SPaolo Bonzini
208109dada40SPaolo Bonzini#########################################
2082ec530c81Sbellard# Solaris specific configure tool chain decisions
208309dada40SPaolo Bonzini
2084ec530c81Sbellardif test "$solaris" = "yes" ; then
20856792aa11SLoïc Minier  if has $install; then
20866792aa11SLoïc Minier    :
20876792aa11SLoïc Minier  else
208876ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
208976ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
209076ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2091ec530c81Sbellard  fi
209289138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
209376ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
209476ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
209576ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2096ec530c81Sbellard  fi
20976792aa11SLoïc Minier  if has ar; then
20986792aa11SLoïc Minier    :
20996792aa11SLoïc Minier  else
2100ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
210176ad07a4SPeter Maydell      error_exit "No path includes ar" \
210276ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2103ec530c81Sbellard    fi
210476ad07a4SPeter Maydell    error_exit "No path includes ar"
2105ec530c81Sbellard  fi
2106ec530c81Sbellardfi
2107ec530c81Sbellard
2108afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2109d880a3baSPaolo Bonzini    for target in $default_target_list; do
2110d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2111d880a3baSPaolo Bonzini            target_list="$target_list $target"
2112d880a3baSPaolo Bonzini    done
2113d880a3baSPaolo Bonzini    target_list="${target_list# }"
2114121afa9eSAnthony Liguorielse
211589138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2116d880a3baSPaolo Bonzini    for target in $target_list; do
211725b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
211825b48338SPeter Maydell        # friendly error message than if we let it fall through.
211925b48338SPeter Maydell        case " $default_target_list " in
212025b48338SPeter Maydell            *" $target "*)
212125b48338SPeter Maydell                ;;
212225b48338SPeter Maydell            *)
212325b48338SPeter Maydell                error_exit "Unknown target name '$target'"
212425b48338SPeter Maydell                ;;
212525b48338SPeter Maydell        esac
2126d880a3baSPaolo Bonzini        supported_target $target || exit 1
212725b48338SPeter Maydell    done
2128d880a3baSPaolo Bonzinifi
212925b48338SPeter Maydell
2130f55fe278SPaolo Bonzini# see if system emulation was really requested
2131f55fe278SPaolo Bonzinicase " $target_list " in
2132f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2133f55fe278SPaolo Bonzini  ;;
2134f55fe278SPaolo Bonzini  *) softmmu=no
2135f55fe278SPaolo Bonzini  ;;
2136f55fe278SPaolo Bonziniesac
21375327cf48Sbellard
2138249247c9SJuan Quintelafeature_not_found() {
2139249247c9SJuan Quintela  feature=$1
214021684af0SStewart Smith  remedy=$2
2141249247c9SJuan Quintela
214276ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
214321684af0SStewart Smith      "configure was not able to find it." \
214421684af0SStewart Smith      "$remedy"
2145249247c9SJuan Quintela}
2146249247c9SJuan Quintela
21477d13299dSbellard# ---
21487d13299dSbellard# big/little endian test
21497d13299dSbellardcat > $TMPC << EOF
215061cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
215161cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
215261cc919fSMike Frysingerextern int foo(short *, short *);
215361cc919fSMike Frysingerint main(int argc, char *argv[]) {
215461cc919fSMike Frysinger    return foo(big_endian, little_endian);
21557d13299dSbellard}
21567d13299dSbellardEOF
21577d13299dSbellard
215861cc919fSMike Frysingerif compile_object ; then
215912f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
216061cc919fSMike Frysinger        bigendian="yes"
216112f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
216261cc919fSMike Frysinger        bigendian="no"
21637d13299dSbellard    else
21647d13299dSbellard        echo big/little test failed
21657d13299dSbellard    fi
21667d13299dSbellardelse
216761cc919fSMike Frysinger    echo big/little test failed
21687d13299dSbellardfi
21697d13299dSbellard
2170b0a47e79SJuan Quintela##########################################
2171a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2172a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2173a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2174a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2175a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2176a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2177a30878e7SPeter Maydell    fi
2178a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2179a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2180a30878e7SPeter Maydell    fi
2181a30878e7SPeter Maydell    gtk=no
2182a30878e7SPeter Maydell    sdl=no
2183a30878e7SPeter Maydellfi
2184a30878e7SPeter Maydell
21856b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
21866b39b063SEric Blakecat > $TMPC << EOF
21876b39b063SEric Blake#include <stdint.h>
21886b39b063SEric Blake#include <stdio.h>
21896b39b063SEric Blakeint main(int argc, char *argv[]) {
21906b39b063SEric Blake    return printf("%zu", SIZE_MAX);
21916b39b063SEric Blake}
21926b39b063SEric BlakeEOF
21936b39b063SEric Blakehave_broken_size_max=no
21946b39b063SEric Blakeif ! compile_object -Werror ; then
21956b39b063SEric Blake    have_broken_size_max=yes
21966b39b063SEric Blakefi
21976b39b063SEric Blake
2198a30878e7SPeter Maydell##########################################
2199015a33bdSGonglei# L2TPV3 probe
2200015a33bdSGonglei
2201015a33bdSGongleicat > $TMPC <<EOF
2202015a33bdSGonglei#include <sys/socket.h>
2203bff6cb72SMichael Tokarev#include <linux/ip.h>
2204015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2205015a33bdSGongleiEOF
2206015a33bdSGongleiif compile_prog "" "" ; then
2207015a33bdSGonglei  l2tpv3=yes
2208015a33bdSGongleielse
2209015a33bdSGonglei  l2tpv3=no
2210015a33bdSGongleifi
2211015a33bdSGonglei
2212299e6f19SPaolo Bonzini#########################################
2213299e6f19SPaolo Bonzini# vhost interdependencies and host support
2214299e6f19SPaolo Bonzini
2215299e6f19SPaolo Bonzini# vhost backends
2216299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2217299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2218299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2219299e6f19SPaolo Bonzinifi
2220299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2221299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2222299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2223299e6f19SPaolo Bonzinifi
2224299e6f19SPaolo Bonzini
2225299e6f19SPaolo Bonzini# vhost-kernel devices
2226299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2227299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2228299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2229299e6f19SPaolo Bonzinifi
2230299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2231299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2232299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2233299e6f19SPaolo Bonzinifi
2234299e6f19SPaolo Bonzini
2235299e6f19SPaolo Bonzini# vhost-user backends
2236299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2237299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2238299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2239299e6f19SPaolo Bonzinifi
2240299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2241299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2242299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2243299e6f19SPaolo Bonzinifi
2244*98fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
2245*98fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
2246*98fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
2247*98fc1adaSDr. David Alan Gilbertfi
2248299e6f19SPaolo Bonzini
2249299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2250299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2251299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2252299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2253299e6f19SPaolo Bonzinifi
2254299e6f19SPaolo Bonzini
2255015a33bdSGonglei##########################################
22564d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
22574d9310f4SDaniel P. Berrange
22584d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
22594d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
22604d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
22614d9310f4SDaniel P. Berrange    #
22624d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
22634d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
22644d9310f4SDaniel P. Berrange    #
22654d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
22664d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
22674d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
22684d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
22694d9310f4SDaniel P. Berrange    # that for you.
22704d9310f4SDaniel P. Berrange    #
22714d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
22724d9310f4SDaniel P. Berrange    # are not in fact redundant.
22734d9310f4SDaniel P. Berrangecat > $TMPC << EOF
22744d9310f4SDaniel P. Berrange#include <unistd.h>
22754d9310f4SDaniel P. Berrange#include <time.h>
22764d9310f4SDaniel P. Berrange#undef localtime_r
22774d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
22784d9310f4SDaniel P. BerrangeEOF
22794d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
22804d9310f4SDaniel P. Berrange        localtime_r="yes"
22814d9310f4SDaniel P. Berrange    else
22824d9310f4SDaniel P. Berrange        localtime_r="no"
22834d9310f4SDaniel P. Berrange    fi
22844d9310f4SDaniel P. Berrangefi
22854d9310f4SDaniel P. Berrange
22864d9310f4SDaniel P. Berrange##########################################
2287779ab5e3SStefan Weil# pkg-config probe
2288779ab5e3SStefan Weil
2289779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
229076ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2291779ab5e3SStefan Weilfi
2292779ab5e3SStefan Weil
2293779ab5e3SStefan Weil##########################################
2294b0a47e79SJuan Quintela# NPTL probe
2295b0a47e79SJuan Quintela
229624cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2297bd0c5661Spbrook  cat > $TMPC <<EOF
2298bd0c5661Spbrook#include <sched.h>
229930813ceaSpbrook#include <linux/futex.h>
2300182eacc0SStefan Weilint main(void) {
2301bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2302bd0c5661Spbrook#error bork
2303bd0c5661Spbrook#endif
2304182eacc0SStefan Weil  return 0;
2305bd0c5661Spbrook}
2306bd0c5661SpbrookEOF
230724cb36a6SPeter Maydell  if ! compile_object ; then
230821684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2309b0a47e79SJuan Quintela  fi
2310bd0c5661Spbrookfi
2311bd0c5661Spbrook
2312ac62922eSbalrog##########################################
2313607dacd0Sqiaonuohan# lzo check
2314607dacd0Sqiaonuohan
2315607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2316607dacd0Sqiaonuohan    cat > $TMPC << EOF
2317607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2318607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2319607dacd0SqiaonuohanEOF
2320607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2321607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2322b25c9dffSStefan Weil        lzo="yes"
2323b25c9dffSStefan Weil    else
2324b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2325b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2326b25c9dffSStefan Weil        fi
2327b25c9dffSStefan Weil        lzo="no"
2328b25c9dffSStefan Weil    fi
2329607dacd0Sqiaonuohanfi
2330607dacd0Sqiaonuohan
2331607dacd0Sqiaonuohan##########################################
2332607dacd0Sqiaonuohan# snappy check
2333607dacd0Sqiaonuohan
2334607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2335607dacd0Sqiaonuohan    cat > $TMPC << EOF
2336607dacd0Sqiaonuohan#include <snappy-c.h>
2337607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2338607dacd0SqiaonuohanEOF
2339607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2340607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2341b25c9dffSStefan Weil        snappy="yes"
2342b25c9dffSStefan Weil    else
2343b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2344b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2345b25c9dffSStefan Weil        fi
2346b25c9dffSStefan Weil        snappy="no"
2347b25c9dffSStefan Weil    fi
2348607dacd0Sqiaonuohanfi
2349607dacd0Sqiaonuohan
2350607dacd0Sqiaonuohan##########################################
23516b383c08SPeter Wu# bzip2 check
23526b383c08SPeter Wu
23536b383c08SPeter Wuif test "$bzip2" != "no" ; then
23546b383c08SPeter Wu    cat > $TMPC << EOF
23556b383c08SPeter Wu#include <bzlib.h>
23566b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
23576b383c08SPeter WuEOF
23586b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
23596b383c08SPeter Wu        bzip2="yes"
23606b383c08SPeter Wu    else
23616b383c08SPeter Wu        if test "$bzip2" = "yes"; then
23626b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
23636b383c08SPeter Wu        fi
23646b383c08SPeter Wu        bzip2="no"
23656b383c08SPeter Wu    fi
23666b383c08SPeter Wufi
23676b383c08SPeter Wu
23686b383c08SPeter Wu##########################################
236983bc1f97SJulio Faracco# lzfse check
237083bc1f97SJulio Faracco
237183bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
237283bc1f97SJulio Faracco    cat > $TMPC << EOF
237383bc1f97SJulio Faracco#include <lzfse.h>
237483bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
237583bc1f97SJulio FaraccoEOF
237683bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
237783bc1f97SJulio Faracco        lzfse="yes"
237883bc1f97SJulio Faracco    else
237983bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
238083bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
238183bc1f97SJulio Faracco        fi
238283bc1f97SJulio Faracco        lzfse="no"
238383bc1f97SJulio Faracco    fi
238483bc1f97SJulio Faraccofi
238583bc1f97SJulio Faracco
238683bc1f97SJulio Faracco##########################################
2387f794573eSEduardo Otubo# libseccomp check
2388f794573eSEduardo Otubo
2389f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
23903e684455SMichael Strosaker    libseccomp_minver="2.3.0"
239125ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2392c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2393c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2394f794573eSEduardo Otubo        seccomp="yes"
2395f794573eSEduardo Otubo    else
2396f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2397693e5910SAndrew Jones            feature_not_found "libseccomp" \
2398693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2399896848f0SEduardo Otubo        fi
2400e84d5956SYann E. MORIN        seccomp="no"
2401f794573eSEduardo Otubo    fi
2402f794573eSEduardo Otubofi
2403f794573eSEduardo Otubo##########################################
2404e37630caSaliguori# xen probe
2405e37630caSaliguori
2406fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2407c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2408c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2409c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2410c1cdd9d5SJuergen Gross
2411c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2412c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2413c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2414c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2415c1cdd9d5SJuergen Gross    xen=yes
2416c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2417c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
241858ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
241958ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
242058ea9a7aSAnthony PERARD    fi
2421c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2422c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2423c1cdd9d5SJuergen Gross  else
2424c1cdd9d5SJuergen Gross
2425b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2426d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2427d5b93ddfSAnthony PERARD
242850ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
242950ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
243050ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
243150ced5b3SStefan Weil
243250ced5b3SStefan Weil    # Xen (any)
243350ced5b3SStefan Weil    cat > $TMPC <<EOF
243450ced5b3SStefan Weil#include <xenctrl.h>
243550ced5b3SStefan Weilint main(void) {
243650ced5b3SStefan Weil  return 0;
243750ced5b3SStefan Weil}
243850ced5b3SStefan WeilEOF
243950ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
244050ced5b3SStefan Weil      # Xen not found
244150ced5b3SStefan Weil      if test "$xen" = "yes" ; then
244221684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
244350ced5b3SStefan Weil      fi
244450ced5b3SStefan Weil      xen=no
244550ced5b3SStefan Weil
2446d5b93ddfSAnthony PERARD    # Xen unstable
244769deef08SPeter Maydell    elif
244869deef08SPeter Maydell        cat > $TMPC <<EOF &&
24492cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
24502cbf8903SRoss Lagerwall#define __XEN_TOOLS__
24512cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2452d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
24532cbf8903SRoss Lagerwallint main(void) {
24542cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2455d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
24562cbf8903SRoss Lagerwall
24572cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
24582cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
24592cbf8903SRoss Lagerwall
2460d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2461d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2462d3c49ebbSPaul Durrant
24632cbf8903SRoss Lagerwall  return 0;
24642cbf8903SRoss Lagerwall}
24652cbf8903SRoss LagerwallEOF
24662cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24672cbf8903SRoss Lagerwall      then
24682cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24692cbf8903SRoss Lagerwall      xen_ctrl_version=41100
24702cbf8903SRoss Lagerwall      xen=yes
24712cbf8903SRoss Lagerwall    elif
24722cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
24735ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
24745ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
247558ea9a7aSAnthony PERARD#include <xentoolcore.h>
24765ba3d756SIgor Druzhininint main(void) {
24775ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
24785ba3d756SIgor Druzhinin
24795ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
24805ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
248158ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
24825ba3d756SIgor Druzhinin
24835ba3d756SIgor Druzhinin  return 0;
24845ba3d756SIgor Druzhinin}
24855ba3d756SIgor DruzhininEOF
248658ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
24875ba3d756SIgor Druzhinin      then
248858ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
24895ba3d756SIgor Druzhinin      xen_ctrl_version=41000
24905ba3d756SIgor Druzhinin      xen=yes
24915ba3d756SIgor Druzhinin    elif
24925ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2493da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2494da8090ccSPaul Durrant#define __XEN_TOOLS__
2495da8090ccSPaul Durrant#include <xendevicemodel.h>
2496da8090ccSPaul Durrantint main(void) {
2497da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2498da8090ccSPaul Durrant
2499da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2500da8090ccSPaul Durrant  xendevicemodel_close(xd);
2501da8090ccSPaul Durrant
2502da8090ccSPaul Durrant  return 0;
2503da8090ccSPaul Durrant}
2504da8090ccSPaul DurrantEOF
2505da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2506da8090ccSPaul Durrant      then
2507da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2508f1167ee6SJuergen Gross      xen_ctrl_version=40900
2509da8090ccSPaul Durrant      xen=yes
2510da8090ccSPaul Durrant    elif
2511da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
25125eeb39c2SIan Campbell/*
25135eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
25145eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2515b6eb9b45SPaulina Szubarczyk *
2516b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2517b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2518b6eb9b45SPaulina Szubarczyk */
2519b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2520b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2521b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2522b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2523b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2524b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2525b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2526b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2527b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2528b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2529b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2530b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2531b6eb9b45SPaulina Szubarczyk#endif
2532b6eb9b45SPaulina Szubarczykint main(void) {
2533b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2534b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2535b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2536b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2537b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2538b6eb9b45SPaulina Szubarczyk
2539b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2540b6eb9b45SPaulina Szubarczyk
2541b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2542b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2543b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2544b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2545b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2546b6eb9b45SPaulina Szubarczyk
2547b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2548b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2549b6eb9b45SPaulina Szubarczyk
2550b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2551b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2552b6eb9b45SPaulina Szubarczyk
2553b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2554b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2555b6eb9b45SPaulina Szubarczyk
2556b6eb9b45SPaulina Szubarczyk  return 0;
2557b6eb9b45SPaulina Szubarczyk}
2558b6eb9b45SPaulina SzubarczykEOF
2559b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2560b6eb9b45SPaulina Szubarczyk      then
2561f1167ee6SJuergen Gross      xen_ctrl_version=40800
2562b6eb9b45SPaulina Szubarczyk      xen=yes
2563b6eb9b45SPaulina Szubarczyk    elif
2564b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2565b6eb9b45SPaulina Szubarczyk/*
2566b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2567b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
25685eeb39c2SIan Campbell */
25695eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
25705eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
25715eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25725eeb39c2SIan Campbell#include <xenctrl.h>
25735eeb39c2SIan Campbell#include <xenstore.h>
25745eeb39c2SIan Campbell#include <xenevtchn.h>
25755eeb39c2SIan Campbell#include <xengnttab.h>
25765eeb39c2SIan Campbell#include <xenforeignmemory.h>
25775eeb39c2SIan Campbell#include <stdint.h>
25785eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
25795eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
25805eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
25815eeb39c2SIan Campbell#endif
25825eeb39c2SIan Campbellint main(void) {
25835eeb39c2SIan Campbell  xc_interface *xc = NULL;
25845eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
25855eeb39c2SIan Campbell  xenevtchn_handle *xe;
25865eeb39c2SIan Campbell  xengnttab_handle *xg;
25875eeb39c2SIan Campbell
25885eeb39c2SIan Campbell  xs_daemon_open();
25895eeb39c2SIan Campbell
25905eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
25915eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
25925eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25935eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25945eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
25955eeb39c2SIan Campbell
25965eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
25975eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
25985eeb39c2SIan Campbell
25995eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26005eeb39c2SIan Campbell  xenevtchn_fd(xe);
26015eeb39c2SIan Campbell
26025eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26035eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26045eeb39c2SIan Campbell
26055eeb39c2SIan Campbell  return 0;
26065eeb39c2SIan Campbell}
26075eeb39c2SIan CampbellEOF
26085eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26095eeb39c2SIan Campbell      then
2610f1167ee6SJuergen Gross      xen_ctrl_version=40701
26115eeb39c2SIan Campbell      xen=yes
2612cdadde39SRoger Pau Monne
2613cdadde39SRoger Pau Monne    # Xen 4.6
2614cdadde39SRoger Pau Monne    elif
2615cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2616cdadde39SRoger Pau Monne#include <xenctrl.h>
2617e108a3c1SAnthony PERARD#include <xenstore.h>
2618d5b93ddfSAnthony PERARD#include <stdint.h>
2619d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2620d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2621d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2622d5b93ddfSAnthony PERARD#endif
2623d5b93ddfSAnthony PERARDint main(void) {
2624d5b93ddfSAnthony PERARD  xc_interface *xc;
2625d5b93ddfSAnthony PERARD  xs_daemon_open();
2626d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2627d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2628d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2629b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26308688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2631d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
263220a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2633d8b441a3SJan Beulich  return 0;
2634d8b441a3SJan Beulich}
2635d8b441a3SJan BeulichEOF
2636d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2637d8b441a3SJan Beulich      then
2638f1167ee6SJuergen Gross      xen_ctrl_version=40600
2639d8b441a3SJan Beulich      xen=yes
2640d8b441a3SJan Beulich
2641d8b441a3SJan Beulich    # Xen 4.5
2642d8b441a3SJan Beulich    elif
2643d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2644d8b441a3SJan Beulich#include <xenctrl.h>
2645d8b441a3SJan Beulich#include <xenstore.h>
2646d8b441a3SJan Beulich#include <stdint.h>
2647d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2648d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2649d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2650d8b441a3SJan Beulich#endif
2651d8b441a3SJan Beulichint main(void) {
2652d8b441a3SJan Beulich  xc_interface *xc;
2653d8b441a3SJan Beulich  xs_daemon_open();
2654d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2655d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2656d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2657d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2658d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26593996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
26603996e85cSPaul Durrant  return 0;
26613996e85cSPaul Durrant}
26623996e85cSPaul DurrantEOF
26633996e85cSPaul Durrant        compile_prog "" "$xen_libs"
26643996e85cSPaul Durrant      then
2665f1167ee6SJuergen Gross      xen_ctrl_version=40500
26663996e85cSPaul Durrant      xen=yes
26673996e85cSPaul Durrant
26683996e85cSPaul Durrant    elif
26693996e85cSPaul Durrant        cat > $TMPC <<EOF &&
26703996e85cSPaul Durrant#include <xenctrl.h>
26713996e85cSPaul Durrant#include <xenstore.h>
26723996e85cSPaul Durrant#include <stdint.h>
26733996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
26743996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
26753996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
26763996e85cSPaul Durrant#endif
26773996e85cSPaul Durrantint main(void) {
26783996e85cSPaul Durrant  xc_interface *xc;
26793996e85cSPaul Durrant  xs_daemon_open();
26803996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
26813996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26823996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
26833996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26843996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26858688e065SStefano Stabellini  return 0;
26868688e065SStefano Stabellini}
26878688e065SStefano StabelliniEOF
26888688e065SStefano Stabellini        compile_prog "" "$xen_libs"
268969deef08SPeter Maydell      then
2690f1167ee6SJuergen Gross      xen_ctrl_version=40200
26918688e065SStefano Stabellini      xen=yes
26928688e065SStefano Stabellini
2693e37630caSaliguori    else
2694fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2695edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2696edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2697fc321b4bSJuan Quintela      fi
2698fc321b4bSJuan Quintela      xen=no
2699e37630caSaliguori    fi
2700d5b93ddfSAnthony PERARD
2701d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2702f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
27035eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
27045eeb39c2SIan Campbell      fi
2705d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2706d5b93ddfSAnthony PERARD    fi
2707e37630caSaliguori  fi
2708c1cdd9d5SJuergen Grossfi
2709e37630caSaliguori
2710eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2711edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2712eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2713eb6fda0fSAnthony PERARD  else
2714eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
271576ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
271676ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2717eb6fda0fSAnthony PERARD    fi
2718eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2719eb6fda0fSAnthony PERARD  fi
2720eb6fda0fSAnthony PERARDfi
2721eb6fda0fSAnthony PERARD
2722e37630caSaliguori##########################################
2723d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2724d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2725327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2726d661d9a4SJustin Terry (VM)        whpx="yes"
2727d661d9a4SJustin Terry (VM)    else
2728d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
272953537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2730d661d9a4SJustin Terry (VM)        fi
2731d661d9a4SJustin Terry (VM)        whpx="no"
2732d661d9a4SJustin Terry (VM)    fi
2733d661d9a4SJustin Terry (VM)fi
2734d661d9a4SJustin Terry (VM)
2735d661d9a4SJustin Terry (VM)##########################################
2736dfffc653SJuan Quintela# Sparse probe
2737dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
27380dba6195SLoïc Minier  if has cgcc; then
2739dfffc653SJuan Quintela    sparse=yes
2740dfffc653SJuan Quintela  else
2741dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
274221684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2743dfffc653SJuan Quintela    fi
2744dfffc653SJuan Quintela    sparse=no
2745dfffc653SJuan Quintela  fi
2746dfffc653SJuan Quintelafi
2747dfffc653SJuan Quintela
2748dfffc653SJuan Quintela##########################################
2749f676c67eSJeremy White# X11 probe
2750f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
27518781595bSGerd Hoffmann    have_x11=yes
275289138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
275389138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2754f676c67eSJeremy Whitefi
2755f676c67eSJeremy White
2756f676c67eSJeremy White##########################################
2757a4ccabcfSAnthony Liguori# GTK probe
2758a4ccabcfSAnthony Liguori
27595a464e6cSPeter Xuif test "$gtk" != "no"; then
276089d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
276189d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
276258296cb6SDaniel P. Berrangé    gtkversion="3.14.0"
2763bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
276489138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
276589138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
276689138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
27670a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
27688781595bSGerd Hoffmann            need_x11=yes
2769f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2770f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
27710a337ed0SGerd Hoffmann        fi
2772bbbf9bfbSStefan Weil        gtk="yes"
2773bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
27745fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2775bbbf9bfbSStefan Weil    else
2776bbbf9bfbSStefan Weil        gtk="no"
2777bbbf9bfbSStefan Weil    fi
2778bbbf9bfbSStefan Weilfi
2779bbbf9bfbSStefan Weil
2780ddbb0d09SDaniel P. Berrange
2781ddbb0d09SDaniel P. Berrange##########################################
2782ddbb0d09SDaniel P. Berrange# GNUTLS probe
2783ddbb0d09SDaniel P. Berrange
2784ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2785a73e82efSRichard Henderson    pass="no"
2786a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
278789138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
278889138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2789a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
2790a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
2791a73e82efSRichard Henderson        write_c_skeleton
2792a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
2793243dc2cfSRichard Henderson            LIBS="$gnutls_libs $LIBS"
2794ddbb0d09SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2795a73e82efSRichard Henderson            pass="yes"
2796a73e82efSRichard Henderson        fi
2797a73e82efSRichard Henderson    fi
2798a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
2799a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2800ddbb0d09SDaniel P. Berrange    else
2801a73e82efSRichard Henderson        gnutls="$pass"
2802ddbb0d09SDaniel P. Berrange    fi
2803ddbb0d09SDaniel P. Berrangefi
2804ddbb0d09SDaniel P. Berrange
280591bfcdb0SDaniel P. Berrange
280691bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
280791bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2808a0722409SDaniel P. Berrangé# explicitly
280991bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
281091bfcdb0SDaniel P. Berrangethen
2811a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
281291bfcdb0SDaniel P. Berrange    then
281391bfcdb0SDaniel P. Berrange        gcrypt="no"
281491bfcdb0SDaniel P. Berrange    fi
281591bfcdb0SDaniel P. Berrangefi
281691bfcdb0SDaniel P. Berrange
281791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
281891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2819a0722409SDaniel P. Berrangé# explicitly
282091bfcdb0SDaniel P. Berrangeif test -z "$nettle"
282191bfcdb0SDaniel P. Berrangethen
2822a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
282391bfcdb0SDaniel P. Berrange    then
282491bfcdb0SDaniel P. Berrange        nettle="no"
282591bfcdb0SDaniel P. Berrange    fi
282691bfcdb0SDaniel P. Berrangefi
282791bfcdb0SDaniel P. Berrange
2828dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
282991bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
283091bfcdb0SDaniel P. Berrange    then
283191bfcdb0SDaniel P. Berrange	return 1
283291bfcdb0SDaniel P. Berrange    fi
283391bfcdb0SDaniel P. Berrange
283491bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
283591bfcdb0SDaniel P. Berrange    then
283689138857SStefan Weil	host=$(libgcrypt-config --host)
283791bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
283891bfcdb0SDaniel P. Berrange	then
283991bfcdb0SDaniel P. Berrange	    return 1
284091bfcdb0SDaniel P. Berrange	fi
284191bfcdb0SDaniel P. Berrange    fi
284291bfcdb0SDaniel P. Berrange
2843dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2844dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2845dea7a64eSDaniel P. Berrangé
2846dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2847dea7a64eSDaniel P. Berrangé    then
2848dea7a64eSDaniel P. Berrangé       return 1
2849dea7a64eSDaniel P. Berrangé    fi
2850dea7a64eSDaniel P. Berrangé
285191bfcdb0SDaniel P. Berrange    return 0
285291bfcdb0SDaniel P. Berrange}
285391bfcdb0SDaniel P. Berrange
2854a0722409SDaniel P. Berrangé
2855a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
2856a73e82efSRichard Henderson    pass="no"
285764dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2858a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2859a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2860a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2861a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2862a73e82efSRichard Henderson        write_c_skeleton
2863a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
2864243dc2cfSRichard Henderson            LIBS="$nettle_libs $LIBS"
2865a0722409SDaniel P. Berrangé            QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2866a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
2867a0722409SDaniel P. Berrangé               gcrypt="no"
2868a0722409SDaniel P. Berrangé            fi
2869a73e82efSRichard Henderson            pass="yes"
2870a73e82efSRichard Henderson        fi
2871a73e82efSRichard Henderson    fi
2872a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
287364dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2874a0722409SDaniel P. Berrangé    else
2875a73e82efSRichard Henderson        nettle="$pass"
2876a0722409SDaniel P. Berrangé    fi
2877a0722409SDaniel P. Berrangéfi
2878a0722409SDaniel P. Berrangé
287991bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2880a73e82efSRichard Henderson    pass="no"
2881dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
288289138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
288389138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
2884a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
288591bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
288691bfcdb0SDaniel P. Berrange        # turn breaks static builds...
288791bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
288891bfcdb0SDaniel P. Berrange        then
288991bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
289091bfcdb0SDaniel P. Berrange        fi
28911f923c70SLongpeng(Mike)
2892a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2893a73e82efSRichard Henderson        write_c_skeleton
2894a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
2895243dc2cfSRichard Henderson            LIBS="$gcrypt_libs $LIBS"
289637788f25SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2897a73e82efSRichard Henderson            pass="yes"
2898a73e82efSRichard Henderson        fi
2899a73e82efSRichard Henderson    fi
2900a73e82efSRichard Henderson    if test "$pass" = "yes"; then
290137788f25SDaniel P. Berrange        gcrypt="yes"
29021f923c70SLongpeng(Mike)        cat > $TMPC << EOF
29031f923c70SLongpeng(Mike)#include <gcrypt.h>
29041f923c70SLongpeng(Mike)int main(void) {
29051f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
29061f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
29071f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
29081f923c70SLongpeng(Mike)  return 0;
29091f923c70SLongpeng(Mike)}
29101f923c70SLongpeng(Mike)EOF
29111f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
29121f923c70SLongpeng(Mike)            gcrypt_hmac=yes
29131f923c70SLongpeng(Mike)        fi
2914a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
2915dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
291691bfcdb0SDaniel P. Berrange    else
291791bfcdb0SDaniel P. Berrange        gcrypt="no"
291891bfcdb0SDaniel P. Berrange    fi
291962893b67SDaniel P. Berrangefi
292062893b67SDaniel P. Berrange
2921ddbb0d09SDaniel P. Berrange
292291bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
292391bfcdb0SDaniel P. Berrangethen
292491bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
292591bfcdb0SDaniel P. Berrangefi
2926ed754746SDaniel P. Berrange
29279a2fd434SDaniel P. Berrange##########################################
29289a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
29299a2fd434SDaniel P. Berrange
29309a2fd434SDaniel P. Berrangetasn1=yes
293190246037SDaniel P. Berrangetasn1_cflags=""
293290246037SDaniel P. Berrangetasn1_libs=""
29339a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
293489138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
293589138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
29369a2fd434SDaniel P. Berrangeelse
29379a2fd434SDaniel P. Berrange    tasn1=no
29389a2fd434SDaniel P. Berrangefi
29399a2fd434SDaniel P. Berrange
2940ed754746SDaniel P. Berrange
2941bbbf9bfbSStefan Weil##########################################
29428953caf3SDaniel P. Berrange# PAM probe
29438953caf3SDaniel P. Berrange
29448953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
29458953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
29468953caf3SDaniel P. Berrange#include <security/pam_appl.h>
29478953caf3SDaniel P. Berrange#include <stdio.h>
29488953caf3SDaniel P. Berrangeint main(void) {
29498953caf3SDaniel P. Berrange   const char *service_name = "qemu";
29508953caf3SDaniel P. Berrange   const char *user = "frank";
29519c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
29528953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
29539c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
29548953caf3SDaniel P. Berrange   return 0;
29558953caf3SDaniel P. Berrange}
29568953caf3SDaniel P. BerrangeEOF
29578953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
29588953caf3SDaniel P. Berrange        auth_pam=yes
29598953caf3SDaniel P. Berrange    else
29608953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
29618953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
29628953caf3SDaniel P. Berrange        else
29638953caf3SDaniel P. Berrange            auth_pam=no
29648953caf3SDaniel P. Berrange        fi
29658953caf3SDaniel P. Berrange    fi
29668953caf3SDaniel P. Berrangefi
29678953caf3SDaniel P. Berrange
29688953caf3SDaniel P. Berrange##########################################
2969559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2970559607eaSDaniel P. Berrange
2971559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2972559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2973559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2974559607eaSDaniel P. Berrangefi
2975559607eaSDaniel P. Berrange
2976559607eaSDaniel P. Berrange##########################################
2977bbbf9bfbSStefan Weil# VTE probe
2978bbbf9bfbSStefan Weil
2979bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2980c6feff9eSCole Robinson    vteminversion="0.32.0"
2981c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
2982c6feff9eSCole Robinson      vtepackage="vte-2.91"
2983c6feff9eSCole Robinson    else
2984528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
2985c6feff9eSCole Robinson    fi
2986c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
298789138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
298889138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
298989138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2990bbbf9bfbSStefan Weil        vte="yes"
2991bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
2992c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
29939e04c683SStefan Weil    else
2994bbbf9bfbSStefan Weil        vte="no"
2995a4ccabcfSAnthony Liguori    fi
2996a4ccabcfSAnthony Liguorifi
2997a4ccabcfSAnthony Liguori
2998a4ccabcfSAnthony Liguori##########################################
299911d9f695Sbellard# SDL probe
300011d9f695Sbellard
3001aee8a619SCarlo Marcelo Arenas Belón# Look for sdl configuration program (pkg-config or sdl2-config).  Try
3002aee8a619SCarlo Marcelo Arenas Belón# sdl2-config even without cross prefix, and favour pkg-config over sdl2-config.
300347c03744SDave Airlie
3004c6093a05SPeter Xusdl_probe ()
3005c6093a05SPeter Xu{
30060015ca5cSDaniel P. Berrangé  if $pkg_config sdl2 --exists; then
30070015ca5cSDaniel P. Berrangé    sdlconfig="$pkg_config sdl2"
300889138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
3009aee8a619SCarlo Marcelo Arenas Belón  elif has "$sdl2_config"; then
30100015ca5cSDaniel P. Berrangé    sdlconfig="$sdl2_config"
301189138857SStefan Weil    sdlversion=$($sdlconfig --version)
3012a0dfd8a4SLoïc Minier  else
3013a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
30148f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
3015a0dfd8a4SLoïc Minier    fi
3016a0dfd8a4SLoïc Minier    sdl=no
3017c6093a05SPeter Xu    # no need to do the rest
3018c6093a05SPeter Xu    return
30199316f803SPaolo Bonzini  fi
3020aee8a619SCarlo Marcelo Arenas Belón  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then
30213ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
30223ec87ffeSPaolo Bonzini  fi
302311d9f695Sbellard
302411d9f695Sbellard  cat > $TMPC << EOF
302511d9f695Sbellard#include <SDL.h>
302611d9f695Sbellard#undef main /* We don't want SDL to override our main() */
302711d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
302811d9f695SbellardEOF
302989138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
30302ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
303174f42e18STeLeMan  if test "$static" = "yes" ; then
30320015ca5cSDaniel P. Berrangé    if $pkg_config sdl2 --exists; then
30330015ca5cSDaniel P. Berrangé      sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
30345f37e6d4SThomas Huth    else
303589138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
30365f37e6d4SThomas Huth    fi
303774f42e18STeLeMan  else
303889138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
303974f42e18STeLeMan  fi
304052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
304111d9f695Sbellard    sdl=yes
30427c1f25b4Sbellard
304367c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3044e633a5c6SEric Blake    if test "$sdl" = "yes" && test "$static" = "yes" ; then
304567c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
304689138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
304789138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
304811d9f695Sbellard      fi
304952166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
30501ac88f28SJuan Quintela	:
30511ac88f28SJuan Quintela      else
30521ac88f28SJuan Quintela        sdl=no
30537c1f25b4Sbellard      fi
30547c1f25b4Sbellard    fi # static link
3055c4198157SJuan Quintela  else # sdl not found
3056c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
30570015ca5cSDaniel P. Berrangé      feature_not_found "sdl" "Install SDL2 devel"
3058c4198157SJuan Quintela    fi
3059c4198157SJuan Quintela    sdl=no
30607c1f25b4Sbellard  fi # sdl compile test
3061c6093a05SPeter Xu}
3062c6093a05SPeter Xu
3063a442fe2fSDaniel P. Berrangésdl_image_probe ()
3064a442fe2fSDaniel P. Berrangé{
3065a442fe2fSDaniel P. Berrangé    if test "$sdl_image" != "no" ; then
3066a442fe2fSDaniel P. Berrangé        if $pkg_config SDL2_image --exists; then
3067a442fe2fSDaniel P. Berrangé            if test "$static" = "yes"; then
3068a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3069a442fe2fSDaniel P. Berrangé            else
3070a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3071a442fe2fSDaniel P. Berrangé            fi
3072a442fe2fSDaniel P. Berrangé            sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3073a442fe2fSDaniel P. Berrangé            sdl_image=yes
3074a442fe2fSDaniel P. Berrangé
3075a442fe2fSDaniel P. Berrangé            sdl_cflags="$sdl_cflags $sdl_image_cflags"
3076a442fe2fSDaniel P. Berrangé            sdl_libs="$sdl_libs $sdl_image_libs"
3077a442fe2fSDaniel P. Berrangé        else
3078a442fe2fSDaniel P. Berrangé            if test "$sdl_image" = "yes" ; then
3079a442fe2fSDaniel P. Berrangé                feature_not_found "sdl_image" "Install SDL Image devel"
3080a442fe2fSDaniel P. Berrangé            else
3081a442fe2fSDaniel P. Berrangé                sdl_image=no
3082a442fe2fSDaniel P. Berrangé            fi
3083a442fe2fSDaniel P. Berrangé        fi
3084a442fe2fSDaniel P. Berrangé    fi
3085a442fe2fSDaniel P. Berrangé}
3086a442fe2fSDaniel P. Berrangé
3087c6093a05SPeter Xuif test "$sdl" != "no" ; then
3088c6093a05SPeter Xu  sdl_probe
3089fd677642Sthsfi
309011d9f695Sbellard
30915368a422Saliguoriif test "$sdl" = "yes" ; then
3092a442fe2fSDaniel P. Berrangé  sdl_image_probe
3093a442fe2fSDaniel P. Berrangéelse
3094a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes"; then
3095a442fe2fSDaniel P. Berrangé    echo "warning: SDL Image requested, but SDL is not available, disabling"
3096a442fe2fSDaniel P. Berrangé  fi
3097a442fe2fSDaniel P. Berrangé  sdl_image=no
3098a442fe2fSDaniel P. Berrangéfi
3099a442fe2fSDaniel P. Berrangé
3100a442fe2fSDaniel P. Berrangéif test "$sdl" = "yes" ; then
31015368a422Saliguori  cat > $TMPC <<EOF
31025368a422Saliguori#include <SDL.h>
31035368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
31045368a422Saliguori#include <X11/XKBlib.h>
31055368a422Saliguori#else
31065368a422Saliguori#error No x11 support
31075368a422Saliguori#endif
31085368a422Saliguoriint main(void) { return 0; }
31095368a422SaliguoriEOF
3110f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
31118781595bSGerd Hoffmann    need_x11=yes
3112f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3113f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
31145368a422Saliguori  fi
31155368a422Saliguorifi
31165368a422Saliguori
31178f28f3fbSths##########################################
31182da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
31192da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
31202da776dbSMichael R. Hines  cat > $TMPC <<EOF
31212da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
31222da776dbSMichael R. Hinesint main(void) { return 0; }
31232da776dbSMichael R. HinesEOF
3124ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
31252da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
31262da776dbSMichael R. Hines    rdma="yes"
3127ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
31282da776dbSMichael R. Hines  else
31292da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
31302da776dbSMichael R. Hines        error_exit \
3131ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
31322da776dbSMichael R. Hines            " Your options:" \
3133ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
31342da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
31352da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
31362da776dbSMichael R. Hines    fi
31372da776dbSMichael R. Hines    rdma="no"
31382da776dbSMichael R. Hines  fi
31392da776dbSMichael R. Hinesfi
31402da776dbSMichael R. Hines
314121ab34c9SMarcel Apfelbaum##########################################
314221ab34c9SMarcel Apfelbaum# PVRDMA detection
314321ab34c9SMarcel Apfelbaum
314421ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
314521ab34c9SMarcel Apfelbaum#include <sys/mman.h>
314621ab34c9SMarcel Apfelbaum
314721ab34c9SMarcel Apfelbaumint
314821ab34c9SMarcel Apfelbaummain(void)
314921ab34c9SMarcel Apfelbaum{
315021ab34c9SMarcel Apfelbaum    char buf = 0;
315121ab34c9SMarcel Apfelbaum    void *addr = &buf;
315221ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
315321ab34c9SMarcel Apfelbaum
315421ab34c9SMarcel Apfelbaum    return 0;
315521ab34c9SMarcel Apfelbaum}
315621ab34c9SMarcel ApfelbaumEOF
315721ab34c9SMarcel Apfelbaum
315821ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
315921ab34c9SMarcel Apfelbaum    case "$pvrdma" in
316021ab34c9SMarcel Apfelbaum    "")
316121ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
316221ab34c9SMarcel Apfelbaum            pvrdma="yes"
316321ab34c9SMarcel Apfelbaum        else
316421ab34c9SMarcel Apfelbaum            pvrdma="no"
316521ab34c9SMarcel Apfelbaum        fi
316621ab34c9SMarcel Apfelbaum        ;;
316721ab34c9SMarcel Apfelbaum    "yes")
316821ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
316921ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
317021ab34c9SMarcel Apfelbaum        fi
317121ab34c9SMarcel Apfelbaum        pvrdma="yes"
317221ab34c9SMarcel Apfelbaum        ;;
317321ab34c9SMarcel Apfelbaum    "no")
317421ab34c9SMarcel Apfelbaum        pvrdma="no"
317521ab34c9SMarcel Apfelbaum        ;;
317621ab34c9SMarcel Apfelbaum    esac
317721ab34c9SMarcel Apfelbaumelse
317821ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
317921ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
318021ab34c9SMarcel Apfelbaum    fi
318121ab34c9SMarcel Apfelbaum    pvrdma="no"
318221ab34c9SMarcel Apfelbaumfi
318395c6bff3SBenoît Canet
318495c6bff3SBenoît Canet##########################################
31852f9606b3Saliguori# VNC SASL detection
3186e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
31872f9606b3Saliguori  cat > $TMPC <<EOF
31882f9606b3Saliguori#include <sasl/sasl.h>
31892f9606b3Saliguori#include <stdio.h>
31902f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
31912f9606b3SaliguoriEOF
31922f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
31932f9606b3Saliguori  vnc_sasl_cflags=""
31942f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
319552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3196ea784e3bSJuan Quintela    vnc_sasl=yes
3197fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3198ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
31992f9606b3Saliguori  else
3200ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
320121684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3202ea784e3bSJuan Quintela    fi
3203ea784e3bSJuan Quintela    vnc_sasl=no
32042f9606b3Saliguori  fi
32052f9606b3Saliguorifi
32062f9606b3Saliguori
32072f9606b3Saliguori##########################################
32082f6f5c7aSCorentin Chary# VNC JPEG detection
3209e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
32102f6f5c7aSCorentin Charycat > $TMPC <<EOF
32112f6f5c7aSCorentin Chary#include <stdio.h>
32122f6f5c7aSCorentin Chary#include <jpeglib.h>
32132f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
32142f6f5c7aSCorentin CharyEOF
32152f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
32162f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
32172f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
32182f6f5c7aSCorentin Chary    vnc_jpeg=yes
32192f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3220ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
32212f6f5c7aSCorentin Chary  else
32222f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
322321684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
32242f6f5c7aSCorentin Chary    fi
32252f6f5c7aSCorentin Chary    vnc_jpeg=no
32262f6f5c7aSCorentin Chary  fi
32272f6f5c7aSCorentin Charyfi
32282f6f5c7aSCorentin Chary
32292f6f5c7aSCorentin Chary##########################################
3230efe556adSCorentin Chary# VNC PNG detection
3231e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3232efe556adSCorentin Charycat > $TMPC <<EOF
3233efe556adSCorentin Chary//#include <stdio.h>
3234efe556adSCorentin Chary#include <png.h>
3235832ce9c2SScott Wood#include <stddef.h>
3236efe556adSCorentin Charyint main(void) {
3237efe556adSCorentin Chary    png_structp png_ptr;
3238efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
32397edc3fedSPeter Maydell    return png_ptr != 0;
3240efe556adSCorentin Chary}
3241efe556adSCorentin CharyEOF
324265d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
324389138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
324489138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
32459af8025eSBrad  else
3246efe556adSCorentin Chary    vnc_png_cflags=""
3247efe556adSCorentin Chary    vnc_png_libs="-lpng"
32489af8025eSBrad  fi
3249efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3250efe556adSCorentin Chary    vnc_png=yes
3251efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
32529af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3253efe556adSCorentin Chary  else
3254efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
325521684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3256efe556adSCorentin Chary    fi
3257efe556adSCorentin Chary    vnc_png=no
3258efe556adSCorentin Chary  fi
3259efe556adSCorentin Charyfi
3260efe556adSCorentin Chary
3261efe556adSCorentin Chary##########################################
32626a021536SGerd Hoffmann# xkbcommon probe
32636a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
32646a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
32656a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
32666a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
32676a021536SGerd Hoffmann    xkbcommon=yes
32686a021536SGerd Hoffmann  else
32696a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
32706a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
32716a021536SGerd Hoffmann    fi
32726a021536SGerd Hoffmann    xkbcommon=no
32736a021536SGerd Hoffmann  fi
32746a021536SGerd Hoffmannfi
32756a021536SGerd Hoffmann
327676655d6dSaliguori
327776655d6dSaliguori##########################################
3278c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3279dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3280dce512deSChristoph Hellwig  cat > $TMPC << EOF
3281ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3282dce512deSChristoph Hellwig#include <xfs/xfs.h>
3283dce512deSChristoph Hellwigint main(void)
3284dce512deSChristoph Hellwig{
3285dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3286dce512deSChristoph Hellwig    return 0;
3287dce512deSChristoph Hellwig}
3288dce512deSChristoph HellwigEOF
3289dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3290dce512deSChristoph Hellwig    xfs="yes"
3291dce512deSChristoph Hellwig  else
3292dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
329321684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3294dce512deSChristoph Hellwig    fi
3295dce512deSChristoph Hellwig    xfs=no
3296dce512deSChristoph Hellwig  fi
3297dce512deSChristoph Hellwigfi
3298dce512deSChristoph Hellwig
3299dce512deSChristoph Hellwig##########################################
33008a16d273Sths# vde libraries probe
3301dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
33024baae0acSJuan Quintela  vde_libs="-lvdeplug"
33038a16d273Sths  cat > $TMPC << EOF
33048a16d273Sths#include <libvdeplug.h>
33054a7f0e06Spbrookint main(void)
33064a7f0e06Spbrook{
33074a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3308fea08e08SPeter Maydell    char s[] = "";
3309fea08e08SPeter Maydell    vde_open(s, s, &a);
33104a7f0e06Spbrook    return 0;
33114a7f0e06Spbrook}
33128a16d273SthsEOF
331352166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
33144baae0acSJuan Quintela    vde=yes
3315dfb278bdSJuan Quintela  else
3316dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
331721684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3318dfb278bdSJuan Quintela    fi
3319dfb278bdSJuan Quintela    vde=no
33208a16d273Sths  fi
33218a16d273Sthsfi
33228a16d273Sths
33238a16d273Sths##########################################
33240a985b37SVincenzo Maffione# netmap support probe
33250a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
33260a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
33270a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
33280a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
33290a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
333058952137SVincenzo Maffioneif test "$netmap" != "no" ; then
333158952137SVincenzo Maffione  cat > $TMPC << EOF
333258952137SVincenzo Maffione#include <inttypes.h>
333358952137SVincenzo Maffione#include <net/if.h>
333458952137SVincenzo Maffione#include <net/netmap.h>
333558952137SVincenzo Maffione#include <net/netmap_user.h>
33360a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
33370a985b37SVincenzo Maffione#error
33380a985b37SVincenzo Maffione#endif
333958952137SVincenzo Maffioneint main(void) { return 0; }
334058952137SVincenzo MaffioneEOF
334158952137SVincenzo Maffione  if compile_prog "" "" ; then
334258952137SVincenzo Maffione    netmap=yes
334358952137SVincenzo Maffione  else
334458952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
334558952137SVincenzo Maffione      feature_not_found "netmap"
334658952137SVincenzo Maffione    fi
334758952137SVincenzo Maffione    netmap=no
334858952137SVincenzo Maffione  fi
334958952137SVincenzo Maffionefi
335058952137SVincenzo Maffione
335158952137SVincenzo Maffione##########################################
335247e98658SCorey Bryant# libcap-ng library probe
335347e98658SCorey Bryantif test "$cap_ng" != "no" ; then
335447e98658SCorey Bryant  cap_libs="-lcap-ng"
335547e98658SCorey Bryant  cat > $TMPC << EOF
335647e98658SCorey Bryant#include <cap-ng.h>
335747e98658SCorey Bryantint main(void)
335847e98658SCorey Bryant{
335947e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
336047e98658SCorey Bryant    return 0;
336147e98658SCorey Bryant}
336247e98658SCorey BryantEOF
336347e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
336447e98658SCorey Bryant    cap_ng=yes
336547e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
336647e98658SCorey Bryant  else
336747e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
336821684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
336947e98658SCorey Bryant    fi
337047e98658SCorey Bryant    cap_ng=no
337147e98658SCorey Bryant  fi
337247e98658SCorey Bryantfi
337347e98658SCorey Bryant
337447e98658SCorey Bryant##########################################
3375c2de5c91Smalc# Sound support libraries probe
33768f28f3fbSths
337789138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3378c2de5c91Smalcfor drv in $audio_drv_list; do
3379c2de5c91Smalc    case $drv in
3380e42975a1SGerd Hoffmann    alsa | try-alsa)
3381c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3382c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3383e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3384e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3385e42975a1SGerd Hoffmann        fi
3386e42975a1SGerd Hoffmann    else
3387e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3388e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3389c80a867fSGerd Hoffmann        else
3390c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3391c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3392c80a867fSGerd Hoffmann        fi
3393e42975a1SGerd Hoffmann    fi
3394c2de5c91Smalc    ;;
3395c2de5c91Smalc
3396e42975a1SGerd Hoffmann    pa | try-pa)
3397c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3398c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3399e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3400e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3401e42975a1SGerd Hoffmann        fi
3402e42975a1SGerd Hoffmann    else
3403e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3404e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3405c80a867fSGerd Hoffmann        else
3406c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3407c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3408c80a867fSGerd Hoffmann        fi
3409e42975a1SGerd Hoffmann    fi
3410b8e59f18Smalc    ;;
3411b8e59f18Smalc
3412373967b2SGerd Hoffmann    sdl)
3413373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3414373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3415373967b2SGerd Hoffmann    fi
3416373967b2SGerd Hoffmann    ;;
3417373967b2SGerd Hoffmann
3418e42975a1SGerd Hoffmann    try-sdl)
3419e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3420e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3421e42975a1SGerd Hoffmann    else
3422e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3423e42975a1SGerd Hoffmann    fi
3424e42975a1SGerd Hoffmann    ;;
3425e42975a1SGerd Hoffmann
3426997e690aSJuan Quintela    coreaudio)
3427b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3428997e690aSJuan Quintela    ;;
3429997e690aSJuan Quintela
3430a4bf6780SJuan Quintela    dsound)
3431b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3432d5631638Smalc      audio_win_int="yes"
3433a4bf6780SJuan Quintela    ;;
3434a4bf6780SJuan Quintela
3435a4bf6780SJuan Quintela    oss)
3436b1149911SFam Zheng      oss_libs="$oss_lib"
3437a4bf6780SJuan Quintela    ;;
3438a4bf6780SJuan Quintela
3439e4c63a6aSmalc    *)
34401c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
344176ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
344276ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3443e4c63a6aSmalc    }
3444e4c63a6aSmalc    ;;
3445c2de5c91Smalc    esac
3446c2de5c91Smalcdone
34478f28f3fbSths
34484d3b6f6eSbalrog##########################################
34492e4d9fb1Saurel32# BrlAPI probe
34502e4d9fb1Saurel32
34514ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3452eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
34532e4d9fb1Saurel32  cat > $TMPC << EOF
34542e4d9fb1Saurel32#include <brlapi.h>
3455832ce9c2SScott Wood#include <stddef.h>
34562e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
34572e4d9fb1Saurel32EOF
345852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
34592e4d9fb1Saurel32    brlapi=yes
34604ffcedb6SJuan Quintela  else
34614ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
346221684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
34634ffcedb6SJuan Quintela    fi
34644ffcedb6SJuan Quintela    brlapi=no
3465eb82284fSJuan Quintela  fi
3466eb82284fSJuan Quintelafi
34672e4d9fb1Saurel32
34682e4d9fb1Saurel32##########################################
3469e08bb301SSamuel Thibault# iconv probe
3470e08bb301SSamuel Thibaultif test "$iconv" != "no" ; then
3471e08bb301SSamuel Thibault  cat > $TMPC << EOF
3472e08bb301SSamuel Thibault#include <iconv.h>
3473e08bb301SSamuel Thibaultint main(void) {
3474e08bb301SSamuel Thibault  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3475e08bb301SSamuel Thibault  return conv != (iconv_t) -1;
3476e08bb301SSamuel Thibault}
3477e08bb301SSamuel ThibaultEOF
3478e08bb301SSamuel Thibault  iconv_prefix_list="/usr/local:/usr"
3479e08bb301SSamuel Thibault  iconv_lib_list=":-liconv"
3480e08bb301SSamuel Thibault  IFS=:
3481e08bb301SSamuel Thibault  for iconv_prefix in $iconv_prefix_list; do
3482e08bb301SSamuel Thibault    IFS=:
3483e08bb301SSamuel Thibault    iconv_cflags="-I$iconv_prefix/include"
3484e08bb301SSamuel Thibault    iconv_ldflags="-L$iconv_prefix/lib"
3485e08bb301SSamuel Thibault    for iconv_link in $iconv_lib_list; do
3486e08bb301SSamuel Thibault      unset IFS
3487e08bb301SSamuel Thibault      iconv_lib="$iconv_ldflags $iconv_link"
3488e08bb301SSamuel Thibault      echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3489e08bb301SSamuel Thibault      if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3490e08bb301SSamuel Thibault        iconv_found=yes
3491e08bb301SSamuel Thibault        break
3492e08bb301SSamuel Thibault      fi
3493e08bb301SSamuel Thibault    done
3494e08bb301SSamuel Thibault    if test "$iconv_found" = yes ; then
3495e08bb301SSamuel Thibault      break
3496e08bb301SSamuel Thibault    fi
3497e08bb301SSamuel Thibault  done
3498e08bb301SSamuel Thibault  if test "$iconv_found" = "yes" ; then
3499e08bb301SSamuel Thibault    iconv=yes
3500e08bb301SSamuel Thibault  else
3501e08bb301SSamuel Thibault    if test "$iconv" = "yes" ; then
3502e08bb301SSamuel Thibault      feature_not_found "iconv" "Install iconv devel"
3503e08bb301SSamuel Thibault    fi
3504e08bb301SSamuel Thibault    iconv=no
3505e08bb301SSamuel Thibault  fi
3506e08bb301SSamuel Thibaultfi
3507e08bb301SSamuel Thibault
3508e08bb301SSamuel Thibault##########################################
35094d3b6f6eSbalrog# curses probe
3510e08bb301SSamuel Thibaultif test "$iconv" = "no" ; then
3511e08bb301SSamuel Thibault  # curses will need iconv
3512e08bb301SSamuel Thibault  curses=no
3513e08bb301SSamuel Thibaultfi
3514a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3515e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
35168ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
35178ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3518e095e2f3SStefan Weil  else
35197c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
35208ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3521e095e2f3SStefan Weil  fi
3522c584a6d0SJuan Quintela  curses_found=no
35234d3b6f6eSbalrog  cat > $TMPC << EOF
35248ddc5bf9SSamuel Thibault#include <locale.h>
35254d3b6f6eSbalrog#include <curses.h>
35268ddc5bf9SSamuel Thibault#include <wchar.h>
35272f8b7cd5SSamuel Thibault#include <langinfo.h>
3528ef9a2524SStefan Weilint main(void) {
35292f8b7cd5SSamuel Thibault  const char *codeset;
35308ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
35318ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3532ef9a2524SStefan Weil  resize_term(0, 0);
35338ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
35348ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
35357c703002SSamuel Thibault  add_wch(WACS_DEGREE);
35362f8b7cd5SSamuel Thibault  codeset = nl_langinfo(CODESET);
35372f8b7cd5SSamuel Thibault  return codeset != 0;
3538ef9a2524SStefan Weil}
35394d3b6f6eSbalrogEOF
3540ecbe251fSVadim Evard  IFS=:
35418ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3542b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3543b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
35447c703002SSamuel Thibault    IFS=:
35458ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3546ecbe251fSVadim Evard      unset IFS
35478ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3548c584a6d0SJuan Quintela        curses_found=yes
35494f78ef9aSJuan Quintela        break
35504d3b6f6eSbalrog      fi
35514f78ef9aSJuan Quintela    done
35527c703002SSamuel Thibault    if test "$curses_found" = yes ; then
35537c703002SSamuel Thibault      break
35547c703002SSamuel Thibault    fi
35558ddc5bf9SSamuel Thibault  done
3556ecbe251fSVadim Evard  unset IFS
3557c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3558c584a6d0SJuan Quintela    curses=yes
3559c584a6d0SJuan Quintela  else
3560c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
356121684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3562c584a6d0SJuan Quintela    fi
3563c584a6d0SJuan Quintela    curses=no
3564c584a6d0SJuan Quintela  fi
35654f78ef9aSJuan Quintelafi
35664d3b6f6eSbalrog
3567414f0dabSblueswir1##########################################
3568769ce76dSAlexander Graf# curl probe
3569a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
357065d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3571a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
35724e2b0658SPaolo Bonzini  else
35734e2b0658SPaolo Bonzini    curlconfig=curl-config
35744e2b0658SPaolo Bonzini  fi
3575769ce76dSAlexander Graf  cat > $TMPC << EOF
3576769ce76dSAlexander Graf#include <curl/curl.h>
35770b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3578769ce76dSAlexander GrafEOF
357989138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
358089138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3581b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3582769ce76dSAlexander Graf    curl=yes
3583788c8196SJuan Quintela  else
3584788c8196SJuan Quintela    if test "$curl" = "yes" ; then
358521684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3586788c8196SJuan Quintela    fi
3587788c8196SJuan Quintela    curl=no
3588769ce76dSAlexander Graf  fi
3589769ce76dSAlexander Graffi # test "$curl"
3590769ce76dSAlexander Graf
3591769ce76dSAlexander Graf##########################################
3592fb599c9aSbalrog# bluez support probe
3593a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3594e820e3f4Sbalrog  cat > $TMPC << EOF
3595e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3596e820e3f4Sbalrogint main(void) { return bt_error(0); }
3597e820e3f4SbalrogEOF
359889138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
359989138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
360052166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3601a20a6f46SJuan Quintela    bluez=yes
3602e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3603e820e3f4Sbalrog  else
3604a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
360521684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3606a20a6f46SJuan Quintela    fi
3607e820e3f4Sbalrog    bluez="no"
3608e820e3f4Sbalrog  fi
3609fb599c9aSbalrogfi
3610fb599c9aSbalrog
3611fb599c9aSbalrog##########################################
3612e18df141SAnthony Liguori# glib support probe
3613a52d28afSPaolo Bonzini
361400f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3615aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3616aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3617a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3618aa0d1f44SPaolo Bonzinifi
3619e26110cfSFam Zheng
36204eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
36214eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
36224eaf7202SSameeh Jubran
3623e633a5c6SEric Blakeif test "$static" = yes && test "$mingw32" = yes; then
36244eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
36254eaf7202SSameeh Jubranfi
36264eaf7202SSameeh Jubran
3627aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3628e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
362989138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
363089138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
36314a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
363214015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3633957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3634e18df141SAnthony Liguori    else
3635e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3636e26110cfSFam Zheng    fi
3637e26110cfSFam Zhengdone
3638e26110cfSFam Zheng
3639f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3640f876b765SMarc-André Lureau    gio=yes
3641f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3642f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
3643f876b765SMarc-André Lureauelse
3644f876b765SMarc-André Lureau    gio=no
3645f876b765SMarc-André Lureaufi
3646f876b765SMarc-André Lureau
3647977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3648977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3649977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3650977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3651977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3652977a82abSDaniel P. Berrange#include <glib.h>
3653977a82abSDaniel P. Berrange#include <unistd.h>
3654977a82abSDaniel P. Berrange
3655977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3656977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3657977a82abSDaniel P. Berrange
3658977a82abSDaniel P. Berrangeint main(void) {
3659977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3660977a82abSDaniel P. Berrange   return 0;
3661977a82abSDaniel P. Berrange}
3662977a82abSDaniel P. BerrangeEOF
3663977a82abSDaniel P. Berrange
36645919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3665977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3666977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3667977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3668977a82abSDaniel P. Berrange	       "build target"
3669977a82abSDaniel P. Berrangefi
3670977a82abSDaniel P. Berrange
3671bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3672bbbf2e04SJohn Snowcat > $TMPC << EOF
3673bbbf2e04SJohn Snow#include <glib.h>
3674bbbf2e04SJohn Snowint main(void) { return 0; }
3675bbbf2e04SJohn SnowEOF
3676bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3677bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3678bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3679bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3680bbbf2e04SJohn Snow    fi
3681bbbf2e04SJohn Snowfi
3682bbbf2e04SJohn Snow
36836a1f42bdSStefan Weil#########################################
36846a1f42bdSStefan Weil# zlib check
36856a1f42bdSStefan Weil
36866a1f42bdSStefan Weilif test "$zlib" != "no" ; then
36876a1f42bdSStefan Weil    if $pkg_config --exists zlib; then
36886a1f42bdSStefan Weil        zlib_cflags=$($pkg_config --cflags zlib)
36896a1f42bdSStefan Weil        zlib_libs=$($pkg_config --libs zlib)
36906a1f42bdSStefan Weil        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
36916a1f42bdSStefan Weil        LIBS="$zlib_libs $LIBS"
36926a1f42bdSStefan Weil    else
36936a1f42bdSStefan Weil        cat > $TMPC << EOF
36946a1f42bdSStefan Weil#include <zlib.h>
36956a1f42bdSStefan Weilint main(void) { zlibVersion(); return 0; }
36966a1f42bdSStefan WeilEOF
36976a1f42bdSStefan Weil        if compile_prog "" "-lz" ; then
36986a1f42bdSStefan Weil            LIBS="$LIBS -lz"
36996a1f42bdSStefan Weil        else
37006a1f42bdSStefan Weil            error_exit "zlib check failed" \
37016a1f42bdSStefan Weil                "Make sure to have the zlib libs and headers installed."
37026a1f42bdSStefan Weil        fi
37036a1f42bdSStefan Weil    fi
37046a1f42bdSStefan Weilfi
37056a1f42bdSStefan Weil
3706e26110cfSFam Zheng##########################################
3707e26110cfSFam Zheng# SHA command probe for modules
3708e26110cfSFam Zhengif test "$modules" = yes; then
3709e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3710e26110cfSFam Zheng    for c in $shacmd_probe; do
37118ccefb91SFam Zheng        if has $c; then
3712e26110cfSFam Zheng            shacmd="$c"
3713e26110cfSFam Zheng            break
3714e26110cfSFam Zheng        fi
3715e26110cfSFam Zheng    done
3716e26110cfSFam Zheng    if test "$shacmd" = ""; then
3717e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3718e26110cfSFam Zheng    fi
3719e18df141SAnthony Liguorifi
3720e18df141SAnthony Liguori
3721e18df141SAnthony Liguori##########################################
3722e2134eb9SGerd Hoffmann# pixman support probe
3723e2134eb9SGerd Hoffmann
3724e633a5c6SEric Blakeif test "$want_tools" = "no" && test "$softmmu" = "no"; then
372574880fe2SRobert Schiele  pixman_cflags=
372674880fe2SRobert Schiele  pixman_libs=
372735c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
372889138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
372989138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3730e2134eb9SGerd Hoffmannelse
3731c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3732c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3733e2134eb9SGerd Hoffmannfi
3734e2134eb9SGerd Hoffmann
3735e2134eb9SGerd Hoffmann##########################################
3736fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3737fe8fc5aeSPaolo Bonzini
3738fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
37391b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3740fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3741fe8fc5aeSPaolo Bonzini#include <libudev.h>
3742fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3743fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3744fe8fc5aeSPaolo Bonziniint logsink;
3745b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3746b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3747b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3748b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3749b3f1c8c4SPaolo Bonzinistruct udev *udev;
3750b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3751b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3752b3f1c8c4SPaolo Bonzini
3753fe8fc5aeSPaolo Bonziniint main(void) {
3754b3f1c8c4SPaolo Bonzini    udev = udev_new();
3755b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3756fe8fc5aeSPaolo Bonzini    return 0;
3757fe8fc5aeSPaolo Bonzini}
3758fe8fc5aeSPaolo BonziniEOF
3759fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3760fe8fc5aeSPaolo Bonzini    mpathpersist=yes
37611b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
37621b0578f5SMurilo Opsfelder Araujo  else
37631b0578f5SMurilo Opsfelder Araujo    # probe for the old API
37641b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
37651b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
37661b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
37671b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
37681b0578f5SMurilo Opsfelder Araujoint logsink;
37691b0578f5SMurilo Opsfelder Araujoint main(void) {
37701b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
37711b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
37721b0578f5SMurilo Opsfelder Araujo    return 0;
37731b0578f5SMurilo Opsfelder Araujo}
37741b0578f5SMurilo Opsfelder AraujoEOF
37751b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
37761b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
37771b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3778fe8fc5aeSPaolo Bonzini    else
3779fe8fc5aeSPaolo Bonzini      mpathpersist=no
3780fe8fc5aeSPaolo Bonzini    fi
37811b0578f5SMurilo Opsfelder Araujo  fi
3782fe8fc5aeSPaolo Bonzinielse
3783fe8fc5aeSPaolo Bonzini  mpathpersist=no
3784fe8fc5aeSPaolo Bonzinifi
3785fe8fc5aeSPaolo Bonzini
3786fe8fc5aeSPaolo Bonzini##########################################
378717bff52bSM. Mohan Kumar# libcap probe
378817bff52bSM. Mohan Kumar
378917bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
379017bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
379117bff52bSM. Mohan Kumar#include <stdio.h>
379217bff52bSM. Mohan Kumar#include <sys/capability.h>
3793cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
379417bff52bSM. Mohan KumarEOF
379517bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
379617bff52bSM. Mohan Kumar    cap=yes
379717bff52bSM. Mohan Kumar  else
379817bff52bSM. Mohan Kumar    cap=no
379917bff52bSM. Mohan Kumar  fi
380017bff52bSM. Mohan Kumarfi
380117bff52bSM. Mohan Kumar
380217bff52bSM. Mohan Kumar##########################################
3803e5d355d1Saliguori# pthread probe
38044b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
38053c529d93Saliguori
3806e5d355d1Saliguoripthread=no
3807414f0dabSblueswir1cat > $TMPC << EOF
38083c529d93Saliguori#include <pthread.h>
38097a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
38107a42bbe4SStefan Weilint main(void) {
38117a42bbe4SStefan Weil  pthread_t thread;
38127a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
38137a42bbe4SStefan Weil  return 0;
38147a42bbe4SStefan Weil}
3815414f0dabSblueswir1EOF
3816bd00d539SAndreas Färberif compile_prog "" "" ; then
3817bd00d539SAndreas Färber  pthread=yes
3818bd00d539SAndreas Färberelse
3819de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
382052166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3821e5d355d1Saliguori      pthread=yes
3822e3c56761SPeter Portante      found=no
3823e3c56761SPeter Portante      for lib_entry in $LIBS; do
3824e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3825e3c56761SPeter Portante          found=yes
3826e3c56761SPeter Portante          break
3827e3c56761SPeter Portante        fi
3828e3c56761SPeter Portante      done
3829e3c56761SPeter Portante      if test "$found" = "no"; then
38305572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
383114ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3832e3c56761SPeter Portante      fi
3833409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3834de65fe0fSSebastian Herbszt      break
3835414f0dabSblueswir1    fi
3836de65fe0fSSebastian Herbszt  done
3837bd00d539SAndreas Färberfi
3838414f0dabSblueswir1
3839e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
384076ad07a4SPeter Maydell  error_exit "pthread check failed" \
384176ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3842e5d355d1Saliguorifi
3843e5d355d1Saliguori
3844479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3845479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
38465c312079SDr. David Alan Gilbertcat > $TMPC << EOF
38475c312079SDr. David Alan Gilbert#include <pthread.h>
38485c312079SDr. David Alan Gilbert
38495c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
38505c312079SDr. David Alan Gilbertint main(void)
38515c312079SDr. David Alan Gilbert{
38525c312079SDr. David Alan Gilbert    pthread_t thread;
38535c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
38545c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
38555c312079SDr. David Alan Gilbert    return 0;
38565c312079SDr. David Alan Gilbert}
38575c312079SDr. David Alan GilbertEOF
38585c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3859479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3860479a5747SRoman Bolshakovfi
3861479a5747SRoman Bolshakov
3862479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3863479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3864479a5747SRoman Bolshakovcat > $TMPC << EOF
3865479a5747SRoman Bolshakov#include <pthread.h>
3866479a5747SRoman Bolshakov
3867479a5747SRoman Bolshakovstatic void *f(void *p) { pthread_setname_np("QEMU"); }
3868479a5747SRoman Bolshakovint main(void)
3869479a5747SRoman Bolshakov{
3870479a5747SRoman Bolshakov    pthread_t thread;
3871479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3872479a5747SRoman Bolshakov    return 0;
3873479a5747SRoman Bolshakov}
3874479a5747SRoman BolshakovEOF
3875479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3876479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
38775c312079SDr. David Alan Gilbertfi
38785c312079SDr. David Alan Gilbert
3879bf9298b9Saliguori##########################################
3880f27aaf4bSChristian Brunner# rbd probe
3881f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3882f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3883f27aaf4bSChristian Brunner#include <stdio.h>
3884ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3885f27aaf4bSChristian Brunnerint main(void) {
3886ad32e9c0SJosh Durgin    rados_t cluster;
3887ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3888f27aaf4bSChristian Brunner    return 0;
3889f27aaf4bSChristian Brunner}
3890f27aaf4bSChristian BrunnerEOF
3891ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3892f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3893f27aaf4bSChristian Brunner    rbd=yes
3894f27aaf4bSChristian Brunner  else
3895f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
389621684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3897f27aaf4bSChristian Brunner    fi
3898f27aaf4bSChristian Brunner    rbd=no
3899f27aaf4bSChristian Brunner  fi
3900f27aaf4bSChristian Brunnerfi
3901f27aaf4bSChristian Brunner
3902f27aaf4bSChristian Brunner##########################################
3903b10d49d7SPino Toscano# libssh probe
3904b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3905b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
3906b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3907b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3908b10d49d7SPino Toscano    libssh=yes
39090a12ec87SRichard W.M. Jones  else
3910b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3911b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
39120a12ec87SRichard W.M. Jones    fi
3913b10d49d7SPino Toscano    libssh=no
39140a12ec87SRichard W.M. Jones  fi
39150a12ec87SRichard W.M. Jonesfi
39160a12ec87SRichard W.M. Jones
39170a12ec87SRichard W.M. Jones##########################################
3918b10d49d7SPino Toscano# Check for libssh 0.8
3919b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
3920b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
3921b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
3922b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
39239a2d462eSRichard W.M. Jones
3924b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
39259a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
3926b10d49d7SPino Toscano#include <libssh/libssh.h>
3927b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
39289a2d462eSRichard W.M. JonesEOF
3929b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
3930b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
39319a2d462eSRichard W.M. Jones  fi
39329a2d462eSRichard W.M. Jonesfi
39339a2d462eSRichard W.M. Jones
39349a2d462eSRichard W.M. Jones##########################################
39355c6c3a6cSChristoph Hellwig# linux-aio probe
39365c6c3a6cSChristoph Hellwig
39375c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
39385c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
39395c6c3a6cSChristoph Hellwig#include <libaio.h>
39405c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3941832ce9c2SScott Wood#include <stddef.h>
39425c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
39435c6c3a6cSChristoph HellwigEOF
39445c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
39455c6c3a6cSChristoph Hellwig    linux_aio=yes
39465c6c3a6cSChristoph Hellwig  else
39475c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
394821684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
39495c6c3a6cSChristoph Hellwig    fi
39503cfcae3cSLuiz Capitulino    linux_aio=no
39515c6c3a6cSChristoph Hellwig  fi
39525c6c3a6cSChristoph Hellwigfi
39535c6c3a6cSChristoph Hellwig
39545c6c3a6cSChristoph Hellwig##########################################
39557aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
39563b8acc11SPaolo Bonzini
39577aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
39587aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
39597aaa6a16SPaolo Bonzini    tpm=no
39603b8acc11SPaolo Bonzini  else
39617aaa6a16SPaolo Bonzini    tpm=yes
39627aaa6a16SPaolo Bonzini  fi
39637aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
39647aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
39657aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
39667aaa6a16SPaolo Bonzini  fi
39673b8acc11SPaolo Bonzinifi
39683b8acc11SPaolo Bonzini
39693b8acc11SPaolo Bonzini##########################################
3970758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3971758e8e38SVenkateswararao Jujjuri (JV)
3972758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3973758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3974758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3975758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3976f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3977f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3978f2338fb4SPavel Borzenkov#else
39794f26f2b6SAvi Kivity#include <sys/xattr.h>
3980f2338fb4SPavel Borzenkov#endif
3981758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3982758e8e38SVenkateswararao Jujjuri (JV)EOF
39834f26f2b6SAvi Kivity  if compile_prog "" "" ; then
39844f26f2b6SAvi Kivity    attr=yes
39854f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3986f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3987758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3988758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
39894f26f2b6SAvi Kivity    libattr=yes
3990758e8e38SVenkateswararao Jujjuri (JV)  else
3991758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
399221684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3993758e8e38SVenkateswararao Jujjuri (JV)    fi
3994758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3995758e8e38SVenkateswararao Jujjuri (JV)  fi
3996758e8e38SVenkateswararao Jujjuri (JV)fi
3997758e8e38SVenkateswararao Jujjuri (JV)
3998758e8e38SVenkateswararao Jujjuri (JV)##########################################
3999bf9298b9Saliguori# iovec probe
4000bf9298b9Saliguoricat > $TMPC <<EOF
4001db34f0b3Sblueswir1#include <sys/types.h>
4002bf9298b9Saliguori#include <sys/uio.h>
4003db34f0b3Sblueswir1#include <unistd.h>
4004f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
4005bf9298b9SaliguoriEOF
4006bf9298b9Saliguoriiovec=no
400752166aa0SJuan Quintelaif compile_prog "" "" ; then
4008bf9298b9Saliguori  iovec=yes
4009bf9298b9Saliguorifi
4010bf9298b9Saliguori
4011f652e6afSaurel32##########################################
4012ceb42de8Saliguori# preadv probe
4013ceb42de8Saliguoricat > $TMPC <<EOF
4014ceb42de8Saliguori#include <sys/types.h>
4015ceb42de8Saliguori#include <sys/uio.h>
4016ceb42de8Saliguori#include <unistd.h>
4017c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
4018ceb42de8SaliguoriEOF
4019ceb42de8Saliguoripreadv=no
402052166aa0SJuan Quintelaif compile_prog "" "" ; then
4021ceb42de8Saliguori  preadv=yes
4022ceb42de8Saliguorifi
4023ceb42de8Saliguori
4024ceb42de8Saliguori##########################################
4025f652e6afSaurel32# fdt probe
4026e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
4027e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
4028e169e1e1SPeter Maydellfdt_required=no
4029e169e1e1SPeter Maydellfor target in $target_list; do
4030e169e1e1SPeter Maydell  case $target in
4031a666409fSKONRAD Frederic    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
4032e169e1e1SPeter Maydell      fdt_required=yes
4033e169e1e1SPeter Maydell    ;;
4034e169e1e1SPeter Maydell  esac
4035e169e1e1SPeter Maydelldone
4036e169e1e1SPeter Maydell
4037e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
4038e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
4039e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
4040e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
4041e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
4042e169e1e1SPeter Maydell  fi
4043e169e1e1SPeter Maydell  fdt=yes
4044e169e1e1SPeter Maydellfi
4045e169e1e1SPeter Maydell
40462df87df7SJuan Quintelaif test "$fdt" != "no" ; then
4047b41af4baSJuan Quintela  fdt_libs="-lfdt"
404896ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
40496e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
4050f652e6afSaurel32  cat > $TMPC << EOF
405131ce0adbSThomas Huth#include <libfdt.h>
405296ce6545SPeter Crosthwaite#include <libfdt_env.h>
4053fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
4054f652e6afSaurel32EOF
405552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
4056a540f158SPeter Crosthwaite    # system DTC is good - use it
4057e3971d61SPhilippe Mathieu-Daudé    fdt=system
4058aef45d51SDaniel P. Berrange  else
4059aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
4060aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
4061aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
4062aef45d51SDaniel P. Berrange      fi
4063aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4064e3971d61SPhilippe Mathieu-Daudé          fdt=git
4065a540f158SPeter Crosthwaite          mkdir -p dtc
4066cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
4067a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
4068a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
40692df87df7SJuan Quintela          fi
4070a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
40718a99e9a3SPhilippe Mathieu-Daudé          fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
40728a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4073a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4074aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4075aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4076aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4077a540f158SPeter Crosthwaite      else
4078a540f158SPeter Crosthwaite          # don't have and don't want
4079de3a354aSMichael Walle          fdt_libs=
40802df87df7SJuan Quintela          fdt=no
4081f652e6afSaurel32      fi
4082f652e6afSaurel32  fi
4083aef45d51SDaniel P. Berrangefi
4084f652e6afSaurel32
4085a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
4086a540f158SPeter Crosthwaite
408720ff075bSMichael Walle##########################################
4088fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4089b1546f32SGerd Hoffmann
4090d52c454aSMarc-André Lureaugbm="no"
4091d52c454aSMarc-André Lureauif $pkg_config gbm; then
4092d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
4093d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
4094d52c454aSMarc-André Lureau    gbm="yes"
4095d52c454aSMarc-André Lureaufi
4096d52c454aSMarc-André Lureau
4097da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
40984939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
40995f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
41005f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
41015f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4102da076ffeSGerd Hoffmann    opengl=yes
4103925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4104925a0400SGerd Hoffmann        gtk_gl="yes"
4105925a0400SGerd Hoffmann    fi
4106cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
410720ff075bSMichael Walle  else
4108da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4109dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
411020ff075bSMichael Walle    fi
4111f676c67eSJeremy White    opengl_cflags=""
4112da076ffeSGerd Hoffmann    opengl_libs=""
4113da076ffeSGerd Hoffmann    opengl=no
411420ff075bSMichael Walle  fi
411520ff075bSMichael Wallefi
411620ff075bSMichael Walle
4117014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4118014cb152SGerd Hoffmann  cat > $TMPC << EOF
4119014cb152SGerd Hoffmann#include <epoxy/egl.h>
4120014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4121014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4122014cb152SGerd Hoffmann#endif
4123014cb152SGerd Hoffmannint main(void) { return 0; }
4124014cb152SGerd HoffmannEOF
4125014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4126014cb152SGerd Hoffmann    opengl_dmabuf=yes
4127014cb152SGerd Hoffmann  fi
4128014cb152SGerd Hoffmannfi
4129c9a12e75SChrysostomos Nanakos
4130e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
413199e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
413299e1a93bSPhilippe Mathieu-Daudé    case $target in
413399e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
413499e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
413599e1a93bSPhilippe Mathieu-Daudé      ;;
413699e1a93bSPhilippe Mathieu-Daudé    esac
413799e1a93bSPhilippe Mathieu-Daudé  done
413899e1a93bSPhilippe Mathieu-Daudéfi
413999e1a93bSPhilippe Mathieu-Daudé
4140ed279a06SKlim Kireev##########################################
4141ed279a06SKlim Kireev# libxml2 probe
4142ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4143ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4144ed279a06SKlim Kireev        libxml2="yes"
4145ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4146ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4147ed279a06SKlim Kireev    else
4148ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4149ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4150ed279a06SKlim Kireev        fi
4151ed279a06SKlim Kireev        libxml2="no"
4152ed279a06SKlim Kireev    fi
4153ed279a06SKlim Kireevfi
4154c9a12e75SChrysostomos Nanakos
4155eb100396SBharata B Rao##########################################
4156eb100396SBharata B Rao# glusterfs probe
4157eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
415865d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4159e01bee08SBharata B Rao    glusterfs="yes"
416089138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
416189138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4162d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4163d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4164d85fa9ebSJeff Cody    fi
416565d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
41660c14fb47SBharata B Rao      glusterfs_discard="yes"
41670c14fb47SBharata B Rao    fi
41687c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4169df3a429aSNiels de Vos      glusterfs_fallocate="yes"
41707c815372SBharata B Rao      glusterfs_zerofill="yes"
41717c815372SBharata B Rao    fi
4172e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
4173e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
4174e014dbe7SPrasanna Kumar Kalever
4175e014dbe7SPrasanna Kumar Kaleverint
4176e014dbe7SPrasanna Kumar Kalevermain(void)
4177e014dbe7SPrasanna Kumar Kalever{
4178e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
4179e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
4180e014dbe7SPrasanna Kumar Kalever}
4181e014dbe7SPrasanna Kumar KaleverEOF
4182e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4183e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
4184e014dbe7SPrasanna Kumar Kalever    fi
41850e3b891fSNiels de Vos    cat > $TMPC << EOF
41860e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
41870e3b891fSNiels de Vos
41880e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
41890e3b891fSNiels de Vosstatic void
41900e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
41910e3b891fSNiels de Vos{}
41920e3b891fSNiels de Vos
41930e3b891fSNiels de Vosint
41940e3b891fSNiels de Vosmain(void)
41950e3b891fSNiels de Vos{
41960e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
41970e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
41980e3b891fSNiels de Vos	return 0;
41990e3b891fSNiels de Vos}
42000e3b891fSNiels de VosEOF
42010e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
42020e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
42030e3b891fSNiels de Vos    fi
4204eb100396SBharata B Rao  else
4205eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
42068efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
42078efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4208eb100396SBharata B Rao    fi
4209e01bee08SBharata B Rao    glusterfs="no"
4210eb100396SBharata B Rao  fi
4211eb100396SBharata B Raofi
4212eb100396SBharata B Rao
421339386ac7Saurel32# Check for inotify functions when we are building linux-user
42143b3f24adSaurel32# emulator.  This is done because older glibc versions don't
42153b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
42163b3f24adSaurel32# don't provide them even if kernel supports them.
42173b3f24adSaurel32#
42183b3f24adSaurel32inotify=no
42193b3f24adSaurel32cat > $TMPC << EOF
42203b3f24adSaurel32#include <sys/inotify.h>
42213b3f24adSaurel32
42223b3f24adSaurel32int
42233b3f24adSaurel32main(void)
42243b3f24adSaurel32{
42253b3f24adSaurel32	/* try to start inotify */
42268690e420Saurel32	return inotify_init();
42273b3f24adSaurel32}
42283b3f24adSaurel32EOF
422952166aa0SJuan Quintelaif compile_prog "" "" ; then
42303b3f24adSaurel32  inotify=yes
42313b3f24adSaurel32fi
42323b3f24adSaurel32
4233c05c7a73SRiku Voipioinotify1=no
4234c05c7a73SRiku Voipiocat > $TMPC << EOF
4235c05c7a73SRiku Voipio#include <sys/inotify.h>
4236c05c7a73SRiku Voipio
4237c05c7a73SRiku Voipioint
4238c05c7a73SRiku Voipiomain(void)
4239c05c7a73SRiku Voipio{
4240c05c7a73SRiku Voipio    /* try to start inotify */
4241c05c7a73SRiku Voipio    return inotify_init1(0);
4242c05c7a73SRiku Voipio}
4243c05c7a73SRiku VoipioEOF
4244c05c7a73SRiku Voipioif compile_prog "" "" ; then
4245c05c7a73SRiku Voipio  inotify1=yes
4246c05c7a73SRiku Voipiofi
4247c05c7a73SRiku Voipio
4248099d6b0fSRiku Voipio# check if pipe2 is there
4249099d6b0fSRiku Voipiopipe2=no
4250099d6b0fSRiku Voipiocat > $TMPC << EOF
4251099d6b0fSRiku Voipio#include <unistd.h>
4252099d6b0fSRiku Voipio#include <fcntl.h>
4253099d6b0fSRiku Voipio
4254099d6b0fSRiku Voipioint main(void)
4255099d6b0fSRiku Voipio{
4256099d6b0fSRiku Voipio    int pipefd[2];
42579bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4258099d6b0fSRiku Voipio}
4259099d6b0fSRiku VoipioEOF
426052166aa0SJuan Quintelaif compile_prog "" "" ; then
4261099d6b0fSRiku Voipio  pipe2=yes
4262099d6b0fSRiku Voipiofi
4263099d6b0fSRiku Voipio
426440ff6d7eSKevin Wolf# check if accept4 is there
426540ff6d7eSKevin Wolfaccept4=no
426640ff6d7eSKevin Wolfcat > $TMPC << EOF
426740ff6d7eSKevin Wolf#include <sys/socket.h>
426840ff6d7eSKevin Wolf#include <stddef.h>
426940ff6d7eSKevin Wolf
427040ff6d7eSKevin Wolfint main(void)
427140ff6d7eSKevin Wolf{
427240ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
427340ff6d7eSKevin Wolf    return 0;
427440ff6d7eSKevin Wolf}
427540ff6d7eSKevin WolfEOF
427640ff6d7eSKevin Wolfif compile_prog "" "" ; then
427740ff6d7eSKevin Wolf  accept4=yes
427840ff6d7eSKevin Wolffi
427940ff6d7eSKevin Wolf
42803ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
42813ce34dfbSvibisreenivasansplice=no
42823ce34dfbSvibisreenivasancat > $TMPC << EOF
42833ce34dfbSvibisreenivasan#include <unistd.h>
42843ce34dfbSvibisreenivasan#include <fcntl.h>
42853ce34dfbSvibisreenivasan#include <limits.h>
42863ce34dfbSvibisreenivasan
42873ce34dfbSvibisreenivasanint main(void)
42883ce34dfbSvibisreenivasan{
428966ea0f22SStefan Weil    int len, fd = 0;
42903ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
42913ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
42923ce34dfbSvibisreenivasan    return 0;
42933ce34dfbSvibisreenivasan}
42943ce34dfbSvibisreenivasanEOF
429552166aa0SJuan Quintelaif compile_prog "" "" ; then
42963ce34dfbSvibisreenivasan  splice=yes
42973ce34dfbSvibisreenivasanfi
42983ce34dfbSvibisreenivasan
4299dcc38d1cSMarcelo Tosatti##########################################
4300a99d57bbSWanlong Gao# libnuma probe
4301a99d57bbSWanlong Gao
4302a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4303a99d57bbSWanlong Gao  cat > $TMPC << EOF
4304a99d57bbSWanlong Gao#include <numa.h>
4305a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4306a99d57bbSWanlong GaoEOF
4307a99d57bbSWanlong Gao
4308a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4309a99d57bbSWanlong Gao    numa=yes
4310a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4311a99d57bbSWanlong Gao  else
4312a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4313a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4314a99d57bbSWanlong Gao    fi
4315a99d57bbSWanlong Gao    numa=no
4316a99d57bbSWanlong Gao  fi
4317a99d57bbSWanlong Gaofi
4318a99d57bbSWanlong Gao
43197b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
43207b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
43217b01cb97SAlexandre Derumier    exit 1
43227b01cb97SAlexandre Derumierfi
43237b01cb97SAlexandre Derumier
43245a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
43255a22ab71SYang Zhong# do not support it.
43265a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
43275a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
43285a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
43295a22ab71SYang Zhong    fi
43305a22ab71SYang Zhong    malloc_trim="no"
43315a22ab71SYang Zhongfi
43325a22ab71SYang Zhong
43335a22ab71SYang Zhong#######################################
43345a22ab71SYang Zhong# malloc_trim
43355a22ab71SYang Zhong
43365a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
43375a22ab71SYang Zhong    cat > $TMPC << EOF
43385a22ab71SYang Zhong#include <malloc.h>
43395a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
43405a22ab71SYang ZhongEOF
43415a22ab71SYang Zhong    if compile_prog "" "" ; then
43425a22ab71SYang Zhong        malloc_trim="yes"
43435a22ab71SYang Zhong    else
43445a22ab71SYang Zhong        malloc_trim="no"
43455a22ab71SYang Zhong    fi
43465a22ab71SYang Zhongfi
43475a22ab71SYang Zhong
4348a99d57bbSWanlong Gao##########################################
43492847b469SFam Zheng# tcmalloc probe
43502847b469SFam Zheng
43512847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
43522847b469SFam Zheng  cat > $TMPC << EOF
43532847b469SFam Zheng#include <stdlib.h>
43542847b469SFam Zhengint main(void) { malloc(1); return 0; }
43552847b469SFam ZhengEOF
43562847b469SFam Zheng
43572847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
43582847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
43592847b469SFam Zheng  else
43602847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
43612847b469SFam Zheng  fi
43622847b469SFam Zhengfi
43632847b469SFam Zheng
43642847b469SFam Zheng##########################################
43657b01cb97SAlexandre Derumier# jemalloc probe
43667b01cb97SAlexandre Derumier
43677b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
43687b01cb97SAlexandre Derumier  cat > $TMPC << EOF
43697b01cb97SAlexandre Derumier#include <stdlib.h>
43707b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
43717b01cb97SAlexandre DerumierEOF
43727b01cb97SAlexandre Derumier
43737b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
43747b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
43757b01cb97SAlexandre Derumier  else
43767b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
43777b01cb97SAlexandre Derumier  fi
43787b01cb97SAlexandre Derumierfi
43797b01cb97SAlexandre Derumier
43807b01cb97SAlexandre Derumier##########################################
4381dcc38d1cSMarcelo Tosatti# signalfd probe
4382dcc38d1cSMarcelo Tosattisignalfd="no"
4383dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4384dcc38d1cSMarcelo Tosatti#include <unistd.h>
4385dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4386dcc38d1cSMarcelo Tosatti#include <signal.h>
4387dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4388dcc38d1cSMarcelo TosattiEOF
4389dcc38d1cSMarcelo Tosatti
4390dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4391dcc38d1cSMarcelo Tosatti  signalfd=yes
4392dcc38d1cSMarcelo Tosattifi
4393dcc38d1cSMarcelo Tosatti
4394d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4395d339d766SRichard W.M. Jonesoptreset="no"
4396d339d766SRichard W.M. Jonescat > $TMPC << EOF
4397d339d766SRichard W.M. Jones#include <getopt.h>
4398d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4399d339d766SRichard W.M. JonesEOF
4400d339d766SRichard W.M. Jones
4401d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4402d339d766SRichard W.M. Jones  optreset=yes
4403d339d766SRichard W.M. Jonesfi
4404d339d766SRichard W.M. Jones
4405c2882b96SRiku Voipio# check if eventfd is supported
4406c2882b96SRiku Voipioeventfd=no
4407c2882b96SRiku Voipiocat > $TMPC << EOF
4408c2882b96SRiku Voipio#include <sys/eventfd.h>
4409c2882b96SRiku Voipio
4410c2882b96SRiku Voipioint main(void)
4411c2882b96SRiku Voipio{
441255cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4413c2882b96SRiku Voipio}
4414c2882b96SRiku VoipioEOF
4415c2882b96SRiku Voipioif compile_prog "" "" ; then
4416c2882b96SRiku Voipio  eventfd=yes
4417c2882b96SRiku Voipiofi
4418c2882b96SRiku Voipio
4419751bcc39SMarc-André Lureau# check if memfd is supported
4420751bcc39SMarc-André Lureaumemfd=no
4421751bcc39SMarc-André Lureaucat > $TMPC << EOF
442275e5b70eSPaolo Bonzini#include <sys/mman.h>
4423751bcc39SMarc-André Lureau
4424751bcc39SMarc-André Lureauint main(void)
4425751bcc39SMarc-André Lureau{
4426751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4427751bcc39SMarc-André Lureau}
4428751bcc39SMarc-André LureauEOF
4429751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4430751bcc39SMarc-André Lureau  memfd=yes
4431751bcc39SMarc-André Lureaufi
4432751bcc39SMarc-André Lureau
4433955727d2SCortland Tölva# check for usbfs
4434955727d2SCortland Tölvahave_usbfs=no
4435955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
443696566d09SThomas Petazzoni  cat > $TMPC << EOF
443796566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
443896566d09SThomas Petazzoni
443996566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
444096566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
444196566d09SThomas Petazzoni#endif
444296566d09SThomas Petazzoni
444396566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
444496566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
444596566d09SThomas Petazzoni#endif
444696566d09SThomas Petazzoni
444796566d09SThomas Petazzoniint main(void)
444896566d09SThomas Petazzoni{
444996566d09SThomas Petazzoni    return 0;
445096566d09SThomas Petazzoni}
445196566d09SThomas PetazzoniEOF
445296566d09SThomas Petazzoni  if compile_prog "" ""; then
4453955727d2SCortland Tölva    have_usbfs=yes
4454955727d2SCortland Tölva  fi
4455955727d2SCortland Tölvafi
4456751bcc39SMarc-André Lureau
4457d0927938SUlrich Hecht# check for fallocate
4458d0927938SUlrich Hechtfallocate=no
4459d0927938SUlrich Hechtcat > $TMPC << EOF
4460d0927938SUlrich Hecht#include <fcntl.h>
4461d0927938SUlrich Hecht
4462d0927938SUlrich Hechtint main(void)
4463d0927938SUlrich Hecht{
4464d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4465d0927938SUlrich Hecht    return 0;
4466d0927938SUlrich Hecht}
4467d0927938SUlrich HechtEOF
44688fb03151SPeter Maydellif compile_prog "" "" ; then
4469d0927938SUlrich Hecht  fallocate=yes
4470d0927938SUlrich Hechtfi
4471d0927938SUlrich Hecht
44723d4fa43eSKusanagi Kouichi# check for fallocate hole punching
44733d4fa43eSKusanagi Kouichifallocate_punch_hole=no
44743d4fa43eSKusanagi Kouichicat > $TMPC << EOF
44753d4fa43eSKusanagi Kouichi#include <fcntl.h>
44763d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
44773d4fa43eSKusanagi Kouichi
44783d4fa43eSKusanagi Kouichiint main(void)
44793d4fa43eSKusanagi Kouichi{
44803d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
44813d4fa43eSKusanagi Kouichi    return 0;
44823d4fa43eSKusanagi Kouichi}
44833d4fa43eSKusanagi KouichiEOF
44843d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
44853d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
44863d4fa43eSKusanagi Kouichifi
44873d4fa43eSKusanagi Kouichi
4488b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4489b953f075SDenis V. Lunevfallocate_zero_range=no
4490b953f075SDenis V. Lunevcat > $TMPC << EOF
4491b953f075SDenis V. Lunev#include <fcntl.h>
4492b953f075SDenis V. Lunev#include <linux/falloc.h>
4493b953f075SDenis V. Lunev
4494b953f075SDenis V. Lunevint main(void)
4495b953f075SDenis V. Lunev{
4496b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4497b953f075SDenis V. Lunev    return 0;
4498b953f075SDenis V. Lunev}
4499b953f075SDenis V. LunevEOF
4500b953f075SDenis V. Lunevif compile_prog "" "" ; then
4501b953f075SDenis V. Lunev  fallocate_zero_range=yes
4502b953f075SDenis V. Lunevfi
4503b953f075SDenis V. Lunev
4504ed911435SKevin Wolf# check for posix_fallocate
4505ed911435SKevin Wolfposix_fallocate=no
4506ed911435SKevin Wolfcat > $TMPC << EOF
4507ed911435SKevin Wolf#include <fcntl.h>
4508ed911435SKevin Wolf
4509ed911435SKevin Wolfint main(void)
4510ed911435SKevin Wolf{
4511ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4512ed911435SKevin Wolf    return 0;
4513ed911435SKevin Wolf}
4514ed911435SKevin WolfEOF
4515ed911435SKevin Wolfif compile_prog "" "" ; then
4516ed911435SKevin Wolf    posix_fallocate=yes
4517ed911435SKevin Wolffi
4518ed911435SKevin Wolf
4519c727f47dSPeter Maydell# check for sync_file_range
4520c727f47dSPeter Maydellsync_file_range=no
4521c727f47dSPeter Maydellcat > $TMPC << EOF
4522c727f47dSPeter Maydell#include <fcntl.h>
4523c727f47dSPeter Maydell
4524c727f47dSPeter Maydellint main(void)
4525c727f47dSPeter Maydell{
4526c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4527c727f47dSPeter Maydell    return 0;
4528c727f47dSPeter Maydell}
4529c727f47dSPeter MaydellEOF
45308fb03151SPeter Maydellif compile_prog "" "" ; then
4531c727f47dSPeter Maydell  sync_file_range=yes
4532c727f47dSPeter Maydellfi
4533c727f47dSPeter Maydell
4534dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4535dace20dcSPeter Maydellfiemap=no
4536dace20dcSPeter Maydellcat > $TMPC << EOF
4537dace20dcSPeter Maydell#include <sys/ioctl.h>
4538dace20dcSPeter Maydell#include <linux/fs.h>
4539dace20dcSPeter Maydell#include <linux/fiemap.h>
4540dace20dcSPeter Maydell
4541dace20dcSPeter Maydellint main(void)
4542dace20dcSPeter Maydell{
4543dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4544dace20dcSPeter Maydell    return 0;
4545dace20dcSPeter Maydell}
4546dace20dcSPeter MaydellEOF
45478fb03151SPeter Maydellif compile_prog "" "" ; then
4548dace20dcSPeter Maydell  fiemap=yes
4549dace20dcSPeter Maydellfi
4550dace20dcSPeter Maydell
4551d0927938SUlrich Hecht# check for dup3
4552d0927938SUlrich Hechtdup3=no
4553d0927938SUlrich Hechtcat > $TMPC << EOF
4554d0927938SUlrich Hecht#include <unistd.h>
4555d0927938SUlrich Hecht
4556d0927938SUlrich Hechtint main(void)
4557d0927938SUlrich Hecht{
4558d0927938SUlrich Hecht    dup3(0, 0, 0);
4559d0927938SUlrich Hecht    return 0;
4560d0927938SUlrich Hecht}
4561d0927938SUlrich HechtEOF
456278f5d726SJan Kiszkaif compile_prog "" "" ; then
4563d0927938SUlrich Hecht  dup3=yes
4564d0927938SUlrich Hechtfi
4565d0927938SUlrich Hecht
45664e0c6529SAlex Bligh# check for ppoll support
45674e0c6529SAlex Blighppoll=no
45684e0c6529SAlex Blighcat > $TMPC << EOF
45694e0c6529SAlex Bligh#include <poll.h>
45704e0c6529SAlex Bligh
45714e0c6529SAlex Blighint main(void)
45724e0c6529SAlex Bligh{
45734e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
45744e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
45754e0c6529SAlex Bligh    return 0;
45764e0c6529SAlex Bligh}
45774e0c6529SAlex BlighEOF
45784e0c6529SAlex Blighif compile_prog "" "" ; then
45794e0c6529SAlex Bligh  ppoll=yes
45804e0c6529SAlex Blighfi
45814e0c6529SAlex Bligh
4582cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4583cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4584cd758dd0SAlex Blighcat > $TMPC << EOF
4585cd758dd0SAlex Bligh#include <sys/prctl.h>
4586cd758dd0SAlex Bligh
4587cd758dd0SAlex Blighint main(void)
4588cd758dd0SAlex Bligh{
4589cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4590cd758dd0SAlex Bligh    return 0;
4591cd758dd0SAlex Bligh}
4592cd758dd0SAlex BlighEOF
4593cd758dd0SAlex Blighif compile_prog "" "" ; then
4594cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4595cd758dd0SAlex Blighfi
4596cd758dd0SAlex Bligh
45973b6edd16SPeter Maydell# check for epoll support
45983b6edd16SPeter Maydellepoll=no
45993b6edd16SPeter Maydellcat > $TMPC << EOF
46003b6edd16SPeter Maydell#include <sys/epoll.h>
46013b6edd16SPeter Maydell
46023b6edd16SPeter Maydellint main(void)
46033b6edd16SPeter Maydell{
46043b6edd16SPeter Maydell    epoll_create(0);
46053b6edd16SPeter Maydell    return 0;
46063b6edd16SPeter Maydell}
46073b6edd16SPeter MaydellEOF
46088fb03151SPeter Maydellif compile_prog "" "" ; then
46093b6edd16SPeter Maydell  epoll=yes
46103b6edd16SPeter Maydellfi
46113b6edd16SPeter Maydell
4612227f0214SPeter Maydell# epoll_create1 is a later addition
4613227f0214SPeter Maydell# so we must check separately for its presence
46143b6edd16SPeter Maydellepoll_create1=no
46153b6edd16SPeter Maydellcat > $TMPC << EOF
46163b6edd16SPeter Maydell#include <sys/epoll.h>
46173b6edd16SPeter Maydell
46183b6edd16SPeter Maydellint main(void)
46193b6edd16SPeter Maydell{
462019e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
462119e83f6bSPeter Maydell     * a function being called. This is necessary so that on
462219e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
462319e83f6bSPeter Maydell     * the library but not declared in the header file we will
462419e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
462519e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
462619e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
462719e83f6bSPeter Maydell     */
4628c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
46293b6edd16SPeter Maydell}
46303b6edd16SPeter MaydellEOF
46318fb03151SPeter Maydellif compile_prog "" "" ; then
46323b6edd16SPeter Maydell  epoll_create1=yes
46333b6edd16SPeter Maydellfi
46343b6edd16SPeter Maydell
4635a8fd1abaSPeter Maydell# check for sendfile support
4636a8fd1abaSPeter Maydellsendfile=no
4637a8fd1abaSPeter Maydellcat > $TMPC << EOF
4638a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4639a8fd1abaSPeter Maydell
4640a8fd1abaSPeter Maydellint main(void)
4641a8fd1abaSPeter Maydell{
4642a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4643a8fd1abaSPeter Maydell}
4644a8fd1abaSPeter MaydellEOF
4645a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4646a8fd1abaSPeter Maydell  sendfile=yes
4647a8fd1abaSPeter Maydellfi
4648a8fd1abaSPeter Maydell
464951834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
465051834341SRiku Voipiotimerfd=no
465151834341SRiku Voipiocat > $TMPC << EOF
465251834341SRiku Voipio#include <sys/timerfd.h>
465351834341SRiku Voipio
465451834341SRiku Voipioint main(void)
465551834341SRiku Voipio{
465651834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
465751834341SRiku Voipio}
465851834341SRiku VoipioEOF
465951834341SRiku Voipioif compile_prog "" "" ; then
466051834341SRiku Voipio  timerfd=yes
466151834341SRiku Voipiofi
466251834341SRiku Voipio
46639af5c906SRiku Voipio# check for setns and unshare support
46649af5c906SRiku Voipiosetns=no
46659af5c906SRiku Voipiocat > $TMPC << EOF
46669af5c906SRiku Voipio#include <sched.h>
46679af5c906SRiku Voipio
46689af5c906SRiku Voipioint main(void)
46699af5c906SRiku Voipio{
46709af5c906SRiku Voipio    int ret;
46719af5c906SRiku Voipio    ret = setns(0, 0);
46729af5c906SRiku Voipio    ret = unshare(0);
46739af5c906SRiku Voipio    return ret;
46749af5c906SRiku Voipio}
46759af5c906SRiku VoipioEOF
46769af5c906SRiku Voipioif compile_prog "" "" ; then
46779af5c906SRiku Voipio  setns=yes
46789af5c906SRiku Voipiofi
46799af5c906SRiku Voipio
468038860a03SAleksandar Markovic# clock_adjtime probe
468138860a03SAleksandar Markovicclock_adjtime=no
468238860a03SAleksandar Markoviccat > $TMPC <<EOF
468338860a03SAleksandar Markovic#include <time.h>
468438860a03SAleksandar Markovic
468538860a03SAleksandar Markovicint main(void)
468638860a03SAleksandar Markovic{
468738860a03SAleksandar Markovic    return clock_adjtime(0, 0);
468838860a03SAleksandar Markovic}
468938860a03SAleksandar MarkovicEOF
469038860a03SAleksandar Markovicclock_adjtime=no
469138860a03SAleksandar Markovicif compile_prog "" "" ; then
469238860a03SAleksandar Markovic  clock_adjtime=yes
469338860a03SAleksandar Markovicfi
469438860a03SAleksandar Markovic
46955a03cd00SAleksandar Markovic# syncfs probe
46965a03cd00SAleksandar Markovicsyncfs=no
46975a03cd00SAleksandar Markoviccat > $TMPC <<EOF
46985a03cd00SAleksandar Markovic#include <unistd.h>
46995a03cd00SAleksandar Markovic
47005a03cd00SAleksandar Markovicint main(void)
47015a03cd00SAleksandar Markovic{
47025a03cd00SAleksandar Markovic    return syncfs(0);
47035a03cd00SAleksandar Markovic}
47045a03cd00SAleksandar MarkovicEOF
47055a03cd00SAleksandar Markovicsyncfs=no
47065a03cd00SAleksandar Markovicif compile_prog "" "" ; then
47075a03cd00SAleksandar Markovic  syncfs=yes
47085a03cd00SAleksandar Markovicfi
47095a03cd00SAleksandar Markovic
47105f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
47115f71eac0SPeter Maydellhas_sphinx_build() {
47125f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
47135f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
47145f71eac0SPeter Maydell    # version requirement). This will fail if either
47155f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
47165f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
47175f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
47185f71eac0SPeter Maydell    sphinx-build -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
47195f71eac0SPeter Maydell}
47205f71eac0SPeter Maydell
4721cc8ae6deSpbrook# Check if tools are available to build documentation.
4722a25dba17SJuan Quintelaif test "$docs" != "no" ; then
47235f71eac0SPeter Maydell  if has makeinfo && has pod2man && has_sphinx_build; then
4724a25dba17SJuan Quintela    docs=yes
472583a3ab8bSJuan Quintela  else
4726a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
47275f71eac0SPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
472883a3ab8bSJuan Quintela    fi
4729a25dba17SJuan Quintela    docs=no
473083a3ab8bSJuan Quintela  fi
4731cc8ae6deSpbrookfi
4732cc8ae6deSpbrook
4733f514f41cSStefan Weil# Search for bswap_32 function
47346ae9a1f4SJuan Quintelabyteswap_h=no
47356ae9a1f4SJuan Quintelacat > $TMPC << EOF
47366ae9a1f4SJuan Quintela#include <byteswap.h>
47376ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
47386ae9a1f4SJuan QuintelaEOF
473952166aa0SJuan Quintelaif compile_prog "" "" ; then
47406ae9a1f4SJuan Quintela  byteswap_h=yes
47416ae9a1f4SJuan Quintelafi
47426ae9a1f4SJuan Quintela
474375f13596SStefan Weil# Search for bswap32 function
47446ae9a1f4SJuan Quintelabswap_h=no
47456ae9a1f4SJuan Quintelacat > $TMPC << EOF
47466ae9a1f4SJuan Quintela#include <sys/endian.h>
47476ae9a1f4SJuan Quintela#include <sys/types.h>
47486ae9a1f4SJuan Quintela#include <machine/bswap.h>
47496ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
47506ae9a1f4SJuan QuintelaEOF
475152166aa0SJuan Quintelaif compile_prog "" "" ; then
47526ae9a1f4SJuan Quintela  bswap_h=yes
47536ae9a1f4SJuan Quintelafi
47546ae9a1f4SJuan Quintela
4755da93a1fdSaliguori##########################################
4756e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4757c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4758e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
47593c33ea96SPaolo Bonzini    libiscsi="yes"
4760ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4761ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4762c589b249SRonnie Sahlberg  else
4763c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4764e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4765c589b249SRonnie Sahlberg    fi
4766c589b249SRonnie Sahlberg    libiscsi="no"
4767c589b249SRonnie Sahlberg  fi
4768c589b249SRonnie Sahlbergfi
4769c589b249SRonnie Sahlberg
4770c589b249SRonnie Sahlberg##########################################
47718bacde8dSNatanael Copa# Do we need libm
47728bacde8dSNatanael Copacat > $TMPC << EOF
47738bacde8dSNatanael Copa#include <math.h>
4774f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
47758bacde8dSNatanael CopaEOF
47768bacde8dSNatanael Copaif compile_prog "" "" ; then
47778bacde8dSNatanael Copa  :
47788bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
47798bacde8dSNatanael Copa  LIBS="-lm $LIBS"
47808bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
47818bacde8dSNatanael Copaelse
478276ad07a4SPeter Maydell  error_exit "libm check failed"
47838bacde8dSNatanael Copafi
47848bacde8dSNatanael Copa
47858bacde8dSNatanael Copa##########################################
4786da93a1fdSaliguori# Do we need librt
47878bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
47888bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
47898bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
47908bacde8dSNatanael Copa# function in addition.
4791da93a1fdSaliguoricat > $TMPC <<EOF
4792da93a1fdSaliguori#include <signal.h>
4793da93a1fdSaliguori#include <time.h>
47948bacde8dSNatanael Copaint main(void) {
47958bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
47968bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
47978bacde8dSNatanael Copa}
4798da93a1fdSaliguoriEOF
4799da93a1fdSaliguori
480052166aa0SJuan Quintelaif compile_prog "" "" ; then
480107ffa4bdSJuan Quintela  :
48028bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
480318e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
480418e588b1SRick Liu  LIBS="$LIBS -lrt"
480518e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4806da93a1fdSaliguorifi
4807da93a1fdSaliguori
4808d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
4809d99e97e6SThomas Huthcat > $TMPC << EOF
4810d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4811d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4812d99e97e6SThomas HuthEOF
4813d99e97e6SThomas Huth
4814d99e97e6SThomas Huthif ! compile_prog "" "" ; then
4815d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
48166362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
4817d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
4818d99e97e6SThomas Huth  fi
48196362a53fSJuan Quintelafi
48206362a53fSJuan Quintela
4821de5071c5SBlue Swirl##########################################
4822cd4ec0b4SGerd Hoffmann# spice probe
4823cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4824cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4825cd4ec0b4SGerd Hoffmann#include <spice.h>
4826cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4827cd4ec0b4SGerd HoffmannEOF
4828710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4829710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
48301b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
483165d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4832cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4833cd4ec0b4SGerd Hoffmann    spice="yes"
4834cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4835cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
48362e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
48372e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4838cd4ec0b4SGerd Hoffmann  else
4839cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
48408efc9363SHu Tao      feature_not_found "spice" \
48411b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4842cd4ec0b4SGerd Hoffmann    fi
4843cd4ec0b4SGerd Hoffmann    spice="no"
4844cd4ec0b4SGerd Hoffmann  fi
4845cd4ec0b4SGerd Hoffmannfi
4846cd4ec0b4SGerd Hoffmann
48477b02f544SMarc-André Lureau# check for smartcard support
48487b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
48490f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
48507b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
48517b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
48527b02f544SMarc-André Lureau        smartcard="yes"
4853111a38b0SRobert Relyea    else
48547b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
48557b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4856111a38b0SRobert Relyea        fi
48577b02f544SMarc-André Lureau        smartcard="no"
4858111a38b0SRobert Relyea    fi
4859111a38b0SRobert Relyeafi
4860111a38b0SRobert Relyea
48612b2325ffSGerd Hoffmann# check for libusb
48622b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
486365d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
48642b2325ffSGerd Hoffmann        libusb="yes"
4865ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4866ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
48672b2325ffSGerd Hoffmann    else
48682b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
48698efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
48702b2325ffSGerd Hoffmann        fi
48712b2325ffSGerd Hoffmann        libusb="no"
48722b2325ffSGerd Hoffmann    fi
48732b2325ffSGerd Hoffmannfi
48742b2325ffSGerd Hoffmann
487569354a83SHans de Goede# check for usbredirparser for usb network redirection support
487669354a83SHans de Goedeif test "$usb_redir" != "no" ; then
487765d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
487869354a83SHans de Goede        usb_redir="yes"
4879ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4880ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
488169354a83SHans de Goede    else
488269354a83SHans de Goede        if test "$usb_redir" = "yes"; then
488321684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
488469354a83SHans de Goede        fi
488569354a83SHans de Goede        usb_redir="no"
488669354a83SHans de Goede    fi
488769354a83SHans de Goedefi
488869354a83SHans de Goede
4889cd4ec0b4SGerd Hoffmann##########################################
4890d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4891d9840e25STomoki Sekiyama
4892e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4893e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
4894d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4895690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4896d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4897d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4898690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4899d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4900d9840e25STomoki Sekiyama	  ;;
4901690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4902d9840e25STomoki Sekiyama  esac
4903d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4904d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4905d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4906d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4907d9840e25STomoki SekiyamaEOF
4908d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4909d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4910d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4911315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4912f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4913d9840e25STomoki Sekiyama  else
4914d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4915d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4916d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4917d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4918d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4919d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4920d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4921d9840e25STomoki Sekiyama    fi
4922d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4923d9840e25STomoki Sekiyama  fi
4924d9840e25STomoki Sekiyamafi
4925d9840e25STomoki Sekiyama
4926d9840e25STomoki Sekiyama##########################################
4927d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4928d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4929d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4930d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4931d9840e25STomoki Sekiyama
4932e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4933e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4934d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4935d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4936d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4937d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4938d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4939d9840e25STomoki Sekiyama    else
4940d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4941d9840e25STomoki Sekiyama    fi
4942d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4943d9840e25STomoki Sekiyama    win_sdk=""
4944d9840e25STomoki Sekiyama  fi
4945d9840e25STomoki Sekiyamafi
4946d9840e25STomoki Sekiyama
4947d9840e25STomoki Sekiyama##########################################
494850cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4949e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
495050cbebb9SMichael Roth  cat > $TMPC << EOF
495150cbebb9SMichael Roth#include <windows.h>
495250cbebb9SMichael Roth#include <ntddscsi.h>
495350cbebb9SMichael Rothint main(void) {
495450cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
495550cbebb9SMichael Roth#error Missing required ioctl definitions
495650cbebb9SMichael Roth#endif
495750cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
495850cbebb9SMichael Roth  return addr.Lun;
495950cbebb9SMichael Roth}
496050cbebb9SMichael RothEOF
496150cbebb9SMichael Roth  if compile_prog "" "" ; then
496250cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4963996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
496450cbebb9SMichael Roth  fi
496550cbebb9SMichael Rothfi
496650cbebb9SMichael Roth
496750cbebb9SMichael Roth##########################################
49689d9e1521SGerd Hoffmann# virgl renderer probe
49699d9e1521SGerd Hoffmann
49709d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
49719d9e1521SGerd Hoffmann  cat > $TMPC << EOF
49729d9e1521SGerd Hoffmann#include <virglrenderer.h>
49739d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
49749d9e1521SGerd HoffmannEOF
49759d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
49769d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
497747479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
49789d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
49799d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
49809d9e1521SGerd Hoffmann    virglrenderer="yes"
49819d9e1521SGerd Hoffmann  else
49829d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
49839d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
49849d9e1521SGerd Hoffmann    fi
49859d9e1521SGerd Hoffmann    virglrenderer="no"
49869d9e1521SGerd Hoffmann  fi
49879d9e1521SGerd Hoffmannfi
49889d9e1521SGerd Hoffmann
49899d9e1521SGerd Hoffmann##########################################
49908ca80760SRichard Henderson# capstone
49918ca80760SRichard Henderson
4992e219c499SRichard Hendersoncase "$capstone" in
4993e219c499SRichard Henderson  "" | yes)
49948ca80760SRichard Henderson    if $pkg_config capstone; then
4995e219c499SRichard Henderson      capstone=system
4996e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
4997e219c499SRichard Henderson      capstone=git
4998e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4999e219c499SRichard Henderson      capstone=internal
5000e219c499SRichard Henderson    elif test -z "$capstone" ; then
5001e219c499SRichard Henderson      capstone=no
5002e219c499SRichard Henderson    else
5003e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
5004e219c499SRichard Henderson    fi
5005e219c499SRichard Henderson    ;;
5006e219c499SRichard Henderson
5007e219c499SRichard Henderson  system)
5008e219c499SRichard Henderson    if ! $pkg_config capstone; then
5009e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
5010e219c499SRichard Henderson    fi
5011e219c499SRichard Henderson    ;;
5012e219c499SRichard Hendersonesac
5013e219c499SRichard Henderson
5014e219c499SRichard Hendersoncase "$capstone" in
5015e219c499SRichard Henderson  git | internal)
5016e219c499SRichard Henderson    if test "$capstone" = git; then
5017e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
5018e219c499SRichard Henderson    fi
5019e219c499SRichard Henderson    mkdir -p capstone
5020e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
5021e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
5022e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
5023e219c499SRichard Henderson    else
5024e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
5025e219c499SRichard Henderson    fi
502602f9135bSDaniel P. Berrangé    libs_cpu="-L\$(BUILD_DIR)/capstone -lcapstone $libs_cpu"
5027e219c499SRichard Henderson    ;;
5028e219c499SRichard Henderson
5029e219c499SRichard Henderson  system)
50308ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
503102f9135bSDaniel P. Berrangé    libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
5032e219c499SRichard Henderson    ;;
5033e219c499SRichard Henderson
5034e219c499SRichard Henderson  no)
5035e219c499SRichard Henderson    ;;
5036e219c499SRichard Henderson  *)
5037e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
5038e219c499SRichard Henderson    ;;
5039e219c499SRichard Hendersonesac
50408ca80760SRichard Henderson
50418ca80760SRichard Henderson##########################################
50425f6b9e8fSBlue Swirl# check if we have fdatasync
50435f6b9e8fSBlue Swirl
50445f6b9e8fSBlue Swirlfdatasync=no
50455f6b9e8fSBlue Swirlcat > $TMPC << EOF
50465f6b9e8fSBlue Swirl#include <unistd.h>
5047d1722a27SAlexandre Raymondint main(void) {
5048d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5049d1722a27SAlexandre Raymondreturn fdatasync(0);
5050d1722a27SAlexandre Raymond#else
5051e172fe11SStefan Weil#error Not supported
5052d1722a27SAlexandre Raymond#endif
5053d1722a27SAlexandre Raymond}
50545f6b9e8fSBlue SwirlEOF
50555f6b9e8fSBlue Swirlif compile_prog "" "" ; then
50565f6b9e8fSBlue Swirl    fdatasync=yes
50575f6b9e8fSBlue Swirlfi
50585f6b9e8fSBlue Swirl
505994a420b1SStefan Hajnoczi##########################################
5060e78815a5SAndreas Färber# check if we have madvise
5061e78815a5SAndreas Färber
5062e78815a5SAndreas Färbermadvise=no
5063e78815a5SAndreas Färbercat > $TMPC << EOF
5064e78815a5SAndreas Färber#include <sys/types.h>
5065e78815a5SAndreas Färber#include <sys/mman.h>
5066832ce9c2SScott Wood#include <stddef.h>
5067e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5068e78815a5SAndreas FärberEOF
5069e78815a5SAndreas Färberif compile_prog "" "" ; then
5070e78815a5SAndreas Färber    madvise=yes
5071e78815a5SAndreas Färberfi
5072e78815a5SAndreas Färber
5073e78815a5SAndreas Färber##########################################
5074e78815a5SAndreas Färber# check if we have posix_madvise
5075e78815a5SAndreas Färber
5076e78815a5SAndreas Färberposix_madvise=no
5077e78815a5SAndreas Färbercat > $TMPC << EOF
5078e78815a5SAndreas Färber#include <sys/mman.h>
5079832ce9c2SScott Wood#include <stddef.h>
5080e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5081e78815a5SAndreas FärberEOF
5082e78815a5SAndreas Färberif compile_prog "" "" ; then
5083e78815a5SAndreas Färber    posix_madvise=yes
5084e78815a5SAndreas Färberfi
5085e78815a5SAndreas Färber
5086e78815a5SAndreas Färber##########################################
50879bc5a719SAndreas Gustafsson# check if we have posix_memalign()
50889bc5a719SAndreas Gustafsson
50899bc5a719SAndreas Gustafssonposix_memalign=no
50909bc5a719SAndreas Gustafssoncat > $TMPC << EOF
50919bc5a719SAndreas Gustafsson#include <stdlib.h>
50929bc5a719SAndreas Gustafssonint main(void) {
50939bc5a719SAndreas Gustafsson    void *p;
50949bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
50959bc5a719SAndreas Gustafsson}
50969bc5a719SAndreas GustafssonEOF
50979bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
50989bc5a719SAndreas Gustafsson    posix_memalign=yes
50999bc5a719SAndreas Gustafssonfi
51009bc5a719SAndreas Gustafsson
51019bc5a719SAndreas Gustafsson##########################################
51020a852417SPaul Durrant# check if we have posix_syslog
51030a852417SPaul Durrant
51040a852417SPaul Durrantposix_syslog=no
51050a852417SPaul Durrantcat > $TMPC << EOF
51060a852417SPaul Durrant#include <syslog.h>
51070a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
51080a852417SPaul DurrantEOF
51090a852417SPaul Durrantif compile_prog "" "" ; then
51100a852417SPaul Durrant    posix_syslog=yes
51110a852417SPaul Durrantfi
51120a852417SPaul Durrant
51130a852417SPaul Durrant##########################################
5114401bc051SPeter Maydell# check if we have sem_timedwait
5115401bc051SPeter Maydell
5116401bc051SPeter Maydellsem_timedwait=no
5117401bc051SPeter Maydellcat > $TMPC << EOF
5118401bc051SPeter Maydell#include <semaphore.h>
5119811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5120401bc051SPeter MaydellEOF
5121401bc051SPeter Maydellif compile_prog "" "" ; then
5122401bc051SPeter Maydell    sem_timedwait=yes
5123401bc051SPeter Maydellfi
5124401bc051SPeter Maydell
5125401bc051SPeter Maydell##########################################
51265c99fa37SKeno Fischer# check if we have strchrnul
51275c99fa37SKeno Fischer
51285c99fa37SKeno Fischerstrchrnul=no
51295c99fa37SKeno Fischercat > $TMPC << EOF
51305c99fa37SKeno Fischer#include <string.h>
51315c99fa37SKeno Fischerint main(void);
51325c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
51335c99fa37SKeno Fischerchar *haystack = (char*)&main;
51345c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
51355c99fa37SKeno FischerEOF
51365c99fa37SKeno Fischerif compile_prog "" "" ; then
51375c99fa37SKeno Fischer    strchrnul=yes
51385c99fa37SKeno Fischerfi
51395c99fa37SKeno Fischer
51405c99fa37SKeno Fischer##########################################
514194a420b1SStefan Hajnoczi# check if trace backend exists
514294a420b1SStefan Hajnoczi
51435b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
514494a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
51455b808275SLluís Vilanova  error_exit "invalid trace backends" \
51465b808275SLluís Vilanova      "Please choose supported trace backends."
514794a420b1SStefan Hajnoczifi
514894a420b1SStefan Hajnoczi
51497e24e92aSStefan Hajnoczi##########################################
51507e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
51515b808275SLluís Vilanovaif have_backend "ust"; then
51527e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5153bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
51547e24e92aSStefan Hajnocziint main(void) { return 0; }
51557e24e92aSStefan HajnocziEOF
5156c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5157bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
515889138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
51597e24e92aSStefan Hajnoczi    else
5160c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5161bf15f63cSMohamad Gebai    fi
5162bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
516389138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5164bf15f63cSMohamad Gebai    else
5165bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5166bf15f63cSMohamad Gebai    fi
5167bf15f63cSMohamad Gebai
5168bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5169bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5170bf15f63cSMohamad Gebai  else
5171bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
51727e24e92aSStefan Hajnoczi  fi
51737e24e92aSStefan Hajnoczifi
5174b3d08c02SDaniel P. Berrange
5175b3d08c02SDaniel P. Berrange##########################################
5176b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
51775b808275SLluís Vilanovaif have_backend "dtrace"; then
5178b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
517976ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5180b3d08c02SDaniel P. Berrange  fi
5181c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5182c276b17dSDaniel P. Berrange  if has 'stap' ; then
5183c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5184c276b17dSDaniel P. Berrange  fi
5185b3d08c02SDaniel P. Berrangefi
5186b3d08c02SDaniel P. Berrange
51877e24e92aSStefan Hajnoczi##########################################
5188519175a2SAlex Barcelo# check and set a backend for coroutine
5189d0e2fce5SAneesh Kumar K.V
51907c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
519133c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
519233c53c54SDaniel P. Berrange# specific one.
51937c2acc70SPeter Maydell
51947c2acc70SPeter Maydellucontext_works=no
5195d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5196d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5197d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5198cdf84806SPeter Maydell#ifdef __stub_makecontext
5199cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5200cdf84806SPeter Maydell#endif
520175cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5202d0e2fce5SAneesh Kumar K.VEOF
5203d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
52047c2acc70SPeter Maydell    ucontext_works=yes
5205d0e2fce5SAneesh Kumar K.V  fi
5206519175a2SAlex Barcelofi
52077c2acc70SPeter Maydell
52087c2acc70SPeter Maydellif test "$coroutine" = ""; then
52097c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
52107c2acc70SPeter Maydell    coroutine=win32
52117c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
52127c2acc70SPeter Maydell    coroutine=ucontext
5213519175a2SAlex Barcelo  else
52147c2acc70SPeter Maydell    coroutine=sigaltstack
52157c2acc70SPeter Maydell  fi
52167c2acc70SPeter Maydellelse
52177c2acc70SPeter Maydell  case $coroutine in
52187c2acc70SPeter Maydell  windows)
52197c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
52207c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
52217c2acc70SPeter Maydell    fi
52227c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
52237c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
52247c2acc70SPeter Maydell    coroutine=win32
52257c2acc70SPeter Maydell    ;;
52267c2acc70SPeter Maydell  ucontext)
52277c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
52287c2acc70SPeter Maydell      feature_not_found "ucontext"
52297c2acc70SPeter Maydell    fi
52307c2acc70SPeter Maydell    ;;
523133c53c54SDaniel P. Berrange  sigaltstack)
52327c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
52337c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
52347c2acc70SPeter Maydell    fi
52357c2acc70SPeter Maydell    ;;
52367c2acc70SPeter Maydell  *)
523776ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
52387c2acc70SPeter Maydell    ;;
52397c2acc70SPeter Maydell  esac
5240d0e2fce5SAneesh Kumar K.Vfi
5241d0e2fce5SAneesh Kumar K.V
524270c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
524370c60c08SStefan Hajnoczi  coroutine_pool=yes
524470c60c08SStefan Hajnoczifi
524570c60c08SStefan Hajnoczi
52467d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
52477d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
52487d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
52497d992e4dSPeter Lieven    coroutine_pool=no
52507d992e4dSPeter Lieven  fi
52517d992e4dSPeter Lievenfi
52527d992e4dSPeter Lieven
52537d992e4dSPeter Lieven
5254d0e2fce5SAneesh Kumar K.V##########################################
5255d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5256d2042378SAneesh Kumar K.V
52574e1797f9SStefan Weilopen_by_handle_at=no
5258d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5259d2042378SAneesh Kumar K.V#include <fcntl.h>
5260acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5261acc55ba8SStefan Weil# error missing definition
5262acc55ba8SStefan Weil#else
526375cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5264acc55ba8SStefan Weil#endif
5265d2042378SAneesh Kumar K.VEOF
5266d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5267d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5268d2042378SAneesh Kumar K.Vfi
5269d2042378SAneesh Kumar K.V
5270e06a765eSHarsh Prateek Bora########################################
5271e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5272e06a765eSHarsh Prateek Bora
5273e06a765eSHarsh Prateek Boralinux_magic_h=no
5274e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5275e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5276e06a765eSHarsh Prateek Boraint main(void) {
527775cafad7SStefan Weil  return 0;
5278e06a765eSHarsh Prateek Bora}
5279e06a765eSHarsh Prateek BoraEOF
5280e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5281e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5282e06a765eSHarsh Prateek Borafi
5283e06a765eSHarsh Prateek Bora
52848ab1bf12SLuiz Capitulino########################################
5285c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
5286c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
5287c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
5288c95e3080SKevin Wolf# only a warning.
5289c95e3080SKevin Wolf#
5290c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
5291c95e3080SKevin Wolf# the build doesn't fail anyway.
5292c95e3080SKevin Wolf
529306d71fa1SPeter Maydellpragma_disable_unused_but_set=no
529406d71fa1SPeter Maydellcat > $TMPC << EOF
5295e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
5296c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5297e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
5298c95e3080SKevin Wolf
529906d71fa1SPeter Maydellint main(void) {
530006d71fa1SPeter Maydell    return 0;
530106d71fa1SPeter Maydell}
530206d71fa1SPeter MaydellEOF
530306d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
5304cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
5305c95e3080SKevin Wolfelse
5306c95e3080SKevin Wolf    werror=no
530706d71fa1SPeter Maydellfi
530806d71fa1SPeter Maydell
530906d71fa1SPeter Maydell########################################
5310541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
53113f4349dcSKevin Wolf
53123f4349dcSKevin Wolfvalgrind_h=no
53133f4349dcSKevin Wolfcat > $TMPC << EOF
53143f4349dcSKevin Wolf#include <valgrind/valgrind.h>
53153f4349dcSKevin Wolfint main(void) {
53163f4349dcSKevin Wolf  return 0;
53173f4349dcSKevin Wolf}
53183f4349dcSKevin WolfEOF
53193f4349dcSKevin Wolfif compile_prog "" "" ; then
53203f4349dcSKevin Wolf    valgrind_h=yes
53213f4349dcSKevin Wolffi
53223f4349dcSKevin Wolf
53233f4349dcSKevin Wolf########################################
53248ab1bf12SLuiz Capitulino# check if environ is declared
53258ab1bf12SLuiz Capitulino
53268ab1bf12SLuiz Capitulinohas_environ=no
53278ab1bf12SLuiz Capitulinocat > $TMPC << EOF
53288ab1bf12SLuiz Capitulino#include <unistd.h>
53298ab1bf12SLuiz Capitulinoint main(void) {
5330c075a723SBlue Swirl    environ = 0;
53318ab1bf12SLuiz Capitulino    return 0;
53328ab1bf12SLuiz Capitulino}
53338ab1bf12SLuiz CapitulinoEOF
53348ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
53358ab1bf12SLuiz Capitulino    has_environ=yes
53368ab1bf12SLuiz Capitulinofi
53378ab1bf12SLuiz Capitulino
533876a347e1SRichard Henderson########################################
533976a347e1SRichard Henderson# check if cpuid.h is usable.
534076a347e1SRichard Henderson
534176a347e1SRichard Hendersoncat > $TMPC << EOF
534276a347e1SRichard Henderson#include <cpuid.h>
534376a347e1SRichard Hendersonint main(void) {
5344774d566cSPeter Maydell    unsigned a, b, c, d;
5345774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5346774d566cSPeter Maydell
5347774d566cSPeter Maydell    if (max >= 1) {
5348774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5349774d566cSPeter Maydell    }
5350774d566cSPeter Maydell
5351774d566cSPeter Maydell    if (max >= 7) {
5352774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5353774d566cSPeter Maydell    }
5354774d566cSPeter Maydell
535576a347e1SRichard Henderson    return 0;
535676a347e1SRichard Henderson}
535776a347e1SRichard HendersonEOF
535876a347e1SRichard Hendersonif compile_prog "" "" ; then
535976a347e1SRichard Henderson    cpuid_h=yes
536076a347e1SRichard Hendersonfi
536176a347e1SRichard Henderson
53625dd89908SRichard Henderson##########################################
53635dd89908SRichard Henderson# avx2 optimization requirement check
53645dd89908SRichard Henderson#
53655dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
53665dd89908SRichard Henderson# since we won't be able to select the new routines.
53675dd89908SRichard Henderson
5368e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
53695dd89908SRichard Henderson  cat > $TMPC << EOF
53705dd89908SRichard Henderson#pragma GCC push_options
53715dd89908SRichard Henderson#pragma GCC target("avx2")
53725dd89908SRichard Henderson#include <cpuid.h>
53735dd89908SRichard Henderson#include <immintrin.h>
53745dd89908SRichard Hendersonstatic int bar(void *a) {
53755dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
53765dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
53775dd89908SRichard Henderson}
53785dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
53795dd89908SRichard HendersonEOF
53805dd89908SRichard Henderson  if compile_object "" ; then
53815dd89908SRichard Henderson    avx2_opt="yes"
538286583a07SLiam Merwick  else
538386583a07SLiam Merwick    avx2_opt="no"
53845dd89908SRichard Henderson  fi
53855dd89908SRichard Hendersonfi
53865dd89908SRichard Henderson
5387f540166bSRichard Henderson########################################
5388f540166bSRichard Henderson# check if __[u]int128_t is usable.
5389f540166bSRichard Henderson
5390f540166bSRichard Hendersonint128=no
5391f540166bSRichard Hendersoncat > $TMPC << EOF
5392f540166bSRichard Henderson__int128_t a;
5393f540166bSRichard Henderson__uint128_t b;
5394f540166bSRichard Hendersonint main (void) {
5395f540166bSRichard Henderson  a = a + b;
5396f540166bSRichard Henderson  b = a * b;
5397464e3671SPeter Maydell  a = a * a;
5398f540166bSRichard Henderson  return 0;
5399f540166bSRichard Henderson}
5400f540166bSRichard HendersonEOF
5401f540166bSRichard Hendersonif compile_prog "" "" ; then
5402f540166bSRichard Henderson    int128=yes
5403f540166bSRichard Hendersonfi
540476a347e1SRichard Henderson
54057ebee43eSRichard Henderson#########################################
54067ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
54077ebee43eSRichard Henderson
54087ebee43eSRichard Hendersonatomic128=no
54097ebee43eSRichard Hendersonif test "$int128" = "yes"; then
54107ebee43eSRichard Henderson  cat > $TMPC << EOF
54117ebee43eSRichard Hendersonint main(void)
54127ebee43eSRichard Henderson{
54137ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
54147ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
54157ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
54167ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
54177ebee43eSRichard Henderson  return 0;
54187ebee43eSRichard Henderson}
54197ebee43eSRichard HendersonEOF
54207ebee43eSRichard Henderson  if compile_prog "" "" ; then
54217ebee43eSRichard Henderson    atomic128=yes
54227ebee43eSRichard Henderson  fi
54237ebee43eSRichard Hendersonfi
54247ebee43eSRichard Henderson
5425e6cd4bb5SRichard Hendersoncmpxchg128=no
5426e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5427e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5428e6cd4bb5SRichard Hendersonint main(void)
5429e6cd4bb5SRichard Henderson{
5430e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5431e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5432e6cd4bb5SRichard Henderson  return 0;
5433e6cd4bb5SRichard Henderson}
5434e6cd4bb5SRichard HendersonEOF
5435e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5436e6cd4bb5SRichard Henderson    cmpxchg128=yes
5437e6cd4bb5SRichard Henderson  fi
5438e6cd4bb5SRichard Hendersonfi
5439e6cd4bb5SRichard Henderson
5440df79b996SRichard Henderson#########################################
5441df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5442df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5443df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5444df79b996SRichard Henderson
5445df79b996SRichard Hendersoncat > $TMPC << EOF
5446df79b996SRichard Henderson#include <stdint.h>
5447df79b996SRichard Hendersonint main(void)
5448df79b996SRichard Henderson{
5449df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5450df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5451df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5452df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5453df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5454df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5455df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5456df79b996SRichard Henderson#else
5457df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5458df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5459df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5460df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5461df79b996SRichard Henderson#endif
5462df79b996SRichard Henderson  return 0;
5463df79b996SRichard Henderson}
5464df79b996SRichard HendersonEOF
5465df79b996SRichard Hendersonif compile_prog "" "" ; then
5466df79b996SRichard Henderson  atomic64=yes
5467df79b996SRichard Hendersonfi
5468df79b996SRichard Henderson
54691e6e9acaSRichard Henderson########################################
5470db432672SRichard Henderson# See if 16-byte vector operations are supported.
5471db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5472db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5473db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5474db432672SRichard Henderson
5475db432672SRichard Hendersoncat > $TMPC << EOF
5476db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5477db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5478db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5479db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5480db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5481db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5482db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5483db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5484db432672SRichard Hendersonstatic U1 a1, b1;
5485db432672SRichard Hendersonstatic U2 a2, b2;
5486db432672SRichard Hendersonstatic U4 a4, b4;
5487db432672SRichard Hendersonstatic U8 a8, b8;
5488db432672SRichard Hendersonstatic S1 c1;
5489db432672SRichard Hendersonstatic S2 c2;
5490db432672SRichard Hendersonstatic S4 c4;
5491db432672SRichard Hendersonstatic S8 c8;
5492db432672SRichard Hendersonstatic int i;
549374912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
549474912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
549574912f6dSLaurent Vivier{
549674912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
549774912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
549874912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
549974912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
550074912f6dSLaurent Vivier}
5501db432672SRichard Hendersonint main(void)
5502db432672SRichard Henderson{
5503db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5504db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5505db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5506db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5507db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5508db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5509db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5510db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5511db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5512db432672SRichard Henderson  return 0;
5513db432672SRichard Henderson}
5514db432672SRichard HendersonEOF
5515db432672SRichard Henderson
5516db432672SRichard Hendersonvector16=no
5517db432672SRichard Hendersonif compile_prog "" "" ; then
5518db432672SRichard Henderson  vector16=yes
5519db432672SRichard Hendersonfi
5520db432672SRichard Henderson
5521db432672SRichard Henderson########################################
55221e6e9acaSRichard Henderson# check if getauxval is available.
55231e6e9acaSRichard Henderson
55241e6e9acaSRichard Hendersongetauxval=no
55251e6e9acaSRichard Hendersoncat > $TMPC << EOF
55261e6e9acaSRichard Henderson#include <sys/auxv.h>
55271e6e9acaSRichard Hendersonint main(void) {
55281e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
55291e6e9acaSRichard Henderson}
55301e6e9acaSRichard HendersonEOF
55311e6e9acaSRichard Hendersonif compile_prog "" "" ; then
55321e6e9acaSRichard Henderson    getauxval=yes
55331e6e9acaSRichard Hendersonfi
55341e6e9acaSRichard Henderson
5535fd0e6053SJohn Snow########################################
5536fd0e6053SJohn Snow# check if ccache is interfering with
5537fd0e6053SJohn Snow# semantic analysis of macros
5538fd0e6053SJohn Snow
55395e4dfd3dSJohn Snowunset CCACHE_CPP2
5540fd0e6053SJohn Snowccache_cpp2=no
5541fd0e6053SJohn Snowcat > $TMPC << EOF
5542fd0e6053SJohn Snowstatic const int Z = 1;
5543fd0e6053SJohn Snow#define fn() ({ Z; })
5544fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5545fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5546fd0e6053SJohn Snow#define ID(X) (X)
5547fd0e6053SJohn Snowint main(int argc, char *argv[])
5548fd0e6053SJohn Snow{
5549fd0e6053SJohn Snow    int x = 0, y = 0;
5550fd0e6053SJohn Snow    x = ID(x);
5551fd0e6053SJohn Snow    x = fn();
5552fd0e6053SJohn Snow    fn();
5553fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5554fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5555fd0e6053SJohn Snow    return 0;
5556fd0e6053SJohn Snow}
5557fd0e6053SJohn SnowEOF
5558fd0e6053SJohn Snow
5559fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5560fd0e6053SJohn Snow    ccache_cpp2=yes
5561fd0e6053SJohn Snowfi
5562fd0e6053SJohn Snow
5563b553a042SJohn Snow#################################################
5564b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5565b553a042SJohn Snow
5566b553a042SJohn Snowif test "$fortify_source" != "no"; then
5567b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5568b553a042SJohn Snow    fortify_source="no";
5569e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5570cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5571b553a042SJohn Snow    fortify_source="no";
5572b553a042SJohn Snow  else
5573b553a042SJohn Snow    fortify_source="yes"
5574b553a042SJohn Snow  fi
5575b553a042SJohn Snowfi
5576b553a042SJohn Snow
55771efad060SFam Zheng###############################################
55781efad060SFam Zheng# Check if copy_file_range is provided by glibc
55791efad060SFam Zhenghave_copy_file_range=no
55801efad060SFam Zhengcat > $TMPC << EOF
55811efad060SFam Zheng#include <unistd.h>
55821efad060SFam Zhengint main(void) {
55831efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
55841efad060SFam Zheng  return 0;
55851efad060SFam Zheng}
55861efad060SFam ZhengEOF
55871efad060SFam Zhengif compile_prog "" "" ; then
55881efad060SFam Zheng    have_copy_file_range=yes
55891efad060SFam Zhengfi
55901efad060SFam Zheng
5591d2042378SAneesh Kumar K.V##########################################
5592277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5593277abf15SJan Vesely
5594277abf15SJan Veselyhave_fsxattr=no
5595277abf15SJan Veselycat > $TMPC << EOF
5596277abf15SJan Vesely#include <linux/fs.h>
5597277abf15SJan Veselystruct fsxattr foo;
5598277abf15SJan Veselyint main(void) {
5599277abf15SJan Vesely  return 0;
5600277abf15SJan Vesely}
5601277abf15SJan VeselyEOF
5602277abf15SJan Veselyif compile_prog "" "" ; then
5603277abf15SJan Vesely    have_fsxattr=yes
5604277abf15SJan Veselyfi
5605277abf15SJan Vesely
5606b66e10e4SPeter Maydell##########################################
5607a40161cbSPaolo Bonzini# check for usable membarrier system call
5608a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5609a40161cbSPaolo Bonzini    have_membarrier=no
5610a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5611a40161cbSPaolo Bonzini        have_membarrier=yes
5612a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5613a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5614a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5615a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5616a40161cbSPaolo Bonzini    #include <unistd.h>
5617a40161cbSPaolo Bonzini    #include <stdlib.h>
5618a40161cbSPaolo Bonzini    int main(void) {
5619a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5620a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5621a40161cbSPaolo Bonzini	exit(0);
5622a40161cbSPaolo Bonzini    }
5623a40161cbSPaolo BonziniEOF
5624a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5625a40161cbSPaolo Bonzini            have_membarrier=yes
5626a40161cbSPaolo Bonzini        fi
5627a40161cbSPaolo Bonzini    fi
5628a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5629a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5630a40161cbSPaolo Bonzini    fi
5631a40161cbSPaolo Bonzinielse
5632a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5633a40161cbSPaolo Bonzini    # work on Wine.
5634a40161cbSPaolo Bonzini    membarrier=no
5635a40161cbSPaolo Bonzinifi
5636a40161cbSPaolo Bonzini
5637a40161cbSPaolo Bonzini##########################################
5638b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5639575b22b1SLaurent Vivierhave_rtnetlink=no
5640575b22b1SLaurent Viviercat > $TMPC << EOF
5641575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5642575b22b1SLaurent Vivierint main(void) {
5643575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5644575b22b1SLaurent Vivier}
5645575b22b1SLaurent VivierEOF
5646575b22b1SLaurent Vivierif compile_prog "" "" ; then
5647575b22b1SLaurent Vivier    have_rtnetlink=yes
5648575b22b1SLaurent Vivierfi
5649575b22b1SLaurent Vivier
56506a02c806SStefan Hajnoczi##########################################
56516a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
56526a02c806SStefan Hajnoczihave_af_vsock=no
56536a02c806SStefan Hajnoczicat > $TMPC << EOF
56546a02c806SStefan Hajnoczi#include <errno.h>
56556a02c806SStefan Hajnoczi#include <sys/types.h>
56566a02c806SStefan Hajnoczi#include <sys/socket.h>
56576a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
56586a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
56596a02c806SStefan Hajnoczi#endif
56606a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
56616a02c806SStefan Hajnocziint main(void) {
56626a02c806SStefan Hajnoczi    int sock, ret;
56636a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
56646a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
56656a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
56666a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
56676a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
56686a02c806SStefan Hajnoczi        return 0;
56696a02c806SStefan Hajnoczi    }
56706a02c806SStefan Hajnoczi    return -1;
56716a02c806SStefan Hajnoczi}
56726a02c806SStefan HajnocziEOF
56736a02c806SStefan Hajnocziif compile_prog "" "" ; then
56746a02c806SStefan Hajnoczi    have_af_vsock=yes
56756a02c806SStefan Hajnoczifi
56766a02c806SStefan Hajnoczi
5677f0d92b56SLongpeng(Mike)##########################################
5678f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5679f0d92b56SLongpeng(Mike)hava_afalg=no
5680f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5681f0d92b56SLongpeng(Mike)#include <errno.h>
5682f0d92b56SLongpeng(Mike)#include <sys/types.h>
5683f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5684f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5685f0d92b56SLongpeng(Mike)int main(void) {
5686f0d92b56SLongpeng(Mike)    int sock;
5687f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5688f0d92b56SLongpeng(Mike)    return sock;
5689f0d92b56SLongpeng(Mike)}
5690f0d92b56SLongpeng(Mike)EOF
5691f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5692f0d92b56SLongpeng(Mike)    have_afalg=yes
5693f0d92b56SLongpeng(Mike)fi
5694f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5695f0d92b56SLongpeng(Mike)then
5696f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5697f0d92b56SLongpeng(Mike)    then
5698f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5699f0d92b56SLongpeng(Mike)    fi
5700f0d92b56SLongpeng(Mike)fi
5701f0d92b56SLongpeng(Mike)
5702f0d92b56SLongpeng(Mike)
57036969ec6cSJames Clarke#################################################
5704c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5705d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5706c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5707c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5708c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5709c97d6d2cSSergio Andres Gomez Del RealEOF
5710c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5711c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5712c97d6d2cSSergio Andres Gomez Del Real  else
5713c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5714c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5715c97d6d2cSSergio Andres Gomez Del Real  fi
5716c97d6d2cSSergio Andres Gomez Del Realfi
5717c97d6d2cSSergio Andres Gomez Del Real
5718c97d6d2cSSergio Andres Gomez Del Real#################################################
57196969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
57206969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
57216969ec6cSJames Clarke# given. It does no harm to give it on other
57226969ec6cSJames Clarke# platforms too.
57236969ec6cSJames Clarke
57246969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
57256969ec6cSJames Clarke#       contains -Wmissing-prototypes
57266969ec6cSJames Clarkecat > $TMPC << EOF
57276969ec6cSJames Clarkeextern int foo(void);
57286969ec6cSJames Clarkeint foo(void) { return 0; }
57296969ec6cSJames ClarkeEOF
57306969ec6cSJames Clarkeif ! compile_object ""; then
57316969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
57326969ec6cSJames Clarkefi
57337ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
57347ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
57357ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
57367ecf44a5SPaolo Bonzini    break
57377ecf44a5SPaolo Bonzini  fi
57387ecf44a5SPaolo Bonzinidone
57397ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
57407ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
57416969ec6cSJames Clarkefi
57426969ec6cSJames Clarke
5743277abf15SJan Vesely##########################################
57444d04351fSChristopher Covington# check for sysmacros.h
57454d04351fSChristopher Covington
57464d04351fSChristopher Covingtonhave_sysmacros=no
57474d04351fSChristopher Covingtoncat > $TMPC << EOF
57484d04351fSChristopher Covington#include <sys/sysmacros.h>
57494d04351fSChristopher Covingtonint main(void) {
57504d04351fSChristopher Covington    return makedev(0, 0);
57514d04351fSChristopher Covington}
57524d04351fSChristopher CovingtonEOF
57534d04351fSChristopher Covingtonif compile_prog "" "" ; then
57544d04351fSChristopher Covington    have_sysmacros=yes
57554d04351fSChristopher Covingtonfi
57564d04351fSChristopher Covington
57574d04351fSChristopher Covington##########################################
5758da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5759da92c3ffSAshish Mittal# Check if libvxhs is installed
5760da92c3ffSAshish Mittal
5761da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5762da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5763da92c3ffSAshish Mittal#include <stdint.h>
5764da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5765da92c3ffSAshish Mittal
5766da92c3ffSAshish Mittalvoid *vxhs_callback;
5767da92c3ffSAshish Mittal
5768da92c3ffSAshish Mittalint main(void) {
5769da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5770da92c3ffSAshish Mittal    return 0;
5771da92c3ffSAshish Mittal}
5772da92c3ffSAshish MittalEOF
5773da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5774da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5775da92c3ffSAshish Mittal    vxhs=yes
5776da92c3ffSAshish Mittal  else
5777da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5778da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5779da92c3ffSAshish Mittal    fi
5780da92c3ffSAshish Mittal    vxhs=no
5781da92c3ffSAshish Mittal  fi
5782da92c3ffSAshish Mittalfi
5783da92c3ffSAshish Mittal
5784da92c3ffSAshish Mittal##########################################
578549e00a18SAndreas Grapentin# check for _Static_assert()
578649e00a18SAndreas Grapentin
578749e00a18SAndreas Grapentinhave_static_assert=no
578849e00a18SAndreas Grapentincat > $TMPC << EOF
578949e00a18SAndreas Grapentin_Static_assert(1, "success");
579049e00a18SAndreas Grapentinint main(void) {
579149e00a18SAndreas Grapentin    return 0;
579249e00a18SAndreas Grapentin}
579349e00a18SAndreas GrapentinEOF
579449e00a18SAndreas Grapentinif compile_prog "" "" ; then
579549e00a18SAndreas Grapentin    have_static_assert=yes
579649e00a18SAndreas Grapentinfi
579749e00a18SAndreas Grapentin
579849e00a18SAndreas Grapentin##########################################
5799e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5800e674605fSTomáš Golembiovský
5801e674605fSTomáš Golembiovskýhave_utmpx=no
5802e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5803e674605fSTomáš Golembiovský#include <utmpx.h>
5804e674605fSTomáš Golembiovskýstruct utmpx user_info;
5805e674605fSTomáš Golembiovskýint main(void) {
5806e674605fSTomáš Golembiovský    return 0;
5807e674605fSTomáš Golembiovský}
5808e674605fSTomáš GolembiovskýEOF
5809e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5810e674605fSTomáš Golembiovský    have_utmpx=yes
5811e674605fSTomáš Golembiovskýfi
5812e674605fSTomáš Golembiovský
5813e674605fSTomáš Golembiovský##########################################
5814db1ed1abSRichard Henderson# check for getrandom()
5815db1ed1abSRichard Henderson
5816db1ed1abSRichard Hendersonhave_getrandom=no
5817db1ed1abSRichard Hendersoncat > $TMPC << EOF
5818db1ed1abSRichard Henderson#include <sys/random.h>
5819db1ed1abSRichard Hendersonint main(void) {
5820db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
5821db1ed1abSRichard Henderson}
5822db1ed1abSRichard HendersonEOF
5823db1ed1abSRichard Hendersonif compile_prog "" "" ; then
5824db1ed1abSRichard Henderson    have_getrandom=yes
5825db1ed1abSRichard Hendersonfi
5826db1ed1abSRichard Henderson
5827db1ed1abSRichard Henderson##########################################
5828247724cbSMarc-André Lureau# checks for sanitizers
5829247724cbSMarc-André Lureau
5830247724cbSMarc-André Lureauhave_asan=no
5831247724cbSMarc-André Lureauhave_ubsan=no
5832d83414e1SMarc-André Lureauhave_asan_iface_h=no
5833d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5834247724cbSMarc-André Lureau
5835247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5836b9f44da2SMarc-André Lureau  write_c_skeleton
5837247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5838247724cbSMarc-André Lureau      have_asan=yes
5839247724cbSMarc-André Lureau  fi
5840b9f44da2SMarc-André Lureau
5841b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5842b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5843b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5844b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5845b9f44da2SMarc-André Lureau#include <stdlib.h>
5846b9f44da2SMarc-André Lureauint main(void) {
5847b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5848b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5849b9f44da2SMarc-André Lureau}
5850b9f44da2SMarc-André LureauEOF
5851247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5852247724cbSMarc-André Lureau      have_ubsan=yes
5853247724cbSMarc-André Lureau  fi
5854d83414e1SMarc-André Lureau
5855d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5856d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5857d83414e1SMarc-André Lureau  fi
5858d83414e1SMarc-André Lureau
5859d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5860d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5861d83414e1SMarc-André Lureauint main(void) {
5862d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5863d83414e1SMarc-André Lureau  return 0;
5864d83414e1SMarc-André Lureau}
5865d83414e1SMarc-André LureauEOF
5866d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5867d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5868d83414e1SMarc-André Lureau  fi
5869247724cbSMarc-André Lureaufi
5870247724cbSMarc-André Lureau
5871247724cbSMarc-André Lureau##########################################
587217824406SJunyan He# check for libpmem
587317824406SJunyan He
587417824406SJunyan Heif test "$libpmem" != "no"; then
587517824406SJunyan He	if $pkg_config --exists "libpmem"; then
587617824406SJunyan He		libpmem="yes"
587717824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
587817824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
587917824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
588017824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
588117824406SJunyan He	else
588217824406SJunyan He		if test "$libpmem" = "yes" ; then
588317824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
588417824406SJunyan He		fi
588517824406SJunyan He		libpmem="no"
588617824406SJunyan He	fi
588717824406SJunyan Hefi
588817824406SJunyan He
588917824406SJunyan He##########################################
5890675b9b53SMarc-André Lureau# check for slirp
5891675b9b53SMarc-André Lureau
5892675b9b53SMarc-André Lureaucase "$slirp" in
5893675b9b53SMarc-André Lureau  "" | yes)
5894675b9b53SMarc-André Lureau    if $pkg_config slirp; then
5895675b9b53SMarc-André Lureau      slirp=system
58967c57bdd8SMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
58977c57bdd8SMarc-André Lureau      slirp=git
5898675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
5899675b9b53SMarc-André Lureau      slirp=internal
5900675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
5901675b9b53SMarc-André Lureau      slirp=no
5902675b9b53SMarc-André Lureau    else
5903675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
5904675b9b53SMarc-André Lureau    fi
5905675b9b53SMarc-André Lureau    ;;
5906675b9b53SMarc-André Lureau
5907675b9b53SMarc-André Lureau  system)
5908675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
5909675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
5910675b9b53SMarc-André Lureau    fi
5911675b9b53SMarc-André Lureau    ;;
5912675b9b53SMarc-André Lureauesac
5913675b9b53SMarc-André Lureau
5914675b9b53SMarc-André Lureaucase "$slirp" in
59157c57bdd8SMarc-André Lureau  git | internal)
59167c57bdd8SMarc-André Lureau    if test "$slirp" = git; then
59177c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
59187c57bdd8SMarc-André Lureau    fi
5919675b9b53SMarc-André Lureau    mkdir -p slirp
5920675b9b53SMarc-André Lureau    slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
5921675b9b53SMarc-André Lureau    slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
5922675b9b53SMarc-André Lureau    ;;
5923675b9b53SMarc-André Lureau
5924675b9b53SMarc-André Lureau  system)
5925675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
5926675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
5927675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
5928675b9b53SMarc-André Lureau    ;;
5929675b9b53SMarc-André Lureau
5930675b9b53SMarc-André Lureau  no)
5931675b9b53SMarc-André Lureau    ;;
5932675b9b53SMarc-André Lureau  *)
5933675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
5934675b9b53SMarc-André Lureau    ;;
5935675b9b53SMarc-André Lureauesac
5936675b9b53SMarc-André Lureau
5937675b9b53SMarc-André Lureau
5938675b9b53SMarc-André Lureau##########################################
5939e86ecd4bSJuan Quintela# End of CC checks
5940e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5941e86ecd4bSJuan Quintela
5942d83414e1SMarc-André Lureauwrite_c_skeleton
5943d83414e1SMarc-André Lureau
59441d728c39SBlue Swirlif test "$gcov" = "yes" ; then
59451d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
59461d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5947b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5948e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
594948e56d50SPaolo Bonzinielif test "$debug" = "no"; then
5950ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5951e86ecd4bSJuan Quintelafi
5952a316e378SJuan Quintela
5953247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5954247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
5955d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5956d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5957d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5958d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5959d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5960d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5961d83414e1SMarc-André Lureau  fi
5962247724cbSMarc-André Lureaufi
5963247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5964247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
5965247724cbSMarc-André Lureaufi
5966247724cbSMarc-André Lureau
59676542aa9cSPeter Lieven##########################################
59686542aa9cSPeter Lieven# Do we have libnfs
59696542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5970b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
59716542aa9cSPeter Lieven    libnfs="yes"
59726542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
59736542aa9cSPeter Lieven  else
59746542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
59758efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
59766542aa9cSPeter Lieven    fi
59776542aa9cSPeter Lieven    libnfs="no"
59786542aa9cSPeter Lieven  fi
59796542aa9cSPeter Lievenfi
59801d728c39SBlue Swirl
59813efac6ebSTomáš Golembiovský##########################################
59823efac6ebSTomáš Golembiovský# Do we have libudev
59833efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
59843efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
59853efac6ebSTomáš Golembiovský    libudev="yes"
59863efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
59873efac6ebSTomáš Golembiovský  else
59883efac6ebSTomáš Golembiovský    libudev="no"
59893efac6ebSTomáš Golembiovský  fi
59903efac6ebSTomáš Golembiovskýfi
59913efac6ebSTomáš Golembiovský
59926ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
59936ca026cbSPeter Maydellif test "$werror" = "yes"; then
59946ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
59956ca026cbSPeter Maydellfi
59966ca026cbSPeter Maydell
5997e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5998e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
59991156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
6000e86ecd4bSJuan Quintela    fi
6001e86ecd4bSJuan Quintelafi
6002e86ecd4bSJuan Quintela
600394dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
600494dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
600594dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
600694dd53c5SGerd Hoffmannelse
600794dd53c5SGerd Hoffmann    POD2MAN="pod2man"
600894dd53c5SGerd Hoffmannfi
600994dd53c5SGerd Hoffmann
6010952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
6011952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
6012952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
6013e9a3591fSChristian Borntraeger        if ld_has $flag ; then
6014952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
6015952afb71SBlue Swirl        fi
6016952afb71SBlue Swirl    done
6017952afb71SBlue Swirlfi
6018952afb71SBlue Swirl
60197776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
60207776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
60217776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
60227776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
60237776ea6bSPhilippe Mathieu-DaudéEOF
60247776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
60257776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
60267776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
60277776ea6bSPhilippe Mathieu-Daudé    fi
60287776ea6bSPhilippe Mathieu-Daudéfi
60297776ea6bSPhilippe Mathieu-Daudé
603010ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
6031e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
6032528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
6033834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
6034a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
603567ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
60365a67135aSbellard
6037e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
6038e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
6039e0580342SKamil Rytarowski  ivshmem=yes
6040e0580342SKamil Rytarowskifi
6041e0580342SKamil Rytarowski
60424b1c11fdSDaniel P. Berrangetools=""
60434b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
604472d277a7SGerd Hoffmann  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
60454b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
60464b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
6047b1449edbSKamil Rytarowski  fi
6048b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
6049a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
60504b1c11fdSDaniel P. Berrange  fi
60511b9d35f3SViktor Prutyanov  if [ "$curl" = "yes" ]; then
60521b9d35f3SViktor Prutyanov      tools="elf2dmp\$(EXESUF) $tools"
60533fa2d384SViktor Prutyanov  fi
60544b1c11fdSDaniel P. Berrangefi
60554b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
6056b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
6057b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
6058983eef5aSMeador Inge      virtfs=yes
605917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
6060983eef5aSMeador Inge    else
6061983eef5aSMeador Inge      if test "$virtfs" = yes; then
6062b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
6063983eef5aSMeador Inge      fi
606417500370SAndreas Färber      virtfs=no
6065983eef5aSMeador Inge    fi
6066fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
6067fe8fc5aeSPaolo Bonzini      mpath=yes
6068fe8fc5aeSPaolo Bonzini    else
6069fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
6070fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
6071fe8fc5aeSPaolo Bonzini      fi
6072fe8fc5aeSPaolo Bonzini      mpath=no
6073fe8fc5aeSPaolo Bonzini    fi
6074b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
6075b855f8d1SPaolo Bonzini  else
6076b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
6077b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
6078b855f8d1SPaolo Bonzini    fi
6079b855f8d1SPaolo Bonzini    virtfs=no
6080fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
6081fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
6082fe8fc5aeSPaolo Bonzini    fi
6083fe8fc5aeSPaolo Bonzini    mpath=no
608417bff52bSM. Mohan Kumar  fi
60856a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
60866a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
60876a021536SGerd Hoffmann  fi
6088ff69fd8cSLaurent Vivierfi
60899d6bc27bSMichael Roth
60909d6bc27bSMichael Roth# Probe for guest agent support/options
60919d6bc27bSMichael Roth
6092e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
6093a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6094a5125905SLaurent Vivier      guest_agent=no
6095a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
60960814465aSPaolo Bonzini      tools="qemu-ga\$(EXESUF) $tools"
6097e8ef31a3SMichael Tokarev      guest_agent=yes
6098e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
6099e8ef31a3SMichael Tokarev      guest_agent=no
6100e8ef31a3SMichael Tokarev  else
6101e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
6102ca35f780SPaolo Bonzini  fi
61034b1c11fdSDaniel P. Berrangefi
6104ca35f780SPaolo Bonzini
61059d6bc27bSMichael Roth# Guest agent Window MSI  package
61069d6bc27bSMichael Roth
61079d6bc27bSMichael Rothif test "$guest_agent" != yes; then
61089d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
61099d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
61109d6bc27bSMichael Roth  fi
61119d6bc27bSMichael Roth  guest_agent_msi=no
61129d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
61139d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
61149d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
61159d6bc27bSMichael Roth  fi
61169d6bc27bSMichael Roth  guest_agent_msi=no
61179d6bc27bSMichael Rothelif ! has wixl; then
61189d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
61199d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
61209d6bc27bSMichael Roth  fi
61219d6bc27bSMichael Roth  guest_agent_msi=no
61221a34904eSMichael Rothelse
61231a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
61241a34904eSMichael Roth  # disabled explicitly
61251a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
61261a34904eSMichael Roth    guest_agent_msi=yes
61271a34904eSMichael Roth  fi
61289d6bc27bSMichael Rothfi
61299d6bc27bSMichael Roth
61301a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
61319d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
61329d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
61339d6bc27bSMichael Roth  fi
61349d6bc27bSMichael Roth
61359d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
61369d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
61379d6bc27bSMichael Roth  fi
61389d6bc27bSMichael Roth
61399d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
61409d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
61419d6bc27bSMichael Roth  fi
61429d6bc27bSMichael Roth
61439d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
614489138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
61459d6bc27bSMichael Roth  fi
61469d6bc27bSMichael Roth
614789138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
61489d6bc27bSMichael Roth
61499d6bc27bSMichael Roth  case "$cpu" in
61509d6bc27bSMichael Roth  x86_64)
61519d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
61529d6bc27bSMichael Roth    ;;
61539d6bc27bSMichael Roth  i386)
61549d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
61559d6bc27bSMichael Roth    ;;
61569d6bc27bSMichael Roth  *)
61579d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
61589d6bc27bSMichael Roth    ;;
61599d6bc27bSMichael Roth  esac
61609d6bc27bSMichael Rothfi
61619d6bc27bSMichael Roth
6162ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6163ca35f780SPaolo Bonziniroms=
6164e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6165e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6166e633a5c6SEric Blake        test "$softmmu" = yes ; then
6167e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6168c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6169c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6170c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6171e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6172e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6173ca35f780SPaolo Bonzini            roms="optionrom"
6174e57218b6SPeter Maydell            break
6175e57218b6SPeter Maydell        fi
6176e57218b6SPeter Maydell    done
6177ca35f780SPaolo Bonzinifi
6178f8378accSRichard Hendersonif test "$ARCH" = "ppc64" && test "$targetos" != "Darwin" ; then
617939ac8455SDavid Gibson  roms="$roms spapr-rtas"
618039ac8455SDavid Gibsonfi
6181ca35f780SPaolo Bonzini
61822e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
61839933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
61842e33c3f8SThomas Huth  write_c_skeleton
61852e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
61869933c305SChristian Borntraeger    roms="$roms s390-ccw"
61879933c305SChristian Borntraeger  fi
61882e33c3f8SThomas Huthfi
61899933c305SChristian Borntraeger
6190964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
619192fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
6192964c6fa1SRichard Henderson  textseg_addr=
6193964c6fa1SRichard Henderson  case "$cpu" in
6194479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
6195479eb121SRichard Henderson      # ??? Rationale for choosing this address
6196964c6fa1SRichard Henderson      textseg_addr=0x60000000
6197964c6fa1SRichard Henderson      ;;
6198964c6fa1SRichard Henderson    mips)
6199479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
6200479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
6201479eb121SRichard Henderson      textseg_addr=0x60000000
6202964c6fa1SRichard Henderson      ;;
6203964c6fa1SRichard Henderson  esac
6204964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
6205964c6fa1SRichard Henderson    cat > $TMPC <<EOF
6206964c6fa1SRichard Henderson    int main(void) { return 0; }
6207964c6fa1SRichard HendersonEOF
6208964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
6209964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
6210964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
6211964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
6212964c6fa1SRichard Henderson      # at least.
621392fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
621492fe2ba8SPeter Maydell        error_exit \
621592fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
621692fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
621792fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
621892fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
621992fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
622092fe2ba8SPeter Maydell            "--disable-user option to configure."
622192fe2ba8SPeter Maydell      fi
622292fe2ba8SPeter Maydell
6223964c6fa1SRichard Henderson      $ld --verbose | sed \
6224964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
6225964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
6226964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
6227964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
6228964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
6229964c6fa1SRichard Henderson    fi
6230964c6fa1SRichard Henderson  fi
6231964c6fa1SRichard Hendersonfi
6232964c6fa1SRichard Henderson
623311cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
623411cde1c8SBruno 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.
623511cde1c8SBruno Dominguezif has $cxx; then
623611cde1c8SBruno Dominguez    cat > $TMPC <<EOF
623711cde1c8SBruno Dominguezint c_function(void);
623811cde1c8SBruno Dominguezint main(void) { return c_function(); }
623911cde1c8SBruno DominguezEOF
624011cde1c8SBruno Dominguez
624111cde1c8SBruno Dominguez    compile_object
624211cde1c8SBruno Dominguez
624311cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
624411cde1c8SBruno Dominguezextern "C" {
624511cde1c8SBruno Dominguez   int c_function(void);
624611cde1c8SBruno Dominguez}
624711cde1c8SBruno Dominguezint c_function(void) { return 42; }
624811cde1c8SBruno DominguezEOF
624911cde1c8SBruno Dominguez
625011cde1c8SBruno Dominguez    update_cxxflags
625111cde1c8SBruno Dominguez
625211cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
625311cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
625411cde1c8SBruno Dominguez        :
625511cde1c8SBruno Dominguez    else
625611cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
625711cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
625811cde1c8SBruno Dominguez        cxx=
625911cde1c8SBruno Dominguez    fi
626011cde1c8SBruno Dominguezelse
626111cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
626211cde1c8SBruno Dominguez    cxx=
626311cde1c8SBruno Dominguezfi
626411cde1c8SBruno Dominguez
626502d34f62SCole Robinsonecho_version() {
626602d34f62SCole Robinson    if test "$1" = "yes" ; then
626702d34f62SCole Robinson        echo "($2)"
626802d34f62SCole Robinson    fi
626902d34f62SCole Robinson}
627002d34f62SCole Robinson
627150e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
627250e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
62738a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
627450e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
62755ca9388aSGerd Hoffmann
62767d13299dSbellardecho "Install prefix    $prefix"
627789138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
62783d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
627989138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
628089138857SStefan Weilecho "library directory $(eval echo $libdir)"
628189138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
628289138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
628389138857SStefan Weilecho "include directory $(eval echo $includedir)"
628489138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
628511d9f695Sbellardif test "$mingw32" = "no" ; then
628689138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
628789138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
628843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
62895a699bbbSLaszlo Ersekelse
62905a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
6291d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
629211d9f695Sbellardfi
62935a67135aSbellardecho "Source path       $source_path"
6294cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
6295aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
62967d13299dSbellardecho "C compiler        $cc"
629783469015Sbellardecho "Host C compiler   $host_cc"
629883f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
62993c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
630045d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
63010c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
6302a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
63030c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
63048a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
63057d13299dSbellardecho "make              $make"
63066a882643Spbrookecho "install           $install"
6307755ee70fSCleber Rosaecho "python            $python ($python_version)"
6308675b9b53SMarc-André Lureauecho "slirp support     $slirp $(echo_version $slirp $slirp_version)"
6309675b9b53SMarc-André Lureauif test "$slirp" != "no" ; then
6310e2d8830eSBrad    echo "smbd              $smbd"
6311e2d8830eSBradfi
631217969268SFam Zhengecho "module support    $modules"
6313a98fd896Sbellardecho "host CPU          $cpu"
6314de83cd02Sbellardecho "host big endian   $bigendian"
631597a847bcSbellardecho "target list       $target_list"
63167d13299dSbellardecho "gprof enabled     $gprof"
631703b4fe7dSaliguoriecho "sparse enabled    $sparse"
63181625af87Saliguoriecho "strip binaries    $strip_opt"
631905c2a3e7Sbellardecho "profiler          $profiler"
632043ce4dfeSbellardecho "static build      $static"
63215b0753e0Sbellardif test "$darwin" = "yes" ; then
63225b0753e0Sbellard    echo "Cocoa support     $cocoa"
63235b0753e0Sbellardfi
632489138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
6325a442fe2fSDaniel P. Berrangéecho "SDL image support $sdl_image"
632689138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
6327925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
632889138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
6329a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
6330ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
633191bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
633289138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
63339a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
63348953caf3SDaniel P. Berrangeecho "PAM               $auth_pam"
6335e08bb301SSamuel Thibaultecho "iconv support     $iconv"
63364d3b6f6eSbalrogecho "curses support    $curses"
633747479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6338769ce76dSAlexander Grafecho "curl support      $curl"
633967b915a5Sbellardecho "mingw32 support   $mingw32"
63400c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
6341b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
6342b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
6343983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
6344fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
6345821601eaSJes Sorensenecho "VNC support       $vnc"
6346821601eaSJes Sorensenif test "$vnc" = "yes" ; then
63472f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
63482f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
6349efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
6350821601eaSJes Sorensenfi
6351e37630caSaliguoriecho "xen support       $xen"
63523996e85cSPaul Durrantif test "$xen" = "yes" ; then
63533996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
63543996e85cSPaul Durrantfi
63552e4d9fb1Saurel32echo "brlapi support    $brlapi"
6356a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
6357a25dba17SJuan Quintelaecho "Documentation     $docs"
635840d6444eSAvi Kivityecho "PIE               $pie"
63598a16d273Sthsecho "vde support       $vde"
636058952137SVincenzo Maffioneecho "netmap support    $netmap"
63615c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
6362758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
636377755340Sthsecho "Install blobs     $blobs"
6364b31a0277SJuan Quintelaecho "KVM support       $kvm"
6365b0cb0a66SVincent Palatinecho "HAX support       $hax"
6366c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
6367d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
6368b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
6369b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
6370b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
63719195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
6372b3f6ea7eSPaolo Bonzinifi
63735a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
6374b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
637521ab34c9SMarcel Apfelbaumecho "PVRDMA support    $pvrdma"
6376f652e6afSaurel32echo "fdt support       $fdt"
6377a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
6378ceb42de8Saliguoriecho "preadv support    $preadv"
63795f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
6380e78815a5SAndreas Färberecho "madvise           $madvise"
6381e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
63829bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
638347e98658SCorey Bryantecho "libcap-ng support $cap_ng"
6384d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
6385042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
63865e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
6387fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
6388e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
6389*98fc1adaSDr. David Alan Gilbertecho "vhost-user-fs support $vhost_user_fs"
63905b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
6391713572a7SMarc-André Lureauif have_backend "simple"; then
63929410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
6393e00e36fbSStefan Weilfi
639489138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6395f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
6396dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
63977b02f544SMarc-André Lureauecho "smartcard support $smartcard"
63982b2325ffSGerd Hoffmannecho "libusb            $libusb"
639969354a83SHans de Goedeecho "usb net redir     $usb_redir"
6400da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
6401014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
6402c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
64036542aa9cSPeter Lievenecho "libnfs support    $libnfs"
6404d138cee9SMichael Rothecho "build guest agent $guest_agent"
6405d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
640650cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
64074c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
6408f794573eSEduardo Otuboecho "seccomp support   $seccomp"
64097c2acc70SPeter Maydellecho "coroutine backend $coroutine"
641070c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
64117d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
6412ba59fb77SPaolo Bonziniecho "mutex debugging   $debug_mutex"
6413f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
6414eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
64151d728c39SBlue Swirlecho "gcov              $gcov_tool"
64161d728c39SBlue Swirlecho "gcov enabled      $gcov"
6417ab214c29SStefan Bergerecho "TPM support       $tpm"
6418b10d49d7SPino Toscanoecho "libssh support    $libssh"
64193556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
6420ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
6421607dacd0Sqiaonuohanecho "lzo support       $lzo"
6422607dacd0Sqiaonuohanecho "snappy support    $snappy"
64236b383c08SPeter Wuecho "bzip2 support     $bzip2"
642483bc1f97SJulio Faraccoecho "lzfse support     $lzfse"
6425a99d57bbSWanlong Gaoecho "NUMA host support $numa"
6426ed279a06SKlim Kireevecho "libxml2           $libxml2"
64272847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
64287b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
642999f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
6430a6b1d4c0SChanglong Xieecho "replication support $replication"
6431da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
64322f740136SJeff Codyecho "bochs support     $bochs"
64332f740136SJeff Codyecho "cloop support     $cloop"
64342f740136SJeff Codyecho "dmg support       $dmg"
64352f740136SJeff Codyecho "qcow v1 support   $qcow1"
64362f740136SJeff Codyecho "vdi support       $vdi"
64372f740136SJeff Codyecho "vvfat support     $vvfat"
64382f740136SJeff Codyecho "qed support       $qed"
64392f740136SJeff Codyecho "parallels support $parallels"
64402f740136SJeff Codyecho "sheepdog support  $sheepdog"
64418ca80760SRichard Hendersonecho "capstone          $capstone"
644217824406SJunyan Heecho "libpmem support   $libpmem"
64433efac6ebSTomáš Golembiovskýecho "libudev           $libudev"
6444f3494749SPaolo Bonziniecho "default devices   $default_devices"
644567b915a5Sbellard
6446898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
6447898be3e0SPeter Maydell    echo
6448898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6449898be3e0SPeter Maydell    echo
6450898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
6451898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
6452898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6453898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6454898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6455898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6456898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6457898be3e0SPeter Maydellfi
6458898be3e0SPeter Maydell
6459898be3e0SPeter Maydellif test "$supported_os" = "no"; then
6460898be3e0SPeter Maydell    echo
6461898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6462898be3e0SPeter Maydell    echo
6463c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
6464c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
6465898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
6466898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
6467898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
6468898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
6469898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
6470898be3e0SPeter Maydellfi
6471898be3e0SPeter Maydell
6472e5abf59eSEduardo Habkost# Note that if the Python conditional here evaluates True we will exit
6473e5abf59eSEduardo Habkost# with status 1 which is a shell 'false' value.
6474e5abf59eSEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
6475e5abf59eSEduardo Habkost  echo
6476e5abf59eSEduardo Habkost  echo "warning: Python 2 support is deprecated" >&2
6477e5abf59eSEduardo Habkost  echo "warning: Python 3 will be required for building future versions of QEMU" >&2
6478406ab2f3SCleber Rosa  python2="y"
6479e5abf59eSEduardo Habkostfi
6480e5abf59eSEduardo Habkost
648198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
648297a847bcSbellard
6483dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6484dbd99ae3SStefan Weil
648598ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
648698ec69acSJuan Quintelaecho >> $config_host_mak
648798ec69acSJuan Quintela
6488e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
648999d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
649099d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
64913aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
64928bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
64930f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
649499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
649599d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
649622d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
64979afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
64983d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
64999afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6500e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
65015a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6502785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
65035a699bbbSLaszlo Ersekfi
6504f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6505834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6506a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
650767ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
650802f9135bSDaniel P. Berrangéecho "libs_cpu=$libs_cpu" >> $config_host_mak
6509f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6510cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6511aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6512f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6513804edf29SJuan Quintela
651498ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6515727e5283SPaolo Bonzini
6516f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6517f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6518f3494749SPaolo Bonzinielse
6519f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6520f3494749SPaolo Bonzinifi
6521f8393946Saurel32if test "$debug_tcg" = "yes" ; then
65222358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6523f8393946Saurel32fi
65241625af87Saliguoriif test "$strip_opt" = "yes" ; then
652552ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
65261625af87Saliguorifi
65277d13299dSbellardif test "$bigendian" = "yes" ; then
6528e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
652997a847bcSbellardfi
653067b915a5Sbellardif test "$mingw32" = "yes" ; then
653198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
653289138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
65339fe6de94SBlue Swirl  version_major=${rc_version%%.*}
65349fe6de94SBlue Swirl  rc_version=${rc_version#*.}
65359fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
65369fe6de94SBlue Swirl  rc_version=${rc_version#*.}
65379fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
65389fe6de94SBlue Swirl  version_micro=0
65399fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
65409fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6541d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6542d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6543f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6544d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6545d9840e25STomoki Sekiyama  fi
654650cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
654776dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
654850cbebb9SMichael Roth  fi
65491a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
65509dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
65519dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
65529dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
65539dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
65549dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
65559dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
65569dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
65579dacf32dSYossi Hindin  fi
6558210fa556Spbrookelse
655935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6560210fa556Spbrookfi
6561128ab2ffSblueswir1
6562dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6563dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6564dffcb71cSMark McLoughlinfi
6565dffcb71cSMark McLoughlin
656683fb7adfSbellardif test "$darwin" = "yes" ; then
656798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
656883fb7adfSbellardfi
6569b29fe3edSmalc
6570ec530c81Sbellardif test "$solaris" = "yes" ; then
657198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6572ec530c81Sbellardfi
6573179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6574179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6575179cf400SAndreas Färberfi
657697a847bcSbellardif test "$static" = "yes" ; then
657798ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
657897a847bcSbellardfi
65791ba16968SStefan Weilif test "$profiler" = "yes" ; then
65802358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
658105c2a3e7Sbellardfi
6582c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
6583c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
6584c932ce31SPaolo Bonzinifi
6585675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
658698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6587e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6588675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6589675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6590675b9b53SMarc-André Lureaufi
65917c57bdd8SMarc-André Lureauif [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
65923b8593eeSMarkus Armbruster    echo "config-host.h: slirp/all" >> $config_host_mak
6593c20709aaSbellardfi
65948a16d273Sthsif test "$vde" = "yes" ; then
659598ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6596e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
65978a16d273Sthsfi
659858952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
659958952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
660058952137SVincenzo Maffionefi
6601015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6602015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6603015a33bdSGongleifi
660447e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
660547e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
660647e98658SCorey Bryantfi
66072358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
66080c58ac1cSmalcfor drv in $audio_drv_list; do
66091ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6610ce3dc033SGerd Hoffmann    case "$drv" in
6611051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6612ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6613ce3dc033SGerd Hoffmann	*)
6614ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6615ce3dc033SGerd Hoffmann    esac
66160c58ac1cSmalcdone
6617b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6618b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6619b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6620b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6621b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
6622d5631638Smalcif test "$audio_win_int" = "yes" ; then
6623d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6624d5631638Smalcfi
6625b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6626b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6627821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6628821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6629821601eaSJes Sorensenfi
66302f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
663198ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
66322f9606b3Saliguorifi
6633821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
66342f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
66352f6f5c7aSCorentin Charyfi
6636821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6637efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6638efe556adSCorentin Charyfi
66396a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
66406a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
66416a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
66426a021536SGerd Hoffmannfi
6643dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6644dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6645dce512deSChristoph Hellwigfi
664689138857SStefan Weilqemu_version=$(head $source_path/VERSION)
664798ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
66482358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
664998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
66502b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6651a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
665298ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6653cc8ae6deSpbrookfi
665417969268SFam Zhengif test "$modules" = "yes"; then
6655e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6656e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
665789138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
665817969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
665917969268SFam Zhengfi
6660e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
66618781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
66628781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
66638781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
66648781595bSGerd Hoffmannfi
66651ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
666696400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
66678ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
66688ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6669a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes" ; then
6670a442fe2fSDaniel P. Berrangé      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
6671a442fe2fSDaniel P. Berrangé  fi
667249ecc3faSbellardfi
667349ecc3faSbellardif test "$cocoa" = "yes" ; then
667498ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
667549ecc3faSbellardfi
6676e08bb301SSamuel Thibaultif test "$iconv" = "yes" ; then
6677e08bb301SSamuel Thibault  echo "CONFIG_ICONV=y" >> $config_host_mak
6678e08bb301SSamuel Thibault  echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
6679e08bb301SSamuel Thibault  echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
6680e08bb301SSamuel Thibaultfi
66814d3b6f6eSbalrogif test "$curses" = "yes" ; then
66822373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
66832373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
66842373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6685ab4e5602SJan Kiszkafi
6686099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
66872358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6688099d6b0fSRiku Voipiofi
668940ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
669040ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
669140ff6d7eSKevin Wolffi
66923ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
66932358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
66943ce34dfbSvibisreenivasanfi
6695c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6696c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6697c2882b96SRiku Voipiofi
6698751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6699751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6700751bcc39SMarc-André Lureaufi
6701955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6702955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6703955727d2SCortland Tölvafi
6704d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6705d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6706d0927938SUlrich Hechtfi
67073d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
67083d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
67093d4fa43eSKusanagi Kouichifi
6710b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6711b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6712b953f075SDenis V. Lunevfi
6713ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6714ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6715ed911435SKevin Wolffi
6716c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6717c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6718c727f47dSPeter Maydellfi
6719dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6720dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6721dace20dcSPeter Maydellfi
6722d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6723d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6724d0927938SUlrich Hechtfi
67254e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
67264e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
67274e0c6529SAlex Blighfi
6728cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6729cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6730cd758dd0SAlex Blighfi
67313b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
67323b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
67333b6edd16SPeter Maydellfi
67343b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
67353b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
67363b6edd16SPeter Maydellfi
6737a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6738a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6739a8fd1abaSPeter Maydellfi
674051834341SRiku Voipioif test "$timerfd" = "yes" ; then
674151834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
674251834341SRiku Voipiofi
67439af5c906SRiku Voipioif test "$setns" = "yes" ; then
67449af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
67459af5c906SRiku Voipiofi
674638860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
674738860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
674838860a03SAleksandar Markovicfi
67495a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
67505a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
67515a03cd00SAleksandar Markovicfi
67523b3f24adSaurel32if test "$inotify" = "yes" ; then
67532358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
67543b3f24adSaurel32fi
6755c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6756c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6757c05c7a73SRiku Voipiofi
6758401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6759401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6760401bc051SPeter Maydellfi
67615c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
67625c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
67635c99fa37SKeno Fischerfi
67646ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
67656ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
67666ae9a1f4SJuan Quintelafi
67676ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
67686ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
67696ae9a1f4SJuan Quintelafi
6770769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6771d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6772b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
67736ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6774769ce76dSAlexander Graffi
67752e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
677698ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
67778eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
67782e4d9fb1Saurel32fi
6779fb599c9aSbalrogif test "$bluez" = "yes" ; then
678098ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
6781ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6782fb599c9aSbalrogfi
6783a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6784e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6785a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6786014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6787925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6788925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6789925a0400SGerd Hoffmann  fi
6790bbbf9bfbSStefan Weilfi
6791f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6792f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6793f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6794f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
6795f876b765SMarc-André Lureaufi
6796a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6797ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6798ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6799ddbb0d09SDaniel P. Berrangefi
680091bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
680191bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
68021f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
68031f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
68041f923c70SLongpeng(Mike)  fi
680562893b67SDaniel P. Berrangefi
680691bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
680791bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6808becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6809ed754746SDaniel P. Berrangefi
68109a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
68119a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
68129a2fd434SDaniel P. Berrangefi
68138953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
68148953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
68158953caf3SDaniel P. Berrangefi
6816559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6817559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6818559607eaSDaniel P. Berrangefi
68196b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
68206b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
68216b39b063SEric Blakefi
6822277abf15SJan Vesely
6823277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6824277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6825277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6826277abf15SJan Vesely# if this macro is set.
6827277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6828277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6829277abf15SJan Veselyfi
68301efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
68311efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
68321efad060SFam Zhengfi
6833bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6834bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6835a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6836e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6837a4ccabcfSAnthony Liguorifi
68389d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
68399d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
68409d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
68419d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
68429d9e1521SGerd Hoffmannfi
6843e37630caSaliguoriif test "$xen" = "yes" ; then
68446dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6845d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6846e37630caSaliguorifi
68475c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
68485c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
68495c6c3a6cSChristoph Hellwigfi
6850758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6851758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6852758e8e38SVenkateswararao Jujjuri (JV)fi
68534f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
68544f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
68554f26f2b6SAvi Kivityfi
6856983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6857758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6858758e8e38SVenkateswararao Jujjuri (JV)fi
6859fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6860fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
68611b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
68621b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
68631b0578f5SMurilo Opsfelder Araujo  fi
6864fe8fc5aeSPaolo Bonzinifi
68655e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
68665e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
68675e9be92dSNicholas Bellingerfi
6868af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
6869af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
6870af3bba76SPaolo Bonzinifi
6871af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
687256f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
687303ce5744SNikolay Nikolaevfi
6874042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6875042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6876042cea27SGongleifi
6877fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6878fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6879fc0b9b0eSStefan Hajnoczifi
6880299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
6881299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
6882299e6f19SPaolo Bonzinifi
6883e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6884e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6885e6a74868SMarc-André Lureaufi
6886*98fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
6887*98fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
6888*98fc1adaSDr. David Alan Gilbertfi
688977755340Sthsif test "$blobs" = "yes" ; then
689098ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
689177755340Sthsfi
6892bf9298b9Saliguoriif test "$iovec" = "yes" ; then
68932358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6894bf9298b9Saliguorifi
6895ceb42de8Saliguoriif test "$preadv" = "yes" ; then
68962358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6897ceb42de8Saliguorifi
6898e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
68993f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6900f652e6afSaurel32fi
6901a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6902a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6903a40161cbSPaolo Bonzinifi
6904dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6905dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6906dcc38d1cSMarcelo Tosattifi
6907d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
6908d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
6909d339d766SRichard W.M. Jonesfi
6910b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6911b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
69129195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
69139195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
69149195b2c2SStefan Weil  fi
6915b3f6ea7eSPaolo Bonzinifi
69165f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
69175f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
69185f6b9e8fSBlue Swirlfi
6919e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6920e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6921e78815a5SAndreas Färberfi
6922e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6923e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6924e78815a5SAndreas Färberfi
69259bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
69269bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
69279bc5a719SAndreas Gustafssonfi
692897a847bcSbellard
6929cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6930cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6931cd4ec0b4SGerd Hoffmannfi
6932cd4ec0b4SGerd Hoffmann
69337b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
69347b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
69357b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
69367b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6937111a38b0SRobert Relyeafi
6938111a38b0SRobert Relyea
69392b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
69402b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6941b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6942b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
69432b2325ffSGerd Hoffmannfi
69442b2325ffSGerd Hoffmann
694569354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
694669354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6947cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6948cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
694969354a83SHans de Goedefi
695069354a83SHans de Goede
6951da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6952da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6953da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6954014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6955014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6956014cb152SGerd Hoffmann  fi
695720ff075bSMichael Wallefi
695820ff075bSMichael Walle
6959d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
6960d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
6961d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
6962d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
6963d52c454aSMarc-André Lureaufi
6964d52c454aSMarc-André Lureau
6965d52c454aSMarc-André Lureau
69665a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
69675a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
69685a22ab71SYang Zhongfi
69695a22ab71SYang Zhong
697099f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
697199f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
697299f2dbd3SLiang Lifi
697399f2dbd3SLiang Li
6974607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6975607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6976607dacd0Sqiaonuohanfi
6977607dacd0Sqiaonuohan
6978607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6979607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6980607dacd0Sqiaonuohanfi
6981607dacd0Sqiaonuohan
69826b383c08SPeter Wuif test "$bzip2" = "yes" ; then
69836b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
69846b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
69856b383c08SPeter Wufi
69866b383c08SPeter Wu
698783bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
698883bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
698983bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
699083bc1f97SJulio Faraccofi
699183bc1f97SJulio Faracco
6992c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6993d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
69946ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
69956ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6996c589b249SRonnie Sahlbergfi
6997c589b249SRonnie Sahlberg
69986542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
69994be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
70004be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
70016542aa9cSPeter Lievenfi
70026542aa9cSPeter Lieven
7003f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
7004f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
7005c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7006c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7007f794573eSEduardo Otubofi
7008f794573eSEduardo Otubo
700983fb7adfSbellard# XXX: suppress that
70107d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
70112358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
70127d3505c5Sbellardfi
70137d3505c5Sbellard
70144d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
70154d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
70164d9310f4SDaniel P. Berrangefi
70173556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
70183556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
70193556c233SPaolo Bonzinifi
7020f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
7021d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
70226ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
70236ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7024f27aaf4bSChristian Brunnerfi
702520ff6c80SAnthony Liguori
70267c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
702770c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
702870c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
702970c60c08SStefan Hajnoczielse
703070c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
703170c60c08SStefan Hajnoczifi
7032d0e2fce5SAneesh Kumar K.V
70337d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
70347d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
70357d992e4dSPeter Lievenfi
70367d992e4dSPeter Lieven
7037f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
7038f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
7039f0d92b56SLongpeng(Mike)fi
7040f0d92b56SLongpeng(Mike)
7041d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
7042d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7043d2042378SAneesh Kumar K.Vfi
7044d2042378SAneesh Kumar K.V
7045e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
7046e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7047e06a765eSHarsh Prateek Borafi
7048e06a765eSHarsh Prateek Bora
7049cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
7050cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
705106d71fa1SPeter Maydellfi
705206d71fa1SPeter Maydell
70533f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
70543f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
70553f4349dcSKevin Wolffi
70563f4349dcSKevin Wolf
7057d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
7058d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7059d83414e1SMarc-André Lureaufi
7060d83414e1SMarc-André Lureau
70618ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
70628ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
70638ab1bf12SLuiz Capitulinofi
70648ab1bf12SLuiz Capitulino
706576a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
706676a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
706776a347e1SRichard Hendersonfi
706876a347e1SRichard Henderson
7069f540166bSRichard Hendersonif test "$int128" = "yes" ; then
7070f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
7071f540166bSRichard Hendersonfi
7072f540166bSRichard Henderson
70737ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
70747ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
70757ebee43eSRichard Hendersonfi
70767ebee43eSRichard Henderson
7077e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
7078e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7079e6cd4bb5SRichard Hendersonfi
7080e6cd4bb5SRichard Henderson
7081df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
7082df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7083df79b996SRichard Hendersonfi
7084df79b996SRichard Henderson
7085db432672SRichard Hendersonif test "$vector16" = "yes" ; then
7086db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
7087db432672SRichard Hendersonfi
7088db432672SRichard Henderson
70891e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
70901e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
70911e6e9acaSRichard Hendersonfi
70921e6e9acaSRichard Henderson
7093eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
7094d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
70956ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
70966ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7097eb100396SBharata B Raofi
7098eb100396SBharata B Rao
7099d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
7100d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7101d85fa9ebSJeff Codyfi
7102d85fa9ebSJeff Cody
71030c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
71040c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
71050c14fb47SBharata B Raofi
71060c14fb47SBharata B Rao
7107df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
7108df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7109df3a429aSNiels de Vosfi
7110df3a429aSNiels de Vos
71117c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
71127c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
71137c815372SBharata B Raofi
71147c815372SBharata B Rao
7115e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7116e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7117e014dbe7SPrasanna Kumar Kaleverfi
7118e014dbe7SPrasanna Kumar Kalever
71190e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
71200e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
71210e3b891fSNiels de Vosfi
71220e3b891fSNiels de Vos
7123b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
7124b10d49d7SPino Toscano  echo "CONFIG_LIBSSH=m" >> $config_host_mak
7125b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7126b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
71270a12ec87SRichard W.M. Jonesfi
71280a12ec87SRichard W.M. Jones
7129ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
7130ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7131ed1701c6SDr. David Alan Gilbertfi
7132ed1701c6SDr. David Alan Gilbert
71333b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
71343cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
71353b8acc11SPaolo Bonzinifi
71363b8acc11SPaolo Bonzini
71375b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
71385b808275SLluís Vilanovaif have_backend "nop"; then
71396d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
714022890ab5SPrerna Saxenafi
71415b808275SLluís Vilanovaif have_backend "simple"; then
71426d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
71436d8a764eSLluís  # Set the appropriate trace file.
7144953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
71459410b56cSPrerna Saxenafi
7146ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7147ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
71486d8a764eSLluísfi
71495b808275SLluís Vilanovaif have_backend "ust"; then
71506d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
71516d8a764eSLluísfi
71525b808275SLluís Vilanovaif have_backend "dtrace"; then
71536d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
71546d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
71556d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
71566d8a764eSLluís  fi
7157c276b17dSDaniel P. Berrangefi
71585b808275SLluís Vilanovaif have_backend "ftrace"; then
7159781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7160781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7161781e9545SEiichi Tsukata  else
716221684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7163781e9545SEiichi Tsukata  fi
7164781e9545SEiichi Tsukatafi
71650a852417SPaul Durrantif have_backend "syslog"; then
71660a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
71670a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
71680a852417SPaul Durrant  else
71690a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
71700a852417SPaul Durrant  fi
71710a852417SPaul Durrantfi
71729410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
71739410b56cSPrerna Saxena
71742da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
71752da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7176392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
71772da776dbSMichael R. Hinesfi
71782da776dbSMichael R. Hines
717921ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
718021ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
718121ab34c9SMarcel Apfelbaumfi
718221ab34c9SMarcel Apfelbaum
7183575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7184575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7185575b22b1SLaurent Vivierfi
7186575b22b1SLaurent Vivier
7187ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7188ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7189ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7190ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7191ed279a06SKlim Kireevfi
7192ed279a06SKlim Kireev
7193a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7194a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7195a6b1d4c0SChanglong Xiefi
7196a6b1d4c0SChanglong Xie
71976a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
71986a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
71996a02c806SStefan Hajnoczifi
72006a02c806SStefan Hajnoczi
72014d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
72024d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
72034d04351fSChristopher Covingtonfi
72044d04351fSChristopher Covington
720549e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
720649e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
720749e00a18SAndreas Grapentinfi
720849e00a18SAndreas Grapentin
7209e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7210e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7211e674605fSTomáš Golembiovskýfi
7212db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
7213db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7214db1ed1abSRichard Hendersonfi
7215e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7216e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7217e0580342SKamil Rytarowskifi
7218e219c499SRichard Hendersonif test "$capstone" != "no" ; then
72198ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
72208ca80760SRichard Hendersonfi
7221ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7222ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7223ba59fb77SPaolo Bonzinifi
7224e0580342SKamil Rytarowski
72255c312079SDr. David Alan Gilbert# Hold two types of flag:
72265c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
72275c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7228479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
72295c312079SDr. David Alan Gilbert#                                     platform
7230479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
72315c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7232479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7233479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7234479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7235479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
72365c312079SDr. David Alan Gilbertfi
72375c312079SDr. David Alan Gilbert
7238da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
7239da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
7240da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
7241da92c3ffSAshish Mittalfi
7242da92c3ffSAshish Mittal
724317824406SJunyan Heif test "$libpmem" = "yes" ; then
724417824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
724517824406SJunyan Hefi
724617824406SJunyan He
72472f740136SJeff Codyif test "$bochs" = "yes" ; then
72482f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
72492f740136SJeff Codyfi
72502f740136SJeff Codyif test "$cloop" = "yes" ; then
72512f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
72522f740136SJeff Codyfi
72532f740136SJeff Codyif test "$dmg" = "yes" ; then
72542f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
72552f740136SJeff Codyfi
72562f740136SJeff Codyif test "$qcow1" = "yes" ; then
72572f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
72582f740136SJeff Codyfi
72592f740136SJeff Codyif test "$vdi" = "yes" ; then
72602f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
72612f740136SJeff Codyfi
72622f740136SJeff Codyif test "$vvfat" = "yes" ; then
72632f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
72642f740136SJeff Codyfi
72652f740136SJeff Codyif test "$qed" = "yes" ; then
72662f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
72672f740136SJeff Codyfi
72682f740136SJeff Codyif test "$parallels" = "yes" ; then
72692f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
72702f740136SJeff Codyfi
72712f740136SJeff Codyif test "$sheepdog" = "yes" ; then
72722f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
72732f740136SJeff Codyfi
72742f740136SJeff Cody
72755b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
72769edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
72775b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
72789edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
72795b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
72809edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7281e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
72829edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
728340d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
72849edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7285e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
7286c4f80543SAlistair Francis  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
72875b5e3037SPaolo Bonzinielse
72889edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
72895b5e3037SPaolo Bonzinifi
72909edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
72915b5e3037SPaolo Bonzini
729298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
729398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7294804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7295804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
72961901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
72971901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
72981901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
729921655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7300c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
7301406ab2f3SCleber Rosaecho "PYTHON2=$python2" >> $config_host_mak
7302804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7303a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7304a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
7305a31a8642SMichael S. Tsirkinfi
7306804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
730783f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
73083c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7309804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
731045d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7311cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
73125f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
73133dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7314804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7315804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
73169f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
73174852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
7318daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
73199fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7320e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
732146eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7322a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
732311cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7324f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7325e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7326e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
732780fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
73282944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
7329e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
7330e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7331e39f0062SPaolo Bonzinifi
7332e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
733346eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
73348a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
73356969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7336e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
733773da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
73383e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7339409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7340804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
734117969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
734217969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7343957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
734490246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
734590246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
734694dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
73471d728c39SBlue Swirlif test "$gcov" = "yes" ; then
73481d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
73491d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
73501d728c39SBlue Swirlfi
7351804edf29SJuan Quintela
73523efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
73533efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
73543efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
73553efac6ebSTomáš Golembiovskýfi
73563efac6ebSTomáš Golembiovský
73576efd7517SPeter Maydell# use included Linux headers
73586efd7517SPeter Maydellif test "$linux" = "yes" ; then
7359a307beb6SAndreas Färber  mkdir -p linux-headers
73606efd7517SPeter Maydell  case "$cpu" in
7361c72b26ecSRichard Henderson  i386|x86_64|x32)
736208312a63SPeter Maydell    linux_arch=x86
73636efd7517SPeter Maydell    ;;
7364f8378accSRichard Henderson  ppc|ppc64|ppc64le)
736508312a63SPeter Maydell    linux_arch=powerpc
73666efd7517SPeter Maydell    ;;
73676efd7517SPeter Maydell  s390x)
736808312a63SPeter Maydell    linux_arch=s390
736908312a63SPeter Maydell    ;;
73701f080313SClaudio Fontana  aarch64)
73711f080313SClaudio Fontana    linux_arch=arm64
73721f080313SClaudio Fontana    ;;
7373222e7d11SSanjay Lal  mips64)
7374222e7d11SSanjay Lal    linux_arch=mips
7375222e7d11SSanjay Lal    ;;
737608312a63SPeter Maydell  *)
737708312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
737808312a63SPeter Maydell    linux_arch="$cpu"
73796efd7517SPeter Maydell    ;;
73806efd7517SPeter Maydell  esac
738108312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
738208312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
738308312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
738408312a63SPeter Maydell    fi
73856efd7517SPeter Maydellfi
73866efd7517SPeter Maydell
738797a847bcSbellardfor target in $target_list; do
738897a847bcSbellardtarget_dir="$target"
738925be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
739089138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
739152bf9771Stony.nguyen@bt.comtarget_aligned_only="no"
739252bf9771Stony.nguyen@bt.comcase "$target_name" in
739352bf9771Stony.nguyen@bt.com  alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
739452bf9771Stony.nguyen@bt.com  target_aligned_only="yes"
739552bf9771Stony.nguyen@bt.com  ;;
739652bf9771Stony.nguyen@bt.comesac
739797a847bcSbellardtarget_bigendian="no"
7398c1799a84SPaolo Bonzinicase "$target_name" in
7399a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
740052bf9771Stony.nguyen@bt.com  target_bigendian="yes"
7401ea2d6a39SJuan Quintela  ;;
7402ea2d6a39SJuan Quintelaesac
740397a847bcSbellardtarget_softmmu="no"
7404997344f3Sbellardtarget_user_only="no"
7405831b7825Sthstarget_linux_user="no"
740684778508Sblueswir1target_bsd_user="no"
74079e407a85Spbrookcase "$target" in
7408c1799a84SPaolo Bonzini  ${target_name}-softmmu)
74099e407a85Spbrook    target_softmmu="yes"
74109e407a85Spbrook    ;;
7411c1799a84SPaolo Bonzini  ${target_name}-linux-user)
74129e407a85Spbrook    target_user_only="yes"
74139e407a85Spbrook    target_linux_user="yes"
74149e407a85Spbrook    ;;
7415c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
741684778508Sblueswir1    target_user_only="yes"
741784778508Sblueswir1    target_bsd_user="yes"
741884778508Sblueswir1    ;;
74199e407a85Spbrook  *)
742076ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
74219e407a85Spbrook    exit 1
74229e407a85Spbrook    ;;
74239e407a85Spbrookesac
7424831b7825Sths
742597a847bcSbellardmkdir -p $target_dir
742625be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
742797a847bcSbellard
7428e5fe0c52Spbrookbflt="no"
7429ca759f9eSAlex Bennéemttcg="no"
743089138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
743156aebc89Spbrookgdb_xml_files=""
74327ba1e619Saliguori
7433c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
74346acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7435e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
7436e73aae67SJuan Quintela
7437c1799a84SPaolo Bonzinicase "$target_name" in
74382408a527Saurel32  i386)
74390a7fa00aSEmilio G. Cota    mttcg="yes"
74407b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
74412408a527Saurel32  ;;
74422408a527Saurel32  x86_64)
74436acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
74440a7fa00aSEmilio G. Cota    mttcg="yes"
74457b0f97baSDoug Gale	gdb_xml_files="i386-64bit.xml"
74462408a527Saurel32  ;;
74472408a527Saurel32  alpha)
74485ee4f3c2SRichard Henderson    mttcg="yes"
74492408a527Saurel32  ;;
74502408a527Saurel32  arm|armeb)
7451b498c8a0SJuan Quintela    TARGET_ARCH=arm
7452e5fe0c52Spbrook    bflt="yes"
7453ca759f9eSAlex Bennée    mttcg="yes"
745456aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
74552408a527Saurel32  ;;
7456722dd7beSMichael Weiser  aarch64|aarch64_be)
7457722dd7beSMichael Weiser    TARGET_ARCH=aarch64
74586a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
74596a49fa95SAlexander Graf    bflt="yes"
7460ca759f9eSAlex Bennée    mttcg="yes"
74618f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
74626a49fa95SAlexander Graf  ;;
74632408a527Saurel32  cris)
74642408a527Saurel32  ;;
746561766fe9SRichard Henderson  hppa)
74667b93dab5SRichard Henderson    mttcg="yes"
746761766fe9SRichard Henderson  ;;
7468613a22c9SMichael Walle  lm32)
7469613a22c9SMichael Walle  ;;
74702408a527Saurel32  m68k)
74710938cda5Saurel32    bflt="yes"
74725a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
74732408a527Saurel32  ;;
7474877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7475877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
747672b675caSEdgar E. Iglesias    bflt="yes"
7477be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
747872b675caSEdgar E. Iglesias  ;;
74792408a527Saurel32  mips|mipsel)
74800454728cSAleksandar Markovic    mttcg="yes"
7481b498c8a0SJuan Quintela    TARGET_ARCH=mips
748225be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
74832408a527Saurel32  ;;
74842408a527Saurel32  mipsn32|mipsn32el)
74850454728cSAleksandar Markovic    mttcg="yes"
7486597e2cecSRichard Henderson    TARGET_ARCH=mips64
74876acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
748825be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7489597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
74902408a527Saurel32  ;;
74912408a527Saurel32  mips64|mips64el)
74920454728cSAleksandar Markovic    mttcg="yes"
7493b498c8a0SJuan Quintela    TARGET_ARCH=mips64
74946acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
749525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
74962408a527Saurel32  ;;
7497d15a9c23SAnthony Green  moxie)
7498d15a9c23SAnthony Green  ;;
7499e671711cSMarek Vasut  nios2)
7500e671711cSMarek Vasut  ;;
75014a09d0bbSRichard Henderson  or1k)
7502e67db06eSJia Liu    TARGET_ARCH=openrisc
7503e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7504e67db06eSJia Liu  ;;
75052408a527Saurel32  ppc)
7506c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
75072408a527Saurel32  ;;
75082408a527Saurel32  ppc64)
75096acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7510e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
7511f0b0685dSNikunj A Dadhania    mttcg=yes
75121438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
75132408a527Saurel32  ;;
75149c35126cSDoug Kwan  ppc64le)
75159c35126cSDoug Kwan    TARGET_ARCH=ppc64
75169c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
75179c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
7518f0b0685dSNikunj A Dadhania    mttcg=yes
75191438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
75209c35126cSDoug Kwan  ;;
75212408a527Saurel32  ppc64abi32)
7522b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
75236acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7524e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
752525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
75261438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
75272408a527Saurel32  ;;
752825fa194bSMichael Clark  riscv32)
752925fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
753025fa194bSMichael Clark    TARGET_ABI_DIR=riscv
753125fa194bSMichael Clark    mttcg=yes
75321a987a1dSJim Wilson    gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-32bit-csr.xml"
753325fa194bSMichael Clark  ;;
753425fa194bSMichael Clark  riscv64)
753525fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
753625fa194bSMichael Clark    TARGET_ABI_DIR=riscv
753725fa194bSMichael Clark    mttcg=yes
7538c670970dSJim Wilson    gdb_xml_files="riscv-64bit-cpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml"
753925fa194bSMichael Clark  ;;
75402408a527Saurel32  sh4|sh4eb)
7541b498c8a0SJuan Quintela    TARGET_ARCH=sh4
75424dbed897Spbrook    bflt="yes"
75432408a527Saurel32  ;;
75442408a527Saurel32  sparc)
75452408a527Saurel32  ;;
75462408a527Saurel32  sparc64)
75476acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
75482408a527Saurel32  ;;
75492408a527Saurel32  sparc32plus)
7550b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
75516acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7552e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
755325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
75542408a527Saurel32  ;;
755524e804ecSAlexander Graf  s390x)
755663685bc4SDavid Hildenbrand    mttcg=yes
755786158a2aSChristian 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"
755824e804ecSAlexander Graf  ;;
7559444e06b1SChen Gang  tilegx)
7560444e06b1SChen Gang  ;;
75615ecaa4edSPeter Crosthwaite  tricore)
75625ecaa4edSPeter Crosthwaite  ;;
7563d2fbca94SGuan Xuetao  unicore32)
7564d2fbca94SGuan Xuetao  ;;
7565cfa550c6SMax Filippov  xtensa|xtensaeb)
7566cfa550c6SMax Filippov    TARGET_ARCH=xtensa
756702e33e9fSMax Filippov    bflt="yes"
75689fb40342SMax Filippov    mttcg="yes"
7569cfa550c6SMax Filippov  ;;
75702408a527Saurel32  *)
757176ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
75722408a527Saurel32  ;;
75732408a527Saurel32esac
75745e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
75755e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
75765e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
75775e8861a0SPaolo Bonzinifi
75785e8861a0SPaolo Bonzini
75795e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
75805e8861a0SPaolo Bonzini
758199afc91dSDaniel P. Berrangeupper() {
758299afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
758399afc91dSDaniel P. Berrange}
758499afc91dSDaniel P. Berrange
758589138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
758625be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7587c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
758825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7589e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7590e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7591e6e91b9cSJuan Quintelafi
759225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7593adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7594adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7595adfc3e91SStacey Sonfi
75963b6b7550SPaolo Bonzini
75973b6b7550SPaolo Bonziniif supported_xen_target $target; then
759825be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7599e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
7600eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7601eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7602eb6fda0fSAnthony PERARD    fi
7603e0e312f3SPaolo Bonzinielse
7604e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
7605432d268cSJun Nakajimafi
76063b6b7550SPaolo Bonziniif supported_kvm_target $target; then
760725be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
7608e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
7609e0e312f3SPaolo Bonzinielse
7610e0e312f3SPaolo Bonzini    echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
7611c59249f9SJuan Quintelafi
76123b6b7550SPaolo Bonziniif supported_hax_target $target; then
7613b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7614b0cb0a66SVincent Palatinfi
7615c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7616c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7617c97d6d2cSSergio Andres Gomez Del Realfi
7618d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7619d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7620d661d9a4SJustin Terry (VM)fi
762152bf9771Stony.nguyen@bt.comif test "$target_aligned_only" = "yes" ; then
762252bf9771Stony.nguyen@bt.com  echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
762352bf9771Stony.nguyen@bt.comfi
7624de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
762525be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
762697a847bcSbellardfi
762797a847bcSbellardif test "$target_softmmu" = "yes" ; then
762825be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7629ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7630ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7631ca759f9eSAlex Bennée  fi
7632de83cd02Sbellardfi
7633997344f3Sbellardif test "$target_user_only" = "yes" ; then
763425be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7635a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7636997344f3Sbellardfi
7637831b7825Sthsif test "$target_linux_user" = "yes" ; then
763825be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7639831b7825Sthsfi
764056aebc89Spbrooklist=""
764156aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
764256aebc89Spbrook  for x in $gdb_xml_files; do
764356aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
764456aebc89Spbrook  done
764525be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
76463d0f1517SJuan Quintelafi
7647de83cd02Sbellard
7648e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
764925be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7650e5fe0c52Spbrookfi
765184778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
765225be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
765384778508Sblueswir1fi
76545b0753e0Sbellard
7655d75402b5SAlex Bennée
76564afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7657fa282484SJuan Quintela
76584afddb55SJuan Quintelacflags=""
7659fa282484SJuan Quintelaldflags=""
76609b8e111fSJuan Quintela
7661c765fcacSPeter Crosthwaitedisas_config() {
7662c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7663c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7664c765fcacSPeter Crosthwaite}
7665c765fcacSPeter Crosthwaite
766664656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
766764656024SJuan Quintela  case "$i" in
766864656024SJuan Quintela  alpha)
7669c765fcacSPeter Crosthwaite    disas_config "ALPHA"
767064656024SJuan Quintela  ;;
767182295d8aSRichard Henderson  aarch64)
767282295d8aSRichard Henderson    if test -n "${cxx}"; then
7673c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
767482295d8aSRichard Henderson    fi
767582295d8aSRichard Henderson  ;;
767664656024SJuan Quintela  arm)
7677c765fcacSPeter Crosthwaite    disas_config "ARM"
7678999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7679c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7680999b53ecSClaudio Fontana    fi
768164656024SJuan Quintela  ;;
768264656024SJuan Quintela  cris)
7683c765fcacSPeter Crosthwaite    disas_config "CRIS"
768464656024SJuan Quintela  ;;
7685429b31a2SRichard Henderson  hppa)
7686429b31a2SRichard Henderson    disas_config "HPPA"
7687429b31a2SRichard Henderson  ;;
7688c72b26ecSRichard Henderson  i386|x86_64|x32)
7689c765fcacSPeter Crosthwaite    disas_config "I386"
769064656024SJuan Quintela  ;;
769179368f49SMichael Walle  lm32)
7692c765fcacSPeter Crosthwaite    disas_config "LM32"
769379368f49SMichael Walle  ;;
769464656024SJuan Quintela  m68k)
7695c765fcacSPeter Crosthwaite    disas_config "M68K"
769664656024SJuan Quintela  ;;
7697877fdc12SEdgar E. Iglesias  microblaze*)
7698c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
769964656024SJuan Quintela  ;;
770064656024SJuan Quintela  mips*)
7701c765fcacSPeter Crosthwaite    disas_config "MIPS"
770289a955e8SAleksandar Markovic    if test -n "${cxx}"; then
770389a955e8SAleksandar Markovic      disas_config "NANOMIPS"
770489a955e8SAleksandar Markovic    fi
770564656024SJuan Quintela  ;;
7706d15a9c23SAnthony Green  moxie*)
7707c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7708d15a9c23SAnthony Green  ;;
7709e671711cSMarek Vasut  nios2)
7710e671711cSMarek Vasut    disas_config "NIOS2"
7711e671711cSMarek Vasut  ;;
77124a09d0bbSRichard Henderson  or1k)
7713c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7714e67db06eSJia Liu  ;;
771564656024SJuan Quintela  ppc*)
7716c765fcacSPeter Crosthwaite    disas_config "PPC"
771764656024SJuan Quintela  ;;
7718c4f80543SAlistair Francis  riscv*)
771925fa194bSMichael Clark    disas_config "RISCV"
772025fa194bSMichael Clark  ;;
772124e804ecSAlexander Graf  s390*)
7722c765fcacSPeter Crosthwaite    disas_config "S390"
772364656024SJuan Quintela  ;;
772464656024SJuan Quintela  sh4)
7725c765fcacSPeter Crosthwaite    disas_config "SH4"
772664656024SJuan Quintela  ;;
772764656024SJuan Quintela  sparc*)
7728c765fcacSPeter Crosthwaite    disas_config "SPARC"
772964656024SJuan Quintela  ;;
7730cfa550c6SMax Filippov  xtensa*)
7731c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7732cfa550c6SMax Filippov  ;;
773364656024SJuan Quintela  esac
773464656024SJuan Quinteladone
77359195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7736c765fcacSPeter Crosthwaite  disas_config "TCI"
77379195b2c2SStefan Weilfi
773864656024SJuan Quintela
77396ee7126fSJuan Quintelacase "$ARCH" in
77406ee7126fSJuan Quintelaalpha)
77416ee7126fSJuan Quintela  # Ensure there's only a single GP
77426ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
77436ee7126fSJuan Quintela;;
77446ee7126fSJuan Quintelaesac
77456ee7126fSJuan Quintela
7746d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
77470acf7dedSPhilippe Mathieu-Daudé  echo "TARGET_GPROF=y" >> $config_target_mak
7748d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7749d02c1db3SJuan Quintela    cflags="-p $cflags"
7750d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7751d02c1db3SJuan Quintela  fi
7752d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7753d02c1db3SJuan Quintela    ldflags="-p $ldflags"
775425be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7755d02c1db3SJuan Quintela  fi
7756d02c1db3SJuan Quintelafi
7757d02c1db3SJuan Quintela
7758e633a5c6SEric Blakeif test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
7759964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7760fa282484SJuan Quintelafi
7761fa282484SJuan Quintela
7762e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7763e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7764e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7765e9a3591fSChristian Borntraeger# header if
7766e9a3591fSChristian Borntraeger#  - we build on s390x
7767e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7768e9a3591fSChristian Borntraeger#  - KVM is enabled
7769e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7770e633a5c6SEric Blakeif test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
7771e633a5c6SEric Blake        test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
7772e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7773e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7774e9a3591fSChristian Borntraeger    fi
7775e9a3591fSChristian Borntraegerfi
7776e9a3591fSChristian Borntraeger
777725be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
777825be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7779fa282484SJuan Quintela
778097a847bcSbellarddone # for target in $targets
77817d13299dSbellard
7782d52c454aSMarc-André Lureauecho "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
7783d52c454aSMarc-André Lureauecho "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
7784d52c454aSMarc-André Lureau
7785e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
77863b8593eeSMarkus Armbruster  echo "config-host.h: dtc/all" >> $config_host_mak
7787a540f158SPeter Crosthwaitefi
7788e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
77893b8593eeSMarkus Armbruster  echo "config-host.h: capstone/all" >> $config_host_mak
7790e219c499SRichard Hendersonfi
7791e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7792e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7793e219c499SRichard Hendersonfi
7794a540f158SPeter Crosthwaite
7795a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7796a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7797a99d57bbSWanlong Gaofi
7798a99d57bbSWanlong Gao
7799fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7800fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7801fd0e6053SJohn Snowfi
7802fd0e6053SJohn Snow
7803e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
7804e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
7805e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
7806e29e5c6eSPeter Maydell# (these can be both files and directories).
7807e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
7808e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
7809e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
7810e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
7811e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
7812e29e5c6eSPeter Maydell# directory and symlink the directory instead.
78132038f8c8SPaolo BonziniDIRS="tests tests/tcg tests/tcg/lm32 tests/libqos tests/qapi-schema tests/qemu-iotests tests/vm"
7814fc281c80SEmanuele Giuseppe EspositoDIRS="$DIRS tests/fp tests/qgraph"
7815b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
78169933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
78172d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
78182038f8c8SPaolo BonziniLINKS="Makefile"
78192038f8c8SPaolo BonziniLINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
78202038f8c8SPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
7821e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7822e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/spapr-rtas/Makefile"
7823e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
7824e29e5c6eSPeter MaydellLINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7825e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
7826e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
782739950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
782839950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
78298f8fd9edSCleber RosaLINKS="$LINKS python"
7830753d11f2SRichard Hendersonfor bios_file in \
7831753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7832225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
7833753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7834753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7835e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7836753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
78374e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
783826ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
7839753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7840753d11f2SRichard Hendersondo
7841e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
78427ea78b74SJan Kiszkadone
7843d1807a4fSPaolo Bonzinimkdir -p $DIRS
7844e29e5c6eSPeter Maydellfor f in $LINKS ; do
7845cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7846f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7847f9245e10SPeter Maydell    fi
78487d13299dSbellarddone
78491ad2134fSPaul Brook
78502038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
78512038f8c8SPaolo Bonzini  export $i
78522038f8c8SPaolo Bonzinidone
78532038f8c8SPaolo Bonziniexport target_list source_path
78542038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
78552038f8c8SPaolo Bonzini
7856c34ebfdcSAnthony Liguori# temporary config to build submodules
78572d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
7858c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
785937116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7860c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7861cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
78625f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7863c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7864c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
78653dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7866c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7867a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7868c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
78699f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7870c34ebfdcSAnthony Liguoridone
7871c34ebfdcSAnthony Liguori
787276c7560aSMax Reitz# set up qemu-iotests in this build directory
787376c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
787476c7560aSMax Reitz
787576c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
787676c7560aSMax Reitzecho >> "$iotests_common_env"
787776c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
787876c7560aSMax Reitz
7879dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7880dc655404SMichael S. Tsirkincat <<EOD >config.status
7881dc655404SMichael S. Tsirkin#!/bin/sh
7882dc655404SMichael S. Tsirkin# Generated by configure.
7883dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7884dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7885dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7886dc655404SMichael S. TsirkinEOD
7887e811da7fSDaniel P. Berrangé
7888e811da7fSDaniel P. Berrangépreserve_env() {
7889e811da7fSDaniel P. Berrangé    envname=$1
7890e811da7fSDaniel P. Berrangé
7891e811da7fSDaniel P. Berrangé    eval envval=\$$envname
7892e811da7fSDaniel P. Berrangé
7893e811da7fSDaniel P. Berrangé    if test -n "$envval"
7894e811da7fSDaniel P. Berrangé    then
7895e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
7896e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
7897e811da7fSDaniel P. Berrangé    else
7898e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
7899e811da7fSDaniel P. Berrangé    fi
7900e811da7fSDaniel P. Berrangé}
7901e811da7fSDaniel P. Berrangé
7902e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
7903e811da7fSDaniel P. Berrangé# features/build target configure will detect
7904e811da7fSDaniel P. Berrangépreserve_env AR
7905e811da7fSDaniel P. Berrangépreserve_env AS
7906e811da7fSDaniel P. Berrangépreserve_env CC
7907e811da7fSDaniel P. Berrangépreserve_env CPP
7908e811da7fSDaniel P. Berrangépreserve_env CXX
7909e811da7fSDaniel P. Berrangépreserve_env INSTALL
7910e811da7fSDaniel P. Berrangépreserve_env LD
7911e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
7912e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
7913e811da7fSDaniel P. Berrangépreserve_env MAKE
7914e811da7fSDaniel P. Berrangépreserve_env NM
7915e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
7916e811da7fSDaniel P. Berrangépreserve_env PATH
7917e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
7918e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
7919e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
7920e811da7fSDaniel P. Berrangépreserve_env PYTHON
7921e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
7922e811da7fSDaniel P. Berrangépreserve_env SMBD
7923e811da7fSDaniel P. Berrangépreserve_env STRIP
7924e811da7fSDaniel P. Berrangépreserve_env WINDRES
7925e811da7fSDaniel P. Berrangé
7926dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7927dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
7928cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7929dc655404SMichael S. Tsirkinchmod +x config.status
7930dc655404SMichael S. Tsirkin
79318cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7932