xref: /openbmc/qemu/configure (revision d75402b5)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
148cd05ab6SPeter Maydell# Temporary directory used for files created while
158cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
168cd05ab6SPeter Maydell# we can safely blow away any previous version of it
178cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
188cd05ab6SPeter Maydell# it when configure exits.)
198cd05ab6SPeter MaydellTMPDIR1="config-temp"
208cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
218cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
228cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
238cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
248cd05ab6SPeter Maydell    exit 1
257d13299dSbellardfi
267d13299dSbellard
278cd05ab6SPeter MaydellTMPB="qemu-conf"
288cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
2966518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
309c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
318cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
326969ec6cSJames ClarkeTMPMO="${TMPDIR1}/${TMPB}.mo"
337d13299dSbellard
34da1d85e3SGerd Hoffmannrm -f config.log
359ac81bbbSmalc
36b48e3611SPeter Maydell# Print a helpful header at the top of config.log
37b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
38979ae168SPeter Maydellprintf "# Configured with:" >> config.log
39979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
40979ae168SPeter Maydellecho >> config.log
41b48e3611SPeter Maydellecho "#" >> config.log
42b48e3611SPeter Maydell
43d880a3baSPaolo Bonziniprint_error() {
44d880a3baSPaolo Bonzini    (echo
4576ad07a4SPeter Maydell    echo "ERROR: $1"
4676ad07a4SPeter Maydell    while test -n "$2"; do
4776ad07a4SPeter Maydell        echo "       $2"
4876ad07a4SPeter Maydell        shift
4976ad07a4SPeter Maydell    done
50d880a3baSPaolo Bonzini    echo) >&2
51d880a3baSPaolo Bonzini}
52d880a3baSPaolo Bonzini
53d880a3baSPaolo Bonzinierror_exit() {
54d880a3baSPaolo Bonzini    print_error "$@"
5576ad07a4SPeter Maydell    exit 1
5676ad07a4SPeter Maydell}
5776ad07a4SPeter Maydell
589c83ffd8SPeter Maydelldo_compiler() {
599c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
609c83ffd8SPeter Maydell    # is compiler binary to execute.
619c83ffd8SPeter Maydell    local compiler="$1"
629c83ffd8SPeter Maydell    shift
638bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
648bbe05d7SIan Jackson        echo >>config.log "
658bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
668bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
678bbe05d7SIan Jackson    '; fi
689c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
699c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
708dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
718dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
728dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
738dc38a78SPeter Maydell    # obvious to developers.
748dc38a78SPeter Maydell    if test "$werror" != "yes"; then
758dc38a78SPeter Maydell        return 0
768dc38a78SPeter Maydell    fi
778dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
788dc38a78SPeter Maydell    case "$*" in
798dc38a78SPeter Maydell        *-Werror*)
808dc38a78SPeter Maydell           return 0
818dc38a78SPeter Maydell        ;;
828dc38a78SPeter Maydell    esac
839c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
849c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
8576ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
8676ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8776ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8876ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
898dc38a78SPeter Maydell}
908dc38a78SPeter Maydell
919c83ffd8SPeter Maydelldo_cc() {
929c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
939c83ffd8SPeter Maydell}
949c83ffd8SPeter Maydell
959c83ffd8SPeter Maydelldo_cxx() {
969c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
979c83ffd8SPeter Maydell}
989c83ffd8SPeter Maydell
999c83ffd8SPeter Maydellupdate_cxxflags() {
1009c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1019c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1029c83ffd8SPeter Maydell    # because they only make sense for C programs.
10311cde1c8SBruno Dominguez    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
10411cde1c8SBruno Dominguez
1059c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1069c83ffd8SPeter Maydell        case $arg in
1079c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1089c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1099c83ffd8SPeter Maydell                ;;
1109c83ffd8SPeter Maydell            *)
1119c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1129c83ffd8SPeter Maydell                ;;
1139c83ffd8SPeter Maydell        esac
1149c83ffd8SPeter Maydell    done
1159c83ffd8SPeter Maydell}
1169c83ffd8SPeter Maydell
11752166aa0SJuan Quintelacompile_object() {
118fd0e6053SJohn Snow  local_cflags="$1"
119fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
12052166aa0SJuan Quintela}
12152166aa0SJuan Quintela
12252166aa0SJuan Quintelacompile_prog() {
12352166aa0SJuan Quintela  local_cflags="$1"
12452166aa0SJuan Quintela  local_ldflags="$2"
1258dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
12652166aa0SJuan Quintela}
12752166aa0SJuan Quintela
12811568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
12911568d6dSPaolo Bonzinisymlink() {
13072b8b5a1SStefan Weil  rm -rf "$2"
131ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
13272b8b5a1SStefan Weil  ln -s "$1" "$2"
13311568d6dSPaolo Bonzini}
13411568d6dSPaolo Bonzini
1350dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1360dba6195SLoïc Minier# executable or a builtin)
1370dba6195SLoïc Minierhas() {
1380dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1390dba6195SLoïc Minier}
1400dba6195SLoïc Minier
1410dba6195SLoïc Minier# search for an executable in PATH
1420dba6195SLoïc Minierpath_of() {
1430dba6195SLoïc Minier    local_command="$1"
1440dba6195SLoïc Minier    local_ifs="$IFS"
1450dba6195SLoïc Minier    local_dir=""
1460dba6195SLoïc Minier
1470dba6195SLoïc Minier    # pathname has a dir component?
1480dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1490dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1500dba6195SLoïc Minier            echo "$local_command"
1510dba6195SLoïc Minier            return 0
1520dba6195SLoïc Minier        fi
1530dba6195SLoïc Minier    fi
1540dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1550dba6195SLoïc Minier        return 1
1560dba6195SLoïc Minier    fi
1570dba6195SLoïc Minier
1580dba6195SLoïc Minier    IFS=:
1590dba6195SLoïc Minier    for local_dir in $PATH; do
1600dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1610dba6195SLoïc Minier            echo "$local_dir/$local_command"
1620dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1630dba6195SLoïc Minier            return 0
1640dba6195SLoïc Minier        fi
1650dba6195SLoïc Minier    done
1660dba6195SLoïc Minier    # not found
1670dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1680dba6195SLoïc Minier    return 1
1690dba6195SLoïc Minier}
1700dba6195SLoïc Minier
1715b808275SLluís Vilanovahave_backend () {
1725b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1735b808275SLluís Vilanova}
1745b808275SLluís Vilanova
1753b6b7550SPaolo Bonziniglob() {
1763b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1773b6b7550SPaolo Bonzini}
1783b6b7550SPaolo Bonzini
1793b6b7550SPaolo Bonzinisupported_hax_target() {
1803b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1813b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1823b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1833b6b7550SPaolo Bonzini        i386|x86_64)
1843b6b7550SPaolo Bonzini            return 0
1853b6b7550SPaolo Bonzini        ;;
1863b6b7550SPaolo Bonzini    esac
1873b6b7550SPaolo Bonzini    return 1
1883b6b7550SPaolo Bonzini}
1893b6b7550SPaolo Bonzini
1903b6b7550SPaolo Bonzinisupported_kvm_target() {
1913b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1923b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1933b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1943b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1953b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
1963b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
1973b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
1983b6b7550SPaolo Bonzini        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
1993b6b7550SPaolo Bonzini        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
2003b6b7550SPaolo Bonzini        s390x:s390x)
2013b6b7550SPaolo Bonzini            return 0
2023b6b7550SPaolo Bonzini        ;;
2033b6b7550SPaolo Bonzini    esac
2043b6b7550SPaolo Bonzini    return 1
2053b6b7550SPaolo Bonzini}
2063b6b7550SPaolo Bonzini
2073b6b7550SPaolo Bonzinisupported_xen_target() {
2083b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2093b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
210b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
211b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
212b5ed2e11SPaolo Bonzini        i386|x86_64)
2133b6b7550SPaolo Bonzini            return 0
2143b6b7550SPaolo Bonzini        ;;
2153b6b7550SPaolo Bonzini    esac
2163b6b7550SPaolo Bonzini    return 1
2173b6b7550SPaolo Bonzini}
2183b6b7550SPaolo Bonzini
219c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
220c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
221c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
222c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
223c97d6d2cSSergio Andres Gomez Del Real        x86_64)
224c97d6d2cSSergio Andres Gomez Del Real            return 0
225c97d6d2cSSergio Andres Gomez Del Real        ;;
226c97d6d2cSSergio Andres Gomez Del Real    esac
227c97d6d2cSSergio Andres Gomez Del Real    return 1
228c97d6d2cSSergio Andres Gomez Del Real}
229c97d6d2cSSergio Andres Gomez Del Real
230d661d9a4SJustin Terry (VM)supported_whpx_target() {
231d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
232d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
233d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
234d661d9a4SJustin Terry (VM)        i386|x86_64)
235d661d9a4SJustin Terry (VM)            return 0
236d661d9a4SJustin Terry (VM)        ;;
237d661d9a4SJustin Terry (VM)    esac
238d661d9a4SJustin Terry (VM)    return 1
239d661d9a4SJustin Terry (VM)}
240d661d9a4SJustin Terry (VM)
241d880a3baSPaolo Bonzinisupported_target() {
242d880a3baSPaolo Bonzini    case "$1" in
243d880a3baSPaolo Bonzini        *-softmmu)
244d880a3baSPaolo Bonzini            ;;
245d880a3baSPaolo Bonzini        *-linux-user)
246d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
247d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
248d880a3baSPaolo Bonzini                return 1
249d880a3baSPaolo Bonzini            fi
250d880a3baSPaolo Bonzini            ;;
251d880a3baSPaolo Bonzini        *-bsd-user)
252d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
253d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
254d880a3baSPaolo Bonzini                return 1
255d880a3baSPaolo Bonzini            fi
256d880a3baSPaolo Bonzini            ;;
257d880a3baSPaolo Bonzini        *)
258d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
259d880a3baSPaolo Bonzini            return 1
260d880a3baSPaolo Bonzini            ;;
261d880a3baSPaolo Bonzini    esac
262b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
263b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
264b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
265b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
266c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
267d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
268b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
269b3f6ea7eSPaolo Bonzini    return 1
270d880a3baSPaolo Bonzini}
271d880a3baSPaolo Bonzini
272e9a3591fSChristian Borntraeger
273e9a3591fSChristian Borntraegerld_has() {
274e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
275e9a3591fSChristian Borntraeger}
276e9a3591fSChristian Borntraeger
2777d13299dSbellard# default parameters
27889138857SStefan Weilsource_path=$(dirname "$0")
2792ff6b91eSJuan Quintelacpu=""
280a31a8642SMichael S. Tsirkiniasl="iasl"
2811e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
28243ce4dfeSbellardstatic="no"
2837d13299dSbellardcross_prefix=""
2840c58ac1cSmalcaudio_drv_list=""
285b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
286b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
287e49d021eSPeter Maydellhost_cc="cc"
28873da375eSJuan Quintelalibs_softmmu=""
2893e2e0e6bSJuan Quintelalibs_tools=""
29067f86e8eSJuan Quintelaaudio_pt_int=""
291d5631638Smalcaudio_win_int=""
2922b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
293957f1f99SMichael Rothlibs_qga=""
2945bc62e01SGerd Hoffmanndebug_info="yes"
29563678e17SSteven Noonanstack_protector=""
296ac0df51dSaliguori
29792712822SDaniel P. Berrangeif test -e "$source_path/.git"
29892712822SDaniel P. Berrangethen
299f62bbee5SDaniel P. Berrange    git_update=yes
30092712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
30192712822SDaniel P. Berrangeelse
302f62bbee5SDaniel P. Berrange    git_update=no
303aef45d51SDaniel P. Berrange    git_submodules=""
30492712822SDaniel P. Berrangefi
305cc84d63aSDaniel P. Berrangegit="git"
306ac0df51dSaliguori
307afb63ebdSStefan Weil# Don't accept a target_list environment variable.
308afb63ebdSStefan Weilunset target_list
309377529c0SPaolo Bonzini
310377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
311377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
312377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
313377529c0SPaolo Bonzini#              unless --disable-foo is given
314377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
315377529c0SPaolo Bonzini#              feature will searched for,
316377529c0SPaolo Bonzini#              if not found, configure exits with error
317377529c0SPaolo Bonzini#
318377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
319377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
320377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
321377529c0SPaolo Bonzini
322377529c0SPaolo Bonzinibluez=""
323377529c0SPaolo Bonzinibrlapi=""
324377529c0SPaolo Bonzinicurl=""
325377529c0SPaolo Bonzinicurses=""
326377529c0SPaolo Bonzinidocs=""
327377529c0SPaolo Bonzinifdt=""
32858952137SVincenzo Maffionenetmap="no"
329377529c0SPaolo Bonzinisdl=""
330ee8466d0SCole Robinsonsdlabi=""
331983eef5aSMeador Ingevirtfs=""
332fe8fc5aeSPaolo Bonzinimpath=""
333821601eaSJes Sorensenvnc="yes"
334377529c0SPaolo Bonzinisparse="no"
335377529c0SPaolo Bonzinivde=""
336377529c0SPaolo Bonzinivnc_sasl=""
337377529c0SPaolo Bonzinivnc_jpeg=""
338377529c0SPaolo Bonzinivnc_png=""
3396a021536SGerd Hoffmannxkbcommon=""
340377529c0SPaolo Bonzinixen=""
341d5b93ddfSAnthony PERARDxen_ctrl_version=""
34264a7ad6fSIan Campbellxen_pv_domain_build="no"
343eb6fda0fSAnthony PERARDxen_pci_passthrough=""
344377529c0SPaolo Bonzinilinux_aio=""
34547e98658SCorey Bryantcap_ng=""
346377529c0SPaolo Bonziniattr=""
3474f26f2b6SAvi Kivitylibattr=""
348377529c0SPaolo Bonzinixfs=""
349b3f6ea7eSPaolo Bonzinitcg="yes"
350a40161cbSPaolo Bonzinimembarrier=""
351d41a75a2SBradvhost_net="no"
352042cea27SGongleivhost_crypto="no"
3535e9be92dSNicholas Bellingervhost_scsi="no"
354fc0b9b0eSStefan Hajnoczivhost_vsock="no"
355e6a74868SMarc-André Lureauvhost_user=""
356d41a75a2SBradkvm="no"
357b0cb0a66SVincent Palatinhax="no"
358c97d6d2cSSergio Andres Gomez Del Realhvf="no"
359d661d9a4SJustin Terry (VM)whpx="no"
3602da776dbSMichael R. Hinesrdma=""
361377529c0SPaolo Bonzinigprof="no"
362377529c0SPaolo Bonzinidebug_tcg="no"
363377529c0SPaolo Bonzinidebug="no"
364247724cbSMarc-André Lureausanitizers="no"
365b553a042SJohn Snowfortify_source=""
366377529c0SPaolo Bonzinistrip_opt="yes"
3679195b2c2SStefan Weiltcg_interpreter="no"
368377529c0SPaolo Bonzinibigendian="no"
369377529c0SPaolo Bonzinimingw32="no"
3701d728c39SBlue Swirlgcov="no"
3711d728c39SBlue Swirlgcov_tool="gcov"
372377529c0SPaolo BonziniEXESUF=""
37317969268SFam ZhengDSOSUF=".so"
37417969268SFam ZhengLDFLAGS_SHARED="-shared"
37517969268SFam Zhengmodules="no"
376377529c0SPaolo Bonziniprefix="/usr/local"
377377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
378528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
3793d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
380850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
381377529c0SPaolo Bonzinibindir="\${prefix}/bin"
3823aa5d2beSAlon Levylibdir="\${prefix}/lib"
3838bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
3840f94d6daSAlon Levyincludedir="\${prefix}/include"
385377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
386785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
387377529c0SPaolo Bonziniconfsuffix="/qemu"
388377529c0SPaolo Bonzinislirp="yes"
389377529c0SPaolo Bonzinioss_lib=""
390377529c0SPaolo Bonzinibsd="no"
391377529c0SPaolo Bonzinilinux="no"
392377529c0SPaolo Bonzinisolaris="no"
393377529c0SPaolo Bonziniprofiler="no"
394377529c0SPaolo Bonzinicocoa="no"
395377529c0SPaolo Bonzinisoftmmu="yes"
396377529c0SPaolo Bonzinilinux_user="no"
397377529c0SPaolo Bonzinibsd_user="no"
398377529c0SPaolo Bonziniblobs="yes"
399377529c0SPaolo Bonzinipkgversion=""
40040d6444eSAvi Kivitypie=""
4013556c233SPaolo Bonziniqom_cast_debug="yes"
402baf86d6bSPaolo Bonzinitrace_backends="log"
403377529c0SPaolo Bonzinitrace_file="trace"
404377529c0SPaolo Bonzinispice=""
405377529c0SPaolo Bonzinirbd=""
4067b02f544SMarc-André Lureausmartcard=""
4072b2325ffSGerd Hoffmannlibusb=""
40869354a83SHans de Goedeusb_redir=""
409da076ffeSGerd Hoffmannopengl=""
410014cb152SGerd Hoffmannopengl_dmabuf="no"
4115dd89908SRichard Hendersoncpuid_h="no"
41299f2dbd3SLiang Liavx2_opt="no"
4131ece9905SAlon Levyzlib="yes"
4148ca80760SRichard Hendersoncapstone=""
415b25c9dffSStefan Weillzo=""
416b25c9dffSStefan Weilsnappy=""
4176b383c08SPeter Wubzip2=""
418e8ef31a3SMichael Tokarevguest_agent=""
419d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
42050cbebb9SMichael Rothguest_agent_ntddscsi="no"
4219dacf32dSYossi Hindinguest_agent_msi=""
422d9840e25STomoki Sekiyamavss_win32_sdk=""
423d9840e25STomoki Sekiyamawin_sdk="no"
4244b1c11fdSDaniel P. Berrangewant_tools="yes"
425c589b249SRonnie Sahlberglibiscsi=""
4266542aa9cSPeter Lievenlibnfs=""
427519175a2SAlex Barcelocoroutine=""
42870c60c08SStefan Hajnoczicoroutine_pool=""
4297d992e4dSPeter Lievendebug_stack_usage="no"
430f0d92b56SLongpeng(Mike)crypto_afalg="no"
431f794573eSEduardo Otuboseccomp=""
432eb100396SBharata B Raoglusterfs=""
433d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4340c14fb47SBharata B Raoglusterfs_discard="no"
435df3a429aSNiels de Vosglusterfs_fallocate="no"
4367c815372SBharata B Raoglusterfs_zerofill="no"
437a4ccabcfSAnthony Liguorigtk=""
4389e04c683SStefan Weilgtkabi=""
439925a0400SGerd Hoffmanngtk_gl="no"
440a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
441ddbb0d09SDaniel P. Berrangegnutls=""
442b917da4cSDaniel P. Berrangegnutls_rnd=""
44391bfcdb0SDaniel P. Berrangenettle=""
444fff2f982SDaniel P. Berrangenettle_kdf="no"
44591bfcdb0SDaniel P. Berrangegcrypt=""
4461f923c70SLongpeng(Mike)gcrypt_hmac="no"
44737788f25SDaniel P. Berrangegcrypt_kdf="no"
448bbbf9bfbSStefan Weilvte=""
4499d9e1521SGerd Hoffmannvirglrenderer=""
450e91c793cSCole Robinsontpm="yes"
4510a12ec87SRichard W.M. Joneslibssh2=""
452ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
453a99d57bbSWanlong Gaonuma=""
4542847b469SFam Zhengtcmalloc="no"
4557b01cb97SAlexandre Derumierjemalloc="no"
456a6b1d4c0SChanglong Xiereplication="yes"
457da92c3ffSAshish Mittalvxhs=""
458ed279a06SKlim Kireevlibxml2=""
45951a12b51SAlex Bennéedocker="no"
460377529c0SPaolo Bonzini
461*d75402b5SAlex Bennée# cross compilers defaults, can be overridden with --cross-cc-ARCH
462*d75402b5SAlex Bennéecross_cc_aarch64="aarch64-linux-gnu-gcc"
463*d75402b5SAlex Bennéecross_cc_arm="arm-linux-gnueabihf-gcc"
464*d75402b5SAlex Bennéecross_cc_powerpc="powerpc-linux-gnu-gcc"
465*d75402b5SAlex Bennée
466*d75402b5SAlex Bennéeenabled_cross_compilers=""
467*d75402b5SAlex Bennée
468898be3e0SPeter Maydellsupported_cpu="no"
469898be3e0SPeter Maydellsupported_os="no"
470fb59dabdSPeter Maydellbogus_os="no"
4715a22ab71SYang Zhongmalloc_trim=""
472898be3e0SPeter Maydell
473ac0df51dSaliguori# parse CC options first
474ac0df51dSaliguorifor opt do
47589138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
476ac0df51dSaliguori  case "$opt" in
477ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
478ac0df51dSaliguori  ;;
4793d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
480ac0df51dSaliguori  ;;
48183f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
48283f73fceSTomoki Sekiyama  ;;
483ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
484ca4deeb1SPaolo Bonzini  ;;
4852ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4862ff6b91eSJuan Quintela  ;;
487de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
488e2a2ed06SJuan Quintela  ;;
48911cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
49011cde1c8SBruno Dominguez  ;;
491a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
492f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
493e2a2ed06SJuan Quintela  ;;
4945bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4955bc62e01SGerd Hoffmann  ;;
4965bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4975bc62e01SGerd Hoffmann  ;;
498*d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
499*d75402b5SAlex Bennée  ;;
500*d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
501*d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
502*d75402b5SAlex Bennée  ;;
503ac0df51dSaliguori  esac
504ac0df51dSaliguoridone
505ac0df51dSaliguori# OS specific
506ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
50793148aa5SStefan Weil# we can eliminate its usage altogether.
508ac0df51dSaliguori
509e49d021eSPeter Maydell# Preferred compiler:
510e49d021eSPeter Maydell#  ${CC} (if set)
511e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
512e49d021eSPeter Maydell#  system compiler
513e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
514e49d021eSPeter Maydell  cc="$host_cc"
515e49d021eSPeter Maydellelse
516b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
517e49d021eSPeter Maydellfi
518e49d021eSPeter Maydell
51983f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
52083f73fceSTomoki Sekiyama  cxx="c++"
52183f73fceSTomoki Sekiyamaelse
52283f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
52383f73fceSTomoki Sekiyamafi
52483f73fceSTomoki Sekiyama
525b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
526cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5275f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5283dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
529b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
530b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5319f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5324852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
533b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
534b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
53517884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
53617884d7bSSergei Trofimovichquery_pkg_config() {
53717884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
53817884d7bSSergei Trofimovich}
53917884d7bSSergei Trofimovichpkg_config=query_pkg_config
540b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
54147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
542ac0df51dSaliguori
54345d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
54445d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
54545d285abSPeter Maydell
546be17dc90SMichael S. Tsirkin# default flags for all hosts
5472d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5482d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5492d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5502d31515bSPeter Maydell# provides these semantics.)
5512d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
552f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
553c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
554be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5559edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5565bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5575bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
558be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5595bc62e01SGerd Hoffmannfi
560be17dc90SMichael S. Tsirkin
561ca4deeb1SPaolo Bonzini# make source path absolute
56289138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
563ca4deeb1SPaolo Bonzini
564cab00a5aSMichael S. Tsirkin# running configure in the source tree?
565cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
566cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
567cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
568cab00a5aSMichael S. Tsirkinelse
569cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
570cab00a5aSMichael S. Tsirkinfi
571cab00a5aSMichael S. Tsirkin
572ac0df51dSaliguoricheck_define() {
573ac0df51dSaliguoricat > $TMPC <<EOF
574ac0df51dSaliguori#if !defined($1)
575fd786e1aSPeter Maydell#error $1 not defined
576ac0df51dSaliguori#endif
577ac0df51dSaliguoriint main(void) { return 0; }
578ac0df51dSaliguoriEOF
57952166aa0SJuan Quintela  compile_object
580ac0df51dSaliguori}
581ac0df51dSaliguori
582307119e7SGerd Hoffmanncheck_include() {
583307119e7SGerd Hoffmanncat > $TMPC <<EOF
584307119e7SGerd Hoffmann#include <$1>
585307119e7SGerd Hoffmannint main(void) { return 0; }
586307119e7SGerd HoffmannEOF
587307119e7SGerd Hoffmann  compile_object
588307119e7SGerd Hoffmann}
589307119e7SGerd Hoffmann
59093b25869SJohn Snowwrite_c_skeleton() {
59193b25869SJohn Snow    cat > $TMPC <<EOF
59293b25869SJohn Snowint main(void) { return 0; }
59393b25869SJohn SnowEOF
59493b25869SJohn Snow}
59593b25869SJohn Snow
596bbea4050SPeter Maydellif check_define __linux__ ; then
597bbea4050SPeter Maydell  targetos="Linux"
598bbea4050SPeter Maydellelif check_define _WIN32 ; then
599bbea4050SPeter Maydell  targetos='MINGW32'
600bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
601bbea4050SPeter Maydell  targetos='OpenBSD'
602bbea4050SPeter Maydellelif check_define __sun__ ; then
603bbea4050SPeter Maydell  targetos='SunOS'
604bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
605bbea4050SPeter Maydell  targetos='Haiku'
606951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
607951fedfcSPeter Maydell  targetos='FreeBSD'
608951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
609951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
610951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
611951fedfcSPeter Maydell  targetos='DragonFly'
612951fedfcSPeter Maydellelif check_define __NetBSD__; then
613951fedfcSPeter Maydell  targetos='NetBSD'
614951fedfcSPeter Maydellelif check_define __APPLE__; then
615951fedfcSPeter Maydell  targetos='Darwin'
616bbea4050SPeter Maydellelse
617951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
618951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
619951fedfcSPeter Maydell  # be the result of a missing compiler.
620951fedfcSPeter Maydell  targetos='bogus'
621951fedfcSPeter Maydell  bogus_os='yes'
622bbea4050SPeter Maydellfi
623bbea4050SPeter Maydell
624bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
625bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
626bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
627bbea4050SPeter Maydell# the correct CPU with the --cpu option.
628bbea4050SPeter Maydellcase $targetos in
629bbea4050SPeter MaydellDarwin)
630bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
631bbea4050SPeter Maydell  # run 64-bit userspace code.
632bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
633bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
634bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
635bbea4050SPeter Maydell    cpu="x86_64"
636bbea4050SPeter Maydell  fi
637bbea4050SPeter Maydell  ;;
638bbea4050SPeter MaydellSunOS)
63989138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
640bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
641bbea4050SPeter Maydell    cpu="x86_64"
642bbea4050SPeter Maydell  fi
643bbea4050SPeter Maydellesac
644bbea4050SPeter Maydell
6452ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6462ff6b91eSJuan Quintela  # command line argument
6472ff6b91eSJuan Quintela  :
6482ff6b91eSJuan Quintelaelif check_define __i386__ ; then
649ac0df51dSaliguori  cpu="i386"
650ac0df51dSaliguorielif check_define __x86_64__ ; then
651c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
652c72b26ecSRichard Henderson    cpu="x32"
653c72b26ecSRichard Henderson  else
654ac0df51dSaliguori    cpu="x86_64"
655c72b26ecSRichard Henderson  fi
6563aa9bd6cSblueswir1elif check_define __sparc__ ; then
6573aa9bd6cSblueswir1  if check_define __arch64__ ; then
6583aa9bd6cSblueswir1    cpu="sparc64"
6593aa9bd6cSblueswir1  else
6603aa9bd6cSblueswir1    cpu="sparc"
6613aa9bd6cSblueswir1  fi
662fdf7ed96Smalcelif check_define _ARCH_PPC ; then
663fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
664fdf7ed96Smalc    cpu="ppc64"
665ac0df51dSaliguori  else
666fdf7ed96Smalc    cpu="ppc"
667fdf7ed96Smalc  fi
668afa05235SAurelien Jarnoelif check_define __mips__ ; then
669afa05235SAurelien Jarno  cpu="mips"
670d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
671d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
672d66ed0eaSAurelien Jarno    cpu="s390x"
673d66ed0eaSAurelien Jarno  else
674d66ed0eaSAurelien Jarno    cpu="s390"
675d66ed0eaSAurelien Jarno  fi
67621d89f84SPeter Maydellelif check_define __arm__ ; then
67721d89f84SPeter Maydell  cpu="arm"
6781f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6791f080313SClaudio Fontana  cpu="aarch64"
680fdf7ed96Smalcelse
68189138857SStefan Weil  cpu=$(uname -m)
682ac0df51dSaliguorifi
683ac0df51dSaliguori
684359bc95dSPeter MaydellARCH=
685359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
686359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6877d13299dSbellardcase "$cpu" in
6886499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
689898be3e0SPeter Maydell    cpu="$cpu"
690898be3e0SPeter Maydell    supported_cpu="yes"
691*d75402b5SAlex Bennée    eval "cross_cc_${cpu}=\$host_cc"
692898be3e0SPeter Maydell  ;;
6937d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
69497a847bcSbellard    cpu="i386"
695898be3e0SPeter Maydell    supported_cpu="yes"
696*d75402b5SAlex Bennée    cross_cc_i386=$host_cc
6977d13299dSbellard  ;;
698aaa5fa14Saurel32  x86_64|amd64)
699aaa5fa14Saurel32    cpu="x86_64"
700898be3e0SPeter Maydell    supported_cpu="yes"
701*d75402b5SAlex Bennée    cross_cc_x86_64=$host_cc
702aaa5fa14Saurel32  ;;
70321d89f84SPeter Maydell  armv*b|armv*l|arm)
70421d89f84SPeter Maydell    cpu="arm"
705898be3e0SPeter Maydell    supported_cpu="yes"
706*d75402b5SAlex Bennée    cross_cc_arm=$host_cc
7077d13299dSbellard  ;;
7081f080313SClaudio Fontana  aarch64)
7091f080313SClaudio Fontana    cpu="aarch64"
710898be3e0SPeter Maydell    supported_cpu="yes"
711*d75402b5SAlex Bennée    cross_cc_aarch64=$host_cc
7121f080313SClaudio Fontana  ;;
713afa05235SAurelien Jarno  mips*)
714afa05235SAurelien Jarno    cpu="mips"
715898be3e0SPeter Maydell    supported_cpu="yes"
716*d75402b5SAlex Bennée    cross_cc_mips=$host_cc
717afa05235SAurelien Jarno  ;;
7183142255cSblueswir1  sparc|sun4[cdmuv])
719ae228531Sbellard    cpu="sparc"
7206499fd15SPeter Maydell    supported_cpu="yes"
721*d75402b5SAlex Bennée    cross_cc_sparc=$host_cc
722ae228531Sbellard  ;;
7237d13299dSbellard  *)
724359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
725359bc95dSPeter Maydell    ARCH=unknown
7267d13299dSbellard  ;;
7277d13299dSbellardesac
728359bc95dSPeter Maydellif test -z "$ARCH"; then
729359bc95dSPeter Maydell  ARCH="$cpu"
730359bc95dSPeter Maydellfi
731e2d52ad3SJuan Quintela
7327d13299dSbellard# OS specific
7330dbfc675SJuan Quintela
734adfc3e91SStacey Son# host *BSD for user mode
735adfc3e91SStacey SonHOST_VARIANT_DIR=""
736adfc3e91SStacey Son
7377d13299dSbellardcase $targetos in
73867b915a5SbellardMINGW32*)
73967b915a5Sbellard  mingw32="yes"
740b0cb0a66SVincent Palatin  hax="yes"
7413cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
742307119e7SGerd Hoffmann  if check_include dsound.h; then
7433cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
744307119e7SGerd Hoffmann  else
745307119e7SGerd Hoffmann    audio_drv_list=""
746307119e7SGerd Hoffmann  fi
747898be3e0SPeter Maydell  supported_os="yes"
74867b915a5Sbellard;;
7495c40d2bdSthsGNU/kFreeBSD)
750a167ba50SAurelien Jarno  bsd="yes"
7510c58ac1cSmalc  audio_drv_list="oss"
7520bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7535c40d2bdSths;;
7547d3505c5SbellardFreeBSD)
7557d3505c5Sbellard  bsd="yes"
7560db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7570c58ac1cSmalc  audio_drv_list="oss"
7580bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
759f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
760f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
761a7764f15SEd Maste  # needed for kinfo_getproc
762a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
76358952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
764adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
765898be3e0SPeter Maydell  supported_os="yes"
7667d3505c5Sbellard;;
767c5e97233Sblueswir1DragonFly)
768c5e97233Sblueswir1  bsd="yes"
7690db4a067SPaolo Bonzini  make="${MAKE-gmake}"
770c5e97233Sblueswir1  audio_drv_list="oss"
7710bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
772adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
773c5e97233Sblueswir1;;
7747d3505c5SbellardNetBSD)
7757d3505c5Sbellard  bsd="yes"
7760db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7770c58ac1cSmalc  audio_drv_list="oss"
7780bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7798ef92a88Sblueswir1  oss_lib="-lossaudio"
780adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
7813c2bdbc1SKamil Rytarowski  supported_os="yes"
7827d3505c5Sbellard;;
7837d3505c5SbellardOpenBSD)
7847d3505c5Sbellard  bsd="yes"
7850db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7864f6ab397SBrad Smith  audio_drv_list="sdl"
7870bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
788adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7890a773d55SBrad Smith  supported_os="yes"
7907d3505c5Sbellard;;
79183fb7adfSbellardDarwin)
79283fb7adfSbellard  bsd="yes"
79383fb7adfSbellard  darwin="yes"
794b0cb0a66SVincent Palatin  hax="yes"
795c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
79617969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7971b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
798a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7990c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
8001b0f9cc2Saliguori  fi
801fd677642Sths  cocoa="yes"
8020c58ac1cSmalc  audio_drv_list="coreaudio"
80314382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
8040c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
8057973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
806a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
807a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
808a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
809adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
810898be3e0SPeter Maydell  supported_os="yes"
81183fb7adfSbellard;;
812ec530c81SbellardSunOS)
813ec530c81Sbellard  solaris="yes"
8140db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8150db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
816e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8176b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8180c58ac1cSmalc    audio_drv_list="oss"
8196b4d2ba1Sths  fi
820c2de5c91Smalc  audio_possible_drivers="oss sdl"
821d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
822d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
823d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
824d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
825a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
826560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
827560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
828560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
829ec530c81Sbellard;;
830179cf400SAndreas FärberHaiku)
831179cf400SAndreas Färber  haiku="yes"
832179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
833179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
834179cf400SAndreas Färber;;
835898be3e0SPeter MaydellLinux)
8360c58ac1cSmalc  audio_drv_list="oss"
8370bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8385327cf48Sbellard  linux="yes"
839831b7825Sths  linux_user="yes"
840af2be207SJan Kiszka  kvm="yes"
841af2be207SJan Kiszka  vhost_net="yes"
842042cea27SGonglei  vhost_crypto="yes"
8435e9be92dSNicholas Bellinger  vhost_scsi="yes"
844fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
845a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
846898be3e0SPeter Maydell  supported_os="yes"
847898be3e0SPeter Maydell;;
8487d13299dSbellardesac
8497d13299dSbellard
8507d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
851b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
85284778508Sblueswir1    bsd_user="yes"
8537d3505c5Sbellard  fi
85408de3949SAndreas Färberfi
8557d3505c5Sbellard
8560db4a067SPaolo Bonzini: ${make=${MAKE-make}}
8570db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
85852510f8bSStefan Weil: ${python=${PYTHON-python}}
859e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8600db4a067SPaolo Bonzini
8613c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8623c4a4d0dSPeter Maydellif has clang; then
8633c4a4d0dSPeter Maydell  objcc=clang
8643c4a4d0dSPeter Maydellelse
8653c4a4d0dSPeter Maydell  objcc="$cc"
8663c4a4d0dSPeter Maydellfi
8673c4a4d0dSPeter Maydell
8683457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8693457a3f8SJuan Quintela  EXESUF=".exe"
87017969268SFam Zheng  DSOSUF=".dll"
871a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
872e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
873e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
87478e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
87578e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
876f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
87793b25869SJohn Snow  write_c_skeleton;
878f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
879f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
880f7cf5d5bSStefan Weil  fi
881c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
882683035deSPaolo Bonzini  mandir="\${prefix}"
883528ae5b8SEduardo Habkost  datadir="\${prefix}"
884850da188SEduardo Habkost  qemu_docdir="\${prefix}"
885683035deSPaolo Bonzini  bindir="\${prefix}"
886683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8875a699bbbSLaszlo Ersek  local_statedir=
888683035deSPaolo Bonzini  confsuffix=""
889105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8903457a3f8SJuan Quintelafi
8913457a3f8SJuan Quintela
892487fefdbSAnthony Liguoriwerror=""
89385aa5189Sbellard
8947d13299dSbellardfor opt do
89589138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8967d13299dSbellard  case "$opt" in
8972efc3265Sbellard  --help|-h) show_help=yes
8982efc3265Sbellard  ;;
89999123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
90099123e13SMike Frysinger  ;;
901b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9027d13299dSbellard  ;;
903b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
90432ce6337Sbellard  ;;
905ca4deeb1SPaolo Bonzini  --source-path=*)
9067d13299dSbellard  ;;
907ac0df51dSaliguori  --cross-prefix=*)
9087d13299dSbellard  ;;
909ac0df51dSaliguori  --cc=*)
9107d13299dSbellard  ;;
911b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
91283469015Sbellard  ;;
91383f73fceSTomoki Sekiyama  --cxx=*)
91483f73fceSTomoki Sekiyama  ;;
915e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
916e007dbecSMichael S. Tsirkin  ;;
9173c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
9183c4a4d0dSPeter Maydell  ;;
919b1a550a0Spbrook  --make=*) make="$optarg"
9207d13299dSbellard  ;;
9216a882643Spbrook  --install=*) install="$optarg"
9226a882643Spbrook  ;;
923c886edfbSBlue Swirl  --python=*) python="$optarg"
924c886edfbSBlue Swirl  ;;
9251d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
9261d728c39SBlue Swirl  ;;
927e2d8830eSBrad  --smbd=*) smbd="$optarg"
928e2d8830eSBrad  ;;
929e2a2ed06SJuan Quintela  --extra-cflags=*)
9307d13299dSbellard  ;;
93111cde1c8SBruno Dominguez  --extra-cxxflags=*)
93211cde1c8SBruno Dominguez  ;;
933e2a2ed06SJuan Quintela  --extra-ldflags=*)
9347d13299dSbellard  ;;
9355bc62e01SGerd Hoffmann  --enable-debug-info)
9365bc62e01SGerd Hoffmann  ;;
9375bc62e01SGerd Hoffmann  --disable-debug-info)
9385bc62e01SGerd Hoffmann  ;;
939*d75402b5SAlex Bennée  --cross-cc-*)
940*d75402b5SAlex Bennée  ;;
94117969268SFam Zheng  --enable-modules)
94217969268SFam Zheng      modules="yes"
94317969268SFam Zheng  ;;
9443aa88b31SStefan Hajnoczi  --disable-modules)
9453aa88b31SStefan Hajnoczi      modules="no"
9463aa88b31SStefan Hajnoczi  ;;
9472ff6b91eSJuan Quintela  --cpu=*)
9487d13299dSbellard  ;;
949b1a550a0Spbrook  --target-list=*) target_list="$optarg"
950de83cd02Sbellard  ;;
9515b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9525b808275SLluís Vilanova  ;;
9535b808275SLluís Vilanova  # XXX: backwards compatibility
9545b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
95594a420b1SStefan Hajnoczi  ;;
95674242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9579410b56cSPrerna Saxena  ;;
9587d13299dSbellard  --enable-gprof) gprof="yes"
9597d13299dSbellard  ;;
9601d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9611d728c39SBlue Swirl  ;;
96279427693SLoïc Minier  --static)
96379427693SLoïc Minier    static="yes"
96479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
96517884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
96643ce4dfeSbellard  ;;
9670b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9680b24e75fSPaolo Bonzini  ;;
9690b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9700b24e75fSPaolo Bonzini  ;;
9713aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9723aa5d2beSAlon Levy  ;;
9738bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9748bf188aaSMichael Tokarev  ;;
9750f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9760f94d6daSAlon Levy  ;;
977528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9780b24e75fSPaolo Bonzini  ;;
979023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
980023d3d67SEduardo Habkost  ;;
981850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9820b24e75fSPaolo Bonzini  ;;
983ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
98407381cc1SAnthony Liguori  ;;
985785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
986785c23aeSLuiz Capitulino  ;;
9873d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9883d5eecabSGerd Hoffmann  ;;
989181ce1d0SOlaf Hering  --host=*|--build=*|\
990181ce1d0SOlaf Hering  --disable-dependency-tracking|\
991785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
992023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
993023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
994023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
995023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
996023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
997023ddd74SMax Filippov    # lots of directory switches by default.
998023ddd74SMax Filippov  ;;
99997a847bcSbellard  --disable-sdl) sdl="no"
100097a847bcSbellard  ;;
1001c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1002c4198157SJuan Quintela  ;;
100347c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
100447c03744SDave Airlie  ;;
10053556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10063556c233SPaolo Bonzini  ;;
10073556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10083556c233SPaolo Bonzini  ;;
1009983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1010983eef5aSMeador Inge  ;;
1011983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1012983eef5aSMeador Inge  ;;
1013fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1014fe8fc5aeSPaolo Bonzini  ;;
1015fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1016fe8fc5aeSPaolo Bonzini  ;;
1017821601eaSJes Sorensen  --disable-vnc) vnc="no"
1018821601eaSJes Sorensen  ;;
1019821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1020821601eaSJes Sorensen  ;;
10212f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10222f6a1ab0Sblueswir1  ;;
10230c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10240c58ac1cSmalc  ;;
102589138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1026b64ec4e4SFam Zheng  ;;
102789138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1028eb852011SMarkus Armbruster  ;;
1029f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1030f8393946Saurel32  ;;
1031f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1032f8393946Saurel32  ;;
1033f3d08ee6SPaul Brook  --enable-debug)
1034f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1035f3d08ee6SPaul Brook      debug_tcg="yes"
1036f3d08ee6SPaul Brook      debug="yes"
1037f3d08ee6SPaul Brook      strip_opt="no"
1038b553a042SJohn Snow      fortify_source="no"
1039f3d08ee6SPaul Brook  ;;
1040247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1041247724cbSMarc-André Lureau  ;;
1042247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1043247724cbSMarc-André Lureau  ;;
104403b4fe7dSaliguori  --enable-sparse) sparse="yes"
104503b4fe7dSaliguori  ;;
104603b4fe7dSaliguori  --disable-sparse) sparse="no"
104703b4fe7dSaliguori  ;;
10481625af87Saliguori  --disable-strip) strip_opt="no"
10491625af87Saliguori  ;;
10502f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
10512f9606b3Saliguori  ;;
1052ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1053ea784e3bSJuan Quintela  ;;
10542f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
10552f6f5c7aSCorentin Chary  ;;
10562f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
10572f6f5c7aSCorentin Chary  ;;
1058efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1059efe556adSCorentin Chary  ;;
1060efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1061efe556adSCorentin Chary  ;;
1062443f1376Sbellard  --disable-slirp) slirp="no"
1063c20709aaSbellard  ;;
1064e0e6c8c0Saliguori  --disable-vde) vde="no"
10658a16d273Sths  ;;
1066dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1067dfb278bdSJuan Quintela  ;;
106858952137SVincenzo Maffione  --disable-netmap) netmap="no"
106958952137SVincenzo Maffione  ;;
107058952137SVincenzo Maffione  --enable-netmap) netmap="yes"
107158952137SVincenzo Maffione  ;;
1072e37630caSaliguori  --disable-xen) xen="no"
1073e37630caSaliguori  ;;
1074fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1075fc321b4bSJuan Quintela  ;;
1076eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1077eb6fda0fSAnthony PERARD  ;;
1078eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1079eb6fda0fSAnthony PERARD  ;;
108064a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
108164a7ad6fSIan Campbell  ;;
108264a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
108364a7ad6fSIan Campbell  ;;
10842e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10852e4d9fb1Saurel32  ;;
10864ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10874ffcedb6SJuan Quintela  ;;
1088fb599c9aSbalrog  --disable-bluez) bluez="no"
1089fb599c9aSbalrog  ;;
1090a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1091a20a6f46SJuan Quintela  ;;
10927ba1e619Saliguori  --disable-kvm) kvm="no"
10937ba1e619Saliguori  ;;
1094b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1095b31a0277SJuan Quintela  ;;
1096b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1097180fb750Szhanghailiang  ;;
1098b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1099180fb750Szhanghailiang  ;;
1100c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1101c97d6d2cSSergio Andres Gomez Del Real  ;;
1102c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1103c97d6d2cSSergio Andres Gomez Del Real  ;;
1104d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1105d661d9a4SJustin Terry (VM)  ;;
1106d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1107d661d9a4SJustin Terry (VM)  ;;
11089195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11099195b2c2SStefan Weil  ;;
11109195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11119195b2c2SStefan Weil  ;;
111247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
111347e98658SCorey Bryant  ;;
111447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
111547e98658SCorey Bryant  ;;
1116b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1117b3f6ea7eSPaolo Bonzini  ;;
1118b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1119b3f6ea7eSPaolo Bonzini  ;;
11205a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
11215a22ab71SYang Zhong  ;;
11225a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
11235a22ab71SYang Zhong  ;;
1124cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1125cd4ec0b4SGerd Hoffmann  ;;
1126cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1127cd4ec0b4SGerd Hoffmann  ;;
1128c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1129c589b249SRonnie Sahlberg  ;;
1130c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1131c589b249SRonnie Sahlberg  ;;
11326542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11336542aa9cSPeter Lieven  ;;
11346542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11356542aa9cSPeter Lieven  ;;
113605c2a3e7Sbellard  --enable-profiler) profiler="yes"
113705c2a3e7Sbellard  ;;
113814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
113914821030SPavel Borzenkov  ;;
1140c2de5c91Smalc  --enable-cocoa)
1141c2de5c91Smalc      cocoa="yes" ;
114289138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
11435b0753e0Sbellard  ;;
1144cad25d69Spbrook  --disable-system) softmmu="no"
11450a8e90f4Spbrook  ;;
1146cad25d69Spbrook  --enable-system) softmmu="yes"
11470a8e90f4Spbrook  ;;
11480953a80fSZachary Amsden  --disable-user)
11490953a80fSZachary Amsden      linux_user="no" ;
11500953a80fSZachary Amsden      bsd_user="no" ;
11510953a80fSZachary Amsden  ;;
11520953a80fSZachary Amsden  --enable-user) ;;
1153831b7825Sths  --disable-linux-user) linux_user="no"
11540a8e90f4Spbrook  ;;
1155831b7825Sths  --enable-linux-user) linux_user="yes"
1156831b7825Sths  ;;
115784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
115884778508Sblueswir1  ;;
115984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
116084778508Sblueswir1  ;;
116140d6444eSAvi Kivity  --enable-pie) pie="yes"
116234005a00SKirill A. Shutemov  ;;
116340d6444eSAvi Kivity  --disable-pie) pie="no"
116434005a00SKirill A. Shutemov  ;;
116585aa5189Sbellard  --enable-werror) werror="yes"
116685aa5189Sbellard  ;;
116785aa5189Sbellard  --disable-werror) werror="no"
116885aa5189Sbellard  ;;
116963678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
117063678e17SSteven Noonan  ;;
117163678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
117263678e17SSteven Noonan  ;;
11734d3b6f6eSbalrog  --disable-curses) curses="no"
11744d3b6f6eSbalrog  ;;
1175c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1176c584a6d0SJuan Quintela  ;;
1177769ce76dSAlexander Graf  --disable-curl) curl="no"
1178769ce76dSAlexander Graf  ;;
1179788c8196SJuan Quintela  --enable-curl) curl="yes"
1180788c8196SJuan Quintela  ;;
11812df87df7SJuan Quintela  --disable-fdt) fdt="no"
11822df87df7SJuan Quintela  ;;
11832df87df7SJuan Quintela  --enable-fdt) fdt="yes"
11842df87df7SJuan Quintela  ;;
11855c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
11865c6c3a6cSChristoph Hellwig  ;;
11875c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
11885c6c3a6cSChristoph Hellwig  ;;
1189758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1190758e8e38SVenkateswararao Jujjuri (JV)  ;;
1191758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1192758e8e38SVenkateswararao Jujjuri (JV)  ;;
1193a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1194a40161cbSPaolo Bonzini  ;;
1195a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1196a40161cbSPaolo Bonzini  ;;
119777755340Sths  --disable-blobs) blobs="no"
119877755340Sths  ;;
11997e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12004a19f1ecSpbrook  ;;
1201519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1202519175a2SAlex Barcelo  ;;
120370c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
120470c60c08SStefan Hajnoczi  ;;
120570c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
120670c60c08SStefan Hajnoczi  ;;
12077d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12087d992e4dSPeter Lieven  ;;
1209f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1210f0d92b56SLongpeng(Mike)  ;;
1211f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1212f0d92b56SLongpeng(Mike)  ;;
1213a25dba17SJuan Quintela  --disable-docs) docs="no"
121470ec5dc0SAnthony Liguori  ;;
1215a25dba17SJuan Quintela  --enable-docs) docs="yes"
121683a3ab8bSJuan Quintela  ;;
1217d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1218d5970055SMichael S. Tsirkin  ;;
1219d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1220d5970055SMichael S. Tsirkin  ;;
1221042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1222042cea27SGonglei  ;;
1223042cea27SGonglei  --enable-vhost-crypto)
1224042cea27SGonglei      vhost_crypto="yes"
1225042cea27SGonglei      if test "$mingw32" = "yes"; then
1226042cea27SGonglei          error_exit "vhost-crypto isn't available on win32"
1227042cea27SGonglei      fi
1228042cea27SGonglei  ;;
12295e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12305e9be92dSNicholas Bellinger  ;;
12315e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12325e9be92dSNicholas Bellinger  ;;
1233fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1234fc0b9b0eSStefan Hajnoczi  ;;
1235fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1236fc0b9b0eSStefan Hajnoczi  ;;
1237da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
123820ff075bSMichael Walle  ;;
1239da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
124020ff075bSMichael Walle  ;;
1241f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1242f27aaf4bSChristian Brunner  ;;
1243f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1244f27aaf4bSChristian Brunner  ;;
12458c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12468c84cf11SSergei Trofimovich  ;;
12478c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12488c84cf11SSergei Trofimovich  ;;
12497b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1250111a38b0SRobert Relyea  ;;
12517b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1252111a38b0SRobert Relyea  ;;
12532b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
12542b2325ffSGerd Hoffmann  ;;
12552b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
12562b2325ffSGerd Hoffmann  ;;
125769354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
125869354a83SHans de Goede  ;;
125969354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
126069354a83SHans de Goede  ;;
12611ece9905SAlon Levy  --disable-zlib-test) zlib="no"
12621ece9905SAlon Levy  ;;
1263b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1264b25c9dffSStefan Weil  ;;
1265607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1266607dacd0Sqiaonuohan  ;;
1267b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1268b25c9dffSStefan Weil  ;;
1269607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1270607dacd0Sqiaonuohan  ;;
12716b383c08SPeter Wu  --disable-bzip2) bzip2="no"
12726b383c08SPeter Wu  ;;
12736b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
12746b383c08SPeter Wu  ;;
1275d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1276d138cee9SMichael Roth  ;;
1277d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1278d138cee9SMichael Roth  ;;
12799dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
12809dacf32dSYossi Hindin  ;;
12819dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
12829dacf32dSYossi Hindin  ;;
1283d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1284d9840e25STomoki Sekiyama  ;;
1285d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1286d9840e25STomoki Sekiyama  ;;
1287d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1288d9840e25STomoki Sekiyama  ;;
1289d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1290d9840e25STomoki Sekiyama  ;;
1291d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1292d9840e25STomoki Sekiyama  ;;
1293d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1294d9840e25STomoki Sekiyama  ;;
12954b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
12964b1c11fdSDaniel P. Berrange  ;;
12974b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
12984b1c11fdSDaniel P. Berrange  ;;
1299f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1300f794573eSEduardo Otubo  ;;
1301f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1302f794573eSEduardo Otubo  ;;
1303eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1304eb100396SBharata B Rao  ;;
1305eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1306eb100396SBharata B Rao  ;;
130752b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
130852b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1309583f6e7bSStefan Hajnoczi  ;;
1310cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1311cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1312cb6414dfSFam Zheng  ;;
1313315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1314315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1315315d3184SFam Zheng  ;;
1316a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1317a4ccabcfSAnthony Liguori  ;;
1318a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1319a4ccabcfSAnthony Liguori  ;;
1320a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1321a1c5e949SDaniel P. Berrange  ;;
1322ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1323ddbb0d09SDaniel P. Berrange  ;;
1324ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1325ddbb0d09SDaniel P. Berrange  ;;
132691bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
132791bfcdb0SDaniel P. Berrange  ;;
132891bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
132991bfcdb0SDaniel P. Berrange  ;;
133091bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
133191bfcdb0SDaniel P. Berrange  ;;
133291bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
133391bfcdb0SDaniel P. Berrange  ;;
13342da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13352da776dbSMichael R. Hines  ;;
13362da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13372da776dbSMichael R. Hines  ;;
1338528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1339528de90aSDaniel P. Berrange  ;;
1340bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1341bbbf9bfbSStefan Weil  ;;
1342bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1343bbbf9bfbSStefan Weil  ;;
13449d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
13459d9e1521SGerd Hoffmann  ;;
13469d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
13479d9e1521SGerd Hoffmann  ;;
1348e91c793cSCole Robinson  --disable-tpm) tpm="no"
1349e91c793cSCole Robinson  ;;
1350ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1351ab214c29SStefan Berger  ;;
13520a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
13530a12ec87SRichard W.M. Jones  ;;
13540a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
13550a12ec87SRichard W.M. Jones  ;;
1356ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1357ed1701c6SDr. David Alan Gilbert  ;;
1358ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1359ed1701c6SDr. David Alan Gilbert  ;;
1360a99d57bbSWanlong Gao  --disable-numa) numa="no"
1361a99d57bbSWanlong Gao  ;;
1362a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1363a99d57bbSWanlong Gao  ;;
1364ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1365ed279a06SKlim Kireev  ;;
1366ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1367ed279a06SKlim Kireev  ;;
13682847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
13692847b469SFam Zheng  ;;
13702847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
13712847b469SFam Zheng  ;;
13727b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
13737b01cb97SAlexandre Derumier  ;;
13747b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
13757b01cb97SAlexandre Derumier  ;;
1376a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1377a6b1d4c0SChanglong Xie  ;;
1378a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1379a6b1d4c0SChanglong Xie  ;;
1380da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1381da92c3ffSAshish Mittal  ;;
1382da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1383da92c3ffSAshish Mittal  ;;
1384e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1385e6a74868SMarc-André Lureau  ;;
1386e6a74868SMarc-André Lureau  --enable-vhost-user)
1387e6a74868SMarc-André Lureau      vhost_user="yes"
1388e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1389e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1390e6a74868SMarc-André Lureau      fi
1391e6a74868SMarc-André Lureau  ;;
13928ca80760SRichard Henderson  --disable-capstone) capstone="no"
13938ca80760SRichard Henderson  ;;
13948ca80760SRichard Henderson  --enable-capstone) capstone="yes"
13958ca80760SRichard Henderson  ;;
1396e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1397e219c499SRichard Henderson  ;;
1398e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1399e219c499SRichard Henderson  ;;
1400cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1401cc84d63aSDaniel P. Berrange  ;;
1402f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1403f62bbee5SDaniel P. Berrange  ;;
1404f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1405f62bbee5SDaniel P. Berrange  ;;
14062d2ad6d0SFam Zheng  *)
14072d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
14082d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
14092d2ad6d0SFam Zheng      exit 1
14107f1559c6Sbalrog  ;;
14117d13299dSbellard  esac
14127d13299dSbellarddone
14137d13299dSbellard
1414e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1415e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1416e6a74868SMarc-André Lureau        vhost_user="no"
1417e6a74868SMarc-André Lureau    else
1418e6a74868SMarc-André Lureau        vhost_user="yes"
1419e6a74868SMarc-André Lureau    fi
1420e6a74868SMarc-André Lureaufi
1421e6a74868SMarc-André Lureau
142240293e58Sbellardcase "$cpu" in
1423e3608d66SRichard Henderson    ppc)
1424e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1425e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1426e3608d66SRichard Henderson           ;;
1427e3608d66SRichard Henderson    ppc64)
1428e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1429e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1430e3608d66SRichard Henderson           ;;
14319b9c37c3SRichard Henderson    sparc)
1432f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1433f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
14343142255cSblueswir1           ;;
1435ed968ff1SJuan Quintela    sparc64)
143679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1437f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
14383142255cSblueswir1           ;;
143976d83bdeSths    s390)
1440061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
144128d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
144228d7cc49SRichard Henderson           ;;
144328d7cc49SRichard Henderson    s390x)
1444061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
144528d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
144676d83bdeSths           ;;
144740293e58Sbellard    i386)
144879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
14490c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
14502b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
145140293e58Sbellard           ;;
145240293e58Sbellard    x86_64)
14537ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
14547ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
14557ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
14567ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
14570c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
14582b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1459379f6698SPaul Brook           ;;
1460c72b26ecSRichard Henderson    x32)
1461c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1462c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1463c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1464c72b26ecSRichard Henderson           ;;
146530163d89SPeter Maydell    # No special flags required for other host CPUs
14663142255cSblueswir1esac
14673142255cSblueswir1
146879f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
146979f3b12fSPeter Crosthwaite
1470affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1471affc88ccSPeter Maydell# support, even if we're using TCI.
1472affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1473affc88ccSPeter Maydell  bsd_user="no"
1474affc88ccSPeter Maydell  linux_user="no"
1475affc88ccSPeter Maydellfi
1476affc88ccSPeter Maydell
147760e0df25SPeter Maydelldefault_target_list=""
147860e0df25SPeter Maydell
14796e92f823SPeter Maydellmak_wilds=""
14806e92f823SPeter Maydell
148160e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
14826e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
148360e0df25SPeter Maydellfi
148460e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
14856e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
148660e0df25SPeter Maydellfi
148760e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
14886e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
148960e0df25SPeter Maydellfi
149060e0df25SPeter Maydell
14916e92f823SPeter Maydellfor config in $mak_wilds; do
14926e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
14936e92f823SPeter Maydelldone
14946e92f823SPeter Maydell
1495c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
149664a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1497c53eeaf7SStefan Hajnoczi
1498af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1499af5db58eSpbrookcat << EOF
1500af5db58eSpbrook
1501af5db58eSpbrookUsage: configure [options]
1502af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1503af5db58eSpbrook
150408fb77edSStefan WeilStandard options:
150508fb77edSStefan Weil  --help                   print this message
150608fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
150708fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
150808fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
150908fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
151008fb77edSStefan Weil$(echo Available targets: $default_target_list | \
151108fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
151208fb77edSStefan Weil
151308fb77edSStefan WeilAdvanced options (experts only):
151408fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
151508fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
151608fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
151708fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
151808fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
151908fb77edSStefan Weil                           build time
152008fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
152108fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
152208fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
152311cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
152408fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1525*d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
152608fb77edSStefan Weil  --make=MAKE              use specified make [$make]
152708fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
152808fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
152908fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1530db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
153108fb77edSStefan Weil  --static                 enable static build [$static]
153208fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
153308fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
153408fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
153508fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
153608fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1537db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
153808fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
153908fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
15403d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1541e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1542db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
154308fb77edSStefan Weil  --enable-debug           enable common debug build options
1544247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
154508fb77edSStefan Weil  --disable-strip          disable stripping binaries
154608fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
154763678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
154808fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
154908fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
155008fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
155108fb77edSStefan Weil  --block-drv-rw-whitelist=L
155208fb77edSStefan Weil                           set block driver read-write whitelist
155308fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
155408fb77edSStefan Weil  --block-drv-ro-whitelist=L
155508fb77edSStefan Weil                           set block driver read-only whitelist
155608fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
15575b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1558c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
155908fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
156008fb77edSStefan Weil                           Default:trace-<pid>
1561c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1562c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
15635a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1564c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1565c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
156608fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
156733c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
156808fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
156908fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1570c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1571c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1572c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1573a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1574c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1575c12d66aaSLin Ma  --enable-profiler        profiler support
1576c12d66aaSLin Ma  --enable-xen-pv-domain-build
1577c12d66aaSLin Ma                           xen pv domain builder
1578c12d66aaSLin Ma  --enable-debug-stack-usage
1579c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1580c23f23b9SMichael Tokarev
1581c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1582c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1583c23f23b9SMichael Tokarev
1584c23f23b9SMichael Tokarev  system          all system emulation targets
1585c23f23b9SMichael Tokarev  user            supported user emulation targets
1586c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1587c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1588c23f23b9SMichael Tokarev  docs            build documentation
1589c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1590c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1591c23f23b9SMichael Tokarev  pie             Position Independent Executables
1592c23f23b9SMichael Tokarev  modules         modules support
1593c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1594c23f23b9SMichael Tokarev  debug-info      debugging information
1595c23f23b9SMichael Tokarev  sparse          sparse checker
1596c23f23b9SMichael Tokarev
1597ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
159891bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
159991bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1600c23f23b9SMichael Tokarev  sdl             SDL UI
1601c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1602c23f23b9SMichael Tokarev  gtk             gtk UI
1603c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1604c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1605c23f23b9SMichael Tokarev  curses          curses UI
1606c23f23b9SMichael Tokarev  vnc             VNC UI support
1607c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1608c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1609c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1610c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1611c23f23b9SMichael Tokarev  virtfs          VirtFS
1612fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1613c23f23b9SMichael Tokarev  xen             xen backend driver support
161470c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1615c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1616c23f23b9SMichael Tokarev  curl            curl connectivity
1617a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1618c23f23b9SMichael Tokarev  fdt             fdt device tree
1619c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1620c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1621b0cb0a66SVincent Palatin  hax             HAX acceleration support
1622c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1623d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
1624ef6d4ccdSYuval Shaia  rdma            Enable RDMA-based migration and PVRDMA support
1625c23f23b9SMichael Tokarev  vde             support for vde network
1626c23f23b9SMichael Tokarev  netmap          support for netmap network
1627c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1628c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1629c23f23b9SMichael Tokarev  attr            attr and xattr support
1630c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1631042cea27SGonglei  vhost-crypto    vhost-crypto acceleration support
1632c23f23b9SMichael Tokarev  spice           spice
1633c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1634c23f23b9SMichael Tokarev  libiscsi        iscsi support
1635c23f23b9SMichael Tokarev  libnfs          nfs support
16367b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1637c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1638ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1639c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1640c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1641c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1642c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1643c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1644c23f23b9SMichael Tokarev  seccomp         seccomp support
1645c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1646c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1647c23f23b9SMichael Tokarev  tpm             TPM support
1648c23f23b9SMichael Tokarev  libssh2         ssh block device support
1649c23f23b9SMichael Tokarev  numa            libnuma support
1650ed279a06SKlim Kireev  libxml2         for Parallels image format
1651c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
16527b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1653a6b1d4c0SChanglong Xie  replication     replication support
1654c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1655c12d66aaSLin Ma  opengl          opengl support
1656c12d66aaSLin Ma  virglrenderer   virgl rendering support
1657c12d66aaSLin Ma  xfsctl          xfsctl support
1658c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1659c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1660da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1661f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1662e6a74868SMarc-André Lureau  vhost-user      vhost-user support
16638ca80760SRichard Henderson  capstone        capstone disassembler support
166408fb77edSStefan Weil
166508fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1666af5db58eSpbrookEOF
16672d2ad6d0SFam Zhengexit 0
1668af5db58eSpbrookfi
1669af5db58eSpbrook
1670c53eeaf7SStefan Hajnocziif ! has $python; then
1671c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1672c53eeaf7SStefan Hajnoczifi
1673c53eeaf7SStefan Hajnoczi
1674c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1675c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
16767f2b5544SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
16777f2b5544SEduardo Habkost  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1678c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1679c53eeaf7SStefan Hajnoczifi
1680c53eeaf7SStefan Hajnoczi
1681c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1682c53eeaf7SStefan Hajnoczipython="$python -B"
1683c53eeaf7SStefan Hajnoczi
16849aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
16859aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
16869aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
16879aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
16889aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
16899aae6e54SDaniel Henrique Barbozaif compile_object ; then
16909aae6e54SDaniel Henrique Barboza  : C compiler works ok
16919aae6e54SDaniel Henrique Barbozaelse
16929aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
16939aae6e54SDaniel Henrique Barbozafi
16949aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
16959aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
16969aae6e54SDaniel Henrique Barbozafi
16979aae6e54SDaniel Henrique Barboza
1698359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1699359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1700359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1701359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1702359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1703359bc95dSPeter Maydell    else
170476ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1705359bc95dSPeter Maydell    fi
1706359bc95dSPeter Maydellfi
1707359bc95dSPeter Maydell
17089c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
17099c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
17109c83ffd8SPeter Maydellif test -z "$werror" ; then
17119c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1712e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
17139c83ffd8SPeter Maydell        werror="yes"
17149c83ffd8SPeter Maydell    else
17159c83ffd8SPeter Maydell        werror="no"
17169c83ffd8SPeter Maydell    fi
17179c83ffd8SPeter Maydellfi
17189c83ffd8SPeter Maydell
1719fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1720fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1721fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1722fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1723fb59dabdSPeter Maydell    # host OS we should stop now.
1724951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1725fb59dabdSPeter Maydellfi
1726fb59dabdSPeter Maydell
17278d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
17288d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1729ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1730435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1731b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
173271429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
17330e39c4aaSGerd Hoffmanngcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
17346ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
17356ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
17366ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
17376ca026cbSPeter Maydell# so it's too error prone.
173893b25869SJohn Snow
173993b25869SJohn Snowcc_has_warning_flag() {
174093b25869SJohn Snow    write_c_skeleton;
174193b25869SJohn Snow
1742a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1743a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1744a1d29d6cSPeter Maydell    # warning options).
174593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
174693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
174793b25869SJohn Snow}
174893b25869SJohn Snow
174993b25869SJohn Snowfor flag in $gcc_flags; do
175093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
17518d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
17528d05095cSPaolo Bonzini    fi
17538d05095cSPaolo Bonzinidone
17548d05095cSPaolo Bonzini
175563678e17SSteven Noonanif test "$stack_protector" != "no"; then
1756fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1757fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1758fccd35a0SRodrigo Rebello{
1759fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1760fccd35a0SRodrigo Rebello    while (*c) {
1761fccd35a0SRodrigo Rebello        *p++ = *c++;
1762fccd35a0SRodrigo Rebello    }
1763fccd35a0SRodrigo Rebello    return 0;
1764fccd35a0SRodrigo Rebello}
1765fccd35a0SRodrigo RebelloEOF
176663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
17673b463a3fSMiroslav Rezanina  sp_on=0
176863678e17SSteven Noonan  for flag in $gcc_flags; do
1769590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1770590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1771590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1772590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
177363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
17743b463a3fSMiroslav Rezanina      sp_on=1
177563678e17SSteven Noonan      break
177663678e17SSteven Noonan    fi
177763678e17SSteven Noonan  done
17783b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
17793b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
17803b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
17813b463a3fSMiroslav Rezanina    fi
17823b463a3fSMiroslav Rezanina  fi
178337746c5eSMarc-André Lureaufi
178437746c5eSMarc-André Lureau
178520bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
178620bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
178720bc94a2SPaolo Bonzinicat > $TMPC << EOF
178820bc94a2SPaolo Bonzinistruct {
178920bc94a2SPaolo Bonzini  int a[2];
179020bc94a2SPaolo Bonzini} x = {0};
179120bc94a2SPaolo BonziniEOF
179220bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
179320bc94a2SPaolo Bonzini  :
179420bc94a2SPaolo Bonzinielse
179520bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
179620bc94a2SPaolo Bonzinifi
179720bc94a2SPaolo Bonzini
1798cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1799cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1800cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1801cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1802cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1803cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1804cbdd1999SPaolo Bonziniint main(void) { return 0; }
1805cbdd1999SPaolo Bonzini#else
1806cbdd1999SPaolo Bonzini#error No bug in this compiler.
1807cbdd1999SPaolo Bonzini#endif
1808cbdd1999SPaolo BonziniEOF
1809cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1810cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1811cbdd1999SPaolo Bonzinifi
1812cbdd1999SPaolo Bonzini
181340d6444eSAvi Kivityif test "$static" = "yes" ; then
1814aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1815aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1816aa0d1f44SPaolo Bonzini  fi
181740d6444eSAvi Kivity  if test "$pie" = "yes" ; then
181876ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
181940d6444eSAvi Kivity  else
182040d6444eSAvi Kivity    pie="no"
182140d6444eSAvi Kivity  fi
182240d6444eSAvi Kivityfi
182340d6444eSAvi Kivity
1824768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1825768b7855SEmilio G. Cota  cat > $TMPC << EOF
1826768b7855SEmilio G. Cotastatic __thread int tls_var;
1827768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1828768b7855SEmilio G. CotaEOF
1829768b7855SEmilio G. Cota
1830768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1831768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1832768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1833768b7855SEmilio G. Cotafi
1834768b7855SEmilio G. Cota
183540d6444eSAvi Kivityif test "$pie" = ""; then
183640d6444eSAvi Kivity  case "$cpu-$targetos" in
1837c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
183840d6444eSAvi Kivity      ;;
183940d6444eSAvi Kivity    *)
184040d6444eSAvi Kivity      pie="no"
184140d6444eSAvi Kivity      ;;
184240d6444eSAvi Kivity  esac
184340d6444eSAvi Kivityfi
184440d6444eSAvi Kivity
184540d6444eSAvi Kivityif test "$pie" != "no" ; then
184640d6444eSAvi Kivity  cat > $TMPC << EOF
184721d4a791SAvi Kivity
184821d4a791SAvi Kivity#ifdef __linux__
184921d4a791SAvi Kivity#  define THREAD __thread
185021d4a791SAvi Kivity#else
185121d4a791SAvi Kivity#  define THREAD
185221d4a791SAvi Kivity#endif
185321d4a791SAvi Kivity
185421d4a791SAvi Kivitystatic THREAD int tls_var;
185521d4a791SAvi Kivity
185621d4a791SAvi Kivityint main(void) { return tls_var; }
185721d4a791SAvi Kivity
185840d6444eSAvi KivityEOF
185940d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
186040d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
186140d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
186240d6444eSAvi Kivity    pie="yes"
186340d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
186440d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
186540d6444eSAvi Kivity    fi
186640d6444eSAvi Kivity  else
186740d6444eSAvi Kivity    if test "$pie" = "yes"; then
186876ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
186940d6444eSAvi Kivity    else
187040d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
187140d6444eSAvi Kivity      pie="no"
187240d6444eSAvi Kivity    fi
187340d6444eSAvi Kivity  fi
187446eef33bSBrad
1875e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
187646eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
187746eef33bSBrad    LDFLAGS_NOPIE="-nopie"
187846eef33bSBrad  fi
187940d6444eSAvi Kivityfi
188040d6444eSAvi Kivity
188109dada40SPaolo Bonzini##########################################
188209dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
188309dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
188409dada40SPaolo Bonzini# specification is necessary
188509dada40SPaolo Bonzini
188609dada40SPaolo Bonziniif test "$cpu" = "i386"; then
188709dada40SPaolo Bonzini  cat > $TMPC << EOF
188809dada40SPaolo Bonzinistatic int sfaa(int *ptr)
188909dada40SPaolo Bonzini{
189009dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
189109dada40SPaolo Bonzini}
189209dada40SPaolo Bonzini
189309dada40SPaolo Bonziniint main(void)
189409dada40SPaolo Bonzini{
189509dada40SPaolo Bonzini  int val = 42;
18961405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
189709dada40SPaolo Bonzini  sfaa(&val);
189809dada40SPaolo Bonzini  return val;
189909dada40SPaolo Bonzini}
190009dada40SPaolo BonziniEOF
190109dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
190209dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
190309dada40SPaolo Bonzini  fi
190409dada40SPaolo Bonzinifi
190509dada40SPaolo Bonzini
190609dada40SPaolo Bonzini#########################################
1907ec530c81Sbellard# Solaris specific configure tool chain decisions
190809dada40SPaolo Bonzini
1909ec530c81Sbellardif test "$solaris" = "yes" ; then
19106792aa11SLoïc Minier  if has $install; then
19116792aa11SLoïc Minier    :
19126792aa11SLoïc Minier  else
191376ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
191476ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
191576ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1916ec530c81Sbellard  fi
191789138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
191876ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
191976ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
192076ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1921ec530c81Sbellard  fi
19226792aa11SLoïc Minier  if has ar; then
19236792aa11SLoïc Minier    :
19246792aa11SLoïc Minier  else
1925ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
192676ad07a4SPeter Maydell      error_exit "No path includes ar" \
192776ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1928ec530c81Sbellard    fi
192976ad07a4SPeter Maydell    error_exit "No path includes ar"
1930ec530c81Sbellard  fi
1931ec530c81Sbellardfi
1932ec530c81Sbellard
1933afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1934d880a3baSPaolo Bonzini    for target in $default_target_list; do
1935d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1936d880a3baSPaolo Bonzini            target_list="$target_list $target"
1937d880a3baSPaolo Bonzini    done
1938d880a3baSPaolo Bonzini    target_list="${target_list# }"
1939121afa9eSAnthony Liguorielse
194089138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1941d880a3baSPaolo Bonzini    for target in $target_list; do
194225b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
194325b48338SPeter Maydell        # friendly error message than if we let it fall through.
194425b48338SPeter Maydell        case " $default_target_list " in
194525b48338SPeter Maydell            *" $target "*)
194625b48338SPeter Maydell                ;;
194725b48338SPeter Maydell            *)
194825b48338SPeter Maydell                error_exit "Unknown target name '$target'"
194925b48338SPeter Maydell                ;;
195025b48338SPeter Maydell        esac
1951d880a3baSPaolo Bonzini        supported_target $target || exit 1
195225b48338SPeter Maydell    done
1953d880a3baSPaolo Bonzinifi
195425b48338SPeter Maydell
1955f55fe278SPaolo Bonzini# see if system emulation was really requested
1956f55fe278SPaolo Bonzinicase " $target_list " in
1957f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1958f55fe278SPaolo Bonzini  ;;
1959f55fe278SPaolo Bonzini  *) softmmu=no
1960f55fe278SPaolo Bonzini  ;;
1961f55fe278SPaolo Bonziniesac
19625327cf48Sbellard
1963249247c9SJuan Quintelafeature_not_found() {
1964249247c9SJuan Quintela  feature=$1
196521684af0SStewart Smith  remedy=$2
1966249247c9SJuan Quintela
196776ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
196821684af0SStewart Smith      "configure was not able to find it." \
196921684af0SStewart Smith      "$remedy"
1970249247c9SJuan Quintela}
1971249247c9SJuan Quintela
19727d13299dSbellard# ---
19737d13299dSbellard# big/little endian test
19747d13299dSbellardcat > $TMPC << EOF
197561cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
197661cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
197761cc919fSMike Frysingerextern int foo(short *, short *);
197861cc919fSMike Frysingerint main(int argc, char *argv[]) {
197961cc919fSMike Frysinger    return foo(big_endian, little_endian);
19807d13299dSbellard}
19817d13299dSbellardEOF
19827d13299dSbellard
198361cc919fSMike Frysingerif compile_object ; then
198412f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
198561cc919fSMike Frysinger        bigendian="yes"
198612f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
198761cc919fSMike Frysinger        bigendian="no"
19887d13299dSbellard    else
19897d13299dSbellard        echo big/little test failed
19907d13299dSbellard    fi
19917d13299dSbellardelse
199261cc919fSMike Frysinger    echo big/little test failed
19937d13299dSbellardfi
19947d13299dSbellard
1995b0a47e79SJuan Quintela##########################################
1996a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1997a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1998a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1999a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2000a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2001a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2002a30878e7SPeter Maydell    fi
2003a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2004a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2005a30878e7SPeter Maydell    fi
2006a30878e7SPeter Maydell    gtk=no
2007a30878e7SPeter Maydell    sdl=no
2008a30878e7SPeter Maydellfi
2009a30878e7SPeter Maydell
20106b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
20116b39b063SEric Blakecat > $TMPC << EOF
20126b39b063SEric Blake#include <stdint.h>
20136b39b063SEric Blake#include <stdio.h>
20146b39b063SEric Blakeint main(int argc, char *argv[]) {
20156b39b063SEric Blake    return printf("%zu", SIZE_MAX);
20166b39b063SEric Blake}
20176b39b063SEric BlakeEOF
20186b39b063SEric Blakehave_broken_size_max=no
20196b39b063SEric Blakeif ! compile_object -Werror ; then
20206b39b063SEric Blake    have_broken_size_max=yes
20216b39b063SEric Blakefi
20226b39b063SEric Blake
2023a30878e7SPeter Maydell##########################################
2024015a33bdSGonglei# L2TPV3 probe
2025015a33bdSGonglei
2026015a33bdSGongleicat > $TMPC <<EOF
2027015a33bdSGonglei#include <sys/socket.h>
2028bff6cb72SMichael Tokarev#include <linux/ip.h>
2029015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2030015a33bdSGongleiEOF
2031015a33bdSGongleiif compile_prog "" "" ; then
2032015a33bdSGonglei  l2tpv3=yes
2033015a33bdSGongleielse
2034015a33bdSGonglei  l2tpv3=no
2035015a33bdSGongleifi
2036015a33bdSGonglei
2037015a33bdSGonglei##########################################
20384d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
20394d9310f4SDaniel P. Berrange
20404d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
20414d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
20424d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
20434d9310f4SDaniel P. Berrange    #
20444d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
20454d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
20464d9310f4SDaniel P. Berrange    #
20474d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
20484d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
20494d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
20504d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
20514d9310f4SDaniel P. Berrange    # that for you.
20524d9310f4SDaniel P. Berrange    #
20534d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
20544d9310f4SDaniel P. Berrange    # are not in fact redundant.
20554d9310f4SDaniel P. Berrangecat > $TMPC << EOF
20564d9310f4SDaniel P. Berrange#include <unistd.h>
20574d9310f4SDaniel P. Berrange#include <time.h>
20584d9310f4SDaniel P. Berrange#undef localtime_r
20594d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
20604d9310f4SDaniel P. BerrangeEOF
20614d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
20624d9310f4SDaniel P. Berrange        localtime_r="yes"
20634d9310f4SDaniel P. Berrange    else
20644d9310f4SDaniel P. Berrange        localtime_r="no"
20654d9310f4SDaniel P. Berrange    fi
20664d9310f4SDaniel P. Berrangefi
20674d9310f4SDaniel P. Berrange
20684d9310f4SDaniel P. Berrange##########################################
2069779ab5e3SStefan Weil# pkg-config probe
2070779ab5e3SStefan Weil
2071779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
207276ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2073779ab5e3SStefan Weilfi
2074779ab5e3SStefan Weil
2075779ab5e3SStefan Weil##########################################
2076b0a47e79SJuan Quintela# NPTL probe
2077b0a47e79SJuan Quintela
207824cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2079bd0c5661Spbrook  cat > $TMPC <<EOF
2080bd0c5661Spbrook#include <sched.h>
208130813ceaSpbrook#include <linux/futex.h>
2082182eacc0SStefan Weilint main(void) {
2083bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2084bd0c5661Spbrook#error bork
2085bd0c5661Spbrook#endif
2086182eacc0SStefan Weil  return 0;
2087bd0c5661Spbrook}
2088bd0c5661SpbrookEOF
208924cb36a6SPeter Maydell  if ! compile_object ; then
209021684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2091b0a47e79SJuan Quintela  fi
2092bd0c5661Spbrookfi
2093bd0c5661Spbrook
209499f2dbd3SLiang Li#########################################
2095ac62922eSbalrog# zlib check
2096ac62922eSbalrog
20971ece9905SAlon Levyif test "$zlib" != "no" ; then
2098ac62922eSbalrog    cat > $TMPC << EOF
2099ac62922eSbalrog#include <zlib.h>
2100ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
2101ac62922eSbalrogEOF
210252166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
2103ac62922eSbalrog        :
2104ac62922eSbalrog    else
210576ad07a4SPeter Maydell        error_exit "zlib check failed" \
210676ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
2107ac62922eSbalrog    fi
21081ece9905SAlon Levyfi
2109eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
2110ac62922eSbalrog
2111ac62922eSbalrog##########################################
2112607dacd0Sqiaonuohan# lzo check
2113607dacd0Sqiaonuohan
2114607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2115607dacd0Sqiaonuohan    cat > $TMPC << EOF
2116607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2117607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2118607dacd0SqiaonuohanEOF
2119607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2120607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2121b25c9dffSStefan Weil        lzo="yes"
2122b25c9dffSStefan Weil    else
2123b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2124b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2125b25c9dffSStefan Weil        fi
2126b25c9dffSStefan Weil        lzo="no"
2127b25c9dffSStefan Weil    fi
2128607dacd0Sqiaonuohanfi
2129607dacd0Sqiaonuohan
2130607dacd0Sqiaonuohan##########################################
2131607dacd0Sqiaonuohan# snappy check
2132607dacd0Sqiaonuohan
2133607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2134607dacd0Sqiaonuohan    cat > $TMPC << EOF
2135607dacd0Sqiaonuohan#include <snappy-c.h>
2136607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2137607dacd0SqiaonuohanEOF
2138607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2139607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2140b25c9dffSStefan Weil        snappy="yes"
2141b25c9dffSStefan Weil    else
2142b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2143b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2144b25c9dffSStefan Weil        fi
2145b25c9dffSStefan Weil        snappy="no"
2146b25c9dffSStefan Weil    fi
2147607dacd0Sqiaonuohanfi
2148607dacd0Sqiaonuohan
2149607dacd0Sqiaonuohan##########################################
21506b383c08SPeter Wu# bzip2 check
21516b383c08SPeter Wu
21526b383c08SPeter Wuif test "$bzip2" != "no" ; then
21536b383c08SPeter Wu    cat > $TMPC << EOF
21546b383c08SPeter Wu#include <bzlib.h>
21556b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
21566b383c08SPeter WuEOF
21576b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
21586b383c08SPeter Wu        bzip2="yes"
21596b383c08SPeter Wu    else
21606b383c08SPeter Wu        if test "$bzip2" = "yes"; then
21616b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
21626b383c08SPeter Wu        fi
21636b383c08SPeter Wu        bzip2="no"
21646b383c08SPeter Wu    fi
21656b383c08SPeter Wufi
21666b383c08SPeter Wu
21676b383c08SPeter Wu##########################################
2168f794573eSEduardo Otubo# libseccomp check
2169f794573eSEduardo Otubo
2170f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2171693e5910SAndrew Jones    case "$cpu" in
2172693e5910SAndrew Jones    i386|x86_64)
2173ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2174693e5910SAndrew Jones        ;;
21755ce43972SJames Hogan    mips)
21765ce43972SJames Hogan        libseccomp_minver="2.2.0"
21775ce43972SJames Hogan        ;;
2178693e5910SAndrew Jones    arm|aarch64)
2179693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2180693e5910SAndrew Jones        ;;
21813aa35fcfSThomas Huth    ppc|ppc64|s390x)
21823e684455SMichael Strosaker        libseccomp_minver="2.3.0"
21833e684455SMichael Strosaker        ;;
2184693e5910SAndrew Jones    *)
2185693e5910SAndrew Jones        libseccomp_minver=""
2186693e5910SAndrew Jones        ;;
2187693e5910SAndrew Jones    esac
2188693e5910SAndrew Jones
2189693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2190693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2191c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2192c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2193f794573eSEduardo Otubo        seccomp="yes"
2194f794573eSEduardo Otubo    else
2195f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2196693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2197693e5910SAndrew Jones                feature_not_found "libseccomp" \
2198693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2199693e5910SAndrew Jones            else
2200693e5910SAndrew Jones                feature_not_found "libseccomp" \
2201693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2202693e5910SAndrew Jones            fi
2203896848f0SEduardo Otubo        fi
2204e84d5956SYann E. MORIN        seccomp="no"
2205f794573eSEduardo Otubo    fi
2206f794573eSEduardo Otubofi
2207f794573eSEduardo Otubo##########################################
2208e37630caSaliguori# xen probe
2209e37630caSaliguori
2210fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2211c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2212c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2213c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2214c1cdd9d5SJuergen Gross
2215c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2216c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2217c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2218c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2219c1cdd9d5SJuergen Gross    xen=yes
2220c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2221c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
222258ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
222358ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
222458ea9a7aSAnthony PERARD    fi
2225c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2226c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2227c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2228c1cdd9d5SJuergen Gross  else
2229c1cdd9d5SJuergen Gross
2230b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2231d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2232d5b93ddfSAnthony PERARD
223350ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
223450ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
223550ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
223650ced5b3SStefan Weil
223750ced5b3SStefan Weil    # Xen (any)
223850ced5b3SStefan Weil    cat > $TMPC <<EOF
223950ced5b3SStefan Weil#include <xenctrl.h>
224050ced5b3SStefan Weilint main(void) {
224150ced5b3SStefan Weil  return 0;
224250ced5b3SStefan Weil}
224350ced5b3SStefan WeilEOF
224450ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
224550ced5b3SStefan Weil      # Xen not found
224650ced5b3SStefan Weil      if test "$xen" = "yes" ; then
224721684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
224850ced5b3SStefan Weil      fi
224950ced5b3SStefan Weil      xen=no
225050ced5b3SStefan Weil
2251d5b93ddfSAnthony PERARD    # Xen unstable
225269deef08SPeter Maydell    elif
225369deef08SPeter Maydell        cat > $TMPC <<EOF &&
22542cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
22552cbf8903SRoss Lagerwall#define __XEN_TOOLS__
22562cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2257d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
22582cbf8903SRoss Lagerwallint main(void) {
22592cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2260d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
22612cbf8903SRoss Lagerwall
22622cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
22632cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
22642cbf8903SRoss Lagerwall
2265d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2266d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2267d3c49ebbSPaul Durrant
22682cbf8903SRoss Lagerwall  return 0;
22692cbf8903SRoss Lagerwall}
22702cbf8903SRoss LagerwallEOF
22712cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
22722cbf8903SRoss Lagerwall      then
22732cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
22742cbf8903SRoss Lagerwall      xen_ctrl_version=41100
22752cbf8903SRoss Lagerwall      xen=yes
22762cbf8903SRoss Lagerwall    elif
22772cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
22785ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
22795ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
228058ea9a7aSAnthony PERARD#include <xentoolcore.h>
22815ba3d756SIgor Druzhininint main(void) {
22825ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
22835ba3d756SIgor Druzhinin
22845ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
22855ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
228658ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
22875ba3d756SIgor Druzhinin
22885ba3d756SIgor Druzhinin  return 0;
22895ba3d756SIgor Druzhinin}
22905ba3d756SIgor DruzhininEOF
229158ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
22925ba3d756SIgor Druzhinin      then
229358ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
22945ba3d756SIgor Druzhinin      xen_ctrl_version=41000
22955ba3d756SIgor Druzhinin      xen=yes
22965ba3d756SIgor Druzhinin    elif
22975ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2298da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2299da8090ccSPaul Durrant#define __XEN_TOOLS__
2300da8090ccSPaul Durrant#include <xendevicemodel.h>
2301da8090ccSPaul Durrantint main(void) {
2302da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2303da8090ccSPaul Durrant
2304da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2305da8090ccSPaul Durrant  xendevicemodel_close(xd);
2306da8090ccSPaul Durrant
2307da8090ccSPaul Durrant  return 0;
2308da8090ccSPaul Durrant}
2309da8090ccSPaul DurrantEOF
2310da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2311da8090ccSPaul Durrant      then
2312da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2313f1167ee6SJuergen Gross      xen_ctrl_version=40900
2314da8090ccSPaul Durrant      xen=yes
2315da8090ccSPaul Durrant    elif
2316da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
23175eeb39c2SIan Campbell/*
23185eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
23195eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2320b6eb9b45SPaulina Szubarczyk *
2321b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2322b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2323b6eb9b45SPaulina Szubarczyk */
2324b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2325b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2326b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2327b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2328b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2329b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2330b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2331b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2332b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2333b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2334b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2335b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2336b6eb9b45SPaulina Szubarczyk#endif
2337b6eb9b45SPaulina Szubarczykint main(void) {
2338b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2339b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2340b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2341b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2342b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2343b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2344b6eb9b45SPaulina Szubarczyk
2345b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2346b6eb9b45SPaulina Szubarczyk
2347b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2348b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2349b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2350b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2351b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2352b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2353b6eb9b45SPaulina Szubarczyk
2354b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2355b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2356b6eb9b45SPaulina Szubarczyk
2357b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2358b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2359b6eb9b45SPaulina Szubarczyk
2360b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2361b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2362b6eb9b45SPaulina Szubarczyk
2363b6eb9b45SPaulina Szubarczyk  return 0;
2364b6eb9b45SPaulina Szubarczyk}
2365b6eb9b45SPaulina SzubarczykEOF
2366b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2367b6eb9b45SPaulina Szubarczyk      then
2368f1167ee6SJuergen Gross      xen_ctrl_version=40800
2369b6eb9b45SPaulina Szubarczyk      xen=yes
2370b6eb9b45SPaulina Szubarczyk    elif
2371b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2372b6eb9b45SPaulina Szubarczyk/*
2373b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2374b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
23755eeb39c2SIan Campbell */
23765eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
23775eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
23785eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
23795eeb39c2SIan Campbell#include <xenctrl.h>
23805eeb39c2SIan Campbell#include <xenstore.h>
23815eeb39c2SIan Campbell#include <xenevtchn.h>
23825eeb39c2SIan Campbell#include <xengnttab.h>
23835eeb39c2SIan Campbell#include <xenforeignmemory.h>
23845eeb39c2SIan Campbell#include <stdint.h>
23855eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
23865eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
23875eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
23885eeb39c2SIan Campbell#endif
23895eeb39c2SIan Campbellint main(void) {
23905eeb39c2SIan Campbell  xc_interface *xc = NULL;
23915eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
23925eeb39c2SIan Campbell  xenevtchn_handle *xe;
23935eeb39c2SIan Campbell  xengnttab_handle *xg;
23945eeb39c2SIan Campbell  xen_domain_handle_t handle;
23955eeb39c2SIan Campbell
23965eeb39c2SIan Campbell  xs_daemon_open();
23975eeb39c2SIan Campbell
23985eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
23995eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
24005eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
24015eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
24025eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
24035eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
24045eeb39c2SIan Campbell
24055eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
24065eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
24075eeb39c2SIan Campbell
24085eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
24095eeb39c2SIan Campbell  xenevtchn_fd(xe);
24105eeb39c2SIan Campbell
24115eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
24125eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
24135eeb39c2SIan Campbell
24145eeb39c2SIan Campbell  return 0;
24155eeb39c2SIan Campbell}
24165eeb39c2SIan CampbellEOF
24175eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
24185eeb39c2SIan Campbell      then
2419f1167ee6SJuergen Gross      xen_ctrl_version=40701
24205eeb39c2SIan Campbell      xen=yes
24215eeb39c2SIan Campbell    elif
24225eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2423e37630caSaliguori#include <xenctrl.h>
2424cdadde39SRoger Pau Monne#include <stdint.h>
2425cdadde39SRoger Pau Monneint main(void) {
2426cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2427cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2428cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2429cdadde39SRoger Pau Monne  return 0;
2430cdadde39SRoger Pau Monne}
2431cdadde39SRoger Pau MonneEOF
2432cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2433cdadde39SRoger Pau Monne      then
2434f1167ee6SJuergen Gross      xen_ctrl_version=40700
2435cdadde39SRoger Pau Monne      xen=yes
2436cdadde39SRoger Pau Monne
2437cdadde39SRoger Pau Monne    # Xen 4.6
2438cdadde39SRoger Pau Monne    elif
2439cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2440cdadde39SRoger Pau Monne#include <xenctrl.h>
2441e108a3c1SAnthony PERARD#include <xenstore.h>
2442d5b93ddfSAnthony PERARD#include <stdint.h>
2443d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2444d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2445d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2446d5b93ddfSAnthony PERARD#endif
2447d5b93ddfSAnthony PERARDint main(void) {
2448d5b93ddfSAnthony PERARD  xc_interface *xc;
2449d5b93ddfSAnthony PERARD  xs_daemon_open();
2450d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2451d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2452d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2453b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
24548688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2455d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
245620a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2457d8b441a3SJan Beulich  return 0;
2458d8b441a3SJan Beulich}
2459d8b441a3SJan BeulichEOF
2460d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2461d8b441a3SJan Beulich      then
2462f1167ee6SJuergen Gross      xen_ctrl_version=40600
2463d8b441a3SJan Beulich      xen=yes
2464d8b441a3SJan Beulich
2465d8b441a3SJan Beulich    # Xen 4.5
2466d8b441a3SJan Beulich    elif
2467d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2468d8b441a3SJan Beulich#include <xenctrl.h>
2469d8b441a3SJan Beulich#include <xenstore.h>
2470d8b441a3SJan Beulich#include <stdint.h>
2471d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2472d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2473d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2474d8b441a3SJan Beulich#endif
2475d8b441a3SJan Beulichint main(void) {
2476d8b441a3SJan Beulich  xc_interface *xc;
2477d8b441a3SJan Beulich  xs_daemon_open();
2478d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2479d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2480d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2481d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2482d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
24833996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
24843996e85cSPaul Durrant  return 0;
24853996e85cSPaul Durrant}
24863996e85cSPaul DurrantEOF
24873996e85cSPaul Durrant        compile_prog "" "$xen_libs"
24883996e85cSPaul Durrant      then
2489f1167ee6SJuergen Gross      xen_ctrl_version=40500
24903996e85cSPaul Durrant      xen=yes
24913996e85cSPaul Durrant
24923996e85cSPaul Durrant    elif
24933996e85cSPaul Durrant        cat > $TMPC <<EOF &&
24943996e85cSPaul Durrant#include <xenctrl.h>
24953996e85cSPaul Durrant#include <xenstore.h>
24963996e85cSPaul Durrant#include <stdint.h>
24973996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
24983996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
24993996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
25003996e85cSPaul Durrant#endif
25013996e85cSPaul Durrantint main(void) {
25023996e85cSPaul Durrant  xc_interface *xc;
25033996e85cSPaul Durrant  xs_daemon_open();
25043996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
25053996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
25063996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
25073996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
25083996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
25098688e065SStefano Stabellini  return 0;
25108688e065SStefano Stabellini}
25118688e065SStefano StabelliniEOF
25128688e065SStefano Stabellini        compile_prog "" "$xen_libs"
251369deef08SPeter Maydell      then
2514f1167ee6SJuergen Gross      xen_ctrl_version=40200
25158688e065SStefano Stabellini      xen=yes
25168688e065SStefano Stabellini
2517e37630caSaliguori    else
2518fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2519edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2520edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2521fc321b4bSJuan Quintela      fi
2522fc321b4bSJuan Quintela      xen=no
2523e37630caSaliguori    fi
2524d5b93ddfSAnthony PERARD
2525d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2526f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
25275eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
25285eeb39c2SIan Campbell      fi
2529d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2530d5b93ddfSAnthony PERARD    fi
2531e37630caSaliguori  fi
2532c1cdd9d5SJuergen Grossfi
2533e37630caSaliguori
2534eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2535edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2536eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2537eb6fda0fSAnthony PERARD  else
2538eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
253976ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
254076ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2541eb6fda0fSAnthony PERARD    fi
2542eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2543eb6fda0fSAnthony PERARD  fi
2544eb6fda0fSAnthony PERARDfi
2545eb6fda0fSAnthony PERARD
254664a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
254764a7ad6fSIan Campbell   test "$xen" != "yes"; then
254864a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
254964a7ad6fSIan Campbell	       "which requires Xen support."
255064a7ad6fSIan Campbellfi
255164a7ad6fSIan Campbell
2552e37630caSaliguori##########################################
2553d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2554d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2555327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2556d661d9a4SJustin Terry (VM)        whpx="yes"
2557d661d9a4SJustin Terry (VM)    else
2558d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
255953537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2560d661d9a4SJustin Terry (VM)        fi
2561d661d9a4SJustin Terry (VM)        whpx="no"
2562d661d9a4SJustin Terry (VM)    fi
2563d661d9a4SJustin Terry (VM)fi
2564d661d9a4SJustin Terry (VM)
2565d661d9a4SJustin Terry (VM)##########################################
2566dfffc653SJuan Quintela# Sparse probe
2567dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
25680dba6195SLoïc Minier  if has cgcc; then
2569dfffc653SJuan Quintela    sparse=yes
2570dfffc653SJuan Quintela  else
2571dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
257221684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2573dfffc653SJuan Quintela    fi
2574dfffc653SJuan Quintela    sparse=no
2575dfffc653SJuan Quintela  fi
2576dfffc653SJuan Quintelafi
2577dfffc653SJuan Quintela
2578dfffc653SJuan Quintela##########################################
2579f676c67eSJeremy White# X11 probe
2580f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
25818781595bSGerd Hoffmann    have_x11=yes
258289138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
258389138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2584f676c67eSJeremy Whitefi
2585f676c67eSJeremy White
2586f676c67eSJeremy White##########################################
2587a4ccabcfSAnthony Liguori# GTK probe
2588a4ccabcfSAnthony Liguori
25895a464e6cSPeter Xuif test "$gtk" != "no"; then
25909e04c683SStefan Weil    if test "$gtkabi" = ""; then
25915fe309ffSGerd Hoffmann        # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
25925fe309ffSGerd Hoffmann        # Use 2.0 as a fallback if that is available.
25935fe309ffSGerd Hoffmann        if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
25949e04c683SStefan Weil            gtkabi=3.0
25955fe309ffSGerd Hoffmann        elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
25969e04c683SStefan Weil            gtkabi=2.0
25975fe309ffSGerd Hoffmann        else
25985fe309ffSGerd Hoffmann            gtkabi=3.0
25999e04c683SStefan Weil        fi
26009e04c683SStefan Weil    fi
2601528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
26020a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2603528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2604528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2605bbbf9bfbSStefan Weil    else
2606bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2607bbbf9bfbSStefan Weil    fi
2608bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
260989138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
261089138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
261189138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
26120a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
26138781595bSGerd Hoffmann            need_x11=yes
2614f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2615f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
26160a337ed0SGerd Hoffmann        fi
2617bbbf9bfbSStefan Weil        gtk="yes"
2618bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
26195fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2620bbbf9bfbSStefan Weil    else
2621bbbf9bfbSStefan Weil        gtk="no"
2622bbbf9bfbSStefan Weil    fi
2623bbbf9bfbSStefan Weilfi
2624bbbf9bfbSStefan Weil
2625ddbb0d09SDaniel P. Berrange
2626ddbb0d09SDaniel P. Berrange##########################################
2627ddbb0d09SDaniel P. Berrange# GNUTLS probe
2628ddbb0d09SDaniel P. Berrange
262937371299SPeter Maydellgnutls_works() {
263037371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
263137371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
263237371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
263337371299SPeter Maydell    # builds doesn't work:
263437371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
263537371299SPeter Maydell    #
263637371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
263737371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
263837371299SPeter Maydell        return 1
263937371299SPeter Maydell    fi
264037371299SPeter Maydell
264137371299SPeter Maydell    write_c_skeleton
264237371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
264337371299SPeter Maydell}
264437371299SPeter Maydell
264562893b67SDaniel P. Berrangegnutls_gcrypt=no
2646ed754746SDaniel P. Berrangegnutls_nettle=no
2647ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
264837371299SPeter Maydell    if gnutls_works; then
264989138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
265089138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2651ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2652ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2653ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2654ddbb0d09SDaniel P. Berrange        gnutls="yes"
2655ddbb0d09SDaniel P. Berrange
2656b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2657b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2658b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2659b917da4cSDaniel P. Berrange	else
2660b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2661b917da4cSDaniel P. Berrange	fi
2662b917da4cSDaniel P. Berrange
266362893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
266462893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2665ed754746SDaniel P. Berrange	    gnutls_nettle=yes
266662893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
266789138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2668ed754746SDaniel P. Berrange		*gcrypt*)
2669ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2670ed754746SDaniel P. Berrange		    gnutls_nettle=no
2671ed754746SDaniel P. Berrange		    ;;
2672ed754746SDaniel P. Berrange		*nettle*)
2673ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2674ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2675ed754746SDaniel P. Berrange		    ;;
2676ed754746SDaniel P. Berrange		*)
2677ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2678ed754746SDaniel P. Berrange		    gnutls_nettle=no
2679ed754746SDaniel P. Berrange		    ;;
268062893b67SDaniel P. Berrange	    esac
268162893b67SDaniel P. Berrange	else
268262893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2683ed754746SDaniel P. Berrange	    gnutls_nettle=no
268462893b67SDaniel P. Berrange	fi
2685ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2686ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2687ddbb0d09SDaniel P. Berrange    else
2688ddbb0d09SDaniel P. Berrange        gnutls="no"
2689b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2690ddbb0d09SDaniel P. Berrange    fi
2691ddbb0d09SDaniel P. Berrangeelse
2692b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2693ddbb0d09SDaniel P. Berrangefi
2694ddbb0d09SDaniel P. Berrange
269591bfcdb0SDaniel P. Berrange
269691bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
269791bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
269891bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
269991bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
270091bfcdb0SDaniel P. Berrangethen
270191bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
270291bfcdb0SDaniel P. Berrange    then
270391bfcdb0SDaniel P. Berrange        gcrypt="no"
270491bfcdb0SDaniel P. Berrange    fi
270591bfcdb0SDaniel P. Berrangefi
270691bfcdb0SDaniel P. Berrange
270791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
270891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
270991bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
271091bfcdb0SDaniel P. Berrangeif test -z "$nettle"
271191bfcdb0SDaniel P. Berrangethen
271291bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
271391bfcdb0SDaniel P. Berrange    then
271491bfcdb0SDaniel P. Berrange        nettle="no"
271591bfcdb0SDaniel P. Berrange    fi
271691bfcdb0SDaniel P. Berrangefi
271791bfcdb0SDaniel P. Berrange
271891bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
271991bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
272091bfcdb0SDaniel P. Berrange    then
272191bfcdb0SDaniel P. Berrange	return 1
272291bfcdb0SDaniel P. Berrange    fi
272391bfcdb0SDaniel P. Berrange
272491bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
272591bfcdb0SDaniel P. Berrange    then
272689138857SStefan Weil	host=$(libgcrypt-config --host)
272791bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
272891bfcdb0SDaniel P. Berrange	then
272991bfcdb0SDaniel P. Berrange	    return 1
273091bfcdb0SDaniel P. Berrange	fi
273191bfcdb0SDaniel P. Berrange    fi
273291bfcdb0SDaniel P. Berrange
273391bfcdb0SDaniel P. Berrange    return 0
273491bfcdb0SDaniel P. Berrange}
273591bfcdb0SDaniel P. Berrange
273691bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
273791bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
273889138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
273989138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
274091bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
274191bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
274291bfcdb0SDaniel P. Berrange        # turn breaks static builds...
274391bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
274491bfcdb0SDaniel P. Berrange        then
274591bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
274691bfcdb0SDaniel P. Berrange        fi
274762893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
274862893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
274962893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
275091bfcdb0SDaniel P. Berrange        gcrypt="yes"
275191bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
275291bfcdb0SDaniel P. Berrange           nettle="no"
275391bfcdb0SDaniel P. Berrange        fi
275437788f25SDaniel P. Berrange
275537788f25SDaniel P. Berrange        cat > $TMPC << EOF
275637788f25SDaniel P. Berrange#include <gcrypt.h>
275737788f25SDaniel P. Berrangeint main(void) {
275837788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
275937788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
276037788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
276137788f25SDaniel P. Berrange return 0;
276237788f25SDaniel P. Berrange}
276337788f25SDaniel P. BerrangeEOF
276437788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
276537788f25SDaniel P. Berrange            gcrypt_kdf=yes
276637788f25SDaniel P. Berrange        fi
27671f923c70SLongpeng(Mike)
27681f923c70SLongpeng(Mike)        cat > $TMPC << EOF
27691f923c70SLongpeng(Mike)#include <gcrypt.h>
27701f923c70SLongpeng(Mike)int main(void) {
27711f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
27721f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
27731f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
27741f923c70SLongpeng(Mike)  return 0;
27751f923c70SLongpeng(Mike)}
27761f923c70SLongpeng(Mike)EOF
27771f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
27781f923c70SLongpeng(Mike)            gcrypt_hmac=yes
27791f923c70SLongpeng(Mike)        fi
278062893b67SDaniel P. Berrange    else
278191bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
278262893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
278391bfcdb0SDaniel P. Berrange        else
278491bfcdb0SDaniel P. Berrange            gcrypt="no"
278591bfcdb0SDaniel P. Berrange        fi
278662893b67SDaniel P. Berrange    fi
278762893b67SDaniel P. Berrangefi
278862893b67SDaniel P. Berrange
2789ddbb0d09SDaniel P. Berrange
279091bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2791ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
279289138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
279389138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
279489138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2795ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2796ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2797ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
279891bfcdb0SDaniel P. Berrange        nettle="yes"
2799fff2f982SDaniel P. Berrange
2800fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
28019e87a691SSteven Luo#include <stddef.h>
2802fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2803fff2f982SDaniel P. Berrangeint main(void) {
2804fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2805fff2f982SDaniel P. Berrange     return 0;
2806fff2f982SDaniel P. Berrange}
2807fff2f982SDaniel P. BerrangeEOF
2808fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2809fff2f982SDaniel P. Berrange            nettle_kdf=yes
2810fff2f982SDaniel P. Berrange        fi
2811ed754746SDaniel P. Berrange    else
281291bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2813ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
281491bfcdb0SDaniel P. Berrange        else
281591bfcdb0SDaniel P. Berrange            nettle="no"
2816ed754746SDaniel P. Berrange        fi
2817ed754746SDaniel P. Berrange    fi
281891bfcdb0SDaniel P. Berrangefi
281991bfcdb0SDaniel P. Berrange
282091bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
282191bfcdb0SDaniel P. Berrangethen
282291bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
282391bfcdb0SDaniel P. Berrangefi
2824ed754746SDaniel P. Berrange
28259a2fd434SDaniel P. Berrange##########################################
28269a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
28279a2fd434SDaniel P. Berrange
28289a2fd434SDaniel P. Berrangetasn1=yes
282990246037SDaniel P. Berrangetasn1_cflags=""
283090246037SDaniel P. Berrangetasn1_libs=""
28319a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
283289138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
283389138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
28349a2fd434SDaniel P. Berrangeelse
28359a2fd434SDaniel P. Berrange    tasn1=no
28369a2fd434SDaniel P. Berrangefi
28379a2fd434SDaniel P. Berrange
2838ed754746SDaniel P. Berrange
2839bbbf9bfbSStefan Weil##########################################
2840559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2841559607eaSDaniel P. Berrange
2842559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2843559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2844559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2845559607eaSDaniel P. Berrangefi
2846559607eaSDaniel P. Berrange
2847559607eaSDaniel P. Berrange##########################################
2848bbbf9bfbSStefan Weil# VTE probe
2849bbbf9bfbSStefan Weil
2850bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2851bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2852c6feff9eSCole Robinson      vteminversion="0.32.0"
2853c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2854c6feff9eSCole Robinson        vtepackage="vte-2.91"
2855c6feff9eSCole Robinson      else
2856528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2857c6feff9eSCole Robinson      fi
2858528de90aSDaniel P. Berrange    else
2859528de90aSDaniel P. Berrange      vtepackage="vte"
2860c6feff9eSCole Robinson      vteminversion="0.24.0"
2861528de90aSDaniel P. Berrange    fi
2862c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
286389138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
286489138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
286589138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2866bbbf9bfbSStefan Weil        vte="yes"
2867bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
28689e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2869c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
28709e04c683SStefan Weil        else
28719e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
28729e04c683SStefan Weil        fi
2873bbbf9bfbSStefan Weil    else
2874bbbf9bfbSStefan Weil        vte="no"
2875a4ccabcfSAnthony Liguori    fi
2876a4ccabcfSAnthony Liguorifi
2877a4ccabcfSAnthony Liguori
2878a4ccabcfSAnthony Liguori##########################################
287911d9f695Sbellard# SDL probe
288011d9f695Sbellard
28813ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
28823ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
288347c03744SDave Airlie
2884c6093a05SPeter Xusdl_probe ()
2885c6093a05SPeter Xu{
2886c6093a05SPeter Xu  sdl_too_old=no
2887ee8466d0SCole Robinson  if test "$sdlabi" = ""; then
28888f4ea9cdSGerd Hoffmann      if $pkg_config --exists "sdl2"; then
2889ee8466d0SCole Robinson          sdlabi=2.0
28908f4ea9cdSGerd Hoffmann      elif $pkg_config --exists "sdl"; then
2891ee8466d0SCole Robinson          sdlabi=1.2
28928f4ea9cdSGerd Hoffmann      else
28938f4ea9cdSGerd Hoffmann          sdlabi=2.0
2894ee8466d0SCole Robinson      fi
2895ee8466d0SCole Robinson  fi
2896ee8466d0SCole Robinson
289747c03744SDave Airlie  if test $sdlabi = "2.0"; then
289847c03744SDave Airlie      sdl_config=$sdl2_config
289947c03744SDave Airlie      sdlname=sdl2
290047c03744SDave Airlie      sdlconfigname=sdl2_config
2901e07047cfSCole Robinson  elif test $sdlabi = "1.2"; then
290247c03744SDave Airlie      sdlname=sdl
290347c03744SDave Airlie      sdlconfigname=sdl_config
2904e07047cfSCole Robinson  else
2905e07047cfSCole Robinson      error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
29063ec87ffeSPaolo Bonzini  fi
29073ec87ffeSPaolo Bonzini
290889138857SStefan Weil  if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
290947c03744SDave Airlie    sdl_config=$sdlconfigname
291047c03744SDave Airlie  fi
291147c03744SDave Airlie
291247c03744SDave Airlie  if $pkg_config $sdlname --exists; then
291347c03744SDave Airlie    sdlconfig="$pkg_config $sdlname"
291489138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
29153ec87ffeSPaolo Bonzini  elif has ${sdl_config}; then
29163ec87ffeSPaolo Bonzini    sdlconfig="$sdl_config"
291789138857SStefan Weil    sdlversion=$($sdlconfig --version)
2918a0dfd8a4SLoïc Minier  else
2919a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
29208f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
2921a0dfd8a4SLoïc Minier    fi
2922a0dfd8a4SLoïc Minier    sdl=no
2923c6093a05SPeter Xu    # no need to do the rest
2924c6093a05SPeter Xu    return
29259316f803SPaolo Bonzini  fi
292629e5badaSScott Wood  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
29273ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
29283ec87ffeSPaolo Bonzini  fi
292911d9f695Sbellard
293011d9f695Sbellard  cat > $TMPC << EOF
293111d9f695Sbellard#include <SDL.h>
293211d9f695Sbellard#undef main /* We don't want SDL to override our main() */
293311d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
293411d9f695SbellardEOF
293589138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
29362ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
293774f42e18STeLeMan  if test "$static" = "yes" ; then
29385f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
29395f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
29405f37e6d4SThomas Huth    else
294189138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
29425f37e6d4SThomas Huth    fi
294374f42e18STeLeMan  else
294489138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
294574f42e18STeLeMan  fi
294652166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
294789138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
294811d9f695Sbellard      sdl_too_old=yes
294911d9f695Sbellard    else
295011d9f695Sbellard      sdl=yes
295111d9f695Sbellard    fi
29527c1f25b4Sbellard
295367c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
29541ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
295567c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
295689138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
295789138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
295811d9f695Sbellard      fi
295952166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
29601ac88f28SJuan Quintela	:
29611ac88f28SJuan Quintela      else
29621ac88f28SJuan Quintela        sdl=no
29637c1f25b4Sbellard      fi
29647c1f25b4Sbellard    fi # static link
2965c4198157SJuan Quintela  else # sdl not found
2966c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
296721684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2968c4198157SJuan Quintela    fi
2969c4198157SJuan Quintela    sdl=no
29707c1f25b4Sbellard  fi # sdl compile test
2971c6093a05SPeter Xu}
2972c6093a05SPeter Xu
2973c6093a05SPeter Xuif test "$sdl" != "no" ; then
2974c6093a05SPeter Xu  sdl_probe
2975fd677642Sthsfi
297611d9f695Sbellard
29775368a422Saliguoriif test "$sdl" = "yes" ; then
29785368a422Saliguori  cat > $TMPC <<EOF
29795368a422Saliguori#include <SDL.h>
29805368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
29815368a422Saliguori#include <X11/XKBlib.h>
29825368a422Saliguori#else
29835368a422Saliguori#error No x11 support
29845368a422Saliguori#endif
29855368a422Saliguoriint main(void) { return 0; }
29865368a422SaliguoriEOF
2987f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
29888781595bSGerd Hoffmann    need_x11=yes
2989f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2990f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
29915368a422Saliguori  fi
29925368a422Saliguorifi
29935368a422Saliguori
29948f28f3fbSths##########################################
29952da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
29962da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
29972da776dbSMichael R. Hines  cat > $TMPC <<EOF
29982da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
29992da776dbSMichael R. Hinesint main(void) { return 0; }
30002da776dbSMichael R. HinesEOF
3001ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
30022da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
30032da776dbSMichael R. Hines    rdma="yes"
3004ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
30052da776dbSMichael R. Hines  else
30062da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
30072da776dbSMichael R. Hines        error_exit \
3008ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
30092da776dbSMichael R. Hines            " Your options:" \
3010ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
30112da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
30122da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
30132da776dbSMichael R. Hines    fi
30142da776dbSMichael R. Hines    rdma="no"
30152da776dbSMichael R. Hines  fi
30162da776dbSMichael R. Hinesfi
30172da776dbSMichael R. Hines
301895c6bff3SBenoît Canet
301995c6bff3SBenoît Canet##########################################
30202f9606b3Saliguori# VNC SASL detection
3021821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
30222f9606b3Saliguori  cat > $TMPC <<EOF
30232f9606b3Saliguori#include <sasl/sasl.h>
30242f9606b3Saliguori#include <stdio.h>
30252f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
30262f9606b3SaliguoriEOF
30272f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
30282f9606b3Saliguori  vnc_sasl_cflags=""
30292f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
303052166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3031ea784e3bSJuan Quintela    vnc_sasl=yes
3032fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3033ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
30342f9606b3Saliguori  else
3035ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
303621684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3037ea784e3bSJuan Quintela    fi
3038ea784e3bSJuan Quintela    vnc_sasl=no
30392f9606b3Saliguori  fi
30402f9606b3Saliguorifi
30412f9606b3Saliguori
30422f9606b3Saliguori##########################################
30432f6f5c7aSCorentin Chary# VNC JPEG detection
3044821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
30452f6f5c7aSCorentin Charycat > $TMPC <<EOF
30462f6f5c7aSCorentin Chary#include <stdio.h>
30472f6f5c7aSCorentin Chary#include <jpeglib.h>
30482f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
30492f6f5c7aSCorentin CharyEOF
30502f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
30512f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
30522f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
30532f6f5c7aSCorentin Chary    vnc_jpeg=yes
30542f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3055ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
30562f6f5c7aSCorentin Chary  else
30572f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
305821684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
30592f6f5c7aSCorentin Chary    fi
30602f6f5c7aSCorentin Chary    vnc_jpeg=no
30612f6f5c7aSCorentin Chary  fi
30622f6f5c7aSCorentin Charyfi
30632f6f5c7aSCorentin Chary
30642f6f5c7aSCorentin Chary##########################################
3065efe556adSCorentin Chary# VNC PNG detection
3066821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
3067efe556adSCorentin Charycat > $TMPC <<EOF
3068efe556adSCorentin Chary//#include <stdio.h>
3069efe556adSCorentin Chary#include <png.h>
3070832ce9c2SScott Wood#include <stddef.h>
3071efe556adSCorentin Charyint main(void) {
3072efe556adSCorentin Chary    png_structp png_ptr;
3073efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
30747edc3fedSPeter Maydell    return png_ptr != 0;
3075efe556adSCorentin Chary}
3076efe556adSCorentin CharyEOF
307765d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
307889138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
307989138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
30809af8025eSBrad  else
3081efe556adSCorentin Chary    vnc_png_cflags=""
3082efe556adSCorentin Chary    vnc_png_libs="-lpng"
30839af8025eSBrad  fi
3084efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3085efe556adSCorentin Chary    vnc_png=yes
3086efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
30879af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3088efe556adSCorentin Chary  else
3089efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
309021684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3091efe556adSCorentin Chary    fi
3092efe556adSCorentin Chary    vnc_png=no
3093efe556adSCorentin Chary  fi
3094efe556adSCorentin Charyfi
3095efe556adSCorentin Chary
3096efe556adSCorentin Chary##########################################
30976a021536SGerd Hoffmann# xkbcommon probe
30986a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
30996a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
31006a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
31016a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
31026a021536SGerd Hoffmann    xkbcommon=yes
31036a021536SGerd Hoffmann  else
31046a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
31056a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
31066a021536SGerd Hoffmann    fi
31076a021536SGerd Hoffmann    xkbcommon=no
31086a021536SGerd Hoffmann  fi
31096a021536SGerd Hoffmannfi
31106a021536SGerd Hoffmann
31116a021536SGerd Hoffmann##########################################
311276655d6dSaliguori# fnmatch() probe, used for ACL routines
311376655d6dSaliguorifnmatch="no"
311476655d6dSaliguoricat > $TMPC << EOF
311576655d6dSaliguori#include <fnmatch.h>
311676655d6dSaliguoriint main(void)
311776655d6dSaliguori{
311876655d6dSaliguori    fnmatch("foo", "foo", 0);
311976655d6dSaliguori    return 0;
312076655d6dSaliguori}
312176655d6dSaliguoriEOF
312252166aa0SJuan Quintelaif compile_prog "" "" ; then
312376655d6dSaliguori   fnmatch="yes"
312476655d6dSaliguorifi
312576655d6dSaliguori
312676655d6dSaliguori##########################################
3127c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3128dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3129dce512deSChristoph Hellwig  cat > $TMPC << EOF
3130ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3131dce512deSChristoph Hellwig#include <xfs/xfs.h>
3132dce512deSChristoph Hellwigint main(void)
3133dce512deSChristoph Hellwig{
3134dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3135dce512deSChristoph Hellwig    return 0;
3136dce512deSChristoph Hellwig}
3137dce512deSChristoph HellwigEOF
3138dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3139dce512deSChristoph Hellwig    xfs="yes"
3140dce512deSChristoph Hellwig  else
3141dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
314221684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3143dce512deSChristoph Hellwig    fi
3144dce512deSChristoph Hellwig    xfs=no
3145dce512deSChristoph Hellwig  fi
3146dce512deSChristoph Hellwigfi
3147dce512deSChristoph Hellwig
3148dce512deSChristoph Hellwig##########################################
31498a16d273Sths# vde libraries probe
3150dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
31514baae0acSJuan Quintela  vde_libs="-lvdeplug"
31528a16d273Sths  cat > $TMPC << EOF
31538a16d273Sths#include <libvdeplug.h>
31544a7f0e06Spbrookint main(void)
31554a7f0e06Spbrook{
31564a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3157fea08e08SPeter Maydell    char s[] = "";
3158fea08e08SPeter Maydell    vde_open(s, s, &a);
31594a7f0e06Spbrook    return 0;
31604a7f0e06Spbrook}
31618a16d273SthsEOF
316252166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
31634baae0acSJuan Quintela    vde=yes
3164dfb278bdSJuan Quintela  else
3165dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
316621684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3167dfb278bdSJuan Quintela    fi
3168dfb278bdSJuan Quintela    vde=no
31698a16d273Sths  fi
31708a16d273Sthsfi
31718a16d273Sths
31728a16d273Sths##########################################
31730a985b37SVincenzo Maffione# netmap support probe
31740a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
31750a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
31760a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
31770a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
31780a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
317958952137SVincenzo Maffioneif test "$netmap" != "no" ; then
318058952137SVincenzo Maffione  cat > $TMPC << EOF
318158952137SVincenzo Maffione#include <inttypes.h>
318258952137SVincenzo Maffione#include <net/if.h>
318358952137SVincenzo Maffione#include <net/netmap.h>
318458952137SVincenzo Maffione#include <net/netmap_user.h>
31850a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
31860a985b37SVincenzo Maffione#error
31870a985b37SVincenzo Maffione#endif
318858952137SVincenzo Maffioneint main(void) { return 0; }
318958952137SVincenzo MaffioneEOF
319058952137SVincenzo Maffione  if compile_prog "" "" ; then
319158952137SVincenzo Maffione    netmap=yes
319258952137SVincenzo Maffione  else
319358952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
319458952137SVincenzo Maffione      feature_not_found "netmap"
319558952137SVincenzo Maffione    fi
319658952137SVincenzo Maffione    netmap=no
319758952137SVincenzo Maffione  fi
319858952137SVincenzo Maffionefi
319958952137SVincenzo Maffione
320058952137SVincenzo Maffione##########################################
320147e98658SCorey Bryant# libcap-ng library probe
320247e98658SCorey Bryantif test "$cap_ng" != "no" ; then
320347e98658SCorey Bryant  cap_libs="-lcap-ng"
320447e98658SCorey Bryant  cat > $TMPC << EOF
320547e98658SCorey Bryant#include <cap-ng.h>
320647e98658SCorey Bryantint main(void)
320747e98658SCorey Bryant{
320847e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
320947e98658SCorey Bryant    return 0;
321047e98658SCorey Bryant}
321147e98658SCorey BryantEOF
321247e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
321347e98658SCorey Bryant    cap_ng=yes
321447e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
321547e98658SCorey Bryant  else
321647e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
321721684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
321847e98658SCorey Bryant    fi
321947e98658SCorey Bryant    cap_ng=no
322047e98658SCorey Bryant  fi
322147e98658SCorey Bryantfi
322247e98658SCorey Bryant
322347e98658SCorey Bryant##########################################
3224c2de5c91Smalc# Sound support libraries probe
32258f28f3fbSths
3226c2de5c91Smalcaudio_drv_probe()
3227c2de5c91Smalc{
3228c2de5c91Smalc    drv=$1
3229c2de5c91Smalc    hdr=$2
3230c2de5c91Smalc    lib=$3
3231c2de5c91Smalc    exp=$4
3232c2de5c91Smalc    cfl=$5
32338f28f3fbSths        cat > $TMPC << EOF
3234c2de5c91Smalc#include <$hdr>
3235c2de5c91Smalcint main(void) { $exp }
32368f28f3fbSthsEOF
323752166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
32388f28f3fbSths        :
32398f28f3fbSths    else
324076ad07a4SPeter Maydell        error_exit "$drv check failed" \
324176ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
32428f28f3fbSths    fi
3243c2de5c91Smalc}
3244c2de5c91Smalc
324589138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3246c2de5c91Smalcfor drv in $audio_drv_list; do
3247c2de5c91Smalc    case $drv in
3248c2de5c91Smalc    alsa)
3249c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3250e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3251b1149911SFam Zheng    alsa_libs="-lasound"
3252c2de5c91Smalc    ;;
3253c2de5c91Smalc
3254b8e59f18Smalc    pa)
3255e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3256e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3257b1149911SFam Zheng    pulse_libs="-lpulse"
325867f86e8eSJuan Quintela    audio_pt_int="yes"
3259b8e59f18Smalc    ;;
3260b8e59f18Smalc
3261373967b2SGerd Hoffmann    sdl)
3262373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3263373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3264373967b2SGerd Hoffmann    fi
3265373967b2SGerd Hoffmann    ;;
3266373967b2SGerd Hoffmann
3267997e690aSJuan Quintela    coreaudio)
3268b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3269997e690aSJuan Quintela    ;;
3270997e690aSJuan Quintela
3271a4bf6780SJuan Quintela    dsound)
3272b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3273d5631638Smalc      audio_win_int="yes"
3274a4bf6780SJuan Quintela    ;;
3275a4bf6780SJuan Quintela
3276a4bf6780SJuan Quintela    oss)
3277b1149911SFam Zheng      oss_libs="$oss_lib"
3278a4bf6780SJuan Quintela    ;;
3279a4bf6780SJuan Quintela
3280373967b2SGerd Hoffmann    wav)
3281373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
32822f6a1ab0Sblueswir1    ;;
32832f6a1ab0Sblueswir1
3284e4c63a6aSmalc    *)
32851c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
328676ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
328776ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3288e4c63a6aSmalc    }
3289e4c63a6aSmalc    ;;
3290c2de5c91Smalc    esac
3291c2de5c91Smalcdone
32928f28f3fbSths
32934d3b6f6eSbalrog##########################################
32942e4d9fb1Saurel32# BrlAPI probe
32952e4d9fb1Saurel32
32964ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3297eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
32982e4d9fb1Saurel32  cat > $TMPC << EOF
32992e4d9fb1Saurel32#include <brlapi.h>
3300832ce9c2SScott Wood#include <stddef.h>
33012e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
33022e4d9fb1Saurel32EOF
330352166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
33042e4d9fb1Saurel32    brlapi=yes
33054ffcedb6SJuan Quintela  else
33064ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
330721684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
33084ffcedb6SJuan Quintela    fi
33094ffcedb6SJuan Quintela    brlapi=no
3310eb82284fSJuan Quintela  fi
3311eb82284fSJuan Quintelafi
33122e4d9fb1Saurel32
33132e4d9fb1Saurel32##########################################
33144d3b6f6eSbalrog# curses probe
3315a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3316e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
33178ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
33188ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3319e095e2f3SStefan Weil  else
33207c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
33218ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3322e095e2f3SStefan Weil  fi
3323c584a6d0SJuan Quintela  curses_found=no
33244d3b6f6eSbalrog  cat > $TMPC << EOF
33258ddc5bf9SSamuel Thibault#include <locale.h>
33264d3b6f6eSbalrog#include <curses.h>
33278ddc5bf9SSamuel Thibault#include <wchar.h>
3328ef9a2524SStefan Weilint main(void) {
33298ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
33308ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3331ef9a2524SStefan Weil  resize_term(0, 0);
33328ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
33338ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
33347c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3335271f37abSKamil Rytarowski  return 0;
3336ef9a2524SStefan Weil}
33374d3b6f6eSbalrogEOF
3338ecbe251fSVadim Evard  IFS=:
33398ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3340b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3341b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
33427c703002SSamuel Thibault    IFS=:
33438ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3344ecbe251fSVadim Evard      unset IFS
33458ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3346c584a6d0SJuan Quintela        curses_found=yes
33474f78ef9aSJuan Quintela        break
33484d3b6f6eSbalrog      fi
33494f78ef9aSJuan Quintela    done
33507c703002SSamuel Thibault    if test "$curses_found" = yes ; then
33517c703002SSamuel Thibault      break
33527c703002SSamuel Thibault    fi
33538ddc5bf9SSamuel Thibault  done
3354ecbe251fSVadim Evard  unset IFS
3355c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3356c584a6d0SJuan Quintela    curses=yes
3357c584a6d0SJuan Quintela  else
3358c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
335921684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3360c584a6d0SJuan Quintela    fi
3361c584a6d0SJuan Quintela    curses=no
3362c584a6d0SJuan Quintela  fi
33634f78ef9aSJuan Quintelafi
33644d3b6f6eSbalrog
3365414f0dabSblueswir1##########################################
3366769ce76dSAlexander Graf# curl probe
3367a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
336865d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3369a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
33704e2b0658SPaolo Bonzini  else
33714e2b0658SPaolo Bonzini    curlconfig=curl-config
33724e2b0658SPaolo Bonzini  fi
3373769ce76dSAlexander Graf  cat > $TMPC << EOF
3374769ce76dSAlexander Graf#include <curl/curl.h>
33750b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3376769ce76dSAlexander GrafEOF
337789138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
337889138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3379b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3380769ce76dSAlexander Graf    curl=yes
3381788c8196SJuan Quintela  else
3382788c8196SJuan Quintela    if test "$curl" = "yes" ; then
338321684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3384788c8196SJuan Quintela    fi
3385788c8196SJuan Quintela    curl=no
3386769ce76dSAlexander Graf  fi
3387769ce76dSAlexander Graffi # test "$curl"
3388769ce76dSAlexander Graf
3389769ce76dSAlexander Graf##########################################
3390fb599c9aSbalrog# bluez support probe
3391a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3392e820e3f4Sbalrog  cat > $TMPC << EOF
3393e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3394e820e3f4Sbalrogint main(void) { return bt_error(0); }
3395e820e3f4SbalrogEOF
339689138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
339789138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
339852166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3399a20a6f46SJuan Quintela    bluez=yes
3400e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3401e820e3f4Sbalrog  else
3402a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
340321684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3404a20a6f46SJuan Quintela    fi
3405e820e3f4Sbalrog    bluez="no"
3406e820e3f4Sbalrog  fi
3407fb599c9aSbalrogfi
3408fb599c9aSbalrog
3409fb599c9aSbalrog##########################################
3410e18df141SAnthony Liguori# glib support probe
3411a52d28afSPaolo Bonzini
3412ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3413ad04d8cbSPeter Maydell    glib_req_ver=2.30
3414ad04d8cbSPeter Maydellelse
3415f40685c6SJohn Snow    glib_req_ver=2.22
3416ad04d8cbSPeter Maydellfi
3417aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3418aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3419a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3420aa0d1f44SPaolo Bonzinifi
3421e26110cfSFam Zheng
34224eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
34234eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
34244eaf7202SSameeh Jubran
34254eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
34264eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
34274eaf7202SSameeh Jubranfi
34284eaf7202SSameeh Jubran
3429aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3430e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
343189138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
343289138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
34334a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
343414015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3435957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3436e18df141SAnthony Liguori    else
3437e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3438e26110cfSFam Zheng    fi
3439e26110cfSFam Zhengdone
3440e26110cfSFam Zheng
3441977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3442977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3443977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3444977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3445977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3446977a82abSDaniel P. Berrange#include <glib.h>
3447977a82abSDaniel P. Berrange#include <unistd.h>
3448977a82abSDaniel P. Berrange
3449977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3450977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3451977a82abSDaniel P. Berrange
3452977a82abSDaniel P. Berrangeint main(void) {
3453977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3454977a82abSDaniel P. Berrange   return 0;
3455977a82abSDaniel P. Berrange}
3456977a82abSDaniel P. BerrangeEOF
3457977a82abSDaniel P. Berrange
34585919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3459977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3460977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3461977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3462977a82abSDaniel P. Berrange	       "build target"
3463977a82abSDaniel P. Berrangefi
3464977a82abSDaniel P. Berrange
34659d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
34669d41401bSMichael S. Tsirkinglib_subprocess=yes
3467a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
34689d41401bSMichael S. Tsirkin    glib_subprocess=no
34699d41401bSMichael S. Tsirkinfi
34709d41401bSMichael S. Tsirkin
3471bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3472bbbf2e04SJohn Snowcat > $TMPC << EOF
3473bbbf2e04SJohn Snow#include <glib.h>
3474bbbf2e04SJohn Snowint main(void) { return 0; }
3475bbbf2e04SJohn SnowEOF
3476bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3477bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3478bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3479bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3480bbbf2e04SJohn Snow    fi
3481bbbf2e04SJohn Snowfi
3482bbbf2e04SJohn Snow
3483e26110cfSFam Zheng##########################################
3484e26110cfSFam Zheng# SHA command probe for modules
3485e26110cfSFam Zhengif test "$modules" = yes; then
3486e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3487e26110cfSFam Zheng    for c in $shacmd_probe; do
34888ccefb91SFam Zheng        if has $c; then
3489e26110cfSFam Zheng            shacmd="$c"
3490e26110cfSFam Zheng            break
3491e26110cfSFam Zheng        fi
3492e26110cfSFam Zheng    done
3493e26110cfSFam Zheng    if test "$shacmd" = ""; then
3494e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3495e26110cfSFam Zheng    fi
3496e18df141SAnthony Liguorifi
3497e18df141SAnthony Liguori
3498e18df141SAnthony Liguori##########################################
3499e2134eb9SGerd Hoffmann# pixman support probe
3500e2134eb9SGerd Hoffmann
350174880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
350274880fe2SRobert Schiele  pixman_cflags=
350374880fe2SRobert Schiele  pixman_libs=
350435c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
350589138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
350689138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3507e2134eb9SGerd Hoffmannelse
3508c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3509c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3510e2134eb9SGerd Hoffmannfi
3511e2134eb9SGerd Hoffmann
3512e2134eb9SGerd Hoffmann##########################################
3513fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3514fe8fc5aeSPaolo Bonzini
3515fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
3516fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3517fe8fc5aeSPaolo Bonzini#include <libudev.h>
3518fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3519fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3520fe8fc5aeSPaolo Bonziniint logsink;
3521b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3522b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3523b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3524b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3525b3f1c8c4SPaolo Bonzinistruct udev *udev;
3526b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3527b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3528b3f1c8c4SPaolo Bonzini
3529fe8fc5aeSPaolo Bonziniint main(void) {
3530b3f1c8c4SPaolo Bonzini    udev = udev_new();
3531b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3532fe8fc5aeSPaolo Bonzini    return 0;
3533fe8fc5aeSPaolo Bonzini}
3534fe8fc5aeSPaolo BonziniEOF
3535fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3536fe8fc5aeSPaolo Bonzini    mpathpersist=yes
3537fe8fc5aeSPaolo Bonzini  else
3538fe8fc5aeSPaolo Bonzini    mpathpersist=no
3539fe8fc5aeSPaolo Bonzini  fi
3540fe8fc5aeSPaolo Bonzinielse
3541fe8fc5aeSPaolo Bonzini  mpathpersist=no
3542fe8fc5aeSPaolo Bonzinifi
3543fe8fc5aeSPaolo Bonzini
3544fe8fc5aeSPaolo Bonzini##########################################
354517bff52bSM. Mohan Kumar# libcap probe
354617bff52bSM. Mohan Kumar
354717bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
354817bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
354917bff52bSM. Mohan Kumar#include <stdio.h>
355017bff52bSM. Mohan Kumar#include <sys/capability.h>
3551cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
355217bff52bSM. Mohan KumarEOF
355317bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
355417bff52bSM. Mohan Kumar    cap=yes
355517bff52bSM. Mohan Kumar  else
355617bff52bSM. Mohan Kumar    cap=no
355717bff52bSM. Mohan Kumar  fi
355817bff52bSM. Mohan Kumarfi
355917bff52bSM. Mohan Kumar
356017bff52bSM. Mohan Kumar##########################################
3561e5d355d1Saliguori# pthread probe
35624b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
35633c529d93Saliguori
3564e5d355d1Saliguoripthread=no
3565414f0dabSblueswir1cat > $TMPC << EOF
35663c529d93Saliguori#include <pthread.h>
35677a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
35687a42bbe4SStefan Weilint main(void) {
35697a42bbe4SStefan Weil  pthread_t thread;
35707a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
35717a42bbe4SStefan Weil  return 0;
35727a42bbe4SStefan Weil}
3573414f0dabSblueswir1EOF
3574bd00d539SAndreas Färberif compile_prog "" "" ; then
3575bd00d539SAndreas Färber  pthread=yes
3576bd00d539SAndreas Färberelse
3577de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
357852166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3579e5d355d1Saliguori      pthread=yes
3580e3c56761SPeter Portante      found=no
3581e3c56761SPeter Portante      for lib_entry in $LIBS; do
3582e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3583e3c56761SPeter Portante          found=yes
3584e3c56761SPeter Portante          break
3585e3c56761SPeter Portante        fi
3586e3c56761SPeter Portante      done
3587e3c56761SPeter Portante      if test "$found" = "no"; then
35885572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
358914ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3590e3c56761SPeter Portante      fi
3591409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3592de65fe0fSSebastian Herbszt      break
3593414f0dabSblueswir1    fi
3594de65fe0fSSebastian Herbszt  done
3595bd00d539SAndreas Färberfi
3596414f0dabSblueswir1
35974617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
359876ad07a4SPeter Maydell  error_exit "pthread check failed" \
359976ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3600e5d355d1Saliguorifi
3601e5d355d1Saliguori
36025c312079SDr. David Alan Gilbert# check for pthread_setname_np
36035c312079SDr. David Alan Gilbertpthread_setname_np=no
36045c312079SDr. David Alan Gilbertcat > $TMPC << EOF
36055c312079SDr. David Alan Gilbert#include <pthread.h>
36065c312079SDr. David Alan Gilbert
36075c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
36085c312079SDr. David Alan Gilbertint main(void)
36095c312079SDr. David Alan Gilbert{
36105c312079SDr. David Alan Gilbert    pthread_t thread;
36115c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
36125c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
36135c312079SDr. David Alan Gilbert    return 0;
36145c312079SDr. David Alan Gilbert}
36155c312079SDr. David Alan GilbertEOF
36165c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
36175c312079SDr. David Alan Gilbert  pthread_setname_np=yes
36185c312079SDr. David Alan Gilbertfi
36195c312079SDr. David Alan Gilbert
3620bf9298b9Saliguori##########################################
3621f27aaf4bSChristian Brunner# rbd probe
3622f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3623f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3624f27aaf4bSChristian Brunner#include <stdio.h>
3625ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3626f27aaf4bSChristian Brunnerint main(void) {
3627ad32e9c0SJosh Durgin    rados_t cluster;
3628ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3629f27aaf4bSChristian Brunner    return 0;
3630f27aaf4bSChristian Brunner}
3631f27aaf4bSChristian BrunnerEOF
3632ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3633f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3634f27aaf4bSChristian Brunner    rbd=yes
3635f27aaf4bSChristian Brunner  else
3636f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
363721684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3638f27aaf4bSChristian Brunner    fi
3639f27aaf4bSChristian Brunner    rbd=no
3640f27aaf4bSChristian Brunner  fi
3641f27aaf4bSChristian Brunnerfi
3642f27aaf4bSChristian Brunner
3643f27aaf4bSChristian Brunner##########################################
36440a12ec87SRichard W.M. Jones# libssh2 probe
36454fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
36460a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
364765d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
364889138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
364989138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
36500a12ec87SRichard W.M. Jones    libssh2=yes
36510a12ec87SRichard W.M. Jones  else
36520a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
36534fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
36540a12ec87SRichard W.M. Jones    fi
36550a12ec87SRichard W.M. Jones    libssh2=no
36560a12ec87SRichard W.M. Jones  fi
36570a12ec87SRichard W.M. Jonesfi
36580a12ec87SRichard W.M. Jones
36590a12ec87SRichard W.M. Jones##########################################
36609a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
36619a2d462eSRichard W.M. Jones
36629a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
36639a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
36649a2d462eSRichard W.M. Jones#include <stdio.h>
36659a2d462eSRichard W.M. Jones#include <libssh2.h>
36669a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
36679a2d462eSRichard W.M. Jonesint main(void) {
36689a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
36699a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
36709a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
36719a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
36729a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
36739a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
36749a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
36759a2d462eSRichard W.M. Jones    return 0;
36769a2d462eSRichard W.M. Jones}
36779a2d462eSRichard W.M. JonesEOF
36789a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
36799a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
36809a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
36819a2d462eSRichard W.M. Jones  fi
36829a2d462eSRichard W.M. Jonesfi
36839a2d462eSRichard W.M. Jones
36849a2d462eSRichard W.M. Jones##########################################
36855c6c3a6cSChristoph Hellwig# linux-aio probe
36865c6c3a6cSChristoph Hellwig
36875c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
36885c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
36895c6c3a6cSChristoph Hellwig#include <libaio.h>
36905c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3691832ce9c2SScott Wood#include <stddef.h>
36925c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
36935c6c3a6cSChristoph HellwigEOF
36945c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
36955c6c3a6cSChristoph Hellwig    linux_aio=yes
36965c6c3a6cSChristoph Hellwig  else
36975c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
369821684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
36995c6c3a6cSChristoph Hellwig    fi
37003cfcae3cSLuiz Capitulino    linux_aio=no
37015c6c3a6cSChristoph Hellwig  fi
37025c6c3a6cSChristoph Hellwigfi
37035c6c3a6cSChristoph Hellwig
37045c6c3a6cSChristoph Hellwig##########################################
37053b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
37063b8acc11SPaolo Bonzini
37073b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
37083b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
37093b8acc11SPaolo Bonzinielse
37103b8acc11SPaolo Bonzini  tpm_passthrough=no
37113b8acc11SPaolo Bonzinifi
37123b8acc11SPaolo Bonzini
3713f4ede81eSAmarnath Valluri# TPM emulator is for all posix systems
3714f4ede81eSAmarnath Valluriif test "$mingw32" != "yes"; then
3715f4ede81eSAmarnath Valluri  tpm_emulator=$tpm
3716f4ede81eSAmarnath Vallurielse
3717f4ede81eSAmarnath Valluri  tpm_emulator=no
3718f4ede81eSAmarnath Vallurifi
37193b8acc11SPaolo Bonzini##########################################
3720758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3721758e8e38SVenkateswararao Jujjuri (JV)
3722758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3723758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3724758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3725758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3726f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3727f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3728f2338fb4SPavel Borzenkov#else
37294f26f2b6SAvi Kivity#include <sys/xattr.h>
3730f2338fb4SPavel Borzenkov#endif
3731758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3732758e8e38SVenkateswararao Jujjuri (JV)EOF
37334f26f2b6SAvi Kivity  if compile_prog "" "" ; then
37344f26f2b6SAvi Kivity    attr=yes
37354f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3736f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3737758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3738758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
37394f26f2b6SAvi Kivity    libattr=yes
3740758e8e38SVenkateswararao Jujjuri (JV)  else
3741758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
374221684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3743758e8e38SVenkateswararao Jujjuri (JV)    fi
3744758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3745758e8e38SVenkateswararao Jujjuri (JV)  fi
3746758e8e38SVenkateswararao Jujjuri (JV)fi
3747758e8e38SVenkateswararao Jujjuri (JV)
3748758e8e38SVenkateswararao Jujjuri (JV)##########################################
3749bf9298b9Saliguori# iovec probe
3750bf9298b9Saliguoricat > $TMPC <<EOF
3751db34f0b3Sblueswir1#include <sys/types.h>
3752bf9298b9Saliguori#include <sys/uio.h>
3753db34f0b3Sblueswir1#include <unistd.h>
3754f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3755bf9298b9SaliguoriEOF
3756bf9298b9Saliguoriiovec=no
375752166aa0SJuan Quintelaif compile_prog "" "" ; then
3758bf9298b9Saliguori  iovec=yes
3759bf9298b9Saliguorifi
3760bf9298b9Saliguori
3761f652e6afSaurel32##########################################
3762ceb42de8Saliguori# preadv probe
3763ceb42de8Saliguoricat > $TMPC <<EOF
3764ceb42de8Saliguori#include <sys/types.h>
3765ceb42de8Saliguori#include <sys/uio.h>
3766ceb42de8Saliguori#include <unistd.h>
3767c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3768ceb42de8SaliguoriEOF
3769ceb42de8Saliguoripreadv=no
377052166aa0SJuan Quintelaif compile_prog "" "" ; then
3771ceb42de8Saliguori  preadv=yes
3772ceb42de8Saliguorifi
3773ceb42de8Saliguori
3774ceb42de8Saliguori##########################################
3775f652e6afSaurel32# fdt probe
3776e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3777e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3778e169e1e1SPeter Maydellfdt_required=no
3779e169e1e1SPeter Maydellfor target in $target_list; do
3780e169e1e1SPeter Maydell  case $target in
3781a666409fSKONRAD Frederic    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3782e169e1e1SPeter Maydell      fdt_required=yes
3783e169e1e1SPeter Maydell    ;;
3784e169e1e1SPeter Maydell  esac
3785e169e1e1SPeter Maydelldone
3786e169e1e1SPeter Maydell
3787e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3788e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3789e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3790e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3791e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3792e169e1e1SPeter Maydell  fi
3793e169e1e1SPeter Maydell  fdt=yes
3794e169e1e1SPeter Maydellfi
3795e169e1e1SPeter Maydell
37962df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3797b41af4baSJuan Quintela  fdt_libs="-lfdt"
379896ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
37996e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3800f652e6afSaurel32  cat > $TMPC << EOF
380131ce0adbSThomas Huth#include <libfdt.h>
380296ce6545SPeter Crosthwaite#include <libfdt_env.h>
38036e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3804f652e6afSaurel32EOF
380552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3806a540f158SPeter Crosthwaite    # system DTC is good - use it
3807e3971d61SPhilippe Mathieu-Daudé    fdt=system
3808aef45d51SDaniel P. Berrange  else
3809aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3810aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3811aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3812aef45d51SDaniel P. Berrange      fi
3813aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3814e3971d61SPhilippe Mathieu-Daudé          fdt=git
3815a540f158SPeter Crosthwaite          mkdir -p dtc
3816cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3817a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3818a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
38192df87df7SJuan Quintela          fi
3820a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
38218a99e9a3SPhilippe Mathieu-Daudé          fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
38228a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
3823a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
3824aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
3825aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3826aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
3827a540f158SPeter Crosthwaite      else
3828a540f158SPeter Crosthwaite          # don't have and don't want
3829de3a354aSMichael Walle          fdt_libs=
38302df87df7SJuan Quintela          fdt=no
3831f652e6afSaurel32      fi
3832f652e6afSaurel32  fi
3833aef45d51SDaniel P. Berrangefi
3834f652e6afSaurel32
3835a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3836a540f158SPeter Crosthwaite
383720ff075bSMichael Walle##########################################
3838fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3839b1546f32SGerd Hoffmann
3840da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3841014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
38425f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
38435f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
38445f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3845da076ffeSGerd Hoffmann    opengl=yes
3846925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3847925a0400SGerd Hoffmann        gtk_gl="yes"
3848925a0400SGerd Hoffmann    fi
3849cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
385020ff075bSMichael Walle  else
3851da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3852dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
385320ff075bSMichael Walle    fi
3854f676c67eSJeremy White    opengl_cflags=""
3855da076ffeSGerd Hoffmann    opengl_libs=""
3856da076ffeSGerd Hoffmann    opengl=no
385720ff075bSMichael Walle  fi
385820ff075bSMichael Wallefi
385920ff075bSMichael Walle
3860014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3861014cb152SGerd Hoffmann  cat > $TMPC << EOF
3862014cb152SGerd Hoffmann#include <epoxy/egl.h>
3863014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3864014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3865014cb152SGerd Hoffmann#endif
3866014cb152SGerd Hoffmannint main(void) { return 0; }
3867014cb152SGerd HoffmannEOF
3868014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3869014cb152SGerd Hoffmann    opengl_dmabuf=yes
3870014cb152SGerd Hoffmann  fi
3871014cb152SGerd Hoffmannfi
3872c9a12e75SChrysostomos Nanakos
3873ed279a06SKlim Kireev##########################################
3874ed279a06SKlim Kireev# libxml2 probe
3875ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3876ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3877ed279a06SKlim Kireev        libxml2="yes"
3878ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3879ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3880ed279a06SKlim Kireev    else
3881ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3882ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3883ed279a06SKlim Kireev        fi
3884ed279a06SKlim Kireev        libxml2="no"
3885ed279a06SKlim Kireev    fi
3886ed279a06SKlim Kireevfi
3887c9a12e75SChrysostomos Nanakos
3888eb100396SBharata B Rao##########################################
3889eb100396SBharata B Rao# glusterfs probe
3890eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
389165d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3892e01bee08SBharata B Rao    glusterfs="yes"
389389138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
389489138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3895d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3896d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3897d85fa9ebSJeff Cody    fi
389865d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
38990c14fb47SBharata B Rao      glusterfs_discard="yes"
39000c14fb47SBharata B Rao    fi
39017c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3902df3a429aSNiels de Vos      glusterfs_fallocate="yes"
39037c815372SBharata B Rao      glusterfs_zerofill="yes"
39047c815372SBharata B Rao    fi
3905eb100396SBharata B Rao  else
3906eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
39078efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
39088efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3909eb100396SBharata B Rao    fi
3910e01bee08SBharata B Rao    glusterfs="no"
3911eb100396SBharata B Rao  fi
3912eb100396SBharata B Raofi
3913eb100396SBharata B Rao
391439386ac7Saurel32# Check for inotify functions when we are building linux-user
39153b3f24adSaurel32# emulator.  This is done because older glibc versions don't
39163b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
39173b3f24adSaurel32# don't provide them even if kernel supports them.
39183b3f24adSaurel32#
39193b3f24adSaurel32inotify=no
39203b3f24adSaurel32cat > $TMPC << EOF
39213b3f24adSaurel32#include <sys/inotify.h>
39223b3f24adSaurel32
39233b3f24adSaurel32int
39243b3f24adSaurel32main(void)
39253b3f24adSaurel32{
39263b3f24adSaurel32	/* try to start inotify */
39278690e420Saurel32	return inotify_init();
39283b3f24adSaurel32}
39293b3f24adSaurel32EOF
393052166aa0SJuan Quintelaif compile_prog "" "" ; then
39313b3f24adSaurel32  inotify=yes
39323b3f24adSaurel32fi
39333b3f24adSaurel32
3934c05c7a73SRiku Voipioinotify1=no
3935c05c7a73SRiku Voipiocat > $TMPC << EOF
3936c05c7a73SRiku Voipio#include <sys/inotify.h>
3937c05c7a73SRiku Voipio
3938c05c7a73SRiku Voipioint
3939c05c7a73SRiku Voipiomain(void)
3940c05c7a73SRiku Voipio{
3941c05c7a73SRiku Voipio    /* try to start inotify */
3942c05c7a73SRiku Voipio    return inotify_init1(0);
3943c05c7a73SRiku Voipio}
3944c05c7a73SRiku VoipioEOF
3945c05c7a73SRiku Voipioif compile_prog "" "" ; then
3946c05c7a73SRiku Voipio  inotify1=yes
3947c05c7a73SRiku Voipiofi
3948c05c7a73SRiku Voipio
3949099d6b0fSRiku Voipio# check if pipe2 is there
3950099d6b0fSRiku Voipiopipe2=no
3951099d6b0fSRiku Voipiocat > $TMPC << EOF
3952099d6b0fSRiku Voipio#include <unistd.h>
3953099d6b0fSRiku Voipio#include <fcntl.h>
3954099d6b0fSRiku Voipio
3955099d6b0fSRiku Voipioint main(void)
3956099d6b0fSRiku Voipio{
3957099d6b0fSRiku Voipio    int pipefd[2];
39589bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3959099d6b0fSRiku Voipio}
3960099d6b0fSRiku VoipioEOF
396152166aa0SJuan Quintelaif compile_prog "" "" ; then
3962099d6b0fSRiku Voipio  pipe2=yes
3963099d6b0fSRiku Voipiofi
3964099d6b0fSRiku Voipio
396540ff6d7eSKevin Wolf# check if accept4 is there
396640ff6d7eSKevin Wolfaccept4=no
396740ff6d7eSKevin Wolfcat > $TMPC << EOF
396840ff6d7eSKevin Wolf#include <sys/socket.h>
396940ff6d7eSKevin Wolf#include <stddef.h>
397040ff6d7eSKevin Wolf
397140ff6d7eSKevin Wolfint main(void)
397240ff6d7eSKevin Wolf{
397340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
397440ff6d7eSKevin Wolf    return 0;
397540ff6d7eSKevin Wolf}
397640ff6d7eSKevin WolfEOF
397740ff6d7eSKevin Wolfif compile_prog "" "" ; then
397840ff6d7eSKevin Wolf  accept4=yes
397940ff6d7eSKevin Wolffi
398040ff6d7eSKevin Wolf
39813ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
39823ce34dfbSvibisreenivasansplice=no
39833ce34dfbSvibisreenivasancat > $TMPC << EOF
39843ce34dfbSvibisreenivasan#include <unistd.h>
39853ce34dfbSvibisreenivasan#include <fcntl.h>
39863ce34dfbSvibisreenivasan#include <limits.h>
39873ce34dfbSvibisreenivasan
39883ce34dfbSvibisreenivasanint main(void)
39893ce34dfbSvibisreenivasan{
399066ea0f22SStefan Weil    int len, fd = 0;
39913ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
39923ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
39933ce34dfbSvibisreenivasan    return 0;
39943ce34dfbSvibisreenivasan}
39953ce34dfbSvibisreenivasanEOF
399652166aa0SJuan Quintelaif compile_prog "" "" ; then
39973ce34dfbSvibisreenivasan  splice=yes
39983ce34dfbSvibisreenivasanfi
39993ce34dfbSvibisreenivasan
4000dcc38d1cSMarcelo Tosatti##########################################
4001a99d57bbSWanlong Gao# libnuma probe
4002a99d57bbSWanlong Gao
4003a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4004a99d57bbSWanlong Gao  cat > $TMPC << EOF
4005a99d57bbSWanlong Gao#include <numa.h>
4006a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4007a99d57bbSWanlong GaoEOF
4008a99d57bbSWanlong Gao
4009a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4010a99d57bbSWanlong Gao    numa=yes
4011a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4012a99d57bbSWanlong Gao  else
4013a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4014a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4015a99d57bbSWanlong Gao    fi
4016a99d57bbSWanlong Gao    numa=no
4017a99d57bbSWanlong Gao  fi
4018a99d57bbSWanlong Gaofi
4019a99d57bbSWanlong Gao
40207b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
40217b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
40227b01cb97SAlexandre Derumier    exit 1
40237b01cb97SAlexandre Derumierfi
40247b01cb97SAlexandre Derumier
40255a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
40265a22ab71SYang Zhong# do not support it.
40275a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
40285a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
40295a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
40305a22ab71SYang Zhong    fi
40315a22ab71SYang Zhong    malloc_trim="no"
40325a22ab71SYang Zhongfi
40335a22ab71SYang Zhong
40345a22ab71SYang Zhong#######################################
40355a22ab71SYang Zhong# malloc_trim
40365a22ab71SYang Zhong
40375a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
40385a22ab71SYang Zhong    cat > $TMPC << EOF
40395a22ab71SYang Zhong#include <malloc.h>
40405a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
40415a22ab71SYang ZhongEOF
40425a22ab71SYang Zhong    if compile_prog "" "" ; then
40435a22ab71SYang Zhong        malloc_trim="yes"
40445a22ab71SYang Zhong    else
40455a22ab71SYang Zhong        malloc_trim="no"
40465a22ab71SYang Zhong    fi
40475a22ab71SYang Zhongfi
40485a22ab71SYang Zhong
4049a99d57bbSWanlong Gao##########################################
40502847b469SFam Zheng# tcmalloc probe
40512847b469SFam Zheng
40522847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
40532847b469SFam Zheng  cat > $TMPC << EOF
40542847b469SFam Zheng#include <stdlib.h>
40552847b469SFam Zhengint main(void) { malloc(1); return 0; }
40562847b469SFam ZhengEOF
40572847b469SFam Zheng
40582847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
40592847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
40602847b469SFam Zheng  else
40612847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
40622847b469SFam Zheng  fi
40632847b469SFam Zhengfi
40642847b469SFam Zheng
40652847b469SFam Zheng##########################################
40667b01cb97SAlexandre Derumier# jemalloc probe
40677b01cb97SAlexandre Derumier
40687b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
40697b01cb97SAlexandre Derumier  cat > $TMPC << EOF
40707b01cb97SAlexandre Derumier#include <stdlib.h>
40717b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
40727b01cb97SAlexandre DerumierEOF
40737b01cb97SAlexandre Derumier
40747b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
40757b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
40767b01cb97SAlexandre Derumier  else
40777b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
40787b01cb97SAlexandre Derumier  fi
40797b01cb97SAlexandre Derumierfi
40807b01cb97SAlexandre Derumier
40817b01cb97SAlexandre Derumier##########################################
4082dcc38d1cSMarcelo Tosatti# signalfd probe
4083dcc38d1cSMarcelo Tosattisignalfd="no"
4084dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4085dcc38d1cSMarcelo Tosatti#include <unistd.h>
4086dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4087dcc38d1cSMarcelo Tosatti#include <signal.h>
4088dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4089dcc38d1cSMarcelo TosattiEOF
4090dcc38d1cSMarcelo Tosatti
4091dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4092dcc38d1cSMarcelo Tosatti  signalfd=yes
4093dcc38d1cSMarcelo Tosattifi
4094dcc38d1cSMarcelo Tosatti
4095c2882b96SRiku Voipio# check if eventfd is supported
4096c2882b96SRiku Voipioeventfd=no
4097c2882b96SRiku Voipiocat > $TMPC << EOF
4098c2882b96SRiku Voipio#include <sys/eventfd.h>
4099c2882b96SRiku Voipio
4100c2882b96SRiku Voipioint main(void)
4101c2882b96SRiku Voipio{
410255cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4103c2882b96SRiku Voipio}
4104c2882b96SRiku VoipioEOF
4105c2882b96SRiku Voipioif compile_prog "" "" ; then
4106c2882b96SRiku Voipio  eventfd=yes
4107c2882b96SRiku Voipiofi
4108c2882b96SRiku Voipio
4109751bcc39SMarc-André Lureau# check if memfd is supported
4110751bcc39SMarc-André Lureaumemfd=no
4111751bcc39SMarc-André Lureaucat > $TMPC << EOF
411275e5b70eSPaolo Bonzini#include <sys/mman.h>
4113751bcc39SMarc-André Lureau
4114751bcc39SMarc-André Lureauint main(void)
4115751bcc39SMarc-André Lureau{
4116751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4117751bcc39SMarc-André Lureau}
4118751bcc39SMarc-André LureauEOF
4119751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4120751bcc39SMarc-André Lureau  memfd=yes
4121751bcc39SMarc-André Lureaufi
4122751bcc39SMarc-André Lureau
4123751bcc39SMarc-André Lureau
4124751bcc39SMarc-André Lureau
4125d0927938SUlrich Hecht# check for fallocate
4126d0927938SUlrich Hechtfallocate=no
4127d0927938SUlrich Hechtcat > $TMPC << EOF
4128d0927938SUlrich Hecht#include <fcntl.h>
4129d0927938SUlrich Hecht
4130d0927938SUlrich Hechtint main(void)
4131d0927938SUlrich Hecht{
4132d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4133d0927938SUlrich Hecht    return 0;
4134d0927938SUlrich Hecht}
4135d0927938SUlrich HechtEOF
41368fb03151SPeter Maydellif compile_prog "" "" ; then
4137d0927938SUlrich Hecht  fallocate=yes
4138d0927938SUlrich Hechtfi
4139d0927938SUlrich Hecht
41403d4fa43eSKusanagi Kouichi# check for fallocate hole punching
41413d4fa43eSKusanagi Kouichifallocate_punch_hole=no
41423d4fa43eSKusanagi Kouichicat > $TMPC << EOF
41433d4fa43eSKusanagi Kouichi#include <fcntl.h>
41443d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
41453d4fa43eSKusanagi Kouichi
41463d4fa43eSKusanagi Kouichiint main(void)
41473d4fa43eSKusanagi Kouichi{
41483d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
41493d4fa43eSKusanagi Kouichi    return 0;
41503d4fa43eSKusanagi Kouichi}
41513d4fa43eSKusanagi KouichiEOF
41523d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
41533d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
41543d4fa43eSKusanagi Kouichifi
41553d4fa43eSKusanagi Kouichi
4156b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4157b953f075SDenis V. Lunevfallocate_zero_range=no
4158b953f075SDenis V. Lunevcat > $TMPC << EOF
4159b953f075SDenis V. Lunev#include <fcntl.h>
4160b953f075SDenis V. Lunev#include <linux/falloc.h>
4161b953f075SDenis V. Lunev
4162b953f075SDenis V. Lunevint main(void)
4163b953f075SDenis V. Lunev{
4164b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4165b953f075SDenis V. Lunev    return 0;
4166b953f075SDenis V. Lunev}
4167b953f075SDenis V. LunevEOF
4168b953f075SDenis V. Lunevif compile_prog "" "" ; then
4169b953f075SDenis V. Lunev  fallocate_zero_range=yes
4170b953f075SDenis V. Lunevfi
4171b953f075SDenis V. Lunev
4172ed911435SKevin Wolf# check for posix_fallocate
4173ed911435SKevin Wolfposix_fallocate=no
4174ed911435SKevin Wolfcat > $TMPC << EOF
4175ed911435SKevin Wolf#include <fcntl.h>
4176ed911435SKevin Wolf
4177ed911435SKevin Wolfint main(void)
4178ed911435SKevin Wolf{
4179ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4180ed911435SKevin Wolf    return 0;
4181ed911435SKevin Wolf}
4182ed911435SKevin WolfEOF
4183ed911435SKevin Wolfif compile_prog "" "" ; then
4184ed911435SKevin Wolf    posix_fallocate=yes
4185ed911435SKevin Wolffi
4186ed911435SKevin Wolf
4187c727f47dSPeter Maydell# check for sync_file_range
4188c727f47dSPeter Maydellsync_file_range=no
4189c727f47dSPeter Maydellcat > $TMPC << EOF
4190c727f47dSPeter Maydell#include <fcntl.h>
4191c727f47dSPeter Maydell
4192c727f47dSPeter Maydellint main(void)
4193c727f47dSPeter Maydell{
4194c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4195c727f47dSPeter Maydell    return 0;
4196c727f47dSPeter Maydell}
4197c727f47dSPeter MaydellEOF
41988fb03151SPeter Maydellif compile_prog "" "" ; then
4199c727f47dSPeter Maydell  sync_file_range=yes
4200c727f47dSPeter Maydellfi
4201c727f47dSPeter Maydell
4202dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4203dace20dcSPeter Maydellfiemap=no
4204dace20dcSPeter Maydellcat > $TMPC << EOF
4205dace20dcSPeter Maydell#include <sys/ioctl.h>
4206dace20dcSPeter Maydell#include <linux/fs.h>
4207dace20dcSPeter Maydell#include <linux/fiemap.h>
4208dace20dcSPeter Maydell
4209dace20dcSPeter Maydellint main(void)
4210dace20dcSPeter Maydell{
4211dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4212dace20dcSPeter Maydell    return 0;
4213dace20dcSPeter Maydell}
4214dace20dcSPeter MaydellEOF
42158fb03151SPeter Maydellif compile_prog "" "" ; then
4216dace20dcSPeter Maydell  fiemap=yes
4217dace20dcSPeter Maydellfi
4218dace20dcSPeter Maydell
4219d0927938SUlrich Hecht# check for dup3
4220d0927938SUlrich Hechtdup3=no
4221d0927938SUlrich Hechtcat > $TMPC << EOF
4222d0927938SUlrich Hecht#include <unistd.h>
4223d0927938SUlrich Hecht
4224d0927938SUlrich Hechtint main(void)
4225d0927938SUlrich Hecht{
4226d0927938SUlrich Hecht    dup3(0, 0, 0);
4227d0927938SUlrich Hecht    return 0;
4228d0927938SUlrich Hecht}
4229d0927938SUlrich HechtEOF
423078f5d726SJan Kiszkaif compile_prog "" "" ; then
4231d0927938SUlrich Hecht  dup3=yes
4232d0927938SUlrich Hechtfi
4233d0927938SUlrich Hecht
42344e0c6529SAlex Bligh# check for ppoll support
42354e0c6529SAlex Blighppoll=no
42364e0c6529SAlex Blighcat > $TMPC << EOF
42374e0c6529SAlex Bligh#include <poll.h>
42384e0c6529SAlex Bligh
42394e0c6529SAlex Blighint main(void)
42404e0c6529SAlex Bligh{
42414e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
42424e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
42434e0c6529SAlex Bligh    return 0;
42444e0c6529SAlex Bligh}
42454e0c6529SAlex BlighEOF
42464e0c6529SAlex Blighif compile_prog "" "" ; then
42474e0c6529SAlex Bligh  ppoll=yes
42484e0c6529SAlex Blighfi
42494e0c6529SAlex Bligh
4250cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4251cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4252cd758dd0SAlex Blighcat > $TMPC << EOF
4253cd758dd0SAlex Bligh#include <sys/prctl.h>
4254cd758dd0SAlex Bligh
4255cd758dd0SAlex Blighint main(void)
4256cd758dd0SAlex Bligh{
4257cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4258cd758dd0SAlex Bligh    return 0;
4259cd758dd0SAlex Bligh}
4260cd758dd0SAlex BlighEOF
4261cd758dd0SAlex Blighif compile_prog "" "" ; then
4262cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4263cd758dd0SAlex Blighfi
4264cd758dd0SAlex Bligh
42653b6edd16SPeter Maydell# check for epoll support
42663b6edd16SPeter Maydellepoll=no
42673b6edd16SPeter Maydellcat > $TMPC << EOF
42683b6edd16SPeter Maydell#include <sys/epoll.h>
42693b6edd16SPeter Maydell
42703b6edd16SPeter Maydellint main(void)
42713b6edd16SPeter Maydell{
42723b6edd16SPeter Maydell    epoll_create(0);
42733b6edd16SPeter Maydell    return 0;
42743b6edd16SPeter Maydell}
42753b6edd16SPeter MaydellEOF
42768fb03151SPeter Maydellif compile_prog "" "" ; then
42773b6edd16SPeter Maydell  epoll=yes
42783b6edd16SPeter Maydellfi
42793b6edd16SPeter Maydell
4280227f0214SPeter Maydell# epoll_create1 is a later addition
4281227f0214SPeter Maydell# so we must check separately for its presence
42823b6edd16SPeter Maydellepoll_create1=no
42833b6edd16SPeter Maydellcat > $TMPC << EOF
42843b6edd16SPeter Maydell#include <sys/epoll.h>
42853b6edd16SPeter Maydell
42863b6edd16SPeter Maydellint main(void)
42873b6edd16SPeter Maydell{
428819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
428919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
429019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
429119e83f6bSPeter Maydell     * the library but not declared in the header file we will
429219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
429319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
429419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
429519e83f6bSPeter Maydell     */
4296c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
42973b6edd16SPeter Maydell}
42983b6edd16SPeter MaydellEOF
42998fb03151SPeter Maydellif compile_prog "" "" ; then
43003b6edd16SPeter Maydell  epoll_create1=yes
43013b6edd16SPeter Maydellfi
43023b6edd16SPeter Maydell
4303a8fd1abaSPeter Maydell# check for sendfile support
4304a8fd1abaSPeter Maydellsendfile=no
4305a8fd1abaSPeter Maydellcat > $TMPC << EOF
4306a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4307a8fd1abaSPeter Maydell
4308a8fd1abaSPeter Maydellint main(void)
4309a8fd1abaSPeter Maydell{
4310a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4311a8fd1abaSPeter Maydell}
4312a8fd1abaSPeter MaydellEOF
4313a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4314a8fd1abaSPeter Maydell  sendfile=yes
4315a8fd1abaSPeter Maydellfi
4316a8fd1abaSPeter Maydell
431751834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
431851834341SRiku Voipiotimerfd=no
431951834341SRiku Voipiocat > $TMPC << EOF
432051834341SRiku Voipio#include <sys/timerfd.h>
432151834341SRiku Voipio
432251834341SRiku Voipioint main(void)
432351834341SRiku Voipio{
432451834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
432551834341SRiku Voipio}
432651834341SRiku VoipioEOF
432751834341SRiku Voipioif compile_prog "" "" ; then
432851834341SRiku Voipio  timerfd=yes
432951834341SRiku Voipiofi
433051834341SRiku Voipio
43319af5c906SRiku Voipio# check for setns and unshare support
43329af5c906SRiku Voipiosetns=no
43339af5c906SRiku Voipiocat > $TMPC << EOF
43349af5c906SRiku Voipio#include <sched.h>
43359af5c906SRiku Voipio
43369af5c906SRiku Voipioint main(void)
43379af5c906SRiku Voipio{
43389af5c906SRiku Voipio    int ret;
43399af5c906SRiku Voipio    ret = setns(0, 0);
43409af5c906SRiku Voipio    ret = unshare(0);
43419af5c906SRiku Voipio    return ret;
43429af5c906SRiku Voipio}
43439af5c906SRiku VoipioEOF
43449af5c906SRiku Voipioif compile_prog "" "" ; then
43459af5c906SRiku Voipio  setns=yes
43469af5c906SRiku Voipiofi
43479af5c906SRiku Voipio
434838860a03SAleksandar Markovic# clock_adjtime probe
434938860a03SAleksandar Markovicclock_adjtime=no
435038860a03SAleksandar Markoviccat > $TMPC <<EOF
435138860a03SAleksandar Markovic#include <time.h>
435238860a03SAleksandar Markovic
435338860a03SAleksandar Markovicint main(void)
435438860a03SAleksandar Markovic{
435538860a03SAleksandar Markovic    return clock_adjtime(0, 0);
435638860a03SAleksandar Markovic}
435738860a03SAleksandar MarkovicEOF
435838860a03SAleksandar Markovicclock_adjtime=no
435938860a03SAleksandar Markovicif compile_prog "" "" ; then
436038860a03SAleksandar Markovic  clock_adjtime=yes
436138860a03SAleksandar Markovicfi
436238860a03SAleksandar Markovic
43635a03cd00SAleksandar Markovic# syncfs probe
43645a03cd00SAleksandar Markovicsyncfs=no
43655a03cd00SAleksandar Markoviccat > $TMPC <<EOF
43665a03cd00SAleksandar Markovic#include <unistd.h>
43675a03cd00SAleksandar Markovic
43685a03cd00SAleksandar Markovicint main(void)
43695a03cd00SAleksandar Markovic{
43705a03cd00SAleksandar Markovic    return syncfs(0);
43715a03cd00SAleksandar Markovic}
43725a03cd00SAleksandar MarkovicEOF
43735a03cd00SAleksandar Markovicsyncfs=no
43745a03cd00SAleksandar Markovicif compile_prog "" "" ; then
43755a03cd00SAleksandar Markovic  syncfs=yes
43765a03cd00SAleksandar Markovicfi
43775a03cd00SAleksandar Markovic
4378cc8ae6deSpbrook# Check if tools are available to build documentation.
4379a25dba17SJuan Quintelaif test "$docs" != "no" ; then
438001668d98SStefan Weil  if has makeinfo && has pod2man; then
4381a25dba17SJuan Quintela    docs=yes
438283a3ab8bSJuan Quintela  else
4383a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
438421684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
438583a3ab8bSJuan Quintela    fi
4386a25dba17SJuan Quintela    docs=no
438783a3ab8bSJuan Quintela  fi
4388cc8ae6deSpbrookfi
4389cc8ae6deSpbrook
4390f514f41cSStefan Weil# Search for bswap_32 function
43916ae9a1f4SJuan Quintelabyteswap_h=no
43926ae9a1f4SJuan Quintelacat > $TMPC << EOF
43936ae9a1f4SJuan Quintela#include <byteswap.h>
43946ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
43956ae9a1f4SJuan QuintelaEOF
439652166aa0SJuan Quintelaif compile_prog "" "" ; then
43976ae9a1f4SJuan Quintela  byteswap_h=yes
43986ae9a1f4SJuan Quintelafi
43996ae9a1f4SJuan Quintela
440075f13596SStefan Weil# Search for bswap32 function
44016ae9a1f4SJuan Quintelabswap_h=no
44026ae9a1f4SJuan Quintelacat > $TMPC << EOF
44036ae9a1f4SJuan Quintela#include <sys/endian.h>
44046ae9a1f4SJuan Quintela#include <sys/types.h>
44056ae9a1f4SJuan Quintela#include <machine/bswap.h>
44066ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
44076ae9a1f4SJuan QuintelaEOF
440852166aa0SJuan Quintelaif compile_prog "" "" ; then
44096ae9a1f4SJuan Quintela  bswap_h=yes
44106ae9a1f4SJuan Quintelafi
44116ae9a1f4SJuan Quintela
4412da93a1fdSaliguori##########################################
4413e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4414c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4415e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
44163c33ea96SPaolo Bonzini    libiscsi="yes"
4417ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4418ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4419c589b249SRonnie Sahlberg  else
4420c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4421e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4422c589b249SRonnie Sahlberg    fi
4423c589b249SRonnie Sahlberg    libiscsi="no"
4424c589b249SRonnie Sahlberg  fi
4425c589b249SRonnie Sahlbergfi
4426c589b249SRonnie Sahlberg
4427c589b249SRonnie Sahlberg##########################################
44288bacde8dSNatanael Copa# Do we need libm
44298bacde8dSNatanael Copacat > $TMPC << EOF
44308bacde8dSNatanael Copa#include <math.h>
4431f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
44328bacde8dSNatanael CopaEOF
44338bacde8dSNatanael Copaif compile_prog "" "" ; then
44348bacde8dSNatanael Copa  :
44358bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
44368bacde8dSNatanael Copa  LIBS="-lm $LIBS"
44378bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
44388bacde8dSNatanael Copaelse
443976ad07a4SPeter Maydell  error_exit "libm check failed"
44408bacde8dSNatanael Copafi
44418bacde8dSNatanael Copa
44428bacde8dSNatanael Copa##########################################
4443da93a1fdSaliguori# Do we need librt
44448bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
44458bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
44468bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
44478bacde8dSNatanael Copa# function in addition.
4448da93a1fdSaliguoricat > $TMPC <<EOF
4449da93a1fdSaliguori#include <signal.h>
4450da93a1fdSaliguori#include <time.h>
44518bacde8dSNatanael Copaint main(void) {
44528bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
44538bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
44548bacde8dSNatanael Copa}
4455da93a1fdSaliguoriEOF
4456da93a1fdSaliguori
445752166aa0SJuan Quintelaif compile_prog "" "" ; then
445807ffa4bdSJuan Quintela  :
44598bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
446018e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
446118e588b1SRick Liu  LIBS="$LIBS -lrt"
446218e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4463da93a1fdSaliguorifi
4464da93a1fdSaliguori
446531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
446678723752SPeter Maydell        "$haiku" != "yes" ; then
44676362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
44686362a53fSJuan Quintelafi
44696362a53fSJuan Quintela
4470de5071c5SBlue Swirl##########################################
4471cd4ec0b4SGerd Hoffmann# spice probe
4472cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4473cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4474cd4ec0b4SGerd Hoffmann#include <spice.h>
4475cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4476cd4ec0b4SGerd HoffmannEOF
4477710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4478710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
447965d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
448065d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4481cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4482cd4ec0b4SGerd Hoffmann    spice="yes"
4483cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4484cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
44852e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
44862e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4487cd4ec0b4SGerd Hoffmann  else
4488cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
44898efc9363SHu Tao      feature_not_found "spice" \
44908efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4491cd4ec0b4SGerd Hoffmann    fi
4492cd4ec0b4SGerd Hoffmann    spice="no"
4493cd4ec0b4SGerd Hoffmann  fi
4494cd4ec0b4SGerd Hoffmannfi
4495cd4ec0b4SGerd Hoffmann
44967b02f544SMarc-André Lureau# check for smartcard support
44977b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
44980f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
44997b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
45007b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
45017b02f544SMarc-André Lureau        smartcard="yes"
4502111a38b0SRobert Relyea    else
45037b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
45047b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4505111a38b0SRobert Relyea        fi
45067b02f544SMarc-André Lureau        smartcard="no"
4507111a38b0SRobert Relyea    fi
4508111a38b0SRobert Relyeafi
4509111a38b0SRobert Relyea
45102b2325ffSGerd Hoffmann# check for libusb
45112b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
451265d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
45132b2325ffSGerd Hoffmann        libusb="yes"
4514ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4515ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
45162b2325ffSGerd Hoffmann    else
45172b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
45188efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
45192b2325ffSGerd Hoffmann        fi
45202b2325ffSGerd Hoffmann        libusb="no"
45212b2325ffSGerd Hoffmann    fi
45222b2325ffSGerd Hoffmannfi
45232b2325ffSGerd Hoffmann
452469354a83SHans de Goede# check for usbredirparser for usb network redirection support
452569354a83SHans de Goedeif test "$usb_redir" != "no" ; then
452665d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
452769354a83SHans de Goede        usb_redir="yes"
4528ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4529ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
453069354a83SHans de Goede    else
453169354a83SHans de Goede        if test "$usb_redir" = "yes"; then
453221684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
453369354a83SHans de Goede        fi
453469354a83SHans de Goede        usb_redir="no"
453569354a83SHans de Goede    fi
453669354a83SHans de Goedefi
453769354a83SHans de Goede
4538cd4ec0b4SGerd Hoffmann##########################################
4539d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4540d9840e25STomoki Sekiyama
4541d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4542d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4543690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4544d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4545d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4546690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4547d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4548d9840e25STomoki Sekiyama	  ;;
4549690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4550d9840e25STomoki Sekiyama  esac
4551d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4552d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4553d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4554d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4555d9840e25STomoki SekiyamaEOF
4556d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4557d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4558d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4559315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4560f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4561d9840e25STomoki Sekiyama  else
4562d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4563d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4564d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4565d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4566d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4567d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4568d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4569d9840e25STomoki Sekiyama    fi
4570d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4571d9840e25STomoki Sekiyama  fi
4572d9840e25STomoki Sekiyamafi
4573d9840e25STomoki Sekiyama
4574d9840e25STomoki Sekiyama##########################################
4575d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4576d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4577d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4578d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4579d9840e25STomoki Sekiyama
4580d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4581d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4582d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4583d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4584d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4585d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4586d9840e25STomoki Sekiyama    else
4587d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4588d9840e25STomoki Sekiyama    fi
4589d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4590d9840e25STomoki Sekiyama    win_sdk=""
4591d9840e25STomoki Sekiyama  fi
4592d9840e25STomoki Sekiyamafi
4593d9840e25STomoki Sekiyama
4594d9840e25STomoki Sekiyama##########################################
459550cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
459650cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
459750cbebb9SMichael Roth  cat > $TMPC << EOF
459850cbebb9SMichael Roth#include <windows.h>
459950cbebb9SMichael Roth#include <ntddscsi.h>
460050cbebb9SMichael Rothint main(void) {
460150cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
460250cbebb9SMichael Roth#error Missing required ioctl definitions
460350cbebb9SMichael Roth#endif
460450cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
460550cbebb9SMichael Roth  return addr.Lun;
460650cbebb9SMichael Roth}
460750cbebb9SMichael RothEOF
460850cbebb9SMichael Roth  if compile_prog "" "" ; then
460950cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4610c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
461150cbebb9SMichael Roth  fi
461250cbebb9SMichael Rothfi
461350cbebb9SMichael Roth
461450cbebb9SMichael Roth##########################################
46159d9e1521SGerd Hoffmann# virgl renderer probe
46169d9e1521SGerd Hoffmann
46179d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
46189d9e1521SGerd Hoffmann  cat > $TMPC << EOF
46199d9e1521SGerd Hoffmann#include <virglrenderer.h>
46209d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
46219d9e1521SGerd HoffmannEOF
46229d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
46239d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
462447479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
46259d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
46269d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
46279d9e1521SGerd Hoffmann    virglrenderer="yes"
46289d9e1521SGerd Hoffmann  else
46299d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
46309d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
46319d9e1521SGerd Hoffmann    fi
46329d9e1521SGerd Hoffmann    virglrenderer="no"
46339d9e1521SGerd Hoffmann  fi
46349d9e1521SGerd Hoffmannfi
46359d9e1521SGerd Hoffmann
46369d9e1521SGerd Hoffmann##########################################
46378ca80760SRichard Henderson# capstone
46388ca80760SRichard Henderson
4639e219c499SRichard Hendersoncase "$capstone" in
4640e219c499SRichard Henderson  "" | yes)
46418ca80760SRichard Henderson    if $pkg_config capstone; then
4642e219c499SRichard Henderson      capstone=system
4643123ac0bbSAlexey Kardashevskiy    elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
4644e219c499SRichard Henderson      capstone=git
4645e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4646e219c499SRichard Henderson      capstone=internal
4647e219c499SRichard Henderson    elif test -z "$capstone" ; then
4648e219c499SRichard Henderson      capstone=no
4649e219c499SRichard Henderson    else
4650e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4651e219c499SRichard Henderson    fi
4652e219c499SRichard Henderson    ;;
4653e219c499SRichard Henderson
4654e219c499SRichard Henderson  system)
4655e219c499SRichard Henderson    if ! $pkg_config capstone; then
4656e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4657e219c499SRichard Henderson    fi
4658e219c499SRichard Henderson    ;;
4659e219c499SRichard Hendersonesac
4660e219c499SRichard Henderson
4661e219c499SRichard Hendersoncase "$capstone" in
4662e219c499SRichard Henderson  git | internal)
4663e219c499SRichard Henderson    if test "$capstone" = git; then
4664e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4665e219c499SRichard Henderson    fi
4666e219c499SRichard Henderson    mkdir -p capstone
4667e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4668e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4669e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4670e219c499SRichard Henderson    else
4671e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4672e219c499SRichard Henderson    fi
4673e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4674e219c499SRichard Henderson    ;;
4675e219c499SRichard Henderson
4676e219c499SRichard Henderson  system)
46778ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
46788ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4679e219c499SRichard Henderson    ;;
4680e219c499SRichard Henderson
4681e219c499SRichard Henderson  no)
4682e219c499SRichard Henderson    ;;
4683e219c499SRichard Henderson  *)
4684e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4685e219c499SRichard Henderson    ;;
4686e219c499SRichard Hendersonesac
46878ca80760SRichard Henderson
46888ca80760SRichard Henderson##########################################
46895f6b9e8fSBlue Swirl# check if we have fdatasync
46905f6b9e8fSBlue Swirl
46915f6b9e8fSBlue Swirlfdatasync=no
46925f6b9e8fSBlue Swirlcat > $TMPC << EOF
46935f6b9e8fSBlue Swirl#include <unistd.h>
4694d1722a27SAlexandre Raymondint main(void) {
4695d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4696d1722a27SAlexandre Raymondreturn fdatasync(0);
4697d1722a27SAlexandre Raymond#else
4698e172fe11SStefan Weil#error Not supported
4699d1722a27SAlexandre Raymond#endif
4700d1722a27SAlexandre Raymond}
47015f6b9e8fSBlue SwirlEOF
47025f6b9e8fSBlue Swirlif compile_prog "" "" ; then
47035f6b9e8fSBlue Swirl    fdatasync=yes
47045f6b9e8fSBlue Swirlfi
47055f6b9e8fSBlue Swirl
470694a420b1SStefan Hajnoczi##########################################
4707e78815a5SAndreas Färber# check if we have madvise
4708e78815a5SAndreas Färber
4709e78815a5SAndreas Färbermadvise=no
4710e78815a5SAndreas Färbercat > $TMPC << EOF
4711e78815a5SAndreas Färber#include <sys/types.h>
4712e78815a5SAndreas Färber#include <sys/mman.h>
4713832ce9c2SScott Wood#include <stddef.h>
4714e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4715e78815a5SAndreas FärberEOF
4716e78815a5SAndreas Färberif compile_prog "" "" ; then
4717e78815a5SAndreas Färber    madvise=yes
4718e78815a5SAndreas Färberfi
4719e78815a5SAndreas Färber
4720e78815a5SAndreas Färber##########################################
4721e78815a5SAndreas Färber# check if we have posix_madvise
4722e78815a5SAndreas Färber
4723e78815a5SAndreas Färberposix_madvise=no
4724e78815a5SAndreas Färbercat > $TMPC << EOF
4725e78815a5SAndreas Färber#include <sys/mman.h>
4726832ce9c2SScott Wood#include <stddef.h>
4727e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4728e78815a5SAndreas FärberEOF
4729e78815a5SAndreas Färberif compile_prog "" "" ; then
4730e78815a5SAndreas Färber    posix_madvise=yes
4731e78815a5SAndreas Färberfi
4732e78815a5SAndreas Färber
4733e78815a5SAndreas Färber##########################################
47349bc5a719SAndreas Gustafsson# check if we have posix_memalign()
47359bc5a719SAndreas Gustafsson
47369bc5a719SAndreas Gustafssonposix_memalign=no
47379bc5a719SAndreas Gustafssoncat > $TMPC << EOF
47389bc5a719SAndreas Gustafsson#include <stdlib.h>
47399bc5a719SAndreas Gustafssonint main(void) {
47409bc5a719SAndreas Gustafsson    void *p;
47419bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
47429bc5a719SAndreas Gustafsson}
47439bc5a719SAndreas GustafssonEOF
47449bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
47459bc5a719SAndreas Gustafsson    posix_memalign=yes
47469bc5a719SAndreas Gustafssonfi
47479bc5a719SAndreas Gustafsson
47489bc5a719SAndreas Gustafsson##########################################
47490a852417SPaul Durrant# check if we have posix_syslog
47500a852417SPaul Durrant
47510a852417SPaul Durrantposix_syslog=no
47520a852417SPaul Durrantcat > $TMPC << EOF
47530a852417SPaul Durrant#include <syslog.h>
47540a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
47550a852417SPaul DurrantEOF
47560a852417SPaul Durrantif compile_prog "" "" ; then
47570a852417SPaul Durrant    posix_syslog=yes
47580a852417SPaul Durrantfi
47590a852417SPaul Durrant
47600a852417SPaul Durrant##########################################
4761401bc051SPeter Maydell# check if we have sem_timedwait
4762401bc051SPeter Maydell
4763401bc051SPeter Maydellsem_timedwait=no
4764401bc051SPeter Maydellcat > $TMPC << EOF
4765401bc051SPeter Maydell#include <semaphore.h>
4766401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4767401bc051SPeter MaydellEOF
4768401bc051SPeter Maydellif compile_prog "" "" ; then
4769401bc051SPeter Maydell    sem_timedwait=yes
4770401bc051SPeter Maydellfi
4771401bc051SPeter Maydell
4772401bc051SPeter Maydell##########################################
477394a420b1SStefan Hajnoczi# check if trace backend exists
477494a420b1SStefan Hajnoczi
47755b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
477694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
47775b808275SLluís Vilanova  error_exit "invalid trace backends" \
47785b808275SLluís Vilanova      "Please choose supported trace backends."
477994a420b1SStefan Hajnoczifi
478094a420b1SStefan Hajnoczi
47817e24e92aSStefan Hajnoczi##########################################
47827e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
47835b808275SLluís Vilanovaif have_backend "ust"; then
47847e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4785bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
47867e24e92aSStefan Hajnocziint main(void) { return 0; }
47877e24e92aSStefan HajnocziEOF
4788c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4789bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
479089138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
47917e24e92aSStefan Hajnoczi    else
4792c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4793bf15f63cSMohamad Gebai    fi
4794bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
479589138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4796bf15f63cSMohamad Gebai    else
4797bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4798bf15f63cSMohamad Gebai    fi
4799bf15f63cSMohamad Gebai
4800bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4801bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4802bf15f63cSMohamad Gebai  else
4803bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
48047e24e92aSStefan Hajnoczi  fi
48057e24e92aSStefan Hajnoczifi
4806b3d08c02SDaniel P. Berrange
4807b3d08c02SDaniel P. Berrange##########################################
4808b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
48095b808275SLluís Vilanovaif have_backend "dtrace"; then
4810b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
481176ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4812b3d08c02SDaniel P. Berrange  fi
4813c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4814c276b17dSDaniel P. Berrange  if has 'stap' ; then
4815c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4816c276b17dSDaniel P. Berrange  fi
4817b3d08c02SDaniel P. Berrangefi
4818b3d08c02SDaniel P. Berrange
48197e24e92aSStefan Hajnoczi##########################################
4820519175a2SAlex Barcelo# check and set a backend for coroutine
4821d0e2fce5SAneesh Kumar K.V
48227c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
482333c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
482433c53c54SDaniel P. Berrange# specific one.
48257c2acc70SPeter Maydell
48267c2acc70SPeter Maydellucontext_works=no
4827d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4828d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4829d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4830cdf84806SPeter Maydell#ifdef __stub_makecontext
4831cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4832cdf84806SPeter Maydell#endif
483375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4834d0e2fce5SAneesh Kumar K.VEOF
4835d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
48367c2acc70SPeter Maydell    ucontext_works=yes
4837d0e2fce5SAneesh Kumar K.V  fi
4838519175a2SAlex Barcelofi
48397c2acc70SPeter Maydell
48407c2acc70SPeter Maydellif test "$coroutine" = ""; then
48417c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
48427c2acc70SPeter Maydell    coroutine=win32
48437c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
48447c2acc70SPeter Maydell    coroutine=ucontext
4845519175a2SAlex Barcelo  else
48467c2acc70SPeter Maydell    coroutine=sigaltstack
48477c2acc70SPeter Maydell  fi
48487c2acc70SPeter Maydellelse
48497c2acc70SPeter Maydell  case $coroutine in
48507c2acc70SPeter Maydell  windows)
48517c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
48527c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
48537c2acc70SPeter Maydell    fi
48547c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
48557c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
48567c2acc70SPeter Maydell    coroutine=win32
48577c2acc70SPeter Maydell    ;;
48587c2acc70SPeter Maydell  ucontext)
48597c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
48607c2acc70SPeter Maydell      feature_not_found "ucontext"
48617c2acc70SPeter Maydell    fi
48627c2acc70SPeter Maydell    ;;
486333c53c54SDaniel P. Berrange  sigaltstack)
48647c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
48657c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
48667c2acc70SPeter Maydell    fi
48677c2acc70SPeter Maydell    ;;
48687c2acc70SPeter Maydell  *)
486976ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
48707c2acc70SPeter Maydell    ;;
48717c2acc70SPeter Maydell  esac
4872d0e2fce5SAneesh Kumar K.Vfi
4873d0e2fce5SAneesh Kumar K.V
487470c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
487570c60c08SStefan Hajnoczi  coroutine_pool=yes
487670c60c08SStefan Hajnoczifi
487770c60c08SStefan Hajnoczi
48787d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
48797d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
48807d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
48817d992e4dSPeter Lieven    coroutine_pool=no
48827d992e4dSPeter Lieven  fi
48837d992e4dSPeter Lievenfi
48847d992e4dSPeter Lieven
48857d992e4dSPeter Lieven
4886d0e2fce5SAneesh Kumar K.V##########################################
4887d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4888d2042378SAneesh Kumar K.V
48894e1797f9SStefan Weilopen_by_handle_at=no
4890d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4891d2042378SAneesh Kumar K.V#include <fcntl.h>
4892acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4893acc55ba8SStefan Weil# error missing definition
4894acc55ba8SStefan Weil#else
489575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4896acc55ba8SStefan Weil#endif
4897d2042378SAneesh Kumar K.VEOF
4898d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4899d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4900d2042378SAneesh Kumar K.Vfi
4901d2042378SAneesh Kumar K.V
4902e06a765eSHarsh Prateek Bora########################################
4903e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4904e06a765eSHarsh Prateek Bora
4905e06a765eSHarsh Prateek Boralinux_magic_h=no
4906e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4907e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4908e06a765eSHarsh Prateek Boraint main(void) {
490975cafad7SStefan Weil  return 0;
4910e06a765eSHarsh Prateek Bora}
4911e06a765eSHarsh Prateek BoraEOF
4912e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4913e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4914e06a765eSHarsh Prateek Borafi
4915e06a765eSHarsh Prateek Bora
49168ab1bf12SLuiz Capitulino########################################
4917c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4918c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4919c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4920c95e3080SKevin Wolf# only a warning.
4921c95e3080SKevin Wolf#
4922c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4923c95e3080SKevin Wolf# the build doesn't fail anyway.
4924c95e3080SKevin Wolf
492506d71fa1SPeter Maydellpragma_disable_unused_but_set=no
492606d71fa1SPeter Maydellcat > $TMPC << EOF
4927e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
4928c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4929e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4930c95e3080SKevin Wolf
493106d71fa1SPeter Maydellint main(void) {
493206d71fa1SPeter Maydell    return 0;
493306d71fa1SPeter Maydell}
493406d71fa1SPeter MaydellEOF
493506d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4936cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4937c95e3080SKevin Wolfelse
4938c95e3080SKevin Wolf    werror=no
493906d71fa1SPeter Maydellfi
494006d71fa1SPeter Maydell
494106d71fa1SPeter Maydell########################################
4942541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
49433f4349dcSKevin Wolf
49443f4349dcSKevin Wolfvalgrind_h=no
49453f4349dcSKevin Wolfcat > $TMPC << EOF
49463f4349dcSKevin Wolf#include <valgrind/valgrind.h>
49473f4349dcSKevin Wolfint main(void) {
49483f4349dcSKevin Wolf  return 0;
49493f4349dcSKevin Wolf}
49503f4349dcSKevin WolfEOF
49513f4349dcSKevin Wolfif compile_prog "" "" ; then
49523f4349dcSKevin Wolf    valgrind_h=yes
49533f4349dcSKevin Wolffi
49543f4349dcSKevin Wolf
49553f4349dcSKevin Wolf########################################
49568ab1bf12SLuiz Capitulino# check if environ is declared
49578ab1bf12SLuiz Capitulino
49588ab1bf12SLuiz Capitulinohas_environ=no
49598ab1bf12SLuiz Capitulinocat > $TMPC << EOF
49608ab1bf12SLuiz Capitulino#include <unistd.h>
49618ab1bf12SLuiz Capitulinoint main(void) {
4962c075a723SBlue Swirl    environ = 0;
49638ab1bf12SLuiz Capitulino    return 0;
49648ab1bf12SLuiz Capitulino}
49658ab1bf12SLuiz CapitulinoEOF
49668ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
49678ab1bf12SLuiz Capitulino    has_environ=yes
49688ab1bf12SLuiz Capitulinofi
49698ab1bf12SLuiz Capitulino
497076a347e1SRichard Henderson########################################
497176a347e1SRichard Henderson# check if cpuid.h is usable.
497276a347e1SRichard Henderson
497376a347e1SRichard Hendersoncat > $TMPC << EOF
497476a347e1SRichard Henderson#include <cpuid.h>
497576a347e1SRichard Hendersonint main(void) {
4976774d566cSPeter Maydell    unsigned a, b, c, d;
4977774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4978774d566cSPeter Maydell
4979774d566cSPeter Maydell    if (max >= 1) {
4980774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4981774d566cSPeter Maydell    }
4982774d566cSPeter Maydell
4983774d566cSPeter Maydell    if (max >= 7) {
4984774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4985774d566cSPeter Maydell    }
4986774d566cSPeter Maydell
498776a347e1SRichard Henderson    return 0;
498876a347e1SRichard Henderson}
498976a347e1SRichard HendersonEOF
499076a347e1SRichard Hendersonif compile_prog "" "" ; then
499176a347e1SRichard Henderson    cpuid_h=yes
499276a347e1SRichard Hendersonfi
499376a347e1SRichard Henderson
49945dd89908SRichard Henderson##########################################
49955dd89908SRichard Henderson# avx2 optimization requirement check
49965dd89908SRichard Henderson#
49975dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
49985dd89908SRichard Henderson# since we won't be able to select the new routines.
49995dd89908SRichard Henderson
50005dd89908SRichard Hendersonif test $cpuid_h = yes; then
50015dd89908SRichard Henderson  cat > $TMPC << EOF
50025dd89908SRichard Henderson#pragma GCC push_options
50035dd89908SRichard Henderson#pragma GCC target("avx2")
50045dd89908SRichard Henderson#include <cpuid.h>
50055dd89908SRichard Henderson#include <immintrin.h>
50065dd89908SRichard Hendersonstatic int bar(void *a) {
50075dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
50085dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
50095dd89908SRichard Henderson}
50105dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
50115dd89908SRichard HendersonEOF
50125dd89908SRichard Henderson  if compile_object "" ; then
50135dd89908SRichard Henderson    avx2_opt="yes"
50145dd89908SRichard Henderson  fi
50155dd89908SRichard Hendersonfi
50165dd89908SRichard Henderson
5017f540166bSRichard Henderson########################################
5018f540166bSRichard Henderson# check if __[u]int128_t is usable.
5019f540166bSRichard Henderson
5020f540166bSRichard Hendersonint128=no
5021f540166bSRichard Hendersoncat > $TMPC << EOF
5022a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
5023a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
5024a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
5025a00f66abSStefan Weil# endif
5026a00f66abSStefan Weil#endif
5027f540166bSRichard Henderson__int128_t a;
5028f540166bSRichard Henderson__uint128_t b;
5029f540166bSRichard Hendersonint main (void) {
5030f540166bSRichard Henderson  a = a + b;
5031f540166bSRichard Henderson  b = a * b;
5032464e3671SPeter Maydell  a = a * a;
5033f540166bSRichard Henderson  return 0;
5034f540166bSRichard Henderson}
5035f540166bSRichard HendersonEOF
5036f540166bSRichard Hendersonif compile_prog "" "" ; then
5037f540166bSRichard Henderson    int128=yes
5038f540166bSRichard Hendersonfi
503976a347e1SRichard Henderson
50407ebee43eSRichard Henderson#########################################
50417ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
50427ebee43eSRichard Henderson
50437ebee43eSRichard Hendersonatomic128=no
50447ebee43eSRichard Hendersonif test "$int128" = "yes"; then
50457ebee43eSRichard Henderson  cat > $TMPC << EOF
50467ebee43eSRichard Hendersonint main(void)
50477ebee43eSRichard Henderson{
50487ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
50497ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
50507ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
50517ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
50527ebee43eSRichard Henderson  return 0;
50537ebee43eSRichard Henderson}
50547ebee43eSRichard HendersonEOF
50557ebee43eSRichard Henderson  if compile_prog "" "" ; then
50567ebee43eSRichard Henderson    atomic128=yes
50577ebee43eSRichard Henderson  fi
50587ebee43eSRichard Hendersonfi
50597ebee43eSRichard Henderson
5060df79b996SRichard Henderson#########################################
5061df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5062df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5063df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5064df79b996SRichard Henderson
5065df79b996SRichard Hendersoncat > $TMPC << EOF
5066df79b996SRichard Henderson#include <stdint.h>
5067df79b996SRichard Hendersonint main(void)
5068df79b996SRichard Henderson{
5069df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5070df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5071df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5072df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5073df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5074df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5075df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5076df79b996SRichard Henderson#else
5077df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5078df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5079df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5080df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5081df79b996SRichard Henderson#endif
5082df79b996SRichard Henderson  return 0;
5083df79b996SRichard Henderson}
5084df79b996SRichard HendersonEOF
5085df79b996SRichard Hendersonif compile_prog "" "" ; then
5086df79b996SRichard Henderson  atomic64=yes
5087df79b996SRichard Hendersonfi
5088df79b996SRichard Henderson
50891e6e9acaSRichard Henderson########################################
5090db432672SRichard Henderson# See if 16-byte vector operations are supported.
5091db432672SRichard Henderson# Even without a vector unit the compiler may expand these.
5092db432672SRichard Henderson# There is a bug in old GCC for PPC that crashes here.
5093db432672SRichard Henderson# Unfortunately it's the system compiler for Centos 7.
5094db432672SRichard Henderson
5095db432672SRichard Hendersoncat > $TMPC << EOF
5096db432672SRichard Hendersontypedef unsigned char U1 __attribute__((vector_size(16)));
5097db432672SRichard Hendersontypedef unsigned short U2 __attribute__((vector_size(16)));
5098db432672SRichard Hendersontypedef unsigned int U4 __attribute__((vector_size(16)));
5099db432672SRichard Hendersontypedef unsigned long long U8 __attribute__((vector_size(16)));
5100db432672SRichard Hendersontypedef signed char S1 __attribute__((vector_size(16)));
5101db432672SRichard Hendersontypedef signed short S2 __attribute__((vector_size(16)));
5102db432672SRichard Hendersontypedef signed int S4 __attribute__((vector_size(16)));
5103db432672SRichard Hendersontypedef signed long long S8 __attribute__((vector_size(16)));
5104db432672SRichard Hendersonstatic U1 a1, b1;
5105db432672SRichard Hendersonstatic U2 a2, b2;
5106db432672SRichard Hendersonstatic U4 a4, b4;
5107db432672SRichard Hendersonstatic U8 a8, b8;
5108db432672SRichard Hendersonstatic S1 c1;
5109db432672SRichard Hendersonstatic S2 c2;
5110db432672SRichard Hendersonstatic S4 c4;
5111db432672SRichard Hendersonstatic S8 c8;
5112db432672SRichard Hendersonstatic int i;
511374912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i);
511474912f6dSLaurent Viviervoid helper(void *d, void *a, int shift, int i)
511574912f6dSLaurent Vivier{
511674912f6dSLaurent Vivier  *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
511774912f6dSLaurent Vivier  *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
511874912f6dSLaurent Vivier  *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
511974912f6dSLaurent Vivier  *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
512074912f6dSLaurent Vivier}
5121db432672SRichard Hendersonint main(void)
5122db432672SRichard Henderson{
5123db432672SRichard Henderson  a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5124db432672SRichard Henderson  a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5125db432672SRichard Henderson  a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5126db432672SRichard Henderson  a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5127db432672SRichard Henderson  a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5128db432672SRichard Henderson  a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5129db432672SRichard Henderson  a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5130db432672SRichard Henderson  a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5131db432672SRichard Henderson  c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5132db432672SRichard Henderson  return 0;
5133db432672SRichard Henderson}
5134db432672SRichard HendersonEOF
5135db432672SRichard Henderson
5136db432672SRichard Hendersonvector16=no
5137db432672SRichard Hendersonif compile_prog "" "" ; then
5138db432672SRichard Henderson  vector16=yes
5139db432672SRichard Hendersonfi
5140db432672SRichard Henderson
5141db432672SRichard Henderson########################################
51421e6e9acaSRichard Henderson# check if getauxval is available.
51431e6e9acaSRichard Henderson
51441e6e9acaSRichard Hendersongetauxval=no
51451e6e9acaSRichard Hendersoncat > $TMPC << EOF
51461e6e9acaSRichard Henderson#include <sys/auxv.h>
51471e6e9acaSRichard Hendersonint main(void) {
51481e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
51491e6e9acaSRichard Henderson}
51501e6e9acaSRichard HendersonEOF
51511e6e9acaSRichard Hendersonif compile_prog "" "" ; then
51521e6e9acaSRichard Henderson    getauxval=yes
51531e6e9acaSRichard Hendersonfi
51541e6e9acaSRichard Henderson
5155fd0e6053SJohn Snow########################################
5156fd0e6053SJohn Snow# check if ccache is interfering with
5157fd0e6053SJohn Snow# semantic analysis of macros
5158fd0e6053SJohn Snow
51595e4dfd3dSJohn Snowunset CCACHE_CPP2
5160fd0e6053SJohn Snowccache_cpp2=no
5161fd0e6053SJohn Snowcat > $TMPC << EOF
5162fd0e6053SJohn Snowstatic const int Z = 1;
5163fd0e6053SJohn Snow#define fn() ({ Z; })
5164fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5165fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5166fd0e6053SJohn Snow#define ID(X) (X)
5167fd0e6053SJohn Snowint main(int argc, char *argv[])
5168fd0e6053SJohn Snow{
5169fd0e6053SJohn Snow    int x = 0, y = 0;
5170fd0e6053SJohn Snow    x = ID(x);
5171fd0e6053SJohn Snow    x = fn();
5172fd0e6053SJohn Snow    fn();
5173fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5174fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5175fd0e6053SJohn Snow    return 0;
5176fd0e6053SJohn Snow}
5177fd0e6053SJohn SnowEOF
5178fd0e6053SJohn Snow
5179fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5180fd0e6053SJohn Snow    ccache_cpp2=yes
5181fd0e6053SJohn Snowfi
5182fd0e6053SJohn Snow
5183b553a042SJohn Snow#################################################
5184b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5185b553a042SJohn Snow
5186b553a042SJohn Snowif test "$fortify_source" != "no"; then
5187b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5188b553a042SJohn Snow    fortify_source="no";
5189e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5190cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5191b553a042SJohn Snow    fortify_source="no";
5192b553a042SJohn Snow  else
5193b553a042SJohn Snow    fortify_source="yes"
5194b553a042SJohn Snow  fi
5195b553a042SJohn Snowfi
5196b553a042SJohn Snow
51971efad060SFam Zheng###############################################
51981efad060SFam Zheng# Check if copy_file_range is provided by glibc
51991efad060SFam Zhenghave_copy_file_range=no
52001efad060SFam Zhengcat > $TMPC << EOF
52011efad060SFam Zheng#include <unistd.h>
52021efad060SFam Zhengint main(void) {
52031efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
52041efad060SFam Zheng  return 0;
52051efad060SFam Zheng}
52061efad060SFam ZhengEOF
52071efad060SFam Zhengif compile_prog "" "" ; then
52081efad060SFam Zheng    have_copy_file_range=yes
52091efad060SFam Zhengfi
52101efad060SFam Zheng
5211d2042378SAneesh Kumar K.V##########################################
5212277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5213277abf15SJan Vesely
5214277abf15SJan Veselyhave_fsxattr=no
5215277abf15SJan Veselycat > $TMPC << EOF
5216277abf15SJan Vesely#include <linux/fs.h>
5217277abf15SJan Veselystruct fsxattr foo;
5218277abf15SJan Veselyint main(void) {
5219277abf15SJan Vesely  return 0;
5220277abf15SJan Vesely}
5221277abf15SJan VeselyEOF
5222277abf15SJan Veselyif compile_prog "" "" ; then
5223277abf15SJan Vesely    have_fsxattr=yes
5224277abf15SJan Veselyfi
5225277abf15SJan Vesely
5226b66e10e4SPeter Maydell##########################################
5227a40161cbSPaolo Bonzini# check for usable membarrier system call
5228a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5229a40161cbSPaolo Bonzini    have_membarrier=no
5230a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5231a40161cbSPaolo Bonzini        have_membarrier=yes
5232a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5233a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5234a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5235a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5236a40161cbSPaolo Bonzini    #include <unistd.h>
5237a40161cbSPaolo Bonzini    #include <stdlib.h>
5238a40161cbSPaolo Bonzini    int main(void) {
5239a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5240a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5241a40161cbSPaolo Bonzini	exit(0);
5242a40161cbSPaolo Bonzini    }
5243a40161cbSPaolo BonziniEOF
5244a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5245a40161cbSPaolo Bonzini            have_membarrier=yes
5246a40161cbSPaolo Bonzini        fi
5247a40161cbSPaolo Bonzini    fi
5248a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5249a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5250a40161cbSPaolo Bonzini    fi
5251a40161cbSPaolo Bonzinielse
5252a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5253a40161cbSPaolo Bonzini    # work on Wine.
5254a40161cbSPaolo Bonzini    membarrier=no
5255a40161cbSPaolo Bonzinifi
5256a40161cbSPaolo Bonzini
5257a40161cbSPaolo Bonzini##########################################
5258b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5259575b22b1SLaurent Vivierhave_rtnetlink=no
5260575b22b1SLaurent Viviercat > $TMPC << EOF
5261575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5262575b22b1SLaurent Vivierint main(void) {
5263575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5264575b22b1SLaurent Vivier}
5265575b22b1SLaurent VivierEOF
5266575b22b1SLaurent Vivierif compile_prog "" "" ; then
5267575b22b1SLaurent Vivier    have_rtnetlink=yes
5268575b22b1SLaurent Vivierfi
5269575b22b1SLaurent Vivier
52706a02c806SStefan Hajnoczi##########################################
52716a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
52726a02c806SStefan Hajnoczihave_af_vsock=no
52736a02c806SStefan Hajnoczicat > $TMPC << EOF
52746a02c806SStefan Hajnoczi#include <errno.h>
52756a02c806SStefan Hajnoczi#include <sys/types.h>
52766a02c806SStefan Hajnoczi#include <sys/socket.h>
52776a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
52786a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
52796a02c806SStefan Hajnoczi#endif
52806a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
52816a02c806SStefan Hajnocziint main(void) {
52826a02c806SStefan Hajnoczi    int sock, ret;
52836a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
52846a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
52856a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
52866a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
52876a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
52886a02c806SStefan Hajnoczi        return 0;
52896a02c806SStefan Hajnoczi    }
52906a02c806SStefan Hajnoczi    return -1;
52916a02c806SStefan Hajnoczi}
52926a02c806SStefan HajnocziEOF
52936a02c806SStefan Hajnocziif compile_prog "" "" ; then
52946a02c806SStefan Hajnoczi    have_af_vsock=yes
52956a02c806SStefan Hajnoczifi
52966a02c806SStefan Hajnoczi
5297f0d92b56SLongpeng(Mike)##########################################
5298f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5299f0d92b56SLongpeng(Mike)hava_afalg=no
5300f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5301f0d92b56SLongpeng(Mike)#include <errno.h>
5302f0d92b56SLongpeng(Mike)#include <sys/types.h>
5303f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5304f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5305f0d92b56SLongpeng(Mike)int main(void) {
5306f0d92b56SLongpeng(Mike)    int sock;
5307f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5308f0d92b56SLongpeng(Mike)    return sock;
5309f0d92b56SLongpeng(Mike)}
5310f0d92b56SLongpeng(Mike)EOF
5311f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5312f0d92b56SLongpeng(Mike)    have_afalg=yes
5313f0d92b56SLongpeng(Mike)fi
5314f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5315f0d92b56SLongpeng(Mike)then
5316f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5317f0d92b56SLongpeng(Mike)    then
5318f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5319f0d92b56SLongpeng(Mike)    fi
5320f0d92b56SLongpeng(Mike)fi
5321f0d92b56SLongpeng(Mike)
5322f0d92b56SLongpeng(Mike)
53236969ec6cSJames Clarke#################################################
5324c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5325d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5326c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5327c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5328c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5329c97d6d2cSSergio Andres Gomez Del RealEOF
5330c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5331c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5332c97d6d2cSSergio Andres Gomez Del Real  else
5333c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5334c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5335c97d6d2cSSergio Andres Gomez Del Real  fi
5336c97d6d2cSSergio Andres Gomez Del Realfi
5337c97d6d2cSSergio Andres Gomez Del Real
5338c97d6d2cSSergio Andres Gomez Del Real#################################################
53396969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
53406969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
53416969ec6cSJames Clarke# given. It does no harm to give it on other
53426969ec6cSJames Clarke# platforms too.
53436969ec6cSJames Clarke
53446969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
53456969ec6cSJames Clarke#       contains -Wmissing-prototypes
53466969ec6cSJames Clarkecat > $TMPC << EOF
53476969ec6cSJames Clarkeextern int foo(void);
53486969ec6cSJames Clarkeint foo(void) { return 0; }
53496969ec6cSJames ClarkeEOF
53506969ec6cSJames Clarkeif ! compile_object ""; then
53516969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
53526969ec6cSJames Clarkefi
53537ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
53547ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
53557ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
53567ecf44a5SPaolo Bonzini    break
53577ecf44a5SPaolo Bonzini  fi
53587ecf44a5SPaolo Bonzinidone
53597ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
53607ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
53616969ec6cSJames Clarkefi
53626969ec6cSJames Clarke
5363277abf15SJan Vesely##########################################
53644d04351fSChristopher Covington# check for sysmacros.h
53654d04351fSChristopher Covington
53664d04351fSChristopher Covingtonhave_sysmacros=no
53674d04351fSChristopher Covingtoncat > $TMPC << EOF
53684d04351fSChristopher Covington#include <sys/sysmacros.h>
53694d04351fSChristopher Covingtonint main(void) {
53704d04351fSChristopher Covington    return makedev(0, 0);
53714d04351fSChristopher Covington}
53724d04351fSChristopher CovingtonEOF
53734d04351fSChristopher Covingtonif compile_prog "" "" ; then
53744d04351fSChristopher Covington    have_sysmacros=yes
53754d04351fSChristopher Covingtonfi
53764d04351fSChristopher Covington
53774d04351fSChristopher Covington##########################################
5378da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5379da92c3ffSAshish Mittal# Check if libvxhs is installed
5380da92c3ffSAshish Mittal
5381da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5382da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5383da92c3ffSAshish Mittal#include <stdint.h>
5384da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5385da92c3ffSAshish Mittal
5386da92c3ffSAshish Mittalvoid *vxhs_callback;
5387da92c3ffSAshish Mittal
5388da92c3ffSAshish Mittalint main(void) {
5389da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5390da92c3ffSAshish Mittal    return 0;
5391da92c3ffSAshish Mittal}
5392da92c3ffSAshish MittalEOF
5393da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5394da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5395da92c3ffSAshish Mittal    vxhs=yes
5396da92c3ffSAshish Mittal  else
5397da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5398da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5399da92c3ffSAshish Mittal    fi
5400da92c3ffSAshish Mittal    vxhs=no
5401da92c3ffSAshish Mittal  fi
5402da92c3ffSAshish Mittalfi
5403da92c3ffSAshish Mittal
5404da92c3ffSAshish Mittal##########################################
540549e00a18SAndreas Grapentin# check for _Static_assert()
540649e00a18SAndreas Grapentin
540749e00a18SAndreas Grapentinhave_static_assert=no
540849e00a18SAndreas Grapentincat > $TMPC << EOF
540949e00a18SAndreas Grapentin_Static_assert(1, "success");
541049e00a18SAndreas Grapentinint main(void) {
541149e00a18SAndreas Grapentin    return 0;
541249e00a18SAndreas Grapentin}
541349e00a18SAndreas GrapentinEOF
541449e00a18SAndreas Grapentinif compile_prog "" "" ; then
541549e00a18SAndreas Grapentin    have_static_assert=yes
541649e00a18SAndreas Grapentinfi
541749e00a18SAndreas Grapentin
541849e00a18SAndreas Grapentin##########################################
5419e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5420e674605fSTomáš Golembiovský
5421e674605fSTomáš Golembiovskýhave_utmpx=no
5422e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5423e674605fSTomáš Golembiovský#include <utmpx.h>
5424e674605fSTomáš Golembiovskýstruct utmpx user_info;
5425e674605fSTomáš Golembiovskýint main(void) {
5426e674605fSTomáš Golembiovský    return 0;
5427e674605fSTomáš Golembiovský}
5428e674605fSTomáš GolembiovskýEOF
5429e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5430e674605fSTomáš Golembiovský    have_utmpx=yes
5431e674605fSTomáš Golembiovskýfi
5432e674605fSTomáš Golembiovský
5433e674605fSTomáš Golembiovský##########################################
5434247724cbSMarc-André Lureau# checks for sanitizers
5435247724cbSMarc-André Lureau
5436247724cbSMarc-André Lureauhave_asan=no
5437247724cbSMarc-André Lureauhave_ubsan=no
5438d83414e1SMarc-André Lureauhave_asan_iface_h=no
5439d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5440247724cbSMarc-André Lureau
5441247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5442b9f44da2SMarc-André Lureau  write_c_skeleton
5443247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5444247724cbSMarc-André Lureau      have_asan=yes
5445247724cbSMarc-André Lureau  fi
5446b9f44da2SMarc-André Lureau
5447b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5448b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5449b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5450b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5451b9f44da2SMarc-André Lureau#include <stdlib.h>
5452b9f44da2SMarc-André Lureauint main(void) {
5453b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5454b9f44da2SMarc-André Lureau    return *(int *)(tmp + 2);
5455b9f44da2SMarc-André Lureau}
5456b9f44da2SMarc-André LureauEOF
5457247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5458247724cbSMarc-André Lureau      have_ubsan=yes
5459247724cbSMarc-André Lureau  fi
5460d83414e1SMarc-André Lureau
5461d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5462d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5463d83414e1SMarc-André Lureau  fi
5464d83414e1SMarc-André Lureau
5465d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5466d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5467d83414e1SMarc-André Lureauint main(void) {
5468d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5469d83414e1SMarc-André Lureau  return 0;
5470d83414e1SMarc-André Lureau}
5471d83414e1SMarc-André LureauEOF
5472d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5473d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5474d83414e1SMarc-André Lureau  fi
5475247724cbSMarc-André Lureaufi
5476247724cbSMarc-André Lureau
5477247724cbSMarc-André Lureau##########################################
547851a12b51SAlex Bennée# Docker and cross-compiler support
547951a12b51SAlex Bennée#
548051a12b51SAlex Bennée# This is specifically for building test
548151a12b51SAlex Bennée# cases for foreign architectures, not
548251a12b51SAlex Bennée# cross-compiling QEMU itself.
548351a12b51SAlex Bennée
548451a12b51SAlex Bennéeif has "docker"; then
548551a12b51SAlex Bennée    docker=$($python $source_path/tests/docker/docker.py probe)
548651a12b51SAlex Bennéefi
548751a12b51SAlex Bennée
548851a12b51SAlex Bennée##########################################
5489e86ecd4bSJuan Quintela# End of CC checks
5490e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5491e86ecd4bSJuan Quintela
5492d83414e1SMarc-André Lureauwrite_c_skeleton
5493d83414e1SMarc-André Lureau
54941d728c39SBlue Swirlif test "$gcov" = "yes" ; then
54951d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
54961d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5497b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5498e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
549948e56d50SPaolo Bonzinielif test "$debug" = "no"; then
5500ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5501e86ecd4bSJuan Quintelafi
5502a316e378SJuan Quintela
5503247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5504247724cbSMarc-André Lureau  CFLAGS="-fsanitize=address $CFLAGS"
5505d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5506d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5507d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5508d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5509d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5510d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5511d83414e1SMarc-André Lureau  fi
5512247724cbSMarc-André Lureaufi
5513247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5514247724cbSMarc-André Lureau  CFLAGS="-fsanitize=undefined $CFLAGS"
5515247724cbSMarc-André Lureaufi
5516247724cbSMarc-André Lureau
55176542aa9cSPeter Lieven##########################################
55186542aa9cSPeter Lieven# Do we have libnfs
55196542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5520b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
55216542aa9cSPeter Lieven    libnfs="yes"
55226542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
55236542aa9cSPeter Lieven  else
55246542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
55258efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
55266542aa9cSPeter Lieven    fi
55276542aa9cSPeter Lieven    libnfs="no"
55286542aa9cSPeter Lieven  fi
55296542aa9cSPeter Lievenfi
55301d728c39SBlue Swirl
55316ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
55326ca026cbSPeter Maydellif test "$werror" = "yes"; then
55336ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
55346ca026cbSPeter Maydellfi
55356ca026cbSPeter Maydell
5536e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5537e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
55381156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5539e86ecd4bSJuan Quintela    fi
5540e86ecd4bSJuan Quintelafi
5541e86ecd4bSJuan Quintela
554294dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
554394dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
554494dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
554594dd53c5SGerd Hoffmannelse
554694dd53c5SGerd Hoffmann    POD2MAN="pod2man"
554794dd53c5SGerd Hoffmannfi
554894dd53c5SGerd Hoffmann
5549952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5550952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5551952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5552e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5553952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5554952afb71SBlue Swirl        fi
5555952afb71SBlue Swirl    done
5556952afb71SBlue Swirlfi
5557952afb71SBlue Swirl
555810ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5559e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5560528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5561834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
55625a67135aSbellard
5563e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5564e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5565e0580342SKamil Rytarowski  ivshmem=yes
5566e0580342SKamil Rytarowskifi
5567e0580342SKamil Rytarowski
55684b1c11fdSDaniel P. Berrangetools=""
55694b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5570ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
55714b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
55724b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5573b1449edbSKamil Rytarowski  fi
5574b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5575a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
55764b1c11fdSDaniel P. Berrange  fi
55774b1c11fdSDaniel P. Berrangefi
55784b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5579b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5580b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5581983eef5aSMeador Inge      virtfs=yes
558217bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5583983eef5aSMeador Inge    else
5584983eef5aSMeador Inge      if test "$virtfs" = yes; then
5585b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5586983eef5aSMeador Inge      fi
558717500370SAndreas Färber      virtfs=no
5588983eef5aSMeador Inge    fi
5589fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5590fe8fc5aeSPaolo Bonzini      mpath=yes
5591fe8fc5aeSPaolo Bonzini    else
5592fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5593fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5594fe8fc5aeSPaolo Bonzini      fi
5595fe8fc5aeSPaolo Bonzini      mpath=no
5596fe8fc5aeSPaolo Bonzini    fi
5597b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5598b855f8d1SPaolo Bonzini  else
5599b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5600b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5601b855f8d1SPaolo Bonzini    fi
5602b855f8d1SPaolo Bonzini    virtfs=no
5603fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5604fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5605fe8fc5aeSPaolo Bonzini    fi
5606fe8fc5aeSPaolo Bonzini    mpath=no
560717bff52bSM. Mohan Kumar  fi
56086a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
56096a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
56106a021536SGerd Hoffmann  fi
5611ff69fd8cSLaurent Vivierfi
56129d6bc27bSMichael Roth
56139d6bc27bSMichael Roth# Probe for guest agent support/options
56149d6bc27bSMichael Roth
5615e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5616b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5617fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5618e8ef31a3SMichael Tokarev      guest_agent=yes
5619e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5620e8ef31a3SMichael Tokarev      guest_agent=no
5621e8ef31a3SMichael Tokarev  else
5622e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5623ca35f780SPaolo Bonzini  fi
56244b1c11fdSDaniel P. Berrangefi
5625ca35f780SPaolo Bonzini
56269d6bc27bSMichael Roth# Guest agent Window MSI  package
56279d6bc27bSMichael Roth
56289d6bc27bSMichael Rothif test "$guest_agent" != yes; then
56299d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
56309d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
56319d6bc27bSMichael Roth  fi
56329d6bc27bSMichael Roth  guest_agent_msi=no
56339d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
56349d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
56359d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
56369d6bc27bSMichael Roth  fi
56379d6bc27bSMichael Roth  guest_agent_msi=no
56389d6bc27bSMichael Rothelif ! has wixl; then
56399d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
56409d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
56419d6bc27bSMichael Roth  fi
56429d6bc27bSMichael Roth  guest_agent_msi=no
56431a34904eSMichael Rothelse
56441a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
56451a34904eSMichael Roth  # disabled explicitly
56461a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
56471a34904eSMichael Roth    guest_agent_msi=yes
56481a34904eSMichael Roth  fi
56499d6bc27bSMichael Rothfi
56509d6bc27bSMichael Roth
56511a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
56529d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
56539d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
56549d6bc27bSMichael Roth  fi
56559d6bc27bSMichael Roth
56569d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
56579d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
56589d6bc27bSMichael Roth  fi
56599d6bc27bSMichael Roth
56609d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
56619d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
56629d6bc27bSMichael Roth  fi
56639d6bc27bSMichael Roth
56649d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
566589138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
56669d6bc27bSMichael Roth  fi
56679d6bc27bSMichael Roth
566889138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
56699d6bc27bSMichael Roth
56709d6bc27bSMichael Roth  case "$cpu" in
56719d6bc27bSMichael Roth  x86_64)
56729d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
56739d6bc27bSMichael Roth    ;;
56749d6bc27bSMichael Roth  i386)
56759d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
56769d6bc27bSMichael Roth    ;;
56779d6bc27bSMichael Roth  *)
56789d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
56799d6bc27bSMichael Roth    ;;
56809d6bc27bSMichael Roth  esac
56819d6bc27bSMichael Rothfi
56829d6bc27bSMichael Roth
5683ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5684ca35f780SPaolo Bonziniroms=
5685ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5686ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5687ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5688e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5689c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5690c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5691c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5692e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5693e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5694ca35f780SPaolo Bonzini            roms="optionrom"
5695e57218b6SPeter Maydell            break
5696e57218b6SPeter Maydell        fi
5697e57218b6SPeter Maydell    done
5698ca35f780SPaolo Bonzinifi
5699d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
570039ac8455SDavid Gibson  roms="$roms spapr-rtas"
570139ac8455SDavid Gibsonfi
5702ca35f780SPaolo Bonzini
57039933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
57049933c305SChristian Borntraeger  roms="$roms s390-ccw"
57059933c305SChristian Borntraegerfi
57069933c305SChristian Borntraeger
5707964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
570892fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5709964c6fa1SRichard Henderson  textseg_addr=
5710964c6fa1SRichard Henderson  case "$cpu" in
5711479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5712479eb121SRichard Henderson      # ??? Rationale for choosing this address
5713964c6fa1SRichard Henderson      textseg_addr=0x60000000
5714964c6fa1SRichard Henderson      ;;
5715964c6fa1SRichard Henderson    mips)
5716479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5717479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5718479eb121SRichard Henderson      textseg_addr=0x60000000
5719964c6fa1SRichard Henderson      ;;
5720964c6fa1SRichard Henderson  esac
5721964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5722964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5723964c6fa1SRichard Henderson    int main(void) { return 0; }
5724964c6fa1SRichard HendersonEOF
5725964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5726964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5727964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5728964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5729964c6fa1SRichard Henderson      # at least.
573092fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
573192fe2ba8SPeter Maydell        error_exit \
573292fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
573392fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
573492fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
573592fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
573692fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
573792fe2ba8SPeter Maydell            "--disable-user option to configure."
573892fe2ba8SPeter Maydell      fi
573992fe2ba8SPeter Maydell
5740964c6fa1SRichard Henderson      $ld --verbose | sed \
5741964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5742964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5743964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5744964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5745964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5746964c6fa1SRichard Henderson    fi
5747964c6fa1SRichard Henderson  fi
5748964c6fa1SRichard Hendersonfi
5749964c6fa1SRichard Henderson
575011cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
575111cde1c8SBruno 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.
575211cde1c8SBruno Dominguezif has $cxx; then
575311cde1c8SBruno Dominguez    cat > $TMPC <<EOF
575411cde1c8SBruno Dominguezint c_function(void);
575511cde1c8SBruno Dominguezint main(void) { return c_function(); }
575611cde1c8SBruno DominguezEOF
575711cde1c8SBruno Dominguez
575811cde1c8SBruno Dominguez    compile_object
575911cde1c8SBruno Dominguez
576011cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
576111cde1c8SBruno Dominguezextern "C" {
576211cde1c8SBruno Dominguez   int c_function(void);
576311cde1c8SBruno Dominguez}
576411cde1c8SBruno Dominguezint c_function(void) { return 42; }
576511cde1c8SBruno DominguezEOF
576611cde1c8SBruno Dominguez
576711cde1c8SBruno Dominguez    update_cxxflags
576811cde1c8SBruno Dominguez
576911cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
577011cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
577111cde1c8SBruno Dominguez        :
577211cde1c8SBruno Dominguez    else
577311cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
577411cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
577511cde1c8SBruno Dominguez        cxx=
577611cde1c8SBruno Dominguez    fi
577711cde1c8SBruno Dominguezelse
577811cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
577911cde1c8SBruno Dominguez    cxx=
578011cde1c8SBruno Dominguezfi
578111cde1c8SBruno Dominguez
578202d34f62SCole Robinsonecho_version() {
578302d34f62SCole Robinson    if test "$1" = "yes" ; then
578402d34f62SCole Robinson        echo "($2)"
578502d34f62SCole Robinson    fi
578602d34f62SCole Robinson}
578702d34f62SCole Robinson
578850e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
578950e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
57908a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
579150e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
57925ca9388aSGerd Hoffmann
57937d13299dSbellardecho "Install prefix    $prefix"
579489138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
57953d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
579689138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
579789138857SStefan Weilecho "library directory $(eval echo $libdir)"
579889138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
579989138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
580089138857SStefan Weilecho "include directory $(eval echo $includedir)"
580189138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
580211d9f695Sbellardif test "$mingw32" = "no" ; then
580389138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
580489138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
580543ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
58065a699bbbSLaszlo Ersekelse
58075a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5808d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
580911d9f695Sbellardfi
58105a67135aSbellardecho "Source path       $source_path"
5811cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
5812aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
58137d13299dSbellardecho "C compiler        $cc"
581483469015Sbellardecho "Host C compiler   $host_cc"
581583f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
58163c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
581745d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
58180c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5819a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
58200c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
58218a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS      $QEMU_LDFLAGS"
58227d13299dSbellardecho "make              $make"
58236a882643Spbrookecho "install           $install"
5824c886edfbSBlue Swirlecho "python            $python"
5825e2d8830eSBradif test "$slirp" = "yes" ; then
5826e2d8830eSBrad    echo "smbd              $smbd"
5827e2d8830eSBradfi
582817969268SFam Zhengecho "module support    $modules"
5829a98fd896Sbellardecho "host CPU          $cpu"
5830de83cd02Sbellardecho "host big endian   $bigendian"
583197a847bcSbellardecho "target list       $target_list"
58327d13299dSbellardecho "gprof enabled     $gprof"
583303b4fe7dSaliguoriecho "sparse enabled    $sparse"
58341625af87Saliguoriecho "strip binaries    $strip_opt"
583505c2a3e7Sbellardecho "profiler          $profiler"
583643ce4dfeSbellardecho "static build      $static"
58375b0753e0Sbellardif test "$darwin" = "yes" ; then
58385b0753e0Sbellard    echo "Cocoa support     $cocoa"
58395b0753e0Sbellardfi
584089138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
584189138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5842925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
584389138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5844a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5845ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5846b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
584791bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
584837788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
584989138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5850fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
58519a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
58524d3b6f6eSbalrogecho "curses support    $curses"
585347479c55SMarc-André Lureauecho "virgl support     $virglrenderer $(echo_version $virglrenderer $virgl_version)"
5854769ce76dSAlexander Grafecho "curl support      $curl"
585567b915a5Sbellardecho "mingw32 support   $mingw32"
58560c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5857b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5858b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5859983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5860fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
5861821601eaSJes Sorensenecho "VNC support       $vnc"
5862821601eaSJes Sorensenif test "$vnc" = "yes" ; then
58632f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
58642f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5865efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5866821601eaSJes Sorensenfi
58673142255cSblueswir1if test -n "$sparc_cpu"; then
58683142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
58693142255cSblueswir1fi
5870e37630caSaliguoriecho "xen support       $xen"
58713996e85cSPaul Durrantif test "$xen" = "yes" ; then
58723996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
587364a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
58743996e85cSPaul Durrantfi
58752e4d9fb1Saurel32echo "brlapi support    $brlapi"
5876a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5877a25dba17SJuan Quintelaecho "Documentation     $docs"
587840d6444eSAvi Kivityecho "PIE               $pie"
58798a16d273Sthsecho "vde support       $vde"
588058952137SVincenzo Maffioneecho "netmap support    $netmap"
58815c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5882758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
588377755340Sthsecho "Install blobs     $blobs"
5884b31a0277SJuan Quintelaecho "KVM support       $kvm"
5885b0cb0a66SVincent Palatinecho "HAX support       $hax"
5886c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
5887d661d9a4SJustin Terry (VM)echo "WHPX support      $whpx"
5888b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5889b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5890b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
58919195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5892b3f6ea7eSPaolo Bonzinifi
58935a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
5894b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5895f652e6afSaurel32echo "fdt support       $fdt"
5896a40161cbSPaolo Bonziniecho "membarrier        $membarrier"
5897ceb42de8Saliguoriecho "preadv support    $preadv"
58985f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5899e78815a5SAndreas Färberecho "madvise           $madvise"
5900e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
59019bc5a719SAndreas Gustafssonecho "posix_memalign    $posix_memalign"
590247e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5903d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
5904042cea27SGongleiecho "vhost-crypto support $vhost_crypto"
59055e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5906fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5907e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
59085b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5909713572a7SMarc-André Lureauif have_backend "simple"; then
59109410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5911e00e36fbSStefan Weilfi
591289138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5913f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5914dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
59157b02f544SMarc-André Lureauecho "smartcard support $smartcard"
59162b2325ffSGerd Hoffmannecho "libusb            $libusb"
591769354a83SHans de Goedeecho "usb net redir     $usb_redir"
5918da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5919014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5920c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
59216542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5922d138cee9SMichael Rothecho "build guest agent $guest_agent"
5923d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
592450cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
59254c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5926f794573eSEduardo Otuboecho "seccomp support   $seccomp"
59277c2acc70SPeter Maydellecho "coroutine backend $coroutine"
592870c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
59297d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5930f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5931eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
59321d728c39SBlue Swirlecho "gcov              $gcov_tool"
59331d728c39SBlue Swirlecho "gcov enabled      $gcov"
5934ab214c29SStefan Bergerecho "TPM support       $tpm"
59350a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
59363b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
5937f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
59383556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5939ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5940607dacd0Sqiaonuohanecho "lzo support       $lzo"
5941607dacd0Sqiaonuohanecho "snappy support    $snappy"
59426b383c08SPeter Wuecho "bzip2 support     $bzip2"
5943a99d57bbSWanlong Gaoecho "NUMA host support $numa"
5944ed279a06SKlim Kireevecho "libxml2           $libxml2"
59452847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
59467b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
594799f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5948a6b1d4c0SChanglong Xieecho "replication support $replication"
5949da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
59508ca80760SRichard Hendersonecho "capstone          $capstone"
595151a12b51SAlex Bennéeecho "docker            $docker"
595267b915a5Sbellard
59531ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
595424b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5955e8cd23deSbellardfi
595697a847bcSbellard
5957b7715af2SDaniel P. Berrangeif test "$gtkabi" = "2.0"; then
5958b7715af2SDaniel P. Berrange    echo
5959b7715af2SDaniel P. Berrange    echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
5960b7715af2SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using GTK 3.0"
5961b7715af2SDaniel P. Berrangefi
5962b7715af2SDaniel P. Berrange
5963e52c6ba3SDaniel P. Berrangeif test "$sdlabi" = "1.2"; then
5964e52c6ba3SDaniel P. Berrange    echo
5965e52c6ba3SDaniel P. Berrange    echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
5966e52c6ba3SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using SDL 2.0"
5967e52c6ba3SDaniel P. Berrangefi
5968e52c6ba3SDaniel P. Berrange
5969898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5970898be3e0SPeter Maydell    echo
5971898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5972898be3e0SPeter Maydell    echo
5973898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5974898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5975898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5976898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5977898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5978898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5979898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5980898be3e0SPeter Maydellfi
5981898be3e0SPeter Maydell
5982898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5983898be3e0SPeter Maydell    echo
5984898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5985898be3e0SPeter Maydell    echo
5986c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5987c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5988898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5989898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5990898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5991898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5992898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5993898be3e0SPeter Maydellfi
5994898be3e0SPeter Maydell
599598ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
599697a847bcSbellard
5997dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5998dbd99ae3SStefan Weil
599998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
600098ec69acSJuan Quintelaecho >> $config_host_mak
600198ec69acSJuan Quintela
6002e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
600399d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
600499d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
60053aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
60068bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
60070f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
600899d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
600999d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
601022d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
60119afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
60123d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
60139afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6014e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
60155a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6016785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
60175a699bbbSLaszlo Ersekfi
6018f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6019834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6020f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6021cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6022aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6023f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6024804edf29SJuan Quintela
602598ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6026727e5283SPaolo Bonzini
6027f8393946Saurel32if test "$debug_tcg" = "yes" ; then
60282358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6029f8393946Saurel32fi
60301625af87Saliguoriif test "$strip_opt" = "yes" ; then
603152ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
60321625af87Saliguorifi
60337d13299dSbellardif test "$bigendian" = "yes" ; then
6034e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
603597a847bcSbellardfi
603667b915a5Sbellardif test "$mingw32" = "yes" ; then
603798ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
603889138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
60399fe6de94SBlue Swirl  version_major=${rc_version%%.*}
60409fe6de94SBlue Swirl  rc_version=${rc_version#*.}
60419fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
60429fe6de94SBlue Swirl  rc_version=${rc_version#*.}
60439fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
60449fe6de94SBlue Swirl  version_micro=0
60459fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
60469fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6047d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6048d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6049f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6050d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6051d9840e25STomoki Sekiyama  fi
605250cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
605350cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
605450cbebb9SMichael Roth  fi
60551a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
60569dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
60579dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
60589dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
60599dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
60609dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
60619dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
60629dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
60639dacf32dSYossi Hindin  fi
6064210fa556Spbrookelse
606535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6066210fa556Spbrookfi
6067128ab2ffSblueswir1
6068dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6069dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6070dffcb71cSMark McLoughlinfi
6071dffcb71cSMark McLoughlin
607283fb7adfSbellardif test "$darwin" = "yes" ; then
607398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
607483fb7adfSbellardfi
6075b29fe3edSmalc
6076ec530c81Sbellardif test "$solaris" = "yes" ; then
607798ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6078ec530c81Sbellardfi
6079179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6080179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6081179cf400SAndreas Färberfi
608297a847bcSbellardif test "$static" = "yes" ; then
608398ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
608497a847bcSbellardfi
60851ba16968SStefan Weilif test "$profiler" = "yes" ; then
60862358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
608705c2a3e7Sbellardfi
6088c20709aaSbellardif test "$slirp" = "yes" ; then
608998ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6090e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6091c20709aaSbellardfi
60928a16d273Sthsif test "$vde" = "yes" ; then
609398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6094e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
60958a16d273Sthsfi
609658952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
609758952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
609858952137SVincenzo Maffionefi
6099015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6100015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6101015a33bdSGongleifi
610247e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
610347e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
610447e98658SCorey Bryantfi
61052358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
61060c58ac1cSmalcfor drv in $audio_drv_list; do
61071ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6108ce3dc033SGerd Hoffmann    case "$drv" in
6109051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
6110ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
6111ce3dc033SGerd Hoffmann	*)
6112ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
6113ce3dc033SGerd Hoffmann    esac
61140c58ac1cSmalcdone
6115b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6116b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6117b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6118b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6119b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
612067f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
612167f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
612267f86e8eSJuan Quintelafi
6123d5631638Smalcif test "$audio_win_int" = "yes" ; then
6124d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6125d5631638Smalcfi
6126b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6127b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6128821601eaSJes Sorensenif test "$vnc" = "yes" ; then
6129821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
6130821601eaSJes Sorensenfi
61312f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
613298ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
61332f9606b3Saliguorifi
6134821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
61352f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
61362f6f5c7aSCorentin Charyfi
6137821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
6138efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6139efe556adSCorentin Charyfi
61406a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
61416a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
61426a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
61436a021536SGerd Hoffmannfi
614476655d6dSaliguoriif test "$fnmatch" = "yes" ; then
61452358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
614676655d6dSaliguorifi
6147dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6148dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6149dce512deSChristoph Hellwigfi
615089138857SStefan Weilqemu_version=$(head $source_path/VERSION)
615198ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
61522358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
615398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
6154208ecb3eSFam Zhengecho "TARGET_LIST=$target_list" >> $config_host_mak
6155a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
615698ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6157cc8ae6deSpbrookfi
615817969268SFam Zhengif test "$modules" = "yes"; then
6159e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6160e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
616189138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
616217969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
616317969268SFam Zhengfi
61648781595bSGerd Hoffmannif test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
61658781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
61668781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
61678781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
61688781595bSGerd Hoffmannfi
61691ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
617096400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
6171a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
61728ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
61738ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
617449ecc3faSbellardfi
617549ecc3faSbellardif test "$cocoa" = "yes" ; then
617698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
617749ecc3faSbellardfi
61784d3b6f6eSbalrogif test "$curses" = "yes" ; then
61792373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
61802373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
61812373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6182ab4e5602SJan Kiszkafi
6183099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
61842358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6185099d6b0fSRiku Voipiofi
618640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
618740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
618840ff6d7eSKevin Wolffi
61893ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
61902358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
61913ce34dfbSvibisreenivasanfi
6192c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6193c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6194c2882b96SRiku Voipiofi
6195751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6196751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6197751bcc39SMarc-André Lureaufi
6198d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6199d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6200d0927938SUlrich Hechtfi
62013d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
62023d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
62033d4fa43eSKusanagi Kouichifi
6204b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6205b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6206b953f075SDenis V. Lunevfi
6207ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6208ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6209ed911435SKevin Wolffi
6210c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6211c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6212c727f47dSPeter Maydellfi
6213dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6214dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6215dace20dcSPeter Maydellfi
6216d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6217d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6218d0927938SUlrich Hechtfi
62194e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
62204e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
62214e0c6529SAlex Blighfi
6222cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6223cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6224cd758dd0SAlex Blighfi
62253b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
62263b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
62273b6edd16SPeter Maydellfi
62283b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
62293b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
62303b6edd16SPeter Maydellfi
6231a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6232a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6233a8fd1abaSPeter Maydellfi
623451834341SRiku Voipioif test "$timerfd" = "yes" ; then
623551834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
623651834341SRiku Voipiofi
62379af5c906SRiku Voipioif test "$setns" = "yes" ; then
62389af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
62399af5c906SRiku Voipiofi
624038860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
624138860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
624238860a03SAleksandar Markovicfi
62435a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
62445a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
62455a03cd00SAleksandar Markovicfi
62463b3f24adSaurel32if test "$inotify" = "yes" ; then
62472358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
62483b3f24adSaurel32fi
6249c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6250c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6251c05c7a73SRiku Voipiofi
6252401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6253401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6254401bc051SPeter Maydellfi
62556ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
62566ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
62576ae9a1f4SJuan Quintelafi
62586ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
62596ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
62606ae9a1f4SJuan Quintelafi
6261769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6262d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
6263b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
62646ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6265769ce76dSAlexander Graffi
62662e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
626798ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
62688eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
62692e4d9fb1Saurel32fi
6270fb599c9aSbalrogif test "$bluez" = "yes" ; then
627198ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
6272ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6273fb599c9aSbalrogfi
6274d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
62759d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
62769d41401bSMichael S. Tsirkinfi
6277a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6278e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
6279a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
6280a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6281014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6282925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6283925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6284925a0400SGerd Hoffmann  fi
6285bbbf9bfbSStefan Weilfi
6286a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6287ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6288ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6289ddbb0d09SDaniel P. Berrangefi
6290b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
6291b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
6292b917da4cSDaniel P. Berrangefi
629391bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
629491bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
62951f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
62961f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
62971f923c70SLongpeng(Mike)  fi
629837788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
629937788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
630037788f25SDaniel P. Berrange  fi
630162893b67SDaniel P. Berrangefi
630291bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
630391bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6304becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6305fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
6306fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6307fff2f982SDaniel P. Berrange  fi
6308ed754746SDaniel P. Berrangefi
63099a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
63109a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
63119a2fd434SDaniel P. Berrangefi
6312559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6313559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6314559607eaSDaniel P. Berrangefi
63156b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
63166b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
63176b39b063SEric Blakefi
6318277abf15SJan Vesely
6319277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6320277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6321277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6322277abf15SJan Vesely# if this macro is set.
6323277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6324277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6325277abf15SJan Veselyfi
63261efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
63271efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
63281efad060SFam Zhengfi
6329bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6330bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6331a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6332e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6333a4ccabcfSAnthony Liguorifi
63349d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
63359d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
63369d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
63379d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
63389d9e1521SGerd Hoffmannfi
6339e37630caSaliguoriif test "$xen" = "yes" ; then
63406dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6341d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
634264a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
634364a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
634464a7ad6fSIan Campbell  fi
6345e37630caSaliguorifi
63465c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
63475c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
63485c6c3a6cSChristoph Hellwigfi
6349758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6350758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6351758e8e38SVenkateswararao Jujjuri (JV)fi
63524f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
63534f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
63544f26f2b6SAvi Kivityfi
6355983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6356758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6357758e8e38SVenkateswararao Jujjuri (JV)fi
6358fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6359fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
6360fe8fc5aeSPaolo Bonzinifi
63615e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
63625e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
63635e9be92dSNicholas Bellingerfi
6364e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
636503ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
636603ce5744SNikolay Nikolaevfi
6367042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6368042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6369042cea27SGongleifi
6370fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6371fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6372fc0b9b0eSStefan Hajnoczifi
6373e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6374e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6375e6a74868SMarc-André Lureaufi
637677755340Sthsif test "$blobs" = "yes" ; then
637798ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
637877755340Sthsfi
6379bf9298b9Saliguoriif test "$iovec" = "yes" ; then
63802358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6381bf9298b9Saliguorifi
6382ceb42de8Saliguoriif test "$preadv" = "yes" ; then
63832358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6384ceb42de8Saliguorifi
6385e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
63863f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6387f652e6afSaurel32fi
6388a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6389a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6390a40161cbSPaolo Bonzinifi
6391dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6392dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6393dcc38d1cSMarcelo Tosattifi
6394b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6395b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
63969195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
63979195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
63989195b2c2SStefan Weil  fi
6399b3f6ea7eSPaolo Bonzinifi
64005f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
64015f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
64025f6b9e8fSBlue Swirlfi
6403e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6404e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6405e78815a5SAndreas Färberfi
6406e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6407e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6408e78815a5SAndreas Färberfi
64099bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
64109bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
64119bc5a719SAndreas Gustafssonfi
641297a847bcSbellard
6413cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6414cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6415cd4ec0b4SGerd Hoffmannfi
6416cd4ec0b4SGerd Hoffmann
64177b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
64187b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
64197b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
64207b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6421111a38b0SRobert Relyeafi
6422111a38b0SRobert Relyea
64232b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
64242b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6425b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6426b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
64272b2325ffSGerd Hoffmannfi
64282b2325ffSGerd Hoffmann
642969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
643069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6431cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6432cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
643369354a83SHans de Goedefi
643469354a83SHans de Goede
6435da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6436da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6437da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6438014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6439014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6440014cb152SGerd Hoffmann  fi
644120ff075bSMichael Wallefi
644220ff075bSMichael Walle
64435a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
64445a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
64455a22ab71SYang Zhongfi
64465a22ab71SYang Zhong
644799f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
644899f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
644999f2dbd3SLiang Lifi
645099f2dbd3SLiang Li
6451607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6452607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6453607dacd0Sqiaonuohanfi
6454607dacd0Sqiaonuohan
6455607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6456607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6457607dacd0Sqiaonuohanfi
6458607dacd0Sqiaonuohan
64596b383c08SPeter Wuif test "$bzip2" = "yes" ; then
64606b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
64616b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
64626b383c08SPeter Wufi
64636b383c08SPeter Wu
6464c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6465d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
64666ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
64676ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6468c589b249SRonnie Sahlbergfi
6469c589b249SRonnie Sahlberg
64706542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
64714be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
64724be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
64736542aa9cSPeter Lievenfi
64746542aa9cSPeter Lieven
6475f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6476f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6477c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6478c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6479f794573eSEduardo Otubofi
6480f794573eSEduardo Otubo
648183fb7adfSbellard# XXX: suppress that
64827d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
64832358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
64847d3505c5Sbellardfi
64857d3505c5Sbellard
64864d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
64874d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
64884d9310f4SDaniel P. Berrangefi
64893556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
64903556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
64913556c233SPaolo Bonzinifi
6492f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6493d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
64946ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
64956ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6496f27aaf4bSChristian Brunnerfi
649720ff6c80SAnthony Liguori
64987c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
649970c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
650070c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
650170c60c08SStefan Hajnoczielse
650270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
650370c60c08SStefan Hajnoczifi
6504d0e2fce5SAneesh Kumar K.V
65057d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
65067d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
65077d992e4dSPeter Lievenfi
65087d992e4dSPeter Lieven
6509f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6510f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6511f0d92b56SLongpeng(Mike)fi
6512f0d92b56SLongpeng(Mike)
6513d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6514d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6515d2042378SAneesh Kumar K.Vfi
6516d2042378SAneesh Kumar K.V
6517e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6518e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6519e06a765eSHarsh Prateek Borafi
6520e06a765eSHarsh Prateek Bora
6521cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6522cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
652306d71fa1SPeter Maydellfi
652406d71fa1SPeter Maydell
65253f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
65263f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
65273f4349dcSKevin Wolffi
65283f4349dcSKevin Wolf
6529d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
6530d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6531d83414e1SMarc-André Lureaufi
6532d83414e1SMarc-André Lureau
65338ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
65348ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
65358ab1bf12SLuiz Capitulinofi
65368ab1bf12SLuiz Capitulino
653776a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
653876a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
653976a347e1SRichard Hendersonfi
654076a347e1SRichard Henderson
6541f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6542f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6543f540166bSRichard Hendersonfi
6544f540166bSRichard Henderson
65457ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
65467ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
65477ebee43eSRichard Hendersonfi
65487ebee43eSRichard Henderson
6549df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6550df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6551df79b996SRichard Hendersonfi
6552df79b996SRichard Henderson
6553db432672SRichard Hendersonif test "$vector16" = "yes" ; then
6554db432672SRichard Henderson  echo "CONFIG_VECTOR16=y" >> $config_host_mak
6555db432672SRichard Hendersonfi
6556db432672SRichard Henderson
65571e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
65581e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
65591e6e9acaSRichard Hendersonfi
65601e6e9acaSRichard Henderson
6561eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6562d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
65636ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
65646ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6565eb100396SBharata B Raofi
6566eb100396SBharata B Rao
6567d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6568d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6569d85fa9ebSJeff Codyfi
6570d85fa9ebSJeff Cody
65710c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
65720c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
65730c14fb47SBharata B Raofi
65740c14fb47SBharata B Rao
6575df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6576df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6577df3a429aSNiels de Vosfi
6578df3a429aSNiels de Vos
65797c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
65807c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
65817c815372SBharata B Raofi
65827c815372SBharata B Rao
65830a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6584d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
65856ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
65866ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
65870a12ec87SRichard W.M. Jonesfi
65880a12ec87SRichard W.M. Jones
6589ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6590ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6591ed1701c6SDr. David Alan Gilbertfi
6592ed1701c6SDr. David Alan Gilbert
65933b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
65943b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6595f4ede81eSAmarnath Valluri  # TPM passthrough support?
65963b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
65973b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
65983b8acc11SPaolo Bonzini  fi
6599f4ede81eSAmarnath Valluri  # TPM emulator support?
6600f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6601f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6602f4ede81eSAmarnath Valluri  fi
66033b8acc11SPaolo Bonzinifi
66043b8acc11SPaolo Bonzini
66055b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
66065b808275SLluís Vilanovaif have_backend "nop"; then
66076d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
660822890ab5SPrerna Saxenafi
66095b808275SLluís Vilanovaif have_backend "simple"; then
66106d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
66116d8a764eSLluís  # Set the appropriate trace file.
6612953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
66139410b56cSPrerna Saxenafi
6614ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6615ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
66166d8a764eSLluísfi
66175b808275SLluís Vilanovaif have_backend "ust"; then
66186d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
66196d8a764eSLluísfi
66205b808275SLluís Vilanovaif have_backend "dtrace"; then
66216d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
66226d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
66236d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
66246d8a764eSLluís  fi
6625c276b17dSDaniel P. Berrangefi
66265b808275SLluís Vilanovaif have_backend "ftrace"; then
6627781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6628781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6629781e9545SEiichi Tsukata  else
663021684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6631781e9545SEiichi Tsukata  fi
6632781e9545SEiichi Tsukatafi
66330a852417SPaul Durrantif have_backend "syslog"; then
66340a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
66350a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
66360a852417SPaul Durrant  else
66370a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
66380a852417SPaul Durrant  fi
66390a852417SPaul Durrantfi
66409410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
66419410b56cSPrerna Saxena
66422da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
66432da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6644392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
66452da776dbSMichael R. Hinesfi
66462da776dbSMichael R. Hines
6647575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6648575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6649575b22b1SLaurent Vivierfi
6650575b22b1SLaurent Vivier
6651ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6652ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6653ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6654ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6655ed279a06SKlim Kireevfi
6656ed279a06SKlim Kireev
6657a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6658a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6659a6b1d4c0SChanglong Xiefi
6660a6b1d4c0SChanglong Xie
66616a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
66626a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
66636a02c806SStefan Hajnoczifi
66646a02c806SStefan Hajnoczi
66654d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
66664d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
66674d04351fSChristopher Covingtonfi
66684d04351fSChristopher Covington
666949e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
667049e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
667149e00a18SAndreas Grapentinfi
667249e00a18SAndreas Grapentin
6673e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6674e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6675e674605fSTomáš Golembiovskýfi
6676e674605fSTomáš Golembiovský
6677e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6678e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6679e0580342SKamil Rytarowskifi
6680e219c499SRichard Hendersonif test "$capstone" != "no" ; then
66818ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
66828ca80760SRichard Hendersonfi
6683e0580342SKamil Rytarowski
66845c312079SDr. David Alan Gilbert# Hold two types of flag:
66855c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
66865c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
66875c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
66885c312079SDr. David Alan Gilbert#                                     platform
66895c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
66905c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
66915c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
66925c312079SDr. David Alan Gilbertfi
66935c312079SDr. David Alan Gilbert
6694da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6695da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6696da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6697da92c3ffSAshish Mittalfi
6698da92c3ffSAshish Mittal
66995b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
67009edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
67015b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
67029edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
67035b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
67049edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6705c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
67069edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
670740d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
67089edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
67095b5e3037SPaolo Bonzinielse
67109edc19c9SMichael S. Tsirkin  QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
67115b5e3037SPaolo Bonzinifi
67129edc19c9SMichael S. TsirkinQEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
67135b5e3037SPaolo Bonzini
671498ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
671598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6716804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6717804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
67181901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
67191901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
67201901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
672121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6722c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6723804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6724a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6725a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6726a31a8642SMichael S. Tsirkinfi
67272b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6728804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
672983f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
67303c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6731804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
673245d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6733cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
67345f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
67353dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6736804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6737804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
67389f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
67394852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
67409fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6741e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
674246eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6743a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
674411cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6745f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6746e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6747e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
674880fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
67492944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6750e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6751e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6752e39f0062SPaolo Bonzinifi
675342da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
675442da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
675542da6041SGerd Hoffmannelse
675642da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
675742da6041SGerd Hoffmannfi
6758e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
675946eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
67608a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
67616969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6762e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
676373da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
67643e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6765409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6766804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
676717969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
676817969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6769957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
677090246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
677190246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
677294dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6773cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
67741d728c39SBlue Swirlif test "$gcov" = "yes" ; then
67751d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
67761d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
67771d728c39SBlue Swirlfi
6778804edf29SJuan Quintela
677951a12b51SAlex Bennéeif test "$docker" != "no"; then
678051a12b51SAlex Bennée    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
678151a12b51SAlex Bennéefi
678251a12b51SAlex Bennée
67836efd7517SPeter Maydell# use included Linux headers
67846efd7517SPeter Maydellif test "$linux" = "yes" ; then
6785a307beb6SAndreas Färber  mkdir -p linux-headers
67866efd7517SPeter Maydell  case "$cpu" in
6787c72b26ecSRichard Henderson  i386|x86_64|x32)
678808312a63SPeter Maydell    linux_arch=x86
67896efd7517SPeter Maydell    ;;
67906efd7517SPeter Maydell  ppcemb|ppc|ppc64)
679108312a63SPeter Maydell    linux_arch=powerpc
67926efd7517SPeter Maydell    ;;
67936efd7517SPeter Maydell  s390x)
679408312a63SPeter Maydell    linux_arch=s390
679508312a63SPeter Maydell    ;;
67961f080313SClaudio Fontana  aarch64)
67971f080313SClaudio Fontana    linux_arch=arm64
67981f080313SClaudio Fontana    ;;
6799222e7d11SSanjay Lal  mips64)
6800222e7d11SSanjay Lal    linux_arch=mips
6801222e7d11SSanjay Lal    ;;
680208312a63SPeter Maydell  *)
680308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
680408312a63SPeter Maydell    linux_arch="$cpu"
68056efd7517SPeter Maydell    ;;
68066efd7517SPeter Maydell  esac
680708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
680808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
680908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
681008312a63SPeter Maydell    fi
68116efd7517SPeter Maydellfi
68126efd7517SPeter Maydell
681397a847bcSbellardfor target in $target_list; do
681497a847bcSbellardtarget_dir="$target"
681525be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
681689138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
681797a847bcSbellardtarget_bigendian="no"
68181f3d3c8fSJuan Quintela
6819c1799a84SPaolo Bonzinicase "$target_name" in
6820722dd7beSMichael Weiser  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6821ea2d6a39SJuan Quintela  target_bigendian=yes
6822ea2d6a39SJuan Quintela  ;;
6823ea2d6a39SJuan Quintelaesac
682497a847bcSbellardtarget_softmmu="no"
6825997344f3Sbellardtarget_user_only="no"
6826831b7825Sthstarget_linux_user="no"
682784778508Sblueswir1target_bsd_user="no"
68289e407a85Spbrookcase "$target" in
6829c1799a84SPaolo Bonzini  ${target_name}-softmmu)
68309e407a85Spbrook    target_softmmu="yes"
68319e407a85Spbrook    ;;
6832c1799a84SPaolo Bonzini  ${target_name}-linux-user)
68339e407a85Spbrook    target_user_only="yes"
68349e407a85Spbrook    target_linux_user="yes"
68359e407a85Spbrook    ;;
6836c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
683784778508Sblueswir1    target_user_only="yes"
683884778508Sblueswir1    target_bsd_user="yes"
683984778508Sblueswir1    ;;
68409e407a85Spbrook  *)
684176ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
68429e407a85Spbrook    exit 1
68439e407a85Spbrook    ;;
68449e407a85Spbrookesac
6845831b7825Sths
6846*d75402b5SAlex Bennéetarget_compiler=""
6847*d75402b5SAlex Bennéetarget_compiler_static=""
6848*d75402b5SAlex Bennée
684997a847bcSbellardmkdir -p $target_dir
685025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
685197a847bcSbellard
6852e5fe0c52Spbrookbflt="no"
6853ca759f9eSAlex Bennéemttcg="no"
685489138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
685556aebc89Spbrookgdb_xml_files=""
68567ba1e619Saliguori
6857c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
68586acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6859e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6860e73aae67SJuan Quintela
6861c1799a84SPaolo Bonzinicase "$target_name" in
68622408a527Saurel32  i386)
6863b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
6864*d75402b5SAlex Bennée    target_compiler=$cross_cc_i386
68652408a527Saurel32  ;;
68662408a527Saurel32  x86_64)
68676acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6868b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
6869*d75402b5SAlex Bennée    target_compiler=$cross_cc_x86_64
68702408a527Saurel32  ;;
68712408a527Saurel32  alpha)
68725ee4f3c2SRichard Henderson    mttcg="yes"
6873*d75402b5SAlex Bennée    target_compiler=$cross_cc_alpha
68742408a527Saurel32  ;;
68752408a527Saurel32  arm|armeb)
6876b498c8a0SJuan Quintela    TARGET_ARCH=arm
6877e5fe0c52Spbrook    bflt="yes"
6878ca759f9eSAlex Bennée    mttcg="yes"
687956aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6880*d75402b5SAlex Bennée    target_compiler=$cross_cc_arm
68812408a527Saurel32  ;;
6882722dd7beSMichael Weiser  aarch64|aarch64_be)
6883722dd7beSMichael Weiser    TARGET_ARCH=aarch64
68846a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
68856a49fa95SAlexander Graf    bflt="yes"
6886ca759f9eSAlex Bennée    mttcg="yes"
68878f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6888*d75402b5SAlex Bennée    target_compiler=$cross_cc_aarch64
68896a49fa95SAlexander Graf  ;;
68902408a527Saurel32  cris)
6891*d75402b5SAlex Bennée    target_compiler=$cross_cc_cris
68922408a527Saurel32  ;;
689361766fe9SRichard Henderson  hppa)
68947b93dab5SRichard Henderson    mttcg="yes"
6895*d75402b5SAlex Bennée    target_compiler=$cross_cc_hppa
689661766fe9SRichard Henderson  ;;
6897613a22c9SMichael Walle  lm32)
6898*d75402b5SAlex Bennée    target_compiler=$cross_cc_lm32
6899613a22c9SMichael Walle  ;;
69002408a527Saurel32  m68k)
69010938cda5Saurel32    bflt="yes"
69025a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
6903*d75402b5SAlex Bennée    target_compiler=$cross_cc_m68k
69042408a527Saurel32  ;;
6905877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6906877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
690772b675caSEdgar E. Iglesias    bflt="yes"
6908be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
6909*d75402b5SAlex Bennée    target_compiler=$cross_cc_microblaze
691072b675caSEdgar E. Iglesias  ;;
69112408a527Saurel32  mips|mipsel)
6912b498c8a0SJuan Quintela    TARGET_ARCH=mips
6913*d75402b5SAlex Bennée    target_compiler=$cross_cc_mips
691425be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
69152408a527Saurel32  ;;
69162408a527Saurel32  mipsn32|mipsn32el)
6917597e2cecSRichard Henderson    TARGET_ARCH=mips64
69186acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
6919*d75402b5SAlex Bennée    target_compiler=$cross_cc_mipsn32
692025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6921597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
69222408a527Saurel32  ;;
69232408a527Saurel32  mips64|mips64el)
6924b498c8a0SJuan Quintela    TARGET_ARCH=mips64
69256acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
6926*d75402b5SAlex Bennée    target_compiler=$cross_cc_mips64
692725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
69282408a527Saurel32  ;;
6929d15a9c23SAnthony Green  moxie)
6930*d75402b5SAlex Bennée    target_compiler=$cross_cc_moxie
6931d15a9c23SAnthony Green  ;;
6932e671711cSMarek Vasut  nios2)
6933*d75402b5SAlex Bennée    target_compiler=$cross_cc_nios2
6934e671711cSMarek Vasut  ;;
69354a09d0bbSRichard Henderson  or1k)
6936*d75402b5SAlex Bennée    target_compiler=$cross_cc_or1k
6937e67db06eSJia Liu    TARGET_ARCH=openrisc
6938e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6939e67db06eSJia Liu  ;;
69402408a527Saurel32  ppc)
6941c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6942*d75402b5SAlex Bennée    target_compiler=$cross_cc_powerpc
69432408a527Saurel32  ;;
69442408a527Saurel32  ppcemb)
69456acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6946e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6947c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6948*d75402b5SAlex Bennée    target_compiler=$cross_cc_ppcemb
69492408a527Saurel32  ;;
69502408a527Saurel32  ppc64)
69516acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6952e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6953f0b0685dSNikunj A Dadhania    mttcg=yes
69541438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6955*d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64
69562408a527Saurel32  ;;
69579c35126cSDoug Kwan  ppc64le)
69589c35126cSDoug Kwan    TARGET_ARCH=ppc64
69599c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
69609c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6961f0b0685dSNikunj A Dadhania    mttcg=yes
69621438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6963*d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64le
69649c35126cSDoug Kwan  ;;
69652408a527Saurel32  ppc64abi32)
6966b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
69676acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6968e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
696925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
69701438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6971*d75402b5SAlex Bennée    target_compiler=$cross_cc_ppc64abi32
69722408a527Saurel32  ;;
697325fa194bSMichael Clark  riscv32)
697425fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
697525fa194bSMichael Clark    TARGET_ABI_DIR=riscv
697625fa194bSMichael Clark    mttcg=yes
6977*d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv32
697825fa194bSMichael Clark  ;;
697925fa194bSMichael Clark  riscv64)
698025fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
698125fa194bSMichael Clark    TARGET_ABI_DIR=riscv
698225fa194bSMichael Clark    mttcg=yes
6983*d75402b5SAlex Bennée    target_compiler=$cross_cc_riscv64
698425fa194bSMichael Clark  ;;
69852408a527Saurel32  sh4|sh4eb)
6986b498c8a0SJuan Quintela    TARGET_ARCH=sh4
69874dbed897Spbrook    bflt="yes"
6988*d75402b5SAlex Bennée    target_compiler=$cross_cc_sh4
69892408a527Saurel32  ;;
69902408a527Saurel32  sparc)
6991*d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc
69922408a527Saurel32  ;;
69932408a527Saurel32  sparc64)
69946acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6995*d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc64
69962408a527Saurel32  ;;
69972408a527Saurel32  sparc32plus)
6998b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
69996acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7000e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7001*d75402b5SAlex Bennée    target_compiler=$cross_cc_sparc32plus
700225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
70032408a527Saurel32  ;;
700424e804ecSAlexander Graf  s390x)
700563685bc4SDavid Hildenbrand    mttcg=yes
700686158a2aSChristian 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"
7007*d75402b5SAlex Bennée    target_compiler=$cross_cc_s390x
700824e804ecSAlexander Graf  ;;
7009444e06b1SChen Gang  tilegx)
7010*d75402b5SAlex Bennée    target_compiler=$cross_cc_tilegx
7011444e06b1SChen Gang  ;;
70125ecaa4edSPeter Crosthwaite  tricore)
7013*d75402b5SAlex Bennée    target_compiler=$cross_cc_tricore
70145ecaa4edSPeter Crosthwaite  ;;
7015d2fbca94SGuan Xuetao  unicore32)
7016*d75402b5SAlex Bennée    target_compiler=$cross_cc_unicore32
7017d2fbca94SGuan Xuetao  ;;
7018cfa550c6SMax Filippov  xtensa|xtensaeb)
7019cfa550c6SMax Filippov    TARGET_ARCH=xtensa
70209fb40342SMax Filippov    mttcg="yes"
7021*d75402b5SAlex Bennée    target_compiler=$cross_cc_xtensa
7022cfa550c6SMax Filippov  ;;
70232408a527Saurel32  *)
702476ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
70252408a527Saurel32  ;;
70262408a527Saurel32esac
70275e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
70285e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
70295e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
70305e8861a0SPaolo Bonzinifi
70315e8861a0SPaolo Bonzini
7032*d75402b5SAlex Bennée# Do we have a cross compiler for this target?
7033*d75402b5SAlex Bennéeif has $target_compiler; then
7034*d75402b5SAlex Bennée
7035*d75402b5SAlex Bennée    write_c_skeleton
7036*d75402b5SAlex Bennée
7037*d75402b5SAlex Bennée    if ! do_compiler "$target_compiler" -o $TMPE $TMPC -static ; then
7038*d75402b5SAlex Bennée        # For host systems we might get away with building without -static
7039*d75402b5SAlex Bennée        if ! do_compiler "$target_compiler" -o $TMPE $TMPC ; then
7040*d75402b5SAlex Bennée            target_compiler=""
7041*d75402b5SAlex Bennée        else
7042*d75402b5SAlex Bennée            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7043*d75402b5SAlex Bennée            target_compiler_static="n"
7044*d75402b5SAlex Bennée        fi
7045*d75402b5SAlex Bennée    else
7046*d75402b5SAlex Bennée        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7047*d75402b5SAlex Bennée        target_compiler_static="y"
7048*d75402b5SAlex Bennée    fi
7049*d75402b5SAlex Bennéeelse
7050*d75402b5SAlex Bennée    target_compiler=""
7051*d75402b5SAlex Bennéefi
7052*d75402b5SAlex Bennée
70535e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
70545e8861a0SPaolo Bonzini
705599afc91dSDaniel P. Berrangeupper() {
705699afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
705799afc91dSDaniel P. Berrange}
705899afc91dSDaniel P. Berrange
705989138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
706025be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7061c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
706225be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7063e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7064e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7065e6e91b9cSJuan Quintelafi
706625be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7067adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7068adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7069adfc3e91SStacey Sonfi
70703b6b7550SPaolo Bonzini
70713b6b7550SPaolo Bonziniif supported_xen_target $target; then
707225be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7073eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7074eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7075eb6fda0fSAnthony PERARD    fi
7076432d268cSJun Nakajimafi
70773b6b7550SPaolo Bonziniif supported_kvm_target $target; then
707825be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
70791ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
7080d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7081e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
7082e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7083e6a74868SMarc-André Lureau        fi
7084d5970055SMichael S. Tsirkin    fi
7085c59249f9SJuan Quintelafi
70863b6b7550SPaolo Bonziniif supported_hax_target $target; then
7087b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7088b0cb0a66SVincent Palatinfi
7089c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7090c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7091c97d6d2cSSergio Andres Gomez Del Realfi
7092d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7093d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7094d661d9a4SJustin Terry (VM)fi
7095de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
709625be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
709797a847bcSbellardfi
709897a847bcSbellardif test "$target_softmmu" = "yes" ; then
709925be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7100ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7101ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7102ca759f9eSAlex Bennée  fi
7103de83cd02Sbellardfi
7104997344f3Sbellardif test "$target_user_only" = "yes" ; then
710525be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7106a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7107997344f3Sbellardfi
7108831b7825Sthsif test "$target_linux_user" = "yes" ; then
710925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7110831b7825Sthsfi
711156aebc89Spbrooklist=""
711256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
711356aebc89Spbrook  for x in $gdb_xml_files; do
711456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
711556aebc89Spbrook  done
711625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
71173d0f1517SJuan Quintelafi
7118de83cd02Sbellard
7119e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
712025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7121e5fe0c52Spbrookfi
712284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
712325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
712484778508Sblueswir1fi
71255b0753e0Sbellard
7126*d75402b5SAlex Bennéeif test -n "$target_compiler"; then
7127*d75402b5SAlex Bennée  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7128*d75402b5SAlex Bennée
7129*d75402b5SAlex Bennée  if test -n "$target_compiler_static"; then
7130*d75402b5SAlex Bennée      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7131*d75402b5SAlex Bennée  fi
7132*d75402b5SAlex Bennéefi
7133*d75402b5SAlex Bennée
71344afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
7135fa282484SJuan Quintela
71364afddb55SJuan Quintelacflags=""
7137fa282484SJuan Quintelaldflags=""
71389b8e111fSJuan Quintela
7139c765fcacSPeter Crosthwaitedisas_config() {
7140c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7141c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7142c765fcacSPeter Crosthwaite}
7143c765fcacSPeter Crosthwaite
714464656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
714564656024SJuan Quintela  case "$i" in
714664656024SJuan Quintela  alpha)
7147c765fcacSPeter Crosthwaite    disas_config "ALPHA"
714864656024SJuan Quintela  ;;
714982295d8aSRichard Henderson  aarch64)
715082295d8aSRichard Henderson    if test -n "${cxx}"; then
7151c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
715282295d8aSRichard Henderson    fi
715382295d8aSRichard Henderson  ;;
715464656024SJuan Quintela  arm)
7155c765fcacSPeter Crosthwaite    disas_config "ARM"
7156999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7157c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7158999b53ecSClaudio Fontana    fi
715964656024SJuan Quintela  ;;
716064656024SJuan Quintela  cris)
7161c765fcacSPeter Crosthwaite    disas_config "CRIS"
716264656024SJuan Quintela  ;;
7163429b31a2SRichard Henderson  hppa)
7164429b31a2SRichard Henderson    disas_config "HPPA"
7165429b31a2SRichard Henderson  ;;
7166c72b26ecSRichard Henderson  i386|x86_64|x32)
7167c765fcacSPeter Crosthwaite    disas_config "I386"
716864656024SJuan Quintela  ;;
716979368f49SMichael Walle  lm32)
7170c765fcacSPeter Crosthwaite    disas_config "LM32"
717179368f49SMichael Walle  ;;
717264656024SJuan Quintela  m68k)
7173c765fcacSPeter Crosthwaite    disas_config "M68K"
717464656024SJuan Quintela  ;;
7175877fdc12SEdgar E. Iglesias  microblaze*)
7176c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
717764656024SJuan Quintela  ;;
717864656024SJuan Quintela  mips*)
7179c765fcacSPeter Crosthwaite    disas_config "MIPS"
718064656024SJuan Quintela  ;;
7181d15a9c23SAnthony Green  moxie*)
7182c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7183d15a9c23SAnthony Green  ;;
7184e671711cSMarek Vasut  nios2)
7185e671711cSMarek Vasut    disas_config "NIOS2"
7186e671711cSMarek Vasut  ;;
71874a09d0bbSRichard Henderson  or1k)
7188c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
7189e67db06eSJia Liu  ;;
719064656024SJuan Quintela  ppc*)
7191c765fcacSPeter Crosthwaite    disas_config "PPC"
719264656024SJuan Quintela  ;;
719325fa194bSMichael Clark  riscv)
719425fa194bSMichael Clark    disas_config "RISCV"
719525fa194bSMichael Clark  ;;
719624e804ecSAlexander Graf  s390*)
7197c765fcacSPeter Crosthwaite    disas_config "S390"
719864656024SJuan Quintela  ;;
719964656024SJuan Quintela  sh4)
7200c765fcacSPeter Crosthwaite    disas_config "SH4"
720164656024SJuan Quintela  ;;
720264656024SJuan Quintela  sparc*)
7203c765fcacSPeter Crosthwaite    disas_config "SPARC"
720464656024SJuan Quintela  ;;
7205cfa550c6SMax Filippov  xtensa*)
7206c765fcacSPeter Crosthwaite    disas_config "XTENSA"
7207cfa550c6SMax Filippov  ;;
720864656024SJuan Quintela  esac
720964656024SJuan Quinteladone
72109195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
7211c765fcacSPeter Crosthwaite  disas_config "TCI"
72129195b2c2SStefan Weilfi
721364656024SJuan Quintela
72146ee7126fSJuan Quintelacase "$ARCH" in
72156ee7126fSJuan Quintelaalpha)
72166ee7126fSJuan Quintela  # Ensure there's only a single GP
72176ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
72186ee7126fSJuan Quintela;;
72196ee7126fSJuan Quintelaesac
72206ee7126fSJuan Quintela
7221d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
722225be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
7223d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
7224d02c1db3SJuan Quintela    cflags="-p $cflags"
7225d02c1db3SJuan Quintela    ldflags="-p $ldflags"
7226d02c1db3SJuan Quintela  fi
7227d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
7228d02c1db3SJuan Quintela    ldflags="-p $ldflags"
722925be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
7230d02c1db3SJuan Quintela  fi
7231d02c1db3SJuan Quintelafi
7232d02c1db3SJuan Quintela
72339b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
7234964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
7235fa282484SJuan Quintelafi
7236fa282484SJuan Quintela
7237e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
7238e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
7239e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
7240e9a3591fSChristian Borntraeger# header if
7241e9a3591fSChristian Borntraeger#  - we build on s390x
7242e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
7243e9a3591fSChristian Borntraeger#  - KVM is enabled
7244e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
7245e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7246e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
7247e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
7248e9a3591fSChristian Borntraeger    fi
7249e9a3591fSChristian Borntraegerfi
7250e9a3591fSChristian Borntraeger
725125be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
725225be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7253fa282484SJuan Quintela
725497a847bcSbellarddone # for target in $targets
72557d13299dSbellard
7256*d75402b5SAlex Bennéeif test -n "$enabled_cross_compilers"; then
7257*d75402b5SAlex Bennée    echo
7258*d75402b5SAlex Bennée    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7259*d75402b5SAlex Bennéefi
7260*d75402b5SAlex Bennée
7261e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
7262a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
7263a540f158SPeter Crosthwaitefi
7264e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7265e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
7266e219c499SRichard Hendersonfi
7267e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7268e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7269e219c499SRichard Hendersonfi
7270a540f158SPeter Crosthwaite
7271a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7272a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7273a99d57bbSWanlong Gaofi
7274a99d57bbSWanlong Gao
7275fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7276fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7277fd0e6053SJohn Snowfi
7278fd0e6053SJohn Snow
7279d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
7280b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
7281b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
72829933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
72832d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
7284c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
7285c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7286aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7287ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
7288446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
72899933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
72902d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
72914652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
72923a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
7293753d11f2SRichard Hendersonfor bios_file in \
7294753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
7295225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
72965acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
7297753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7298753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7299e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7300753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
73014e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
7302753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7303753d11f2SRichard Hendersondo
730489138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
73057ea78b74SJan Kiszkadone
730689138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
7307c2304b52SMarcel Apfelbaumdo
730889138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
7309c2304b52SMarcel Apfelbaumdone
7310d1807a4fSPaolo Bonzinimkdir -p $DIRS
73117d13299dSbellardfor f in $FILES ; do
7312cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7313f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7314f9245e10SPeter Maydell    fi
73157d13299dSbellarddone
73161ad2134fSPaul Brook
7317c34ebfdcSAnthony Liguori# temporary config to build submodules
73182d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
7319c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
732037116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7321c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7322cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
73235f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7324c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7325c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
73263dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7327c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7328a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7329c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
73309f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7331c34ebfdcSAnthony Liguoridone
7332c34ebfdcSAnthony Liguori
7333fe31017fSMarc-André Lureau# set up tests data directory
73341b145d59SPhilippe Mathieu-Daudéfor tests_subdir in acceptance data; do
73351b145d59SPhilippe Mathieu-Daudé    if [ ! -e tests/$tests_subdir ]; then
73361b145d59SPhilippe Mathieu-Daudé        symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
7337fe31017fSMarc-André Lureau    fi
73381b145d59SPhilippe Mathieu-Daudédone
7339fe31017fSMarc-André Lureau
734076c7560aSMax Reitz# set up qemu-iotests in this build directory
734176c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
734276c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
734376c7560aSMax Reitz
734476c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
734576c7560aSMax Reitzecho >> "$iotests_common_env"
734676c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
734776c7560aSMax Reitz
734876c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
734976c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
735076c7560aSMax Reitzfi
735176c7560aSMax Reitz
7352dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7353dc655404SMichael S. Tsirkincat <<EOD >config.status
7354dc655404SMichael S. Tsirkin#!/bin/sh
7355dc655404SMichael S. Tsirkin# Generated by configure.
7356dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7357dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7358dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7359dc655404SMichael S. TsirkinEOD
7360dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7361dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
7362cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7363dc655404SMichael S. Tsirkinchmod +x config.status
7364dc655404SMichael S. Tsirkin
73658cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7366