xref: /openbmc/qemu/configure (revision 14ab3aa7dc43b2eebbdf8b04a3b351b5ca5e13fe)
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
639c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
649c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
658dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
668dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
678dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
688dc38a78SPeter Maydell    # obvious to developers.
698dc38a78SPeter Maydell    if test "$werror" != "yes"; then
708dc38a78SPeter Maydell        return 0
718dc38a78SPeter Maydell    fi
728dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
738dc38a78SPeter Maydell    case "$*" in
748dc38a78SPeter Maydell        *-Werror*)
758dc38a78SPeter Maydell           return 0
768dc38a78SPeter Maydell        ;;
778dc38a78SPeter Maydell    esac
789c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
799c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
8076ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
8176ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8276ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8376ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
848dc38a78SPeter Maydell}
858dc38a78SPeter Maydell
869c83ffd8SPeter Maydelldo_cc() {
879c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
889c83ffd8SPeter Maydell}
899c83ffd8SPeter Maydell
909c83ffd8SPeter Maydelldo_cxx() {
919c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
929c83ffd8SPeter Maydell}
939c83ffd8SPeter Maydell
949c83ffd8SPeter Maydellupdate_cxxflags() {
959c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
969c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
979c83ffd8SPeter Maydell    # because they only make sense for C programs.
9811cde1c8SBruno Dominguez    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
9911cde1c8SBruno Dominguez
1009c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1019c83ffd8SPeter Maydell        case $arg in
1029c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1039c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1049c83ffd8SPeter Maydell                ;;
1059c83ffd8SPeter Maydell            *)
1069c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1079c83ffd8SPeter Maydell                ;;
1089c83ffd8SPeter Maydell        esac
1099c83ffd8SPeter Maydell    done
1109c83ffd8SPeter Maydell}
1119c83ffd8SPeter Maydell
11252166aa0SJuan Quintelacompile_object() {
113fd0e6053SJohn Snow  local_cflags="$1"
114fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
11552166aa0SJuan Quintela}
11652166aa0SJuan Quintela
11752166aa0SJuan Quintelacompile_prog() {
11852166aa0SJuan Quintela  local_cflags="$1"
11952166aa0SJuan Quintela  local_ldflags="$2"
1208dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
12152166aa0SJuan Quintela}
12252166aa0SJuan Quintela
12311568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
12411568d6dSPaolo Bonzinisymlink() {
12572b8b5a1SStefan Weil  rm -rf "$2"
126ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
12772b8b5a1SStefan Weil  ln -s "$1" "$2"
12811568d6dSPaolo Bonzini}
12911568d6dSPaolo Bonzini
1300dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1310dba6195SLoïc Minier# executable or a builtin)
1320dba6195SLoïc Minierhas() {
1330dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1340dba6195SLoïc Minier}
1350dba6195SLoïc Minier
1360dba6195SLoïc Minier# search for an executable in PATH
1370dba6195SLoïc Minierpath_of() {
1380dba6195SLoïc Minier    local_command="$1"
1390dba6195SLoïc Minier    local_ifs="$IFS"
1400dba6195SLoïc Minier    local_dir=""
1410dba6195SLoïc Minier
1420dba6195SLoïc Minier    # pathname has a dir component?
1430dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1440dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1450dba6195SLoïc Minier            echo "$local_command"
1460dba6195SLoïc Minier            return 0
1470dba6195SLoïc Minier        fi
1480dba6195SLoïc Minier    fi
1490dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1500dba6195SLoïc Minier        return 1
1510dba6195SLoïc Minier    fi
1520dba6195SLoïc Minier
1530dba6195SLoïc Minier    IFS=:
1540dba6195SLoïc Minier    for local_dir in $PATH; do
1550dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1560dba6195SLoïc Minier            echo "$local_dir/$local_command"
1570dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1580dba6195SLoïc Minier            return 0
1590dba6195SLoïc Minier        fi
1600dba6195SLoïc Minier    done
1610dba6195SLoïc Minier    # not found
1620dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1630dba6195SLoïc Minier    return 1
1640dba6195SLoïc Minier}
1650dba6195SLoïc Minier
1665b808275SLluís Vilanovahave_backend () {
1675b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1685b808275SLluís Vilanova}
1695b808275SLluís Vilanova
1703b6b7550SPaolo Bonziniglob() {
1713b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1723b6b7550SPaolo Bonzini}
1733b6b7550SPaolo Bonzini
1743b6b7550SPaolo Bonzinisupported_hax_target() {
1753b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1763b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1773b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1783b6b7550SPaolo Bonzini        i386|x86_64)
1793b6b7550SPaolo Bonzini            return 0
1803b6b7550SPaolo Bonzini        ;;
1813b6b7550SPaolo Bonzini    esac
1823b6b7550SPaolo Bonzini    return 1
1833b6b7550SPaolo Bonzini}
1843b6b7550SPaolo Bonzini
1853b6b7550SPaolo Bonzinisupported_kvm_target() {
1863b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1873b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1883b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1893b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1903b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
1913b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
1923b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
1933b6b7550SPaolo Bonzini        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
1943b6b7550SPaolo Bonzini        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
1953b6b7550SPaolo Bonzini        s390x:s390x)
1963b6b7550SPaolo Bonzini            return 0
1973b6b7550SPaolo Bonzini        ;;
1983b6b7550SPaolo Bonzini    esac
1993b6b7550SPaolo Bonzini    return 1
2003b6b7550SPaolo Bonzini}
2013b6b7550SPaolo Bonzini
2023b6b7550SPaolo Bonzinisupported_xen_target() {
2033b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2043b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
205b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
206b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
207b5ed2e11SPaolo Bonzini        i386|x86_64)
2083b6b7550SPaolo Bonzini            return 0
2093b6b7550SPaolo Bonzini        ;;
2103b6b7550SPaolo Bonzini    esac
2113b6b7550SPaolo Bonzini    return 1
2123b6b7550SPaolo Bonzini}
2133b6b7550SPaolo Bonzini
214c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
215c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
216c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
217c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
218c97d6d2cSSergio Andres Gomez Del Real        x86_64)
219c97d6d2cSSergio Andres Gomez Del Real            return 0
220c97d6d2cSSergio Andres Gomez Del Real        ;;
221c97d6d2cSSergio Andres Gomez Del Real    esac
222c97d6d2cSSergio Andres Gomez Del Real    return 1
223c97d6d2cSSergio Andres Gomez Del Real}
224c97d6d2cSSergio Andres Gomez Del Real
225d880a3baSPaolo Bonzinisupported_target() {
226d880a3baSPaolo Bonzini    case "$1" in
227d880a3baSPaolo Bonzini        *-softmmu)
228d880a3baSPaolo Bonzini            ;;
229d880a3baSPaolo Bonzini        *-linux-user)
230d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
231d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
232d880a3baSPaolo Bonzini                return 1
233d880a3baSPaolo Bonzini            fi
234d880a3baSPaolo Bonzini            ;;
235d880a3baSPaolo Bonzini        *-bsd-user)
236d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
237d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
238d880a3baSPaolo Bonzini                return 1
239d880a3baSPaolo Bonzini            fi
240d880a3baSPaolo Bonzini            ;;
241d880a3baSPaolo Bonzini        *)
242d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
243d880a3baSPaolo Bonzini            return 1
244d880a3baSPaolo Bonzini            ;;
245d880a3baSPaolo Bonzini    esac
246b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
247b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
248b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
249b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
250c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
251b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
252b3f6ea7eSPaolo Bonzini    return 1
253d880a3baSPaolo Bonzini}
254d880a3baSPaolo Bonzini
255e9a3591fSChristian Borntraeger
256e9a3591fSChristian Borntraegerld_has() {
257e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
258e9a3591fSChristian Borntraeger}
259e9a3591fSChristian Borntraeger
2607d13299dSbellard# default parameters
26189138857SStefan Weilsource_path=$(dirname "$0")
2622ff6b91eSJuan Quintelacpu=""
263a31a8642SMichael S. Tsirkiniasl="iasl"
2641e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
26543ce4dfeSbellardstatic="no"
2667d13299dSbellardcross_prefix=""
2670c58ac1cSmalcaudio_drv_list=""
268b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
269b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
270e49d021eSPeter Maydellhost_cc="cc"
27173da375eSJuan Quintelalibs_softmmu=""
2723e2e0e6bSJuan Quintelalibs_tools=""
27367f86e8eSJuan Quintelaaudio_pt_int=""
274d5631638Smalcaudio_win_int=""
2752b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
276957f1f99SMichael Rothlibs_qga=""
2775bc62e01SGerd Hoffmanndebug_info="yes"
27863678e17SSteven Noonanstack_protector=""
279ac0df51dSaliguori
28092712822SDaniel P. Berrangeif test -e "$source_path/.git"
28192712822SDaniel P. Berrangethen
282f62bbee5SDaniel P. Berrange    git_update=yes
28392712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
28492712822SDaniel P. Berrangeelse
285f62bbee5SDaniel P. Berrange    git_update=no
286aef45d51SDaniel P. Berrange    git_submodules=""
28792712822SDaniel P. Berrangefi
288cc84d63aSDaniel P. Berrangegit="git"
289ac0df51dSaliguori
290afb63ebdSStefan Weil# Don't accept a target_list environment variable.
291afb63ebdSStefan Weilunset target_list
292377529c0SPaolo Bonzini
293377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
294377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
295377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
296377529c0SPaolo Bonzini#              unless --disable-foo is given
297377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
298377529c0SPaolo Bonzini#              feature will searched for,
299377529c0SPaolo Bonzini#              if not found, configure exits with error
300377529c0SPaolo Bonzini#
301377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
302377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
303377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
304377529c0SPaolo Bonzini
305377529c0SPaolo Bonzinibluez=""
306377529c0SPaolo Bonzinibrlapi=""
307377529c0SPaolo Bonzinicurl=""
308377529c0SPaolo Bonzinicurses=""
309377529c0SPaolo Bonzinidocs=""
310377529c0SPaolo Bonzinifdt=""
31158952137SVincenzo Maffionenetmap="no"
312377529c0SPaolo Bonzinisdl=""
313ee8466d0SCole Robinsonsdlabi=""
314983eef5aSMeador Ingevirtfs=""
315fe8fc5aeSPaolo Bonzinimpath=""
316821601eaSJes Sorensenvnc="yes"
317377529c0SPaolo Bonzinisparse="no"
318377529c0SPaolo Bonzinivde=""
319377529c0SPaolo Bonzinivnc_sasl=""
320377529c0SPaolo Bonzinivnc_jpeg=""
321377529c0SPaolo Bonzinivnc_png=""
3226a021536SGerd Hoffmannxkbcommon=""
323377529c0SPaolo Bonzinixen=""
324d5b93ddfSAnthony PERARDxen_ctrl_version=""
32564a7ad6fSIan Campbellxen_pv_domain_build="no"
326eb6fda0fSAnthony PERARDxen_pci_passthrough=""
327377529c0SPaolo Bonzinilinux_aio=""
32847e98658SCorey Bryantcap_ng=""
329377529c0SPaolo Bonziniattr=""
3304f26f2b6SAvi Kivitylibattr=""
331377529c0SPaolo Bonzinixfs=""
332b3f6ea7eSPaolo Bonzinitcg="yes"
333377529c0SPaolo Bonzini
334d41a75a2SBradvhost_net="no"
3355e9be92dSNicholas Bellingervhost_scsi="no"
336fc0b9b0eSStefan Hajnoczivhost_vsock="no"
337e6a74868SMarc-André Lureauvhost_user=""
338d41a75a2SBradkvm="no"
339b0cb0a66SVincent Palatinhax="no"
340c97d6d2cSSergio Andres Gomez Del Realhvf="no"
3412da776dbSMichael R. Hinesrdma=""
342377529c0SPaolo Bonzinigprof="no"
343377529c0SPaolo Bonzinidebug_tcg="no"
344377529c0SPaolo Bonzinidebug="no"
345b553a042SJohn Snowfortify_source=""
346377529c0SPaolo Bonzinistrip_opt="yes"
3479195b2c2SStefan Weiltcg_interpreter="no"
348377529c0SPaolo Bonzinibigendian="no"
349377529c0SPaolo Bonzinimingw32="no"
3501d728c39SBlue Swirlgcov="no"
3511d728c39SBlue Swirlgcov_tool="gcov"
352377529c0SPaolo BonziniEXESUF=""
35317969268SFam ZhengDSOSUF=".so"
35417969268SFam ZhengLDFLAGS_SHARED="-shared"
35517969268SFam Zhengmodules="no"
356377529c0SPaolo Bonziniprefix="/usr/local"
357377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
358528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
3593d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
360850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
361377529c0SPaolo Bonzinibindir="\${prefix}/bin"
3623aa5d2beSAlon Levylibdir="\${prefix}/lib"
3638bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
3640f94d6daSAlon Levyincludedir="\${prefix}/include"
365377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
366785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
367377529c0SPaolo Bonziniconfsuffix="/qemu"
368377529c0SPaolo Bonzinislirp="yes"
369377529c0SPaolo Bonzinioss_lib=""
370377529c0SPaolo Bonzinibsd="no"
371377529c0SPaolo Bonzinilinux="no"
372377529c0SPaolo Bonzinisolaris="no"
373377529c0SPaolo Bonziniprofiler="no"
374377529c0SPaolo Bonzinicocoa="no"
375377529c0SPaolo Bonzinisoftmmu="yes"
376377529c0SPaolo Bonzinilinux_user="no"
377377529c0SPaolo Bonzinibsd_user="no"
378377529c0SPaolo Bonziniblobs="yes"
379377529c0SPaolo Bonzinipkgversion=""
38040d6444eSAvi Kivitypie=""
3813556c233SPaolo Bonziniqom_cast_debug="yes"
382baf86d6bSPaolo Bonzinitrace_backends="log"
383377529c0SPaolo Bonzinitrace_file="trace"
384377529c0SPaolo Bonzinispice=""
385377529c0SPaolo Bonzinirbd=""
3867b02f544SMarc-André Lureausmartcard=""
3872b2325ffSGerd Hoffmannlibusb=""
38869354a83SHans de Goedeusb_redir=""
389da076ffeSGerd Hoffmannopengl=""
390014cb152SGerd Hoffmannopengl_dmabuf="no"
3915dd89908SRichard Hendersoncpuid_h="no"
39299f2dbd3SLiang Liavx2_opt="no"
3931ece9905SAlon Levyzlib="yes"
3948ca80760SRichard Hendersoncapstone=""
395b25c9dffSStefan Weillzo=""
396b25c9dffSStefan Weilsnappy=""
3976b383c08SPeter Wubzip2=""
398e8ef31a3SMichael Tokarevguest_agent=""
399d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
40050cbebb9SMichael Rothguest_agent_ntddscsi="no"
4019dacf32dSYossi Hindinguest_agent_msi=""
402d9840e25STomoki Sekiyamavss_win32_sdk=""
403d9840e25STomoki Sekiyamawin_sdk="no"
4044b1c11fdSDaniel P. Berrangewant_tools="yes"
405c589b249SRonnie Sahlberglibiscsi=""
4066542aa9cSPeter Lievenlibnfs=""
407519175a2SAlex Barcelocoroutine=""
40870c60c08SStefan Hajnoczicoroutine_pool=""
4097d992e4dSPeter Lievendebug_stack_usage="no"
410f0d92b56SLongpeng(Mike)crypto_afalg="no"
411f794573eSEduardo Otuboseccomp=""
412eb100396SBharata B Raoglusterfs=""
413d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4140c14fb47SBharata B Raoglusterfs_discard="no"
415df3a429aSNiels de Vosglusterfs_fallocate="no"
4167c815372SBharata B Raoglusterfs_zerofill="no"
417a4ccabcfSAnthony Liguorigtk=""
4189e04c683SStefan Weilgtkabi=""
419925a0400SGerd Hoffmanngtk_gl="no"
420a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
421ddbb0d09SDaniel P. Berrangegnutls=""
422b917da4cSDaniel P. Berrangegnutls_rnd=""
42391bfcdb0SDaniel P. Berrangenettle=""
424fff2f982SDaniel P. Berrangenettle_kdf="no"
42591bfcdb0SDaniel P. Berrangegcrypt=""
4261f923c70SLongpeng(Mike)gcrypt_hmac="no"
42737788f25SDaniel P. Berrangegcrypt_kdf="no"
428bbbf9bfbSStefan Weilvte=""
4299d9e1521SGerd Hoffmannvirglrenderer=""
430e91c793cSCole Robinsontpm="yes"
4310a12ec87SRichard W.M. Joneslibssh2=""
432ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
433a99d57bbSWanlong Gaonuma=""
4342847b469SFam Zhengtcmalloc="no"
4357b01cb97SAlexandre Derumierjemalloc="no"
436a6b1d4c0SChanglong Xiereplication="yes"
437da92c3ffSAshish Mittalvxhs=""
438377529c0SPaolo Bonzini
439898be3e0SPeter Maydellsupported_cpu="no"
440898be3e0SPeter Maydellsupported_os="no"
441fb59dabdSPeter Maydellbogus_os="no"
4425a22ab71SYang Zhongmalloc_trim=""
443898be3e0SPeter Maydell
444ac0df51dSaliguori# parse CC options first
445ac0df51dSaliguorifor opt do
44689138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
447ac0df51dSaliguori  case "$opt" in
448ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
449ac0df51dSaliguori  ;;
4503d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
451ac0df51dSaliguori  ;;
45283f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
45383f73fceSTomoki Sekiyama  ;;
454ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
455ca4deeb1SPaolo Bonzini  ;;
4562ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4572ff6b91eSJuan Quintela  ;;
458de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
459f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
460e2a2ed06SJuan Quintela  ;;
46111cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
46211cde1c8SBruno Dominguez                      EXTRA_CXXFLAGS="$optarg"
46311cde1c8SBruno Dominguez  ;;
464a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
465f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
466e2a2ed06SJuan Quintela  ;;
4675bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4685bc62e01SGerd Hoffmann  ;;
4695bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4705bc62e01SGerd Hoffmann  ;;
471ac0df51dSaliguori  esac
472ac0df51dSaliguoridone
473ac0df51dSaliguori# OS specific
474ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
47593148aa5SStefan Weil# we can eliminate its usage altogether.
476ac0df51dSaliguori
477e49d021eSPeter Maydell# Preferred compiler:
478e49d021eSPeter Maydell#  ${CC} (if set)
479e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
480e49d021eSPeter Maydell#  system compiler
481e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
482e49d021eSPeter Maydell  cc="$host_cc"
483e49d021eSPeter Maydellelse
484b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
485e49d021eSPeter Maydellfi
486e49d021eSPeter Maydell
48783f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
48883f73fceSTomoki Sekiyama  cxx="c++"
48983f73fceSTomoki Sekiyamaelse
49083f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
49183f73fceSTomoki Sekiyamafi
49283f73fceSTomoki Sekiyama
493b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
494cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4955f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4963dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
497b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
498b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
4999f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5004852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
501b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
502b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
50317884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
50417884d7bSSergei Trofimovichquery_pkg_config() {
50517884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
50617884d7bSSergei Trofimovich}
50717884d7bSSergei Trofimovichpkg_config=query_pkg_config
508b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
50947c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
510ac0df51dSaliguori
51145d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
51245d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
51345d285abSPeter Maydell
514be17dc90SMichael S. Tsirkin# default flags for all hosts
5152d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5162d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5172d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5182d31515bSPeter Maydell# provides these semantics.)
5192d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
520f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
521c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
522be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
523244f1441SYang ZhongQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
5245bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5255bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
526be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5275bc62e01SGerd Hoffmannfi
528be17dc90SMichael S. Tsirkin
529ca4deeb1SPaolo Bonzini# make source path absolute
53089138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
531ca4deeb1SPaolo Bonzini
532cab00a5aSMichael S. Tsirkin# running configure in the source tree?
533cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
534cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
535cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
536cab00a5aSMichael S. Tsirkinelse
537cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
538cab00a5aSMichael S. Tsirkinfi
539cab00a5aSMichael S. Tsirkin
540ac0df51dSaliguoricheck_define() {
541ac0df51dSaliguoricat > $TMPC <<EOF
542ac0df51dSaliguori#if !defined($1)
543fd786e1aSPeter Maydell#error $1 not defined
544ac0df51dSaliguori#endif
545ac0df51dSaliguoriint main(void) { return 0; }
546ac0df51dSaliguoriEOF
54752166aa0SJuan Quintela  compile_object
548ac0df51dSaliguori}
549ac0df51dSaliguori
550307119e7SGerd Hoffmanncheck_include() {
551307119e7SGerd Hoffmanncat > $TMPC <<EOF
552307119e7SGerd Hoffmann#include <$1>
553307119e7SGerd Hoffmannint main(void) { return 0; }
554307119e7SGerd HoffmannEOF
555307119e7SGerd Hoffmann  compile_object
556307119e7SGerd Hoffmann}
557307119e7SGerd Hoffmann
55893b25869SJohn Snowwrite_c_skeleton() {
55993b25869SJohn Snow    cat > $TMPC <<EOF
56093b25869SJohn Snowint main(void) { return 0; }
56193b25869SJohn SnowEOF
56293b25869SJohn Snow}
56393b25869SJohn Snow
564bbea4050SPeter Maydellif check_define __linux__ ; then
565bbea4050SPeter Maydell  targetos="Linux"
566bbea4050SPeter Maydellelif check_define _WIN32 ; then
567bbea4050SPeter Maydell  targetos='MINGW32'
568bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
569bbea4050SPeter Maydell  targetos='OpenBSD'
570bbea4050SPeter Maydellelif check_define __sun__ ; then
571bbea4050SPeter Maydell  targetos='SunOS'
572bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
573bbea4050SPeter Maydell  targetos='Haiku'
574951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
575951fedfcSPeter Maydell  targetos='FreeBSD'
576951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
577951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
578951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
579951fedfcSPeter Maydell  targetos='DragonFly'
580951fedfcSPeter Maydellelif check_define __NetBSD__; then
581951fedfcSPeter Maydell  targetos='NetBSD'
582951fedfcSPeter Maydellelif check_define __APPLE__; then
583951fedfcSPeter Maydell  targetos='Darwin'
584bbea4050SPeter Maydellelse
585951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
586951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
587951fedfcSPeter Maydell  # be the result of a missing compiler.
588951fedfcSPeter Maydell  targetos='bogus'
589951fedfcSPeter Maydell  bogus_os='yes'
590bbea4050SPeter Maydellfi
591bbea4050SPeter Maydell
592bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
593bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
594bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
595bbea4050SPeter Maydell# the correct CPU with the --cpu option.
596bbea4050SPeter Maydellcase $targetos in
597bbea4050SPeter MaydellDarwin)
598bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
599bbea4050SPeter Maydell  # run 64-bit userspace code.
600bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
601bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
602bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
603bbea4050SPeter Maydell    cpu="x86_64"
604bbea4050SPeter Maydell  fi
605bbea4050SPeter Maydell  ;;
606bbea4050SPeter MaydellSunOS)
60789138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
608bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
609bbea4050SPeter Maydell    cpu="x86_64"
610bbea4050SPeter Maydell  fi
611bbea4050SPeter Maydellesac
612bbea4050SPeter Maydell
6132ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6142ff6b91eSJuan Quintela  # command line argument
6152ff6b91eSJuan Quintela  :
6162ff6b91eSJuan Quintelaelif check_define __i386__ ; then
617ac0df51dSaliguori  cpu="i386"
618ac0df51dSaliguorielif check_define __x86_64__ ; then
619c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
620c72b26ecSRichard Henderson    cpu="x32"
621c72b26ecSRichard Henderson  else
622ac0df51dSaliguori    cpu="x86_64"
623c72b26ecSRichard Henderson  fi
6243aa9bd6cSblueswir1elif check_define __sparc__ ; then
6253aa9bd6cSblueswir1  if check_define __arch64__ ; then
6263aa9bd6cSblueswir1    cpu="sparc64"
6273aa9bd6cSblueswir1  else
6283aa9bd6cSblueswir1    cpu="sparc"
6293aa9bd6cSblueswir1  fi
630fdf7ed96Smalcelif check_define _ARCH_PPC ; then
631fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
632fdf7ed96Smalc    cpu="ppc64"
633ac0df51dSaliguori  else
634fdf7ed96Smalc    cpu="ppc"
635fdf7ed96Smalc  fi
636afa05235SAurelien Jarnoelif check_define __mips__ ; then
637afa05235SAurelien Jarno  cpu="mips"
638477ba620SAurelien Jarnoelif check_define __ia64__ ; then
639477ba620SAurelien Jarno  cpu="ia64"
640d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
641d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
642d66ed0eaSAurelien Jarno    cpu="s390x"
643d66ed0eaSAurelien Jarno  else
644d66ed0eaSAurelien Jarno    cpu="s390"
645d66ed0eaSAurelien Jarno  fi
64621d89f84SPeter Maydellelif check_define __arm__ ; then
64721d89f84SPeter Maydell  cpu="arm"
6481f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6491f080313SClaudio Fontana  cpu="aarch64"
650fdf7ed96Smalcelse
65189138857SStefan Weil  cpu=$(uname -m)
652ac0df51dSaliguorifi
653ac0df51dSaliguori
654359bc95dSPeter MaydellARCH=
655359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
656359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6577d13299dSbellardcase "$cpu" in
6586499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
659898be3e0SPeter Maydell    cpu="$cpu"
660898be3e0SPeter Maydell    supported_cpu="yes"
661898be3e0SPeter Maydell  ;;
6627d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
66397a847bcSbellard    cpu="i386"
664898be3e0SPeter Maydell    supported_cpu="yes"
6657d13299dSbellard  ;;
666aaa5fa14Saurel32  x86_64|amd64)
667aaa5fa14Saurel32    cpu="x86_64"
668898be3e0SPeter Maydell    supported_cpu="yes"
669aaa5fa14Saurel32  ;;
67021d89f84SPeter Maydell  armv*b|armv*l|arm)
67121d89f84SPeter Maydell    cpu="arm"
672898be3e0SPeter Maydell    supported_cpu="yes"
6737d13299dSbellard  ;;
6741f080313SClaudio Fontana  aarch64)
6751f080313SClaudio Fontana    cpu="aarch64"
676898be3e0SPeter Maydell    supported_cpu="yes"
6771f080313SClaudio Fontana  ;;
678afa05235SAurelien Jarno  mips*)
679afa05235SAurelien Jarno    cpu="mips"
680898be3e0SPeter Maydell    supported_cpu="yes"
681afa05235SAurelien Jarno  ;;
6823142255cSblueswir1  sparc|sun4[cdmuv])
683ae228531Sbellard    cpu="sparc"
6846499fd15SPeter Maydell    supported_cpu="yes"
685ae228531Sbellard  ;;
6867d13299dSbellard  *)
687359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
688359bc95dSPeter Maydell    ARCH=unknown
6897d13299dSbellard  ;;
6907d13299dSbellardesac
691359bc95dSPeter Maydellif test -z "$ARCH"; then
692359bc95dSPeter Maydell  ARCH="$cpu"
693359bc95dSPeter Maydellfi
694e2d52ad3SJuan Quintela
6957d13299dSbellard# OS specific
6960dbfc675SJuan Quintela
697adfc3e91SStacey Son# host *BSD for user mode
698adfc3e91SStacey SonHOST_VARIANT_DIR=""
699adfc3e91SStacey Son
7007d13299dSbellardcase $targetos in
70167b915a5SbellardMINGW32*)
70267b915a5Sbellard  mingw32="yes"
703b0cb0a66SVincent Palatin  hax="yes"
7043cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
705307119e7SGerd Hoffmann  if check_include dsound.h; then
7063cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
707307119e7SGerd Hoffmann  else
708307119e7SGerd Hoffmann    audio_drv_list=""
709307119e7SGerd Hoffmann  fi
710898be3e0SPeter Maydell  supported_os="yes"
71167b915a5Sbellard;;
7125c40d2bdSthsGNU/kFreeBSD)
713a167ba50SAurelien Jarno  bsd="yes"
7140c58ac1cSmalc  audio_drv_list="oss"
7150bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7165c40d2bdSths;;
7177d3505c5SbellardFreeBSD)
7187d3505c5Sbellard  bsd="yes"
7190db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7200c58ac1cSmalc  audio_drv_list="oss"
7210bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
722f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
723f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
724a7764f15SEd Maste  # needed for kinfo_getproc
725a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
72658952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
727adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
728898be3e0SPeter Maydell  supported_os="yes"
7297d3505c5Sbellard;;
730c5e97233Sblueswir1DragonFly)
731c5e97233Sblueswir1  bsd="yes"
7320db4a067SPaolo Bonzini  make="${MAKE-gmake}"
733c5e97233Sblueswir1  audio_drv_list="oss"
7340bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
735adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
736c5e97233Sblueswir1;;
7377d3505c5SbellardNetBSD)
7387d3505c5Sbellard  bsd="yes"
7390db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7400c58ac1cSmalc  audio_drv_list="oss"
7410bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7428ef92a88Sblueswir1  oss_lib="-lossaudio"
743adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
7443c2bdbc1SKamil Rytarowski  supported_os="yes"
7457d3505c5Sbellard;;
7467d3505c5SbellardOpenBSD)
7477d3505c5Sbellard  bsd="yes"
7480db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7494f6ab397SBrad Smith  audio_drv_list="sdl"
7500bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
751adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7527d3505c5Sbellard;;
75383fb7adfSbellardDarwin)
75483fb7adfSbellard  bsd="yes"
75583fb7adfSbellard  darwin="yes"
756b0cb0a66SVincent Palatin  hax="yes"
757c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
75817969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7591b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
760a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7610c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
7621b0f9cc2Saliguori  fi
763fd677642Sths  cocoa="yes"
7640c58ac1cSmalc  audio_drv_list="coreaudio"
76514382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
7660c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7677973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
768a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
769a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
770a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
771adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
772898be3e0SPeter Maydell  supported_os="yes"
77383fb7adfSbellard;;
774ec530c81SbellardSunOS)
775ec530c81Sbellard  solaris="yes"
7760db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7770db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
778e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7796b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7800c58ac1cSmalc    audio_drv_list="oss"
7816b4d2ba1Sths  fi
782c2de5c91Smalc  audio_possible_drivers="oss sdl"
783d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
784d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
785d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
786d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
787a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
788560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
789560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
790560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
791ec530c81Sbellard;;
792179cf400SAndreas FärberHaiku)
793179cf400SAndreas Färber  haiku="yes"
794179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
795179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
796179cf400SAndreas Färber;;
797898be3e0SPeter MaydellLinux)
7980c58ac1cSmalc  audio_drv_list="oss"
7990bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8005327cf48Sbellard  linux="yes"
801831b7825Sths  linux_user="yes"
802af2be207SJan Kiszka  kvm="yes"
803af2be207SJan Kiszka  vhost_net="yes"
8045e9be92dSNicholas Bellinger  vhost_scsi="yes"
805fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
806a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
807898be3e0SPeter Maydell  supported_os="yes"
808898be3e0SPeter Maydell;;
8097d13299dSbellardesac
8107d13299dSbellard
8117d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
812b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
81384778508Sblueswir1    bsd_user="yes"
8147d3505c5Sbellard  fi
81508de3949SAndreas Färberfi
8167d3505c5Sbellard
8170db4a067SPaolo Bonzini: ${make=${MAKE-make}}
8180db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
81952510f8bSStefan Weil: ${python=${PYTHON-python}}
820e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8210db4a067SPaolo Bonzini
8223c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8233c4a4d0dSPeter Maydellif has clang; then
8243c4a4d0dSPeter Maydell  objcc=clang
8253c4a4d0dSPeter Maydellelse
8263c4a4d0dSPeter Maydell  objcc="$cc"
8273c4a4d0dSPeter Maydellfi
8283c4a4d0dSPeter Maydell
8293457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8303457a3f8SJuan Quintela  EXESUF=".exe"
83117969268SFam Zheng  DSOSUF=".dll"
832a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
833e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
834e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
83578e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
83678e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
837f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
83893b25869SJohn Snow  write_c_skeleton;
839f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
840f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
841f7cf5d5bSStefan Weil  fi
842c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
843683035deSPaolo Bonzini  mandir="\${prefix}"
844528ae5b8SEduardo Habkost  datadir="\${prefix}"
845850da188SEduardo Habkost  qemu_docdir="\${prefix}"
846683035deSPaolo Bonzini  bindir="\${prefix}"
847683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8485a699bbbSLaszlo Ersek  local_statedir=
849683035deSPaolo Bonzini  confsuffix=""
850105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8513457a3f8SJuan Quintelafi
8523457a3f8SJuan Quintela
853487fefdbSAnthony Liguoriwerror=""
85485aa5189Sbellard
8557d13299dSbellardfor opt do
85689138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8577d13299dSbellard  case "$opt" in
8582efc3265Sbellard  --help|-h) show_help=yes
8592efc3265Sbellard  ;;
86099123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
86199123e13SMike Frysinger  ;;
862b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8637d13299dSbellard  ;;
864b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
86532ce6337Sbellard  ;;
866ca4deeb1SPaolo Bonzini  --source-path=*)
8677d13299dSbellard  ;;
868ac0df51dSaliguori  --cross-prefix=*)
8697d13299dSbellard  ;;
870ac0df51dSaliguori  --cc=*)
8717d13299dSbellard  ;;
872b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
87383469015Sbellard  ;;
87483f73fceSTomoki Sekiyama  --cxx=*)
87583f73fceSTomoki Sekiyama  ;;
876e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
877e007dbecSMichael S. Tsirkin  ;;
8783c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8793c4a4d0dSPeter Maydell  ;;
880b1a550a0Spbrook  --make=*) make="$optarg"
8817d13299dSbellard  ;;
8826a882643Spbrook  --install=*) install="$optarg"
8836a882643Spbrook  ;;
884c886edfbSBlue Swirl  --python=*) python="$optarg"
885c886edfbSBlue Swirl  ;;
8861d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
8871d728c39SBlue Swirl  ;;
888e2d8830eSBrad  --smbd=*) smbd="$optarg"
889e2d8830eSBrad  ;;
890e2a2ed06SJuan Quintela  --extra-cflags=*)
8917d13299dSbellard  ;;
89211cde1c8SBruno Dominguez  --extra-cxxflags=*)
89311cde1c8SBruno Dominguez  ;;
894e2a2ed06SJuan Quintela  --extra-ldflags=*)
8957d13299dSbellard  ;;
8965bc62e01SGerd Hoffmann  --enable-debug-info)
8975bc62e01SGerd Hoffmann  ;;
8985bc62e01SGerd Hoffmann  --disable-debug-info)
8995bc62e01SGerd Hoffmann  ;;
90017969268SFam Zheng  --enable-modules)
90117969268SFam Zheng      modules="yes"
90217969268SFam Zheng  ;;
9033aa88b31SStefan Hajnoczi  --disable-modules)
9043aa88b31SStefan Hajnoczi      modules="no"
9053aa88b31SStefan Hajnoczi  ;;
9062ff6b91eSJuan Quintela  --cpu=*)
9077d13299dSbellard  ;;
908b1a550a0Spbrook  --target-list=*) target_list="$optarg"
909de83cd02Sbellard  ;;
9105b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9115b808275SLluís Vilanova  ;;
9125b808275SLluís Vilanova  # XXX: backwards compatibility
9135b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
91494a420b1SStefan Hajnoczi  ;;
91574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9169410b56cSPrerna Saxena  ;;
9177d13299dSbellard  --enable-gprof) gprof="yes"
9187d13299dSbellard  ;;
9191d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9201d728c39SBlue Swirl  ;;
92179427693SLoïc Minier  --static)
92279427693SLoïc Minier    static="yes"
92379427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
92417884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
92543ce4dfeSbellard  ;;
9260b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9270b24e75fSPaolo Bonzini  ;;
9280b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9290b24e75fSPaolo Bonzini  ;;
9303aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9313aa5d2beSAlon Levy  ;;
9328bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9338bf188aaSMichael Tokarev  ;;
9340f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9350f94d6daSAlon Levy  ;;
936528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9370b24e75fSPaolo Bonzini  ;;
938023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
939023d3d67SEduardo Habkost  ;;
940850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9410b24e75fSPaolo Bonzini  ;;
942ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
94307381cc1SAnthony Liguori  ;;
944785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
945785c23aeSLuiz Capitulino  ;;
9463d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9473d5eecabSGerd Hoffmann  ;;
948785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
949023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
950023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
951023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
952023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
953023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
954023ddd74SMax Filippov    # lots of directory switches by default.
955023ddd74SMax Filippov  ;;
95697a847bcSbellard  --disable-sdl) sdl="no"
95797a847bcSbellard  ;;
958c4198157SJuan Quintela  --enable-sdl) sdl="yes"
959c4198157SJuan Quintela  ;;
96047c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
96147c03744SDave Airlie  ;;
9623556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9633556c233SPaolo Bonzini  ;;
9643556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9653556c233SPaolo Bonzini  ;;
966983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
967983eef5aSMeador Inge  ;;
968983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
969983eef5aSMeador Inge  ;;
970fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
971fe8fc5aeSPaolo Bonzini  ;;
972fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
973fe8fc5aeSPaolo Bonzini  ;;
974821601eaSJes Sorensen  --disable-vnc) vnc="no"
975821601eaSJes Sorensen  ;;
976821601eaSJes Sorensen  --enable-vnc) vnc="yes"
977821601eaSJes Sorensen  ;;
9782f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
9792f6a1ab0Sblueswir1  ;;
9800c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9810c58ac1cSmalc  ;;
98289138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
983b64ec4e4SFam Zheng  ;;
98489138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
985eb852011SMarkus Armbruster  ;;
986f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
987f8393946Saurel32  ;;
988f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
989f8393946Saurel32  ;;
990f3d08ee6SPaul Brook  --enable-debug)
991f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
992f3d08ee6SPaul Brook      debug_tcg="yes"
993f3d08ee6SPaul Brook      debug="yes"
994f3d08ee6SPaul Brook      strip_opt="no"
995b553a042SJohn Snow      fortify_source="no"
996f3d08ee6SPaul Brook  ;;
99703b4fe7dSaliguori  --enable-sparse) sparse="yes"
99803b4fe7dSaliguori  ;;
99903b4fe7dSaliguori  --disable-sparse) sparse="no"
100003b4fe7dSaliguori  ;;
10011625af87Saliguori  --disable-strip) strip_opt="no"
10021625af87Saliguori  ;;
10032f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
10042f9606b3Saliguori  ;;
1005ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1006ea784e3bSJuan Quintela  ;;
10072f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
10082f6f5c7aSCorentin Chary  ;;
10092f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
10102f6f5c7aSCorentin Chary  ;;
1011efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1012efe556adSCorentin Chary  ;;
1013efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1014efe556adSCorentin Chary  ;;
1015443f1376Sbellard  --disable-slirp) slirp="no"
1016c20709aaSbellard  ;;
1017e0e6c8c0Saliguori  --disable-vde) vde="no"
10188a16d273Sths  ;;
1019dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1020dfb278bdSJuan Quintela  ;;
102158952137SVincenzo Maffione  --disable-netmap) netmap="no"
102258952137SVincenzo Maffione  ;;
102358952137SVincenzo Maffione  --enable-netmap) netmap="yes"
102458952137SVincenzo Maffione  ;;
1025e37630caSaliguori  --disable-xen) xen="no"
1026e37630caSaliguori  ;;
1027fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1028fc321b4bSJuan Quintela  ;;
1029eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1030eb6fda0fSAnthony PERARD  ;;
1031eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1032eb6fda0fSAnthony PERARD  ;;
103364a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
103464a7ad6fSIan Campbell  ;;
103564a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
103664a7ad6fSIan Campbell  ;;
10372e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10382e4d9fb1Saurel32  ;;
10394ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10404ffcedb6SJuan Quintela  ;;
1041fb599c9aSbalrog  --disable-bluez) bluez="no"
1042fb599c9aSbalrog  ;;
1043a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1044a20a6f46SJuan Quintela  ;;
10457ba1e619Saliguori  --disable-kvm) kvm="no"
10467ba1e619Saliguori  ;;
1047b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1048b31a0277SJuan Quintela  ;;
1049b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1050180fb750Szhanghailiang  ;;
1051b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1052180fb750Szhanghailiang  ;;
1053c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1054c97d6d2cSSergio Andres Gomez Del Real  ;;
1055c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1056c97d6d2cSSergio Andres Gomez Del Real  ;;
10579195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
10589195b2c2SStefan Weil  ;;
10599195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
10609195b2c2SStefan Weil  ;;
106147e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
106247e98658SCorey Bryant  ;;
106347e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
106447e98658SCorey Bryant  ;;
1065b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1066b3f6ea7eSPaolo Bonzini  ;;
1067b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1068b3f6ea7eSPaolo Bonzini  ;;
10695a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
10705a22ab71SYang Zhong  ;;
10715a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
10725a22ab71SYang Zhong  ;;
1073cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1074cd4ec0b4SGerd Hoffmann  ;;
1075cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1076cd4ec0b4SGerd Hoffmann  ;;
1077c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1078c589b249SRonnie Sahlberg  ;;
1079c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1080c589b249SRonnie Sahlberg  ;;
10816542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
10826542aa9cSPeter Lieven  ;;
10836542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
10846542aa9cSPeter Lieven  ;;
108505c2a3e7Sbellard  --enable-profiler) profiler="yes"
108605c2a3e7Sbellard  ;;
108714821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
108814821030SPavel Borzenkov  ;;
1089c2de5c91Smalc  --enable-cocoa)
1090c2de5c91Smalc      cocoa="yes" ;
109189138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
10925b0753e0Sbellard  ;;
1093cad25d69Spbrook  --disable-system) softmmu="no"
10940a8e90f4Spbrook  ;;
1095cad25d69Spbrook  --enable-system) softmmu="yes"
10960a8e90f4Spbrook  ;;
10970953a80fSZachary Amsden  --disable-user)
10980953a80fSZachary Amsden      linux_user="no" ;
10990953a80fSZachary Amsden      bsd_user="no" ;
11000953a80fSZachary Amsden  ;;
11010953a80fSZachary Amsden  --enable-user) ;;
1102831b7825Sths  --disable-linux-user) linux_user="no"
11030a8e90f4Spbrook  ;;
1104831b7825Sths  --enable-linux-user) linux_user="yes"
1105831b7825Sths  ;;
110684778508Sblueswir1  --disable-bsd-user) bsd_user="no"
110784778508Sblueswir1  ;;
110884778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
110984778508Sblueswir1  ;;
111040d6444eSAvi Kivity  --enable-pie) pie="yes"
111134005a00SKirill A. Shutemov  ;;
111240d6444eSAvi Kivity  --disable-pie) pie="no"
111334005a00SKirill A. Shutemov  ;;
111485aa5189Sbellard  --enable-werror) werror="yes"
111585aa5189Sbellard  ;;
111685aa5189Sbellard  --disable-werror) werror="no"
111785aa5189Sbellard  ;;
111863678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
111963678e17SSteven Noonan  ;;
112063678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
112163678e17SSteven Noonan  ;;
11224d3b6f6eSbalrog  --disable-curses) curses="no"
11234d3b6f6eSbalrog  ;;
1124c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1125c584a6d0SJuan Quintela  ;;
1126769ce76dSAlexander Graf  --disable-curl) curl="no"
1127769ce76dSAlexander Graf  ;;
1128788c8196SJuan Quintela  --enable-curl) curl="yes"
1129788c8196SJuan Quintela  ;;
11302df87df7SJuan Quintela  --disable-fdt) fdt="no"
11312df87df7SJuan Quintela  ;;
11322df87df7SJuan Quintela  --enable-fdt) fdt="yes"
11332df87df7SJuan Quintela  ;;
11345c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
11355c6c3a6cSChristoph Hellwig  ;;
11365c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
11375c6c3a6cSChristoph Hellwig  ;;
1138758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1139758e8e38SVenkateswararao Jujjuri (JV)  ;;
1140758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1141758e8e38SVenkateswararao Jujjuri (JV)  ;;
114277755340Sths  --disable-blobs) blobs="no"
114377755340Sths  ;;
11444a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
11454a19f1ecSpbrook  ;;
1146519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1147519175a2SAlex Barcelo  ;;
114870c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
114970c60c08SStefan Hajnoczi  ;;
115070c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
115170c60c08SStefan Hajnoczi  ;;
11527d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
11537d992e4dSPeter Lieven  ;;
1154f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1155f0d92b56SLongpeng(Mike)  ;;
1156f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1157f0d92b56SLongpeng(Mike)  ;;
1158a25dba17SJuan Quintela  --disable-docs) docs="no"
115970ec5dc0SAnthony Liguori  ;;
1160a25dba17SJuan Quintela  --enable-docs) docs="yes"
116183a3ab8bSJuan Quintela  ;;
1162d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1163d5970055SMichael S. Tsirkin  ;;
1164d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1165d5970055SMichael S. Tsirkin  ;;
11665e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
11675e9be92dSNicholas Bellinger  ;;
11685e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
11695e9be92dSNicholas Bellinger  ;;
1170fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1171fc0b9b0eSStefan Hajnoczi  ;;
1172fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1173fc0b9b0eSStefan Hajnoczi  ;;
1174da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
117520ff075bSMichael Walle  ;;
1176da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
117720ff075bSMichael Walle  ;;
1178f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1179f27aaf4bSChristian Brunner  ;;
1180f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1181f27aaf4bSChristian Brunner  ;;
11828c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
11838c84cf11SSergei Trofimovich  ;;
11848c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
11858c84cf11SSergei Trofimovich  ;;
11867b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1187111a38b0SRobert Relyea  ;;
11887b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1189111a38b0SRobert Relyea  ;;
11902b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
11912b2325ffSGerd Hoffmann  ;;
11922b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
11932b2325ffSGerd Hoffmann  ;;
119469354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
119569354a83SHans de Goede  ;;
119669354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
119769354a83SHans de Goede  ;;
11981ece9905SAlon Levy  --disable-zlib-test) zlib="no"
11991ece9905SAlon Levy  ;;
1200b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1201b25c9dffSStefan Weil  ;;
1202607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1203607dacd0Sqiaonuohan  ;;
1204b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1205b25c9dffSStefan Weil  ;;
1206607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1207607dacd0Sqiaonuohan  ;;
12086b383c08SPeter Wu  --disable-bzip2) bzip2="no"
12096b383c08SPeter Wu  ;;
12106b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
12116b383c08SPeter Wu  ;;
1212d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1213d138cee9SMichael Roth  ;;
1214d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1215d138cee9SMichael Roth  ;;
12169dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
12179dacf32dSYossi Hindin  ;;
12189dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
12199dacf32dSYossi Hindin  ;;
1220d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1221d9840e25STomoki Sekiyama  ;;
1222d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1223d9840e25STomoki Sekiyama  ;;
1224d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1225d9840e25STomoki Sekiyama  ;;
1226d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1227d9840e25STomoki Sekiyama  ;;
1228d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1229d9840e25STomoki Sekiyama  ;;
1230d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1231d9840e25STomoki Sekiyama  ;;
12324b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
12334b1c11fdSDaniel P. Berrange  ;;
12344b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
12354b1c11fdSDaniel P. Berrange  ;;
1236f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1237f794573eSEduardo Otubo  ;;
1238f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1239f794573eSEduardo Otubo  ;;
1240eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1241eb100396SBharata B Rao  ;;
1242eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1243eb100396SBharata B Rao  ;;
124452b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
124552b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1246583f6e7bSStefan Hajnoczi  ;;
1247cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1248cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1249cb6414dfSFam Zheng  ;;
1250315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1251315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1252315d3184SFam Zheng  ;;
1253a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1254a4ccabcfSAnthony Liguori  ;;
1255a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1256a4ccabcfSAnthony Liguori  ;;
1257a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1258a1c5e949SDaniel P. Berrange  ;;
1259ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1260ddbb0d09SDaniel P. Berrange  ;;
1261ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1262ddbb0d09SDaniel P. Berrange  ;;
126391bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
126491bfcdb0SDaniel P. Berrange  ;;
126591bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
126691bfcdb0SDaniel P. Berrange  ;;
126791bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
126891bfcdb0SDaniel P. Berrange  ;;
126991bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
127091bfcdb0SDaniel P. Berrange  ;;
12712da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
12722da776dbSMichael R. Hines  ;;
12732da776dbSMichael R. Hines  --disable-rdma) rdma="no"
12742da776dbSMichael R. Hines  ;;
1275528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1276528de90aSDaniel P. Berrange  ;;
1277bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1278bbbf9bfbSStefan Weil  ;;
1279bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1280bbbf9bfbSStefan Weil  ;;
12819d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
12829d9e1521SGerd Hoffmann  ;;
12839d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
12849d9e1521SGerd Hoffmann  ;;
1285e91c793cSCole Robinson  --disable-tpm) tpm="no"
1286e91c793cSCole Robinson  ;;
1287ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1288ab214c29SStefan Berger  ;;
12890a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
12900a12ec87SRichard W.M. Jones  ;;
12910a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
12920a12ec87SRichard W.M. Jones  ;;
1293ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1294ed1701c6SDr. David Alan Gilbert  ;;
1295ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1296ed1701c6SDr. David Alan Gilbert  ;;
1297a99d57bbSWanlong Gao  --disable-numa) numa="no"
1298a99d57bbSWanlong Gao  ;;
1299a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1300a99d57bbSWanlong Gao  ;;
13012847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
13022847b469SFam Zheng  ;;
13032847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
13042847b469SFam Zheng  ;;
13057b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
13067b01cb97SAlexandre Derumier  ;;
13077b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
13087b01cb97SAlexandre Derumier  ;;
1309a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1310a6b1d4c0SChanglong Xie  ;;
1311a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1312a6b1d4c0SChanglong Xie  ;;
1313da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1314da92c3ffSAshish Mittal  ;;
1315da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1316da92c3ffSAshish Mittal  ;;
1317e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1318e6a74868SMarc-André Lureau  ;;
1319e6a74868SMarc-André Lureau  --enable-vhost-user)
1320e6a74868SMarc-André Lureau      vhost_user="yes"
1321e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1322e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1323e6a74868SMarc-André Lureau      fi
1324e6a74868SMarc-André Lureau  ;;
13258ca80760SRichard Henderson  --disable-capstone) capstone="no"
13268ca80760SRichard Henderson  ;;
13278ca80760SRichard Henderson  --enable-capstone) capstone="yes"
13288ca80760SRichard Henderson  ;;
1329e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1330e219c499SRichard Henderson  ;;
1331e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1332e219c499SRichard Henderson  ;;
1333cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1334cc84d63aSDaniel P. Berrange  ;;
1335f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1336f62bbee5SDaniel P. Berrange  ;;
1337f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1338f62bbee5SDaniel P. Berrange  ;;
13392d2ad6d0SFam Zheng  *)
13402d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
13412d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
13422d2ad6d0SFam Zheng      exit 1
13437f1559c6Sbalrog  ;;
13447d13299dSbellard  esac
13457d13299dSbellarddone
13467d13299dSbellard
1347e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1348e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1349e6a74868SMarc-André Lureau        vhost_user="no"
1350e6a74868SMarc-André Lureau    else
1351e6a74868SMarc-André Lureau        vhost_user="yes"
1352e6a74868SMarc-André Lureau    fi
1353e6a74868SMarc-André Lureaufi
1354e6a74868SMarc-André Lureau
135540293e58Sbellardcase "$cpu" in
1356e3608d66SRichard Henderson    ppc)
1357e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1358e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1359e3608d66SRichard Henderson           ;;
1360e3608d66SRichard Henderson    ppc64)
1361e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1362e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1363e3608d66SRichard Henderson           ;;
13649b9c37c3SRichard Henderson    sparc)
1365f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1366f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
13673142255cSblueswir1           ;;
1368ed968ff1SJuan Quintela    sparc64)
136979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1370f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
13713142255cSblueswir1           ;;
137276d83bdeSths    s390)
1373061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
137428d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
137528d7cc49SRichard Henderson           ;;
137628d7cc49SRichard Henderson    s390x)
1377061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
137828d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
137976d83bdeSths           ;;
138040293e58Sbellard    i386)
138179f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
13820c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
13832b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
138440293e58Sbellard           ;;
138540293e58Sbellard    x86_64)
13867ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
13877ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
13887ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
13897ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
13900c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
13912b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1392379f6698SPaul Brook           ;;
1393c72b26ecSRichard Henderson    x32)
1394c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1395c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1396c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1397c72b26ecSRichard Henderson           ;;
139830163d89SPeter Maydell    # No special flags required for other host CPUs
13993142255cSblueswir1esac
14003142255cSblueswir1
140179f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
140279f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
140379f3b12fSPeter Crosthwaite
1404affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1405affc88ccSPeter Maydell# support, even if we're using TCI.
1406affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1407affc88ccSPeter Maydell  bsd_user="no"
1408affc88ccSPeter Maydell  linux_user="no"
1409affc88ccSPeter Maydellfi
1410affc88ccSPeter Maydell
141160e0df25SPeter Maydelldefault_target_list=""
141260e0df25SPeter Maydell
14136e92f823SPeter Maydellmak_wilds=""
14146e92f823SPeter Maydell
141560e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
14166e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
141760e0df25SPeter Maydellfi
141860e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
14196e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
142060e0df25SPeter Maydellfi
142160e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
14226e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
142360e0df25SPeter Maydellfi
142460e0df25SPeter Maydell
14256e92f823SPeter Maydellfor config in $mak_wilds; do
14266e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
14276e92f823SPeter Maydelldone
14286e92f823SPeter Maydell
1429c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
143064a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1431c53eeaf7SStefan Hajnoczi
1432af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1433af5db58eSpbrookcat << EOF
1434af5db58eSpbrook
1435af5db58eSpbrookUsage: configure [options]
1436af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1437af5db58eSpbrook
143808fb77edSStefan WeilStandard options:
143908fb77edSStefan Weil  --help                   print this message
144008fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
144108fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
144208fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
144308fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
144408fb77edSStefan Weil$(echo Available targets: $default_target_list | \
144508fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
144608fb77edSStefan Weil
144708fb77edSStefan WeilAdvanced options (experts only):
144808fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
144908fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
145008fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
145108fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
145208fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
145308fb77edSStefan Weil                           build time
145408fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
145508fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
145608fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
145711cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
145808fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
145908fb77edSStefan Weil  --make=MAKE              use specified make [$make]
146008fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
146108fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
146208fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
146308fb77edSStefan Weil  --static                 enable static build [$static]
146408fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
146508fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
146608fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
146708fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
146808fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
146908fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
147008fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
14713d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1472e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
147308fb77edSStefan Weil  --enable-debug           enable common debug build options
147408fb77edSStefan Weil  --disable-strip          disable stripping binaries
147508fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
147663678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
147708fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
147808fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
147908fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
148008fb77edSStefan Weil  --block-drv-rw-whitelist=L
148108fb77edSStefan Weil                           set block driver read-write whitelist
148208fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
148308fb77edSStefan Weil  --block-drv-ro-whitelist=L
148408fb77edSStefan Weil                           set block driver read-only whitelist
148508fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
14865b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1487c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
148808fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
148908fb77edSStefan Weil                           Default:trace-<pid>
1490c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1491c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
14925a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1493c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1494c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
149508fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
149633c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
149708fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
149808fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1499c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1500c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1501c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1502a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1503c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1504c12d66aaSLin Ma  --enable-profiler        profiler support
1505c12d66aaSLin Ma  --enable-xen-pv-domain-build
1506c12d66aaSLin Ma                           xen pv domain builder
1507c12d66aaSLin Ma  --enable-debug-stack-usage
1508c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1509c23f23b9SMichael Tokarev
1510c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1511c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1512c23f23b9SMichael Tokarev
1513c23f23b9SMichael Tokarev  system          all system emulation targets
1514c23f23b9SMichael Tokarev  user            supported user emulation targets
1515c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1516c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1517c23f23b9SMichael Tokarev  docs            build documentation
1518c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1519c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1520c23f23b9SMichael Tokarev  pie             Position Independent Executables
1521c23f23b9SMichael Tokarev  modules         modules support
1522c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1523c23f23b9SMichael Tokarev  debug-info      debugging information
1524c23f23b9SMichael Tokarev  sparse          sparse checker
1525c23f23b9SMichael Tokarev
1526ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
152791bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
152891bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1529c23f23b9SMichael Tokarev  sdl             SDL UI
1530c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1531c23f23b9SMichael Tokarev  gtk             gtk UI
1532c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1533c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1534c23f23b9SMichael Tokarev  curses          curses UI
1535c23f23b9SMichael Tokarev  vnc             VNC UI support
1536c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1537c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1538c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1539c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1540c23f23b9SMichael Tokarev  virtfs          VirtFS
1541fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1542c23f23b9SMichael Tokarev  xen             xen backend driver support
1543c23f23b9SMichael Tokarev  xen-pci-passthrough
1544c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1545c23f23b9SMichael Tokarev  curl            curl connectivity
1546c23f23b9SMichael Tokarev  fdt             fdt device tree
1547c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1548c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1549b0cb0a66SVincent Palatin  hax             HAX acceleration support
1550c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1551c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1552c23f23b9SMichael Tokarev  vde             support for vde network
1553c23f23b9SMichael Tokarev  netmap          support for netmap network
1554c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1555c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1556c23f23b9SMichael Tokarev  attr            attr and xattr support
1557c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1558c23f23b9SMichael Tokarev  spice           spice
1559c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1560c23f23b9SMichael Tokarev  libiscsi        iscsi support
1561c23f23b9SMichael Tokarev  libnfs          nfs support
15627b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1563c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1564ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1565c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1566c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1567c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1568c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1569c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1570c23f23b9SMichael Tokarev  seccomp         seccomp support
1571c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1572c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1573c23f23b9SMichael Tokarev  tpm             TPM support
1574c23f23b9SMichael Tokarev  libssh2         ssh block device support
1575c23f23b9SMichael Tokarev  numa            libnuma support
1576c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
15777b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1578a6b1d4c0SChanglong Xie  replication     replication support
1579c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1580c12d66aaSLin Ma  opengl          opengl support
1581c12d66aaSLin Ma  virglrenderer   virgl rendering support
1582c12d66aaSLin Ma  xfsctl          xfsctl support
1583c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1584c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1585da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1586f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1587e6a74868SMarc-André Lureau  vhost-user      vhost-user support
15888ca80760SRichard Henderson  capstone        capstone disassembler support
158908fb77edSStefan Weil
159008fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1591af5db58eSpbrookEOF
15922d2ad6d0SFam Zhengexit 0
1593af5db58eSpbrookfi
1594af5db58eSpbrook
1595c53eeaf7SStefan Hajnocziif ! has $python; then
1596c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1597c53eeaf7SStefan Hajnoczifi
1598c53eeaf7SStefan Hajnoczi
1599c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1600c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1601c53eeaf7SStefan Hajnocziif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1602c53eeaf7SStefan Hajnoczi  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1603c53eeaf7SStefan Hajnoczi      "Note that Python 3 or later is not yet supported." \
1604c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1605c53eeaf7SStefan Hajnoczifi
1606c53eeaf7SStefan Hajnoczi
1607c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1608c53eeaf7SStefan Hajnoczipython="$python -B"
1609c53eeaf7SStefan Hajnoczi
16109aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
16119aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
16129aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
16139aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
16149aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
16159aae6e54SDaniel Henrique Barbozaif compile_object ; then
16169aae6e54SDaniel Henrique Barboza  : C compiler works ok
16179aae6e54SDaniel Henrique Barbozaelse
16189aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
16199aae6e54SDaniel Henrique Barbozafi
16209aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
16219aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
16229aae6e54SDaniel Henrique Barbozafi
16239aae6e54SDaniel Henrique Barboza
1624359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1625359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1626359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1627359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1628359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1629359bc95dSPeter Maydell    else
163076ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1631359bc95dSPeter Maydell    fi
1632359bc95dSPeter Maydellfi
1633359bc95dSPeter Maydell
16349c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
16359c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
16369c83ffd8SPeter Maydellif test -z "$werror" ; then
16379c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1638e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
16399c83ffd8SPeter Maydell        werror="yes"
16409c83ffd8SPeter Maydell    else
16419c83ffd8SPeter Maydell        werror="no"
16429c83ffd8SPeter Maydell    fi
16439c83ffd8SPeter Maydellfi
16449c83ffd8SPeter Maydell
1645fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1646fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1647fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1648fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1649fb59dabdSPeter Maydell    # host OS we should stop now.
1650951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1651fb59dabdSPeter Maydellfi
1652fb59dabdSPeter Maydell
16538d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
16548d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1655ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1656435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1657b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
165871429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
16596ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
16606ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
16616ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
16626ca026cbSPeter Maydell# so it's too error prone.
166393b25869SJohn Snow
166493b25869SJohn Snowcc_has_warning_flag() {
166593b25869SJohn Snow    write_c_skeleton;
166693b25869SJohn Snow
1667a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1668a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1669a1d29d6cSPeter Maydell    # warning options).
167093b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
167193b25869SJohn Snow    compile_prog "-Werror $optflag" ""
167293b25869SJohn Snow}
167393b25869SJohn Snow
167493b25869SJohn Snowfor flag in $gcc_flags; do
167593b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16768d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16778d05095cSPaolo Bonzini    fi
16788d05095cSPaolo Bonzinidone
16798d05095cSPaolo Bonzini
168063678e17SSteven Noonanif test "$stack_protector" != "no"; then
1681fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1682fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1683fccd35a0SRodrigo Rebello{
1684fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1685fccd35a0SRodrigo Rebello    while (*c) {
1686fccd35a0SRodrigo Rebello        *p++ = *c++;
1687fccd35a0SRodrigo Rebello    }
1688fccd35a0SRodrigo Rebello    return 0;
1689fccd35a0SRodrigo Rebello}
1690fccd35a0SRodrigo RebelloEOF
169163678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16923b463a3fSMiroslav Rezanina  sp_on=0
169363678e17SSteven Noonan  for flag in $gcc_flags; do
1694590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1695590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1696590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1697590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
169863678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16993b463a3fSMiroslav Rezanina      sp_on=1
170063678e17SSteven Noonan      break
170163678e17SSteven Noonan    fi
170263678e17SSteven Noonan  done
17033b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
17043b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
17053b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
17063b463a3fSMiroslav Rezanina    fi
17073b463a3fSMiroslav Rezanina  fi
170837746c5eSMarc-André Lureaufi
170937746c5eSMarc-André Lureau
171020bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
171120bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
171220bc94a2SPaolo Bonzinicat > $TMPC << EOF
171320bc94a2SPaolo Bonzinistruct {
171420bc94a2SPaolo Bonzini  int a[2];
171520bc94a2SPaolo Bonzini} x = {0};
171620bc94a2SPaolo BonziniEOF
171720bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
171820bc94a2SPaolo Bonzini  :
171920bc94a2SPaolo Bonzinielse
172020bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
172120bc94a2SPaolo Bonzinifi
172220bc94a2SPaolo Bonzini
1723cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1724cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1725cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1726cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1727cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1728cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1729cbdd1999SPaolo Bonziniint main(void) { return 0; }
1730cbdd1999SPaolo Bonzini#else
1731cbdd1999SPaolo Bonzini#error No bug in this compiler.
1732cbdd1999SPaolo Bonzini#endif
1733cbdd1999SPaolo BonziniEOF
1734cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1735cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1736cbdd1999SPaolo Bonzinifi
1737cbdd1999SPaolo Bonzini
173840d6444eSAvi Kivityif test "$static" = "yes" ; then
1739aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1740aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1741aa0d1f44SPaolo Bonzini  fi
174240d6444eSAvi Kivity  if test "$pie" = "yes" ; then
174376ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
174440d6444eSAvi Kivity  else
174540d6444eSAvi Kivity    pie="no"
174640d6444eSAvi Kivity  fi
174740d6444eSAvi Kivityfi
174840d6444eSAvi Kivity
1749768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1750768b7855SEmilio G. Cota  cat > $TMPC << EOF
1751768b7855SEmilio G. Cotastatic __thread int tls_var;
1752768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1753768b7855SEmilio G. CotaEOF
1754768b7855SEmilio G. Cota
1755768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1756768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1757768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1758768b7855SEmilio G. Cotafi
1759768b7855SEmilio G. Cota
176040d6444eSAvi Kivityif test "$pie" = ""; then
176140d6444eSAvi Kivity  case "$cpu-$targetos" in
1762c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
176340d6444eSAvi Kivity      ;;
176440d6444eSAvi Kivity    *)
176540d6444eSAvi Kivity      pie="no"
176640d6444eSAvi Kivity      ;;
176740d6444eSAvi Kivity  esac
176840d6444eSAvi Kivityfi
176940d6444eSAvi Kivity
177040d6444eSAvi Kivityif test "$pie" != "no" ; then
177140d6444eSAvi Kivity  cat > $TMPC << EOF
177221d4a791SAvi Kivity
177321d4a791SAvi Kivity#ifdef __linux__
177421d4a791SAvi Kivity#  define THREAD __thread
177521d4a791SAvi Kivity#else
177621d4a791SAvi Kivity#  define THREAD
177721d4a791SAvi Kivity#endif
177821d4a791SAvi Kivity
177921d4a791SAvi Kivitystatic THREAD int tls_var;
178021d4a791SAvi Kivity
178121d4a791SAvi Kivityint main(void) { return tls_var; }
178221d4a791SAvi Kivity
178340d6444eSAvi KivityEOF
178440d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
178540d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
178640d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
178740d6444eSAvi Kivity    pie="yes"
178840d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
178940d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
179040d6444eSAvi Kivity    fi
179140d6444eSAvi Kivity  else
179240d6444eSAvi Kivity    if test "$pie" = "yes"; then
179376ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
179440d6444eSAvi Kivity    else
179540d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
179640d6444eSAvi Kivity      pie="no"
179740d6444eSAvi Kivity    fi
179840d6444eSAvi Kivity  fi
179946eef33bSBrad
1800e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
180146eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
180246eef33bSBrad    LDFLAGS_NOPIE="-nopie"
180346eef33bSBrad  fi
180440d6444eSAvi Kivityfi
180540d6444eSAvi Kivity
180609dada40SPaolo Bonzini##########################################
180709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
180809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
180909dada40SPaolo Bonzini# specification is necessary
181009dada40SPaolo Bonzini
181109dada40SPaolo Bonziniif test "$cpu" = "i386"; then
181209dada40SPaolo Bonzini  cat > $TMPC << EOF
181309dada40SPaolo Bonzinistatic int sfaa(int *ptr)
181409dada40SPaolo Bonzini{
181509dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
181609dada40SPaolo Bonzini}
181709dada40SPaolo Bonzini
181809dada40SPaolo Bonziniint main(void)
181909dada40SPaolo Bonzini{
182009dada40SPaolo Bonzini  int val = 42;
18211405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
182209dada40SPaolo Bonzini  sfaa(&val);
182309dada40SPaolo Bonzini  return val;
182409dada40SPaolo Bonzini}
182509dada40SPaolo BonziniEOF
182609dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
182709dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
182809dada40SPaolo Bonzini  fi
182909dada40SPaolo Bonzinifi
183009dada40SPaolo Bonzini
183109dada40SPaolo Bonzini#########################################
1832ec530c81Sbellard# Solaris specific configure tool chain decisions
183309dada40SPaolo Bonzini
1834ec530c81Sbellardif test "$solaris" = "yes" ; then
18356792aa11SLoïc Minier  if has $install; then
18366792aa11SLoïc Minier    :
18376792aa11SLoïc Minier  else
183876ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
183976ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
184076ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1841ec530c81Sbellard  fi
184289138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
184376ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
184476ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
184576ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1846ec530c81Sbellard  fi
18476792aa11SLoïc Minier  if has ar; then
18486792aa11SLoïc Minier    :
18496792aa11SLoïc Minier  else
1850ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
185176ad07a4SPeter Maydell      error_exit "No path includes ar" \
185276ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1853ec530c81Sbellard    fi
185476ad07a4SPeter Maydell    error_exit "No path includes ar"
1855ec530c81Sbellard  fi
1856ec530c81Sbellardfi
1857ec530c81Sbellard
1858afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1859d880a3baSPaolo Bonzini    for target in $default_target_list; do
1860d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1861d880a3baSPaolo Bonzini            target_list="$target_list $target"
1862d880a3baSPaolo Bonzini    done
1863d880a3baSPaolo Bonzini    target_list="${target_list# }"
1864121afa9eSAnthony Liguorielse
186589138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1866d880a3baSPaolo Bonzini    for target in $target_list; do
186725b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
186825b48338SPeter Maydell        # friendly error message than if we let it fall through.
186925b48338SPeter Maydell        case " $default_target_list " in
187025b48338SPeter Maydell            *" $target "*)
187125b48338SPeter Maydell                ;;
187225b48338SPeter Maydell            *)
187325b48338SPeter Maydell                error_exit "Unknown target name '$target'"
187425b48338SPeter Maydell                ;;
187525b48338SPeter Maydell        esac
1876d880a3baSPaolo Bonzini        supported_target $target || exit 1
187725b48338SPeter Maydell    done
1878d880a3baSPaolo Bonzinifi
187925b48338SPeter Maydell
1880f55fe278SPaolo Bonzini# see if system emulation was really requested
1881f55fe278SPaolo Bonzinicase " $target_list " in
1882f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1883f55fe278SPaolo Bonzini  ;;
1884f55fe278SPaolo Bonzini  *) softmmu=no
1885f55fe278SPaolo Bonzini  ;;
1886f55fe278SPaolo Bonziniesac
18875327cf48Sbellard
1888249247c9SJuan Quintelafeature_not_found() {
1889249247c9SJuan Quintela  feature=$1
189021684af0SStewart Smith  remedy=$2
1891249247c9SJuan Quintela
189276ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
189321684af0SStewart Smith      "configure was not able to find it." \
189421684af0SStewart Smith      "$remedy"
1895249247c9SJuan Quintela}
1896249247c9SJuan Quintela
18977d13299dSbellard# ---
18987d13299dSbellard# big/little endian test
18997d13299dSbellardcat > $TMPC << EOF
190061cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
190161cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
190261cc919fSMike Frysingerextern int foo(short *, short *);
190361cc919fSMike Frysingerint main(int argc, char *argv[]) {
190461cc919fSMike Frysinger    return foo(big_endian, little_endian);
19057d13299dSbellard}
19067d13299dSbellardEOF
19077d13299dSbellard
190861cc919fSMike Frysingerif compile_object ; then
190961cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
191061cc919fSMike Frysinger        bigendian="yes"
191161cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
191261cc919fSMike Frysinger        bigendian="no"
19137d13299dSbellard    else
19147d13299dSbellard        echo big/little test failed
19157d13299dSbellard    fi
19167d13299dSbellardelse
191761cc919fSMike Frysinger    echo big/little test failed
19187d13299dSbellardfi
19197d13299dSbellard
1920b0a47e79SJuan Quintela##########################################
1921a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1922a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1923a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1924a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1925a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1926a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1927a30878e7SPeter Maydell    fi
1928a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1929a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1930a30878e7SPeter Maydell    fi
1931a30878e7SPeter Maydell    gtk=no
1932a30878e7SPeter Maydell    sdl=no
1933a30878e7SPeter Maydellfi
1934a30878e7SPeter Maydell
19356b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
19366b39b063SEric Blakecat > $TMPC << EOF
19376b39b063SEric Blake#include <stdint.h>
19386b39b063SEric Blake#include <stdio.h>
19396b39b063SEric Blakeint main(int argc, char *argv[]) {
19406b39b063SEric Blake    return printf("%zu", SIZE_MAX);
19416b39b063SEric Blake}
19426b39b063SEric BlakeEOF
19436b39b063SEric Blakehave_broken_size_max=no
19446b39b063SEric Blakeif ! compile_object -Werror ; then
19456b39b063SEric Blake    have_broken_size_max=yes
19466b39b063SEric Blakefi
19476b39b063SEric Blake
1948a30878e7SPeter Maydell##########################################
1949015a33bdSGonglei# L2TPV3 probe
1950015a33bdSGonglei
1951015a33bdSGongleicat > $TMPC <<EOF
1952015a33bdSGonglei#include <sys/socket.h>
1953bff6cb72SMichael Tokarev#include <linux/ip.h>
1954015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1955015a33bdSGongleiEOF
1956015a33bdSGongleiif compile_prog "" "" ; then
1957015a33bdSGonglei  l2tpv3=yes
1958015a33bdSGongleielse
1959015a33bdSGonglei  l2tpv3=no
1960015a33bdSGongleifi
1961015a33bdSGonglei
1962015a33bdSGonglei##########################################
19634d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
19644d9310f4SDaniel P. Berrange
19654d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
19664d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
19674d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
19684d9310f4SDaniel P. Berrange    #
19694d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
19704d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
19714d9310f4SDaniel P. Berrange    #
19724d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
19734d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
19744d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
19754d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
19764d9310f4SDaniel P. Berrange    # that for you.
19774d9310f4SDaniel P. Berrange    #
19784d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
19794d9310f4SDaniel P. Berrange    # are not in fact redundant.
19804d9310f4SDaniel P. Berrangecat > $TMPC << EOF
19814d9310f4SDaniel P. Berrange#include <unistd.h>
19824d9310f4SDaniel P. Berrange#include <time.h>
19834d9310f4SDaniel P. Berrange#undef localtime_r
19844d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
19854d9310f4SDaniel P. BerrangeEOF
19864d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
19874d9310f4SDaniel P. Berrange        localtime_r="yes"
19884d9310f4SDaniel P. Berrange    else
19894d9310f4SDaniel P. Berrange        localtime_r="no"
19904d9310f4SDaniel P. Berrange    fi
19914d9310f4SDaniel P. Berrangefi
19924d9310f4SDaniel P. Berrange
19934d9310f4SDaniel P. Berrange##########################################
1994779ab5e3SStefan Weil# pkg-config probe
1995779ab5e3SStefan Weil
1996779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
199776ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1998779ab5e3SStefan Weilfi
1999779ab5e3SStefan Weil
2000779ab5e3SStefan Weil##########################################
2001b0a47e79SJuan Quintela# NPTL probe
2002b0a47e79SJuan Quintela
200324cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2004bd0c5661Spbrook  cat > $TMPC <<EOF
2005bd0c5661Spbrook#include <sched.h>
200630813ceaSpbrook#include <linux/futex.h>
2007182eacc0SStefan Weilint main(void) {
2008bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2009bd0c5661Spbrook#error bork
2010bd0c5661Spbrook#endif
2011182eacc0SStefan Weil  return 0;
2012bd0c5661Spbrook}
2013bd0c5661SpbrookEOF
201424cb36a6SPeter Maydell  if ! compile_object ; then
201521684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2016b0a47e79SJuan Quintela  fi
2017bd0c5661Spbrookfi
2018bd0c5661Spbrook
201999f2dbd3SLiang Li#########################################
2020ac62922eSbalrog# zlib check
2021ac62922eSbalrog
20221ece9905SAlon Levyif test "$zlib" != "no" ; then
2023ac62922eSbalrog    cat > $TMPC << EOF
2024ac62922eSbalrog#include <zlib.h>
2025ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
2026ac62922eSbalrogEOF
202752166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
2028ac62922eSbalrog        :
2029ac62922eSbalrog    else
203076ad07a4SPeter Maydell        error_exit "zlib check failed" \
203176ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
2032ac62922eSbalrog    fi
20331ece9905SAlon Levyfi
2034eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
2035ac62922eSbalrog
2036ac62922eSbalrog##########################################
2037607dacd0Sqiaonuohan# lzo check
2038607dacd0Sqiaonuohan
2039607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2040607dacd0Sqiaonuohan    cat > $TMPC << EOF
2041607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2042607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2043607dacd0SqiaonuohanEOF
2044607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2045607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2046b25c9dffSStefan Weil        lzo="yes"
2047b25c9dffSStefan Weil    else
2048b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2049b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2050b25c9dffSStefan Weil        fi
2051b25c9dffSStefan Weil        lzo="no"
2052b25c9dffSStefan Weil    fi
2053607dacd0Sqiaonuohanfi
2054607dacd0Sqiaonuohan
2055607dacd0Sqiaonuohan##########################################
2056607dacd0Sqiaonuohan# snappy check
2057607dacd0Sqiaonuohan
2058607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2059607dacd0Sqiaonuohan    cat > $TMPC << EOF
2060607dacd0Sqiaonuohan#include <snappy-c.h>
2061607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2062607dacd0SqiaonuohanEOF
2063607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2064607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2065b25c9dffSStefan Weil        snappy="yes"
2066b25c9dffSStefan Weil    else
2067b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2068b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2069b25c9dffSStefan Weil        fi
2070b25c9dffSStefan Weil        snappy="no"
2071b25c9dffSStefan Weil    fi
2072607dacd0Sqiaonuohanfi
2073607dacd0Sqiaonuohan
2074607dacd0Sqiaonuohan##########################################
20756b383c08SPeter Wu# bzip2 check
20766b383c08SPeter Wu
20776b383c08SPeter Wuif test "$bzip2" != "no" ; then
20786b383c08SPeter Wu    cat > $TMPC << EOF
20796b383c08SPeter Wu#include <bzlib.h>
20806b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
20816b383c08SPeter WuEOF
20826b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
20836b383c08SPeter Wu        bzip2="yes"
20846b383c08SPeter Wu    else
20856b383c08SPeter Wu        if test "$bzip2" = "yes"; then
20866b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
20876b383c08SPeter Wu        fi
20886b383c08SPeter Wu        bzip2="no"
20896b383c08SPeter Wu    fi
20906b383c08SPeter Wufi
20916b383c08SPeter Wu
20926b383c08SPeter Wu##########################################
2093f794573eSEduardo Otubo# libseccomp check
2094f794573eSEduardo Otubo
2095f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2096693e5910SAndrew Jones    case "$cpu" in
2097693e5910SAndrew Jones    i386|x86_64)
2098ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2099693e5910SAndrew Jones        ;;
21005ce43972SJames Hogan    mips)
21015ce43972SJames Hogan        libseccomp_minver="2.2.0"
21025ce43972SJames Hogan        ;;
2103693e5910SAndrew Jones    arm|aarch64)
2104693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2105693e5910SAndrew Jones        ;;
21063aa35fcfSThomas Huth    ppc|ppc64|s390x)
21073e684455SMichael Strosaker        libseccomp_minver="2.3.0"
21083e684455SMichael Strosaker        ;;
2109693e5910SAndrew Jones    *)
2110693e5910SAndrew Jones        libseccomp_minver=""
2111693e5910SAndrew Jones        ;;
2112693e5910SAndrew Jones    esac
2113693e5910SAndrew Jones
2114693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2115693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2116c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2117c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2118f794573eSEduardo Otubo        seccomp="yes"
2119f794573eSEduardo Otubo    else
2120f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2121693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2122693e5910SAndrew Jones                feature_not_found "libseccomp" \
2123693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2124693e5910SAndrew Jones            else
2125693e5910SAndrew Jones                feature_not_found "libseccomp" \
2126693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2127693e5910SAndrew Jones            fi
2128896848f0SEduardo Otubo        fi
2129e84d5956SYann E. MORIN        seccomp="no"
2130f794573eSEduardo Otubo    fi
2131f794573eSEduardo Otubofi
2132f794573eSEduardo Otubo##########################################
2133e37630caSaliguori# xen probe
2134e37630caSaliguori
2135fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2136c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2137c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2138c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2139c1cdd9d5SJuergen Gross
2140c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2141c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2142c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2143c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2144c1cdd9d5SJuergen Gross    xen=yes
2145c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2146c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
2147c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2148c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2149c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2150c1cdd9d5SJuergen Gross  else
2151c1cdd9d5SJuergen Gross
2152b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2153d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2154d5b93ddfSAnthony PERARD
215550ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
215650ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
215750ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
215850ced5b3SStefan Weil
215950ced5b3SStefan Weil    # Xen (any)
216050ced5b3SStefan Weil    cat > $TMPC <<EOF
216150ced5b3SStefan Weil#include <xenctrl.h>
216250ced5b3SStefan Weilint main(void) {
216350ced5b3SStefan Weil  return 0;
216450ced5b3SStefan Weil}
216550ced5b3SStefan WeilEOF
216650ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
216750ced5b3SStefan Weil      # Xen not found
216850ced5b3SStefan Weil      if test "$xen" = "yes" ; then
216921684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
217050ced5b3SStefan Weil      fi
217150ced5b3SStefan Weil      xen=no
217250ced5b3SStefan Weil
2173d5b93ddfSAnthony PERARD    # Xen unstable
217469deef08SPeter Maydell    elif
217569deef08SPeter Maydell        cat > $TMPC <<EOF &&
21765ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21775ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
21785ba3d756SIgor Druzhininint main(void) {
21795ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
21805ba3d756SIgor Druzhinin
21815ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
21825ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
21835ba3d756SIgor Druzhinin
21845ba3d756SIgor Druzhinin  return 0;
21855ba3d756SIgor Druzhinin}
21865ba3d756SIgor DruzhininEOF
21875ba3d756SIgor Druzhinin        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
21885ba3d756SIgor Druzhinin      then
21895ba3d756SIgor Druzhinin      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
21905ba3d756SIgor Druzhinin      xen_ctrl_version=41000
21915ba3d756SIgor Druzhinin      xen=yes
21925ba3d756SIgor Druzhinin    elif
21935ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2194da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2195da8090ccSPaul Durrant#define __XEN_TOOLS__
2196da8090ccSPaul Durrant#include <xendevicemodel.h>
2197da8090ccSPaul Durrantint main(void) {
2198da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2199da8090ccSPaul Durrant
2200da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2201da8090ccSPaul Durrant  xendevicemodel_close(xd);
2202da8090ccSPaul Durrant
2203da8090ccSPaul Durrant  return 0;
2204da8090ccSPaul Durrant}
2205da8090ccSPaul DurrantEOF
2206da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2207da8090ccSPaul Durrant      then
2208da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2209f1167ee6SJuergen Gross      xen_ctrl_version=40900
2210da8090ccSPaul Durrant      xen=yes
2211da8090ccSPaul Durrant    elif
2212da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
22135eeb39c2SIan Campbell/*
22145eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
22155eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2216b6eb9b45SPaulina Szubarczyk *
2217b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2218b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2219b6eb9b45SPaulina Szubarczyk */
2220b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2221b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2222b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2223b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2224b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2225b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2226b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2227b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2228b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2229b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2230b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2231b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2232b6eb9b45SPaulina Szubarczyk#endif
2233b6eb9b45SPaulina Szubarczykint main(void) {
2234b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2235b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2236b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2237b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2238b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2239b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2240b6eb9b45SPaulina Szubarczyk
2241b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2242b6eb9b45SPaulina Szubarczyk
2243b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2244b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2245b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2246b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2247b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2248b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2249b6eb9b45SPaulina Szubarczyk
2250b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2251b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2252b6eb9b45SPaulina Szubarczyk
2253b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2254b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2255b6eb9b45SPaulina Szubarczyk
2256b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2257b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2258b6eb9b45SPaulina Szubarczyk
2259b6eb9b45SPaulina Szubarczyk  return 0;
2260b6eb9b45SPaulina Szubarczyk}
2261b6eb9b45SPaulina SzubarczykEOF
2262b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2263b6eb9b45SPaulina Szubarczyk      then
2264f1167ee6SJuergen Gross      xen_ctrl_version=40800
2265b6eb9b45SPaulina Szubarczyk      xen=yes
2266b6eb9b45SPaulina Szubarczyk    elif
2267b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2268b6eb9b45SPaulina Szubarczyk/*
2269b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2270b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
22715eeb39c2SIan Campbell */
22725eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
22735eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
22745eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
22755eeb39c2SIan Campbell#include <xenctrl.h>
22765eeb39c2SIan Campbell#include <xenstore.h>
22775eeb39c2SIan Campbell#include <xenevtchn.h>
22785eeb39c2SIan Campbell#include <xengnttab.h>
22795eeb39c2SIan Campbell#include <xenforeignmemory.h>
22805eeb39c2SIan Campbell#include <stdint.h>
22815eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
22825eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
22835eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
22845eeb39c2SIan Campbell#endif
22855eeb39c2SIan Campbellint main(void) {
22865eeb39c2SIan Campbell  xc_interface *xc = NULL;
22875eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
22885eeb39c2SIan Campbell  xenevtchn_handle *xe;
22895eeb39c2SIan Campbell  xengnttab_handle *xg;
22905eeb39c2SIan Campbell  xen_domain_handle_t handle;
22915eeb39c2SIan Campbell
22925eeb39c2SIan Campbell  xs_daemon_open();
22935eeb39c2SIan Campbell
22945eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
22955eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
22965eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22975eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22985eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
22995eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
23005eeb39c2SIan Campbell
23015eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
23025eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
23035eeb39c2SIan Campbell
23045eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
23055eeb39c2SIan Campbell  xenevtchn_fd(xe);
23065eeb39c2SIan Campbell
23075eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
23085eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
23095eeb39c2SIan Campbell
23105eeb39c2SIan Campbell  return 0;
23115eeb39c2SIan Campbell}
23125eeb39c2SIan CampbellEOF
23135eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
23145eeb39c2SIan Campbell      then
2315f1167ee6SJuergen Gross      xen_ctrl_version=40701
23165eeb39c2SIan Campbell      xen=yes
23175eeb39c2SIan Campbell    elif
23185eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2319e37630caSaliguori#include <xenctrl.h>
2320cdadde39SRoger Pau Monne#include <stdint.h>
2321cdadde39SRoger Pau Monneint main(void) {
2322cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2323cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2324cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2325cdadde39SRoger Pau Monne  return 0;
2326cdadde39SRoger Pau Monne}
2327cdadde39SRoger Pau MonneEOF
2328cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2329cdadde39SRoger Pau Monne      then
2330f1167ee6SJuergen Gross      xen_ctrl_version=40700
2331cdadde39SRoger Pau Monne      xen=yes
2332cdadde39SRoger Pau Monne
2333cdadde39SRoger Pau Monne    # Xen 4.6
2334cdadde39SRoger Pau Monne    elif
2335cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2336cdadde39SRoger Pau Monne#include <xenctrl.h>
2337e108a3c1SAnthony PERARD#include <xenstore.h>
2338d5b93ddfSAnthony PERARD#include <stdint.h>
2339d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2340d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2341d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2342d5b93ddfSAnthony PERARD#endif
2343d5b93ddfSAnthony PERARDint main(void) {
2344d5b93ddfSAnthony PERARD  xc_interface *xc;
2345d5b93ddfSAnthony PERARD  xs_daemon_open();
2346d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2347d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2348d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2349b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23508688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2351d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
235220a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2353d8b441a3SJan Beulich  return 0;
2354d8b441a3SJan Beulich}
2355d8b441a3SJan BeulichEOF
2356d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2357d8b441a3SJan Beulich      then
2358f1167ee6SJuergen Gross      xen_ctrl_version=40600
2359d8b441a3SJan Beulich      xen=yes
2360d8b441a3SJan Beulich
2361d8b441a3SJan Beulich    # Xen 4.5
2362d8b441a3SJan Beulich    elif
2363d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2364d8b441a3SJan Beulich#include <xenctrl.h>
2365d8b441a3SJan Beulich#include <xenstore.h>
2366d8b441a3SJan Beulich#include <stdint.h>
2367d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2368d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2369d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2370d8b441a3SJan Beulich#endif
2371d8b441a3SJan Beulichint main(void) {
2372d8b441a3SJan Beulich  xc_interface *xc;
2373d8b441a3SJan Beulich  xs_daemon_open();
2374d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2375d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2376d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2377d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2378d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23793996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
23803996e85cSPaul Durrant  return 0;
23813996e85cSPaul Durrant}
23823996e85cSPaul DurrantEOF
23833996e85cSPaul Durrant        compile_prog "" "$xen_libs"
23843996e85cSPaul Durrant      then
2385f1167ee6SJuergen Gross      xen_ctrl_version=40500
23863996e85cSPaul Durrant      xen=yes
23873996e85cSPaul Durrant
23883996e85cSPaul Durrant    elif
23893996e85cSPaul Durrant        cat > $TMPC <<EOF &&
23903996e85cSPaul Durrant#include <xenctrl.h>
23913996e85cSPaul Durrant#include <xenstore.h>
23923996e85cSPaul Durrant#include <stdint.h>
23933996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
23943996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
23953996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
23963996e85cSPaul Durrant#endif
23973996e85cSPaul Durrantint main(void) {
23983996e85cSPaul Durrant  xc_interface *xc;
23993996e85cSPaul Durrant  xs_daemon_open();
24003996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
24013996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
24023996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
24033996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
24043996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
24058688e065SStefano Stabellini  return 0;
24068688e065SStefano Stabellini}
24078688e065SStefano StabelliniEOF
24088688e065SStefano Stabellini        compile_prog "" "$xen_libs"
240969deef08SPeter Maydell      then
2410f1167ee6SJuergen Gross      xen_ctrl_version=40200
24118688e065SStefano Stabellini      xen=yes
24128688e065SStefano Stabellini
2413e37630caSaliguori    else
2414fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2415edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2416edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2417fc321b4bSJuan Quintela      fi
2418fc321b4bSJuan Quintela      xen=no
2419e37630caSaliguori    fi
2420d5b93ddfSAnthony PERARD
2421d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2422f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
24235eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
24245eeb39c2SIan Campbell      fi
2425d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2426d5b93ddfSAnthony PERARD    fi
2427e37630caSaliguori  fi
2428c1cdd9d5SJuergen Grossfi
2429e37630caSaliguori
2430eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2431edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2432eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2433eb6fda0fSAnthony PERARD  else
2434eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
243576ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
243676ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2437eb6fda0fSAnthony PERARD    fi
2438eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2439eb6fda0fSAnthony PERARD  fi
2440eb6fda0fSAnthony PERARDfi
2441eb6fda0fSAnthony PERARD
244264a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
244364a7ad6fSIan Campbell   test "$xen" != "yes"; then
244464a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
244564a7ad6fSIan Campbell	       "which requires Xen support."
244664a7ad6fSIan Campbellfi
244764a7ad6fSIan Campbell
2448e37630caSaliguori##########################################
2449dfffc653SJuan Quintela# Sparse probe
2450dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
24510dba6195SLoïc Minier  if has cgcc; then
2452dfffc653SJuan Quintela    sparse=yes
2453dfffc653SJuan Quintela  else
2454dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
245521684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2456dfffc653SJuan Quintela    fi
2457dfffc653SJuan Quintela    sparse=no
2458dfffc653SJuan Quintela  fi
2459dfffc653SJuan Quintelafi
2460dfffc653SJuan Quintela
2461dfffc653SJuan Quintela##########################################
2462f676c67eSJeremy White# X11 probe
2463f676c67eSJeremy Whitex11_cflags=
2464f676c67eSJeremy Whitex11_libs=-lX11
2465f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
246689138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
246789138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2468f676c67eSJeremy Whitefi
2469f676c67eSJeremy White
2470f676c67eSJeremy White##########################################
2471a4ccabcfSAnthony Liguori# GTK probe
2472a4ccabcfSAnthony Liguori
24739e04c683SStefan Weilif test "$gtkabi" = ""; then
24745fe309ffSGerd Hoffmann    # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
24755fe309ffSGerd Hoffmann    # Use 2.0 as a fallback if that is available.
24765fe309ffSGerd Hoffmann    if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
24779e04c683SStefan Weil        gtkabi=3.0
24785fe309ffSGerd Hoffmann    elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
24799e04c683SStefan Weil        gtkabi=2.0
24805fe309ffSGerd Hoffmann    else
24815fe309ffSGerd Hoffmann        gtkabi=3.0
24829e04c683SStefan Weil    fi
24839e04c683SStefan Weilfi
24849e04c683SStefan Weil
2485a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2486528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
24870a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2488528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2489528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2490bbbf9bfbSStefan Weil    else
2491bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2492bbbf9bfbSStefan Weil    fi
2493bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
249489138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
249589138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
249689138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
24970a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2498f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2499f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
25000a337ed0SGerd Hoffmann        fi
2501bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2502bbbf9bfbSStefan Weil        gtk="yes"
2503bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
25045fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2505bbbf9bfbSStefan Weil    else
2506bbbf9bfbSStefan Weil        gtk="no"
2507bbbf9bfbSStefan Weil    fi
2508bbbf9bfbSStefan Weilfi
2509bbbf9bfbSStefan Weil
2510ddbb0d09SDaniel P. Berrange
2511ddbb0d09SDaniel P. Berrange##########################################
2512ddbb0d09SDaniel P. Berrange# GNUTLS probe
2513ddbb0d09SDaniel P. Berrange
251437371299SPeter Maydellgnutls_works() {
251537371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
251637371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
251737371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
251837371299SPeter Maydell    # builds doesn't work:
251937371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
252037371299SPeter Maydell    #
252137371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
252237371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
252337371299SPeter Maydell        return 1
252437371299SPeter Maydell    fi
252537371299SPeter Maydell
252637371299SPeter Maydell    write_c_skeleton
252737371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
252837371299SPeter Maydell}
252937371299SPeter Maydell
253062893b67SDaniel P. Berrangegnutls_gcrypt=no
2531ed754746SDaniel P. Berrangegnutls_nettle=no
2532ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
253337371299SPeter Maydell    if gnutls_works; then
253489138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
253589138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2536ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2537ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2538ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2539ddbb0d09SDaniel P. Berrange        gnutls="yes"
2540ddbb0d09SDaniel P. Berrange
2541b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2542b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2543b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2544b917da4cSDaniel P. Berrange	else
2545b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2546b917da4cSDaniel P. Berrange	fi
2547b917da4cSDaniel P. Berrange
254862893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
254962893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2550ed754746SDaniel P. Berrange	    gnutls_nettle=yes
255162893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
255289138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2553ed754746SDaniel P. Berrange		*gcrypt*)
2554ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2555ed754746SDaniel P. Berrange		    gnutls_nettle=no
2556ed754746SDaniel P. Berrange		    ;;
2557ed754746SDaniel P. Berrange		*nettle*)
2558ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2559ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2560ed754746SDaniel P. Berrange		    ;;
2561ed754746SDaniel P. Berrange		*)
2562ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2563ed754746SDaniel P. Berrange		    gnutls_nettle=no
2564ed754746SDaniel P. Berrange		    ;;
256562893b67SDaniel P. Berrange	    esac
256662893b67SDaniel P. Berrange	else
256762893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2568ed754746SDaniel P. Berrange	    gnutls_nettle=no
256962893b67SDaniel P. Berrange	fi
2570ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2571ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2572ddbb0d09SDaniel P. Berrange    else
2573ddbb0d09SDaniel P. Berrange        gnutls="no"
2574b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2575ddbb0d09SDaniel P. Berrange    fi
2576ddbb0d09SDaniel P. Berrangeelse
2577b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2578ddbb0d09SDaniel P. Berrangefi
2579ddbb0d09SDaniel P. Berrange
258091bfcdb0SDaniel P. Berrange
258191bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
258291bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
258391bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
258491bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
258591bfcdb0SDaniel P. Berrangethen
258691bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
258791bfcdb0SDaniel P. Berrange    then
258891bfcdb0SDaniel P. Berrange        gcrypt="no"
258991bfcdb0SDaniel P. Berrange    fi
259091bfcdb0SDaniel P. Berrangefi
259191bfcdb0SDaniel P. Berrange
259291bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
259391bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
259491bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
259591bfcdb0SDaniel P. Berrangeif test -z "$nettle"
259691bfcdb0SDaniel P. Berrangethen
259791bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
259891bfcdb0SDaniel P. Berrange    then
259991bfcdb0SDaniel P. Berrange        nettle="no"
260091bfcdb0SDaniel P. Berrange    fi
260191bfcdb0SDaniel P. Berrangefi
260291bfcdb0SDaniel P. Berrange
260391bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
260491bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
260591bfcdb0SDaniel P. Berrange    then
260691bfcdb0SDaniel P. Berrange	return 1
260791bfcdb0SDaniel P. Berrange    fi
260891bfcdb0SDaniel P. Berrange
260991bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
261091bfcdb0SDaniel P. Berrange    then
261189138857SStefan Weil	host=$(libgcrypt-config --host)
261291bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
261391bfcdb0SDaniel P. Berrange	then
261491bfcdb0SDaniel P. Berrange	    return 1
261591bfcdb0SDaniel P. Berrange	fi
261691bfcdb0SDaniel P. Berrange    fi
261791bfcdb0SDaniel P. Berrange
261891bfcdb0SDaniel P. Berrange    return 0
261991bfcdb0SDaniel P. Berrange}
262091bfcdb0SDaniel P. Berrange
262191bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
262291bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
262389138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
262489138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
262591bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
262691bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
262791bfcdb0SDaniel P. Berrange        # turn breaks static builds...
262891bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
262991bfcdb0SDaniel P. Berrange        then
263091bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
263191bfcdb0SDaniel P. Berrange        fi
263262893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
263362893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
263462893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
263591bfcdb0SDaniel P. Berrange        gcrypt="yes"
263691bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
263791bfcdb0SDaniel P. Berrange           nettle="no"
263891bfcdb0SDaniel P. Berrange        fi
263937788f25SDaniel P. Berrange
264037788f25SDaniel P. Berrange        cat > $TMPC << EOF
264137788f25SDaniel P. Berrange#include <gcrypt.h>
264237788f25SDaniel P. Berrangeint main(void) {
264337788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
264437788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
264537788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
264637788f25SDaniel P. Berrange return 0;
264737788f25SDaniel P. Berrange}
264837788f25SDaniel P. BerrangeEOF
264937788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
265037788f25SDaniel P. Berrange            gcrypt_kdf=yes
265137788f25SDaniel P. Berrange        fi
26521f923c70SLongpeng(Mike)
26531f923c70SLongpeng(Mike)        cat > $TMPC << EOF
26541f923c70SLongpeng(Mike)#include <gcrypt.h>
26551f923c70SLongpeng(Mike)int main(void) {
26561f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
26571f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
26581f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
26591f923c70SLongpeng(Mike)  return 0;
26601f923c70SLongpeng(Mike)}
26611f923c70SLongpeng(Mike)EOF
26621f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
26631f923c70SLongpeng(Mike)            gcrypt_hmac=yes
26641f923c70SLongpeng(Mike)        fi
266562893b67SDaniel P. Berrange    else
266691bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
266762893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
266891bfcdb0SDaniel P. Berrange        else
266991bfcdb0SDaniel P. Berrange            gcrypt="no"
267091bfcdb0SDaniel P. Berrange        fi
267162893b67SDaniel P. Berrange    fi
267262893b67SDaniel P. Berrangefi
267362893b67SDaniel P. Berrange
2674ddbb0d09SDaniel P. Berrange
267591bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2676ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
267789138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
267889138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
267989138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2680ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2681ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2682ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
268391bfcdb0SDaniel P. Berrange        nettle="yes"
2684fff2f982SDaniel P. Berrange
2685fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
26869e87a691SSteven Luo#include <stddef.h>
2687fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2688fff2f982SDaniel P. Berrangeint main(void) {
2689fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2690fff2f982SDaniel P. Berrange     return 0;
2691fff2f982SDaniel P. Berrange}
2692fff2f982SDaniel P. BerrangeEOF
2693fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2694fff2f982SDaniel P. Berrange            nettle_kdf=yes
2695fff2f982SDaniel P. Berrange        fi
2696ed754746SDaniel P. Berrange    else
269791bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2698ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
269991bfcdb0SDaniel P. Berrange        else
270091bfcdb0SDaniel P. Berrange            nettle="no"
2701ed754746SDaniel P. Berrange        fi
2702ed754746SDaniel P. Berrange    fi
270391bfcdb0SDaniel P. Berrangefi
270491bfcdb0SDaniel P. Berrange
270591bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
270691bfcdb0SDaniel P. Berrangethen
270791bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
270891bfcdb0SDaniel P. Berrangefi
2709ed754746SDaniel P. Berrange
27109a2fd434SDaniel P. Berrange##########################################
27119a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
27129a2fd434SDaniel P. Berrange
27139a2fd434SDaniel P. Berrangetasn1=yes
271490246037SDaniel P. Berrangetasn1_cflags=""
271590246037SDaniel P. Berrangetasn1_libs=""
27169a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
271789138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
271889138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
27199a2fd434SDaniel P. Berrangeelse
27209a2fd434SDaniel P. Berrange    tasn1=no
27219a2fd434SDaniel P. Berrangefi
27229a2fd434SDaniel P. Berrange
2723ed754746SDaniel P. Berrange
2724bbbf9bfbSStefan Weil##########################################
2725559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2726559607eaSDaniel P. Berrange
2727559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2728559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2729559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2730559607eaSDaniel P. Berrangefi
2731559607eaSDaniel P. Berrange
2732559607eaSDaniel P. Berrange##########################################
2733bbbf9bfbSStefan Weil# VTE probe
2734bbbf9bfbSStefan Weil
2735bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2736bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2737c6feff9eSCole Robinson      vteminversion="0.32.0"
2738c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2739c6feff9eSCole Robinson        vtepackage="vte-2.91"
2740c6feff9eSCole Robinson      else
2741528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2742c6feff9eSCole Robinson      fi
2743528de90aSDaniel P. Berrange    else
2744528de90aSDaniel P. Berrange      vtepackage="vte"
2745c6feff9eSCole Robinson      vteminversion="0.24.0"
2746528de90aSDaniel P. Berrange    fi
2747c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
274889138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
274989138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
275089138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2751bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2752bbbf9bfbSStefan Weil        vte="yes"
2753bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
27549e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2755c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
27569e04c683SStefan Weil        else
27579e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
27589e04c683SStefan Weil        fi
2759bbbf9bfbSStefan Weil    else
2760bbbf9bfbSStefan Weil        vte="no"
2761a4ccabcfSAnthony Liguori    fi
2762a4ccabcfSAnthony Liguorifi
2763a4ccabcfSAnthony Liguori
2764a4ccabcfSAnthony Liguori##########################################
276511d9f695Sbellard# SDL probe
276611d9f695Sbellard
27673ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
27683ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
276947c03744SDave Airlie
2770ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
27718f4ea9cdSGerd Hoffmann    if $pkg_config --exists "sdl2"; then
2772ee8466d0SCole Robinson        sdlabi=2.0
27738f4ea9cdSGerd Hoffmann    elif $pkg_config --exists "sdl"; then
2774ee8466d0SCole Robinson        sdlabi=1.2
27758f4ea9cdSGerd Hoffmann    else
27768f4ea9cdSGerd Hoffmann        sdlabi=2.0
2777ee8466d0SCole Robinson    fi
2778ee8466d0SCole Robinsonfi
2779ee8466d0SCole Robinson
278047c03744SDave Airlieif test $sdlabi = "2.0"; then
278147c03744SDave Airlie    sdl_config=$sdl2_config
278247c03744SDave Airlie    sdlname=sdl2
278347c03744SDave Airlie    sdlconfigname=sdl2_config
2784e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
278547c03744SDave Airlie    sdlname=sdl
278647c03744SDave Airlie    sdlconfigname=sdl_config
2787e07047cfSCole Robinsonelse
2788e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
27893ec87ffeSPaolo Bonzinifi
27903ec87ffeSPaolo Bonzini
279189138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
279247c03744SDave Airlie  sdl_config=$sdlconfigname
279347c03744SDave Airliefi
279447c03744SDave Airlie
279547c03744SDave Airlieif $pkg_config $sdlname --exists; then
279647c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
279789138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
27983ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
27993ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
280089138857SStefan Weil  sdlversion=$($sdlconfig --version)
2801a0dfd8a4SLoïc Minierelse
2802a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
28038f4ea9cdSGerd Hoffmann    feature_not_found "sdl" "Install SDL2-devel"
2804a0dfd8a4SLoïc Minier  fi
2805a0dfd8a4SLoïc Minier  sdl=no
28069316f803SPaolo Bonzinifi
280729e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
28083ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
28093ec87ffeSPaolo Bonzinifi
281011d9f695Sbellard
28119316f803SPaolo Bonzinisdl_too_old=no
2812c4198157SJuan Quintelaif test "$sdl" != "no" ; then
281311d9f695Sbellard  cat > $TMPC << EOF
281411d9f695Sbellard#include <SDL.h>
281511d9f695Sbellard#undef main /* We don't want SDL to override our main() */
281611d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
281711d9f695SbellardEOF
281889138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
281974f42e18STeLeMan  if test "$static" = "yes" ; then
28205f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
28215f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
28225f37e6d4SThomas Huth    else
282389138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
28245f37e6d4SThomas Huth    fi
282574f42e18STeLeMan  else
282689138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
282774f42e18STeLeMan  fi
282852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
282989138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
283011d9f695Sbellard      sdl_too_old=yes
283111d9f695Sbellard    else
283211d9f695Sbellard      sdl=yes
283311d9f695Sbellard    fi
28347c1f25b4Sbellard
283567c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
28361ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
283767c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
283889138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
283989138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
284011d9f695Sbellard      fi
284152166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
28421ac88f28SJuan Quintela	:
28431ac88f28SJuan Quintela      else
28441ac88f28SJuan Quintela        sdl=no
28457c1f25b4Sbellard      fi
28467c1f25b4Sbellard    fi # static link
2847c4198157SJuan Quintela  else # sdl not found
2848c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
284921684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2850c4198157SJuan Quintela    fi
2851c4198157SJuan Quintela    sdl=no
28527c1f25b4Sbellard  fi # sdl compile test
2853fd677642Sthsfi
285411d9f695Sbellard
28555368a422Saliguoriif test "$sdl" = "yes" ; then
28565368a422Saliguori  cat > $TMPC <<EOF
28575368a422Saliguori#include <SDL.h>
28585368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
28595368a422Saliguori#include <X11/XKBlib.h>
28605368a422Saliguori#else
28615368a422Saliguori#error No x11 support
28625368a422Saliguori#endif
28635368a422Saliguoriint main(void) { return 0; }
28645368a422SaliguoriEOF
2865f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2866f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2867f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
28685368a422Saliguori  fi
28695368a422Saliguorifi
28705368a422Saliguori
28718f28f3fbSths##########################################
28722da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28732da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28742da776dbSMichael R. Hines  cat > $TMPC <<EOF
28752da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28762da776dbSMichael R. Hinesint main(void) { return 0; }
28772da776dbSMichael R. HinesEOF
28782da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
28792da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28802da776dbSMichael R. Hines    rdma="yes"
28812da776dbSMichael R. Hines  else
28822da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28832da776dbSMichael R. Hines        error_exit \
28842da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28852da776dbSMichael R. Hines            " Your options:" \
28862da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28872da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28882da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28892da776dbSMichael R. Hines    fi
28902da776dbSMichael R. Hines    rdma="no"
28912da776dbSMichael R. Hines  fi
28922da776dbSMichael R. Hinesfi
28932da776dbSMichael R. Hines
289495c6bff3SBenoît Canet
289595c6bff3SBenoît Canet##########################################
28962f9606b3Saliguori# VNC SASL detection
2897821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
28982f9606b3Saliguori  cat > $TMPC <<EOF
28992f9606b3Saliguori#include <sasl/sasl.h>
29002f9606b3Saliguori#include <stdio.h>
29012f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
29022f9606b3SaliguoriEOF
29032f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
29042f9606b3Saliguori  vnc_sasl_cflags=""
29052f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
290652166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2907ea784e3bSJuan Quintela    vnc_sasl=yes
2908fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2909ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
29102f9606b3Saliguori  else
2911ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
291221684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2913ea784e3bSJuan Quintela    fi
2914ea784e3bSJuan Quintela    vnc_sasl=no
29152f9606b3Saliguori  fi
29162f9606b3Saliguorifi
29172f9606b3Saliguori
29182f9606b3Saliguori##########################################
29192f6f5c7aSCorentin Chary# VNC JPEG detection
2920821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
29212f6f5c7aSCorentin Charycat > $TMPC <<EOF
29222f6f5c7aSCorentin Chary#include <stdio.h>
29232f6f5c7aSCorentin Chary#include <jpeglib.h>
29242f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
29252f6f5c7aSCorentin CharyEOF
29262f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
29272f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
29282f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
29292f6f5c7aSCorentin Chary    vnc_jpeg=yes
29302f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2931ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
29322f6f5c7aSCorentin Chary  else
29332f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
293421684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
29352f6f5c7aSCorentin Chary    fi
29362f6f5c7aSCorentin Chary    vnc_jpeg=no
29372f6f5c7aSCorentin Chary  fi
29382f6f5c7aSCorentin Charyfi
29392f6f5c7aSCorentin Chary
29402f6f5c7aSCorentin Chary##########################################
2941efe556adSCorentin Chary# VNC PNG detection
2942821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2943efe556adSCorentin Charycat > $TMPC <<EOF
2944efe556adSCorentin Chary//#include <stdio.h>
2945efe556adSCorentin Chary#include <png.h>
2946832ce9c2SScott Wood#include <stddef.h>
2947efe556adSCorentin Charyint main(void) {
2948efe556adSCorentin Chary    png_structp png_ptr;
2949efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
29507edc3fedSPeter Maydell    return png_ptr != 0;
2951efe556adSCorentin Chary}
2952efe556adSCorentin CharyEOF
295365d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
295489138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
295589138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
29569af8025eSBrad  else
2957efe556adSCorentin Chary    vnc_png_cflags=""
2958efe556adSCorentin Chary    vnc_png_libs="-lpng"
29599af8025eSBrad  fi
2960efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2961efe556adSCorentin Chary    vnc_png=yes
2962efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
29639af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2964efe556adSCorentin Chary  else
2965efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
296621684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2967efe556adSCorentin Chary    fi
2968efe556adSCorentin Chary    vnc_png=no
2969efe556adSCorentin Chary  fi
2970efe556adSCorentin Charyfi
2971efe556adSCorentin Chary
2972efe556adSCorentin Chary##########################################
29736a021536SGerd Hoffmann# xkbcommon probe
29746a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
29756a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
29766a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
29776a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
29786a021536SGerd Hoffmann    xkbcommon=yes
29796a021536SGerd Hoffmann  else
29806a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
29816a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
29826a021536SGerd Hoffmann    fi
29836a021536SGerd Hoffmann    xkbcommon=no
29846a021536SGerd Hoffmann  fi
29856a021536SGerd Hoffmannfi
29866a021536SGerd Hoffmann
29876a021536SGerd Hoffmann##########################################
298876655d6dSaliguori# fnmatch() probe, used for ACL routines
298976655d6dSaliguorifnmatch="no"
299076655d6dSaliguoricat > $TMPC << EOF
299176655d6dSaliguori#include <fnmatch.h>
299276655d6dSaliguoriint main(void)
299376655d6dSaliguori{
299476655d6dSaliguori    fnmatch("foo", "foo", 0);
299576655d6dSaliguori    return 0;
299676655d6dSaliguori}
299776655d6dSaliguoriEOF
299852166aa0SJuan Quintelaif compile_prog "" "" ; then
299976655d6dSaliguori   fnmatch="yes"
300076655d6dSaliguorifi
300176655d6dSaliguori
300276655d6dSaliguori##########################################
3003c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3004dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3005dce512deSChristoph Hellwig  cat > $TMPC << EOF
3006ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3007dce512deSChristoph Hellwig#include <xfs/xfs.h>
3008dce512deSChristoph Hellwigint main(void)
3009dce512deSChristoph Hellwig{
3010dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3011dce512deSChristoph Hellwig    return 0;
3012dce512deSChristoph Hellwig}
3013dce512deSChristoph HellwigEOF
3014dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3015dce512deSChristoph Hellwig    xfs="yes"
3016dce512deSChristoph Hellwig  else
3017dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
301821684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3019dce512deSChristoph Hellwig    fi
3020dce512deSChristoph Hellwig    xfs=no
3021dce512deSChristoph Hellwig  fi
3022dce512deSChristoph Hellwigfi
3023dce512deSChristoph Hellwig
3024dce512deSChristoph Hellwig##########################################
30258a16d273Sths# vde libraries probe
3026dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
30274baae0acSJuan Quintela  vde_libs="-lvdeplug"
30288a16d273Sths  cat > $TMPC << EOF
30298a16d273Sths#include <libvdeplug.h>
30304a7f0e06Spbrookint main(void)
30314a7f0e06Spbrook{
30324a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3033fea08e08SPeter Maydell    char s[] = "";
3034fea08e08SPeter Maydell    vde_open(s, s, &a);
30354a7f0e06Spbrook    return 0;
30364a7f0e06Spbrook}
30378a16d273SthsEOF
303852166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
30394baae0acSJuan Quintela    vde=yes
3040dfb278bdSJuan Quintela  else
3041dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
304221684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3043dfb278bdSJuan Quintela    fi
3044dfb278bdSJuan Quintela    vde=no
30458a16d273Sths  fi
30468a16d273Sthsfi
30478a16d273Sths
30488a16d273Sths##########################################
30490a985b37SVincenzo Maffione# netmap support probe
30500a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
30510a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
30520a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
30530a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
30540a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
305558952137SVincenzo Maffioneif test "$netmap" != "no" ; then
305658952137SVincenzo Maffione  cat > $TMPC << EOF
305758952137SVincenzo Maffione#include <inttypes.h>
305858952137SVincenzo Maffione#include <net/if.h>
305958952137SVincenzo Maffione#include <net/netmap.h>
306058952137SVincenzo Maffione#include <net/netmap_user.h>
30610a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
30620a985b37SVincenzo Maffione#error
30630a985b37SVincenzo Maffione#endif
306458952137SVincenzo Maffioneint main(void) { return 0; }
306558952137SVincenzo MaffioneEOF
306658952137SVincenzo Maffione  if compile_prog "" "" ; then
306758952137SVincenzo Maffione    netmap=yes
306858952137SVincenzo Maffione  else
306958952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
307058952137SVincenzo Maffione      feature_not_found "netmap"
307158952137SVincenzo Maffione    fi
307258952137SVincenzo Maffione    netmap=no
307358952137SVincenzo Maffione  fi
307458952137SVincenzo Maffionefi
307558952137SVincenzo Maffione
307658952137SVincenzo Maffione##########################################
307747e98658SCorey Bryant# libcap-ng library probe
307847e98658SCorey Bryantif test "$cap_ng" != "no" ; then
307947e98658SCorey Bryant  cap_libs="-lcap-ng"
308047e98658SCorey Bryant  cat > $TMPC << EOF
308147e98658SCorey Bryant#include <cap-ng.h>
308247e98658SCorey Bryantint main(void)
308347e98658SCorey Bryant{
308447e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
308547e98658SCorey Bryant    return 0;
308647e98658SCorey Bryant}
308747e98658SCorey BryantEOF
308847e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
308947e98658SCorey Bryant    cap_ng=yes
309047e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
309147e98658SCorey Bryant  else
309247e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
309321684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
309447e98658SCorey Bryant    fi
309547e98658SCorey Bryant    cap_ng=no
309647e98658SCorey Bryant  fi
309747e98658SCorey Bryantfi
309847e98658SCorey Bryant
309947e98658SCorey Bryant##########################################
3100c2de5c91Smalc# Sound support libraries probe
31018f28f3fbSths
3102c2de5c91Smalcaudio_drv_probe()
3103c2de5c91Smalc{
3104c2de5c91Smalc    drv=$1
3105c2de5c91Smalc    hdr=$2
3106c2de5c91Smalc    lib=$3
3107c2de5c91Smalc    exp=$4
3108c2de5c91Smalc    cfl=$5
31098f28f3fbSths        cat > $TMPC << EOF
3110c2de5c91Smalc#include <$hdr>
3111c2de5c91Smalcint main(void) { $exp }
31128f28f3fbSthsEOF
311352166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
31148f28f3fbSths        :
31158f28f3fbSths    else
311676ad07a4SPeter Maydell        error_exit "$drv check failed" \
311776ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
31188f28f3fbSths    fi
3119c2de5c91Smalc}
3120c2de5c91Smalc
312189138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3122c2de5c91Smalcfor drv in $audio_drv_list; do
3123c2de5c91Smalc    case $drv in
3124c2de5c91Smalc    alsa)
3125c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3126e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3127b1149911SFam Zheng    alsa_libs="-lasound"
3128c2de5c91Smalc    ;;
3129c2de5c91Smalc
3130b8e59f18Smalc    pa)
3131e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3132e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3133b1149911SFam Zheng    pulse_libs="-lpulse"
313467f86e8eSJuan Quintela    audio_pt_int="yes"
3135b8e59f18Smalc    ;;
3136b8e59f18Smalc
3137373967b2SGerd Hoffmann    sdl)
3138373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3139373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3140373967b2SGerd Hoffmann    fi
3141373967b2SGerd Hoffmann    ;;
3142373967b2SGerd Hoffmann
3143997e690aSJuan Quintela    coreaudio)
3144b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3145997e690aSJuan Quintela    ;;
3146997e690aSJuan Quintela
3147a4bf6780SJuan Quintela    dsound)
3148b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3149d5631638Smalc      audio_win_int="yes"
3150a4bf6780SJuan Quintela    ;;
3151a4bf6780SJuan Quintela
3152a4bf6780SJuan Quintela    oss)
3153b1149911SFam Zheng      oss_libs="$oss_lib"
3154a4bf6780SJuan Quintela    ;;
3155a4bf6780SJuan Quintela
3156373967b2SGerd Hoffmann    wav)
3157373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
31582f6a1ab0Sblueswir1    ;;
31592f6a1ab0Sblueswir1
3160e4c63a6aSmalc    *)
31611c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
316276ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
316376ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3164e4c63a6aSmalc    }
3165e4c63a6aSmalc    ;;
3166c2de5c91Smalc    esac
3167c2de5c91Smalcdone
31688f28f3fbSths
31694d3b6f6eSbalrog##########################################
31702e4d9fb1Saurel32# BrlAPI probe
31712e4d9fb1Saurel32
31724ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3173eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
31742e4d9fb1Saurel32  cat > $TMPC << EOF
31752e4d9fb1Saurel32#include <brlapi.h>
3176832ce9c2SScott Wood#include <stddef.h>
31772e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
31782e4d9fb1Saurel32EOF
317952166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
31802e4d9fb1Saurel32    brlapi=yes
31814ffcedb6SJuan Quintela  else
31824ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
318321684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
31844ffcedb6SJuan Quintela    fi
31854ffcedb6SJuan Quintela    brlapi=no
3186eb82284fSJuan Quintela  fi
3187eb82284fSJuan Quintelafi
31882e4d9fb1Saurel32
31892e4d9fb1Saurel32##########################################
31904d3b6f6eSbalrog# curses probe
3191a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3192e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
31938ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
31948ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3195e095e2f3SStefan Weil  else
31967c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
31978ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3198e095e2f3SStefan Weil  fi
3199c584a6d0SJuan Quintela  curses_found=no
32004d3b6f6eSbalrog  cat > $TMPC << EOF
32018ddc5bf9SSamuel Thibault#include <locale.h>
32024d3b6f6eSbalrog#include <curses.h>
32038ddc5bf9SSamuel Thibault#include <wchar.h>
3204ef9a2524SStefan Weilint main(void) {
32058ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
32068ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3207ef9a2524SStefan Weil  resize_term(0, 0);
32088ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
32098ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
32107c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3211271f37abSKamil Rytarowski  return 0;
3212ef9a2524SStefan Weil}
32134d3b6f6eSbalrogEOF
3214ecbe251fSVadim Evard  IFS=:
32158ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3216b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3217b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
32187c703002SSamuel Thibault    IFS=:
32198ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3220ecbe251fSVadim Evard      unset IFS
32218ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3222c584a6d0SJuan Quintela        curses_found=yes
32238ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
32244f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
32254f78ef9aSJuan Quintela        break
32264d3b6f6eSbalrog      fi
32274f78ef9aSJuan Quintela    done
32287c703002SSamuel Thibault    if test "$curses_found" = yes ; then
32297c703002SSamuel Thibault      break
32307c703002SSamuel Thibault    fi
32318ddc5bf9SSamuel Thibault  done
3232ecbe251fSVadim Evard  unset IFS
3233c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3234c584a6d0SJuan Quintela    curses=yes
3235c584a6d0SJuan Quintela  else
3236c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
323721684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3238c584a6d0SJuan Quintela    fi
3239c584a6d0SJuan Quintela    curses=no
3240c584a6d0SJuan Quintela  fi
32414f78ef9aSJuan Quintelafi
32424d3b6f6eSbalrog
3243414f0dabSblueswir1##########################################
3244769ce76dSAlexander Graf# curl probe
3245a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
324665d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3247a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
32484e2b0658SPaolo Bonzini  else
32494e2b0658SPaolo Bonzini    curlconfig=curl-config
32504e2b0658SPaolo Bonzini  fi
3251769ce76dSAlexander Graf  cat > $TMPC << EOF
3252769ce76dSAlexander Graf#include <curl/curl.h>
32530b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3254769ce76dSAlexander GrafEOF
325589138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
325689138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3257b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3258769ce76dSAlexander Graf    curl=yes
3259788c8196SJuan Quintela  else
3260788c8196SJuan Quintela    if test "$curl" = "yes" ; then
326121684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3262788c8196SJuan Quintela    fi
3263788c8196SJuan Quintela    curl=no
3264769ce76dSAlexander Graf  fi
3265769ce76dSAlexander Graffi # test "$curl"
3266769ce76dSAlexander Graf
3267769ce76dSAlexander Graf##########################################
3268fb599c9aSbalrog# bluez support probe
3269a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3270e820e3f4Sbalrog  cat > $TMPC << EOF
3271e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3272e820e3f4Sbalrogint main(void) { return bt_error(0); }
3273e820e3f4SbalrogEOF
327489138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
327589138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
327652166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3277a20a6f46SJuan Quintela    bluez=yes
3278e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3279e820e3f4Sbalrog  else
3280a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
328121684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3282a20a6f46SJuan Quintela    fi
3283e820e3f4Sbalrog    bluez="no"
3284e820e3f4Sbalrog  fi
3285fb599c9aSbalrogfi
3286fb599c9aSbalrog
3287fb599c9aSbalrog##########################################
3288e18df141SAnthony Liguori# glib support probe
3289a52d28afSPaolo Bonzini
3290ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3291ad04d8cbSPeter Maydell    glib_req_ver=2.30
3292ad04d8cbSPeter Maydellelse
3293f40685c6SJohn Snow    glib_req_ver=2.22
3294ad04d8cbSPeter Maydellfi
3295aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3296aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3297aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3298aa0d1f44SPaolo Bonzinifi
3299e26110cfSFam Zheng
33004eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
33014eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
33024eaf7202SSameeh Jubran
33034eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
33044eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
33054eaf7202SSameeh Jubranfi
33064eaf7202SSameeh Jubran
3307aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3308e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
330989138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
331089138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
33114a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
331214015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3313957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3314e18df141SAnthony Liguori    else
3315e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3316e26110cfSFam Zheng    fi
3317e26110cfSFam Zhengdone
3318e26110cfSFam Zheng
3319977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3320977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3321977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3322977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3323977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3324977a82abSDaniel P. Berrange#include <glib.h>
3325977a82abSDaniel P. Berrange#include <unistd.h>
3326977a82abSDaniel P. Berrange
3327977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3328977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3329977a82abSDaniel P. Berrange
3330977a82abSDaniel P. Berrangeint main(void) {
3331977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3332977a82abSDaniel P. Berrange   return 0;
3333977a82abSDaniel P. Berrange}
3334977a82abSDaniel P. BerrangeEOF
3335977a82abSDaniel P. Berrange
33365919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3337977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3338977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3339977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3340977a82abSDaniel P. Berrange	       "build target"
3341977a82abSDaniel P. Berrangefi
3342977a82abSDaniel P. Berrange
33439d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
33449d41401bSMichael S. Tsirkinglib_subprocess=yes
3345a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
33469d41401bSMichael S. Tsirkin    glib_subprocess=no
33479d41401bSMichael S. Tsirkinfi
33489d41401bSMichael S. Tsirkin
3349bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3350bbbf2e04SJohn Snowcat > $TMPC << EOF
3351bbbf2e04SJohn Snow#include <glib.h>
3352bbbf2e04SJohn Snowint main(void) { return 0; }
3353bbbf2e04SJohn SnowEOF
3354bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3355bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3356bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3357bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3358bbbf2e04SJohn Snow    fi
3359bbbf2e04SJohn Snowfi
3360bbbf2e04SJohn Snow
3361e26110cfSFam Zheng##########################################
3362e26110cfSFam Zheng# SHA command probe for modules
3363e26110cfSFam Zhengif test "$modules" = yes; then
3364e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3365e26110cfSFam Zheng    for c in $shacmd_probe; do
33668ccefb91SFam Zheng        if has $c; then
3367e26110cfSFam Zheng            shacmd="$c"
3368e26110cfSFam Zheng            break
3369e26110cfSFam Zheng        fi
3370e26110cfSFam Zheng    done
3371e26110cfSFam Zheng    if test "$shacmd" = ""; then
3372e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3373e26110cfSFam Zheng    fi
3374e18df141SAnthony Liguorifi
3375e18df141SAnthony Liguori
3376e18df141SAnthony Liguori##########################################
3377e2134eb9SGerd Hoffmann# pixman support probe
3378e2134eb9SGerd Hoffmann
337974880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
338074880fe2SRobert Schiele  pixman_cflags=
338174880fe2SRobert Schiele  pixman_libs=
338235c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
338389138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
338489138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3385e2134eb9SGerd Hoffmannelse
3386c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3387c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3388e2134eb9SGerd Hoffmannfi
3389e2134eb9SGerd Hoffmann
3390e2134eb9SGerd Hoffmann##########################################
3391fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3392fe8fc5aeSPaolo Bonzini
3393fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
3394fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3395fe8fc5aeSPaolo Bonzini#include <libudev.h>
3396fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3397fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3398fe8fc5aeSPaolo Bonziniint logsink;
3399b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3400b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3401b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3402b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3403b3f1c8c4SPaolo Bonzinistruct udev *udev;
3404b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3405b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3406b3f1c8c4SPaolo Bonzini
3407fe8fc5aeSPaolo Bonziniint main(void) {
3408b3f1c8c4SPaolo Bonzini    udev = udev_new();
3409b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3410fe8fc5aeSPaolo Bonzini    return 0;
3411fe8fc5aeSPaolo Bonzini}
3412fe8fc5aeSPaolo BonziniEOF
3413fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3414fe8fc5aeSPaolo Bonzini    mpathpersist=yes
3415fe8fc5aeSPaolo Bonzini  else
3416fe8fc5aeSPaolo Bonzini    mpathpersist=no
3417fe8fc5aeSPaolo Bonzini  fi
3418fe8fc5aeSPaolo Bonzinielse
3419fe8fc5aeSPaolo Bonzini  mpathpersist=no
3420fe8fc5aeSPaolo Bonzinifi
3421fe8fc5aeSPaolo Bonzini
3422fe8fc5aeSPaolo Bonzini##########################################
342317bff52bSM. Mohan Kumar# libcap probe
342417bff52bSM. Mohan Kumar
342517bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
342617bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
342717bff52bSM. Mohan Kumar#include <stdio.h>
342817bff52bSM. Mohan Kumar#include <sys/capability.h>
3429cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
343017bff52bSM. Mohan KumarEOF
343117bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
343217bff52bSM. Mohan Kumar    cap=yes
343317bff52bSM. Mohan Kumar  else
343417bff52bSM. Mohan Kumar    cap=no
343517bff52bSM. Mohan Kumar  fi
343617bff52bSM. Mohan Kumarfi
343717bff52bSM. Mohan Kumar
343817bff52bSM. Mohan Kumar##########################################
3439e5d355d1Saliguori# pthread probe
34404b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
34413c529d93Saliguori
3442e5d355d1Saliguoripthread=no
3443414f0dabSblueswir1cat > $TMPC << EOF
34443c529d93Saliguori#include <pthread.h>
34457a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
34467a42bbe4SStefan Weilint main(void) {
34477a42bbe4SStefan Weil  pthread_t thread;
34487a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
34497a42bbe4SStefan Weil  return 0;
34507a42bbe4SStefan Weil}
3451414f0dabSblueswir1EOF
3452bd00d539SAndreas Färberif compile_prog "" "" ; then
3453bd00d539SAndreas Färber  pthread=yes
3454bd00d539SAndreas Färberelse
3455de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
345652166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3457e5d355d1Saliguori      pthread=yes
3458e3c56761SPeter Portante      found=no
3459e3c56761SPeter Portante      for lib_entry in $LIBS; do
3460e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3461e3c56761SPeter Portante          found=yes
3462e3c56761SPeter Portante          break
3463e3c56761SPeter Portante        fi
3464e3c56761SPeter Portante      done
3465e3c56761SPeter Portante      if test "$found" = "no"; then
34665572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3467*14ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3468e3c56761SPeter Portante      fi
3469409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3470de65fe0fSSebastian Herbszt      break
3471414f0dabSblueswir1    fi
3472de65fe0fSSebastian Herbszt  done
3473bd00d539SAndreas Färberfi
3474414f0dabSblueswir1
34754617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
347676ad07a4SPeter Maydell  error_exit "pthread check failed" \
347776ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3478e5d355d1Saliguorifi
3479e5d355d1Saliguori
34805c312079SDr. David Alan Gilbert# check for pthread_setname_np
34815c312079SDr. David Alan Gilbertpthread_setname_np=no
34825c312079SDr. David Alan Gilbertcat > $TMPC << EOF
34835c312079SDr. David Alan Gilbert#include <pthread.h>
34845c312079SDr. David Alan Gilbert
34855c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
34865c312079SDr. David Alan Gilbertint main(void)
34875c312079SDr. David Alan Gilbert{
34885c312079SDr. David Alan Gilbert    pthread_t thread;
34895c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
34905c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
34915c312079SDr. David Alan Gilbert    return 0;
34925c312079SDr. David Alan Gilbert}
34935c312079SDr. David Alan GilbertEOF
34945c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
34955c312079SDr. David Alan Gilbert  pthread_setname_np=yes
34965c312079SDr. David Alan Gilbertfi
34975c312079SDr. David Alan Gilbert
3498bf9298b9Saliguori##########################################
3499f27aaf4bSChristian Brunner# rbd probe
3500f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3501f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3502f27aaf4bSChristian Brunner#include <stdio.h>
3503ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3504f27aaf4bSChristian Brunnerint main(void) {
3505ad32e9c0SJosh Durgin    rados_t cluster;
3506ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3507f27aaf4bSChristian Brunner    return 0;
3508f27aaf4bSChristian Brunner}
3509f27aaf4bSChristian BrunnerEOF
3510ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3511f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3512f27aaf4bSChristian Brunner    rbd=yes
3513f27aaf4bSChristian Brunner  else
3514f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
351521684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3516f27aaf4bSChristian Brunner    fi
3517f27aaf4bSChristian Brunner    rbd=no
3518f27aaf4bSChristian Brunner  fi
3519f27aaf4bSChristian Brunnerfi
3520f27aaf4bSChristian Brunner
3521f27aaf4bSChristian Brunner##########################################
35220a12ec87SRichard W.M. Jones# libssh2 probe
35234fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
35240a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
352565d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
352689138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
352789138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
35280a12ec87SRichard W.M. Jones    libssh2=yes
35290a12ec87SRichard W.M. Jones  else
35300a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
35314fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
35320a12ec87SRichard W.M. Jones    fi
35330a12ec87SRichard W.M. Jones    libssh2=no
35340a12ec87SRichard W.M. Jones  fi
35350a12ec87SRichard W.M. Jonesfi
35360a12ec87SRichard W.M. Jones
35370a12ec87SRichard W.M. Jones##########################################
35389a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
35399a2d462eSRichard W.M. Jones
35409a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
35419a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
35429a2d462eSRichard W.M. Jones#include <stdio.h>
35439a2d462eSRichard W.M. Jones#include <libssh2.h>
35449a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
35459a2d462eSRichard W.M. Jonesint main(void) {
35469a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
35479a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
35489a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
35499a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
35509a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
35519a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
35529a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
35539a2d462eSRichard W.M. Jones    return 0;
35549a2d462eSRichard W.M. Jones}
35559a2d462eSRichard W.M. JonesEOF
35569a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
35579a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
35589a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
35599a2d462eSRichard W.M. Jones  fi
35609a2d462eSRichard W.M. Jonesfi
35619a2d462eSRichard W.M. Jones
35629a2d462eSRichard W.M. Jones##########################################
35635c6c3a6cSChristoph Hellwig# linux-aio probe
35645c6c3a6cSChristoph Hellwig
35655c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
35665c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
35675c6c3a6cSChristoph Hellwig#include <libaio.h>
35685c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3569832ce9c2SScott Wood#include <stddef.h>
35705c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
35715c6c3a6cSChristoph HellwigEOF
35725c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
35735c6c3a6cSChristoph Hellwig    linux_aio=yes
35745c6c3a6cSChristoph Hellwig  else
35755c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
357621684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
35775c6c3a6cSChristoph Hellwig    fi
35783cfcae3cSLuiz Capitulino    linux_aio=no
35795c6c3a6cSChristoph Hellwig  fi
35805c6c3a6cSChristoph Hellwigfi
35815c6c3a6cSChristoph Hellwig
35825c6c3a6cSChristoph Hellwig##########################################
35833b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
35843b8acc11SPaolo Bonzini
35853b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
35863b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
35873b8acc11SPaolo Bonzinielse
35883b8acc11SPaolo Bonzini  tpm_passthrough=no
35893b8acc11SPaolo Bonzinifi
35903b8acc11SPaolo Bonzini
3591f4ede81eSAmarnath Valluri# TPM emulator is for all posix systems
3592f4ede81eSAmarnath Valluriif test "$mingw32" != "yes"; then
3593f4ede81eSAmarnath Valluri  tpm_emulator=$tpm
3594f4ede81eSAmarnath Vallurielse
3595f4ede81eSAmarnath Valluri  tpm_emulator=no
3596f4ede81eSAmarnath Vallurifi
35973b8acc11SPaolo Bonzini##########################################
3598758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3599758e8e38SVenkateswararao Jujjuri (JV)
3600758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3601758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3602758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3603758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3604f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3605f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3606f2338fb4SPavel Borzenkov#else
36074f26f2b6SAvi Kivity#include <sys/xattr.h>
3608f2338fb4SPavel Borzenkov#endif
3609758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3610758e8e38SVenkateswararao Jujjuri (JV)EOF
36114f26f2b6SAvi Kivity  if compile_prog "" "" ; then
36124f26f2b6SAvi Kivity    attr=yes
36134f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3614f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3615758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3616758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
36174f26f2b6SAvi Kivity    libattr=yes
3618758e8e38SVenkateswararao Jujjuri (JV)  else
3619758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
362021684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3621758e8e38SVenkateswararao Jujjuri (JV)    fi
3622758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3623758e8e38SVenkateswararao Jujjuri (JV)  fi
3624758e8e38SVenkateswararao Jujjuri (JV)fi
3625758e8e38SVenkateswararao Jujjuri (JV)
3626758e8e38SVenkateswararao Jujjuri (JV)##########################################
3627bf9298b9Saliguori# iovec probe
3628bf9298b9Saliguoricat > $TMPC <<EOF
3629db34f0b3Sblueswir1#include <sys/types.h>
3630bf9298b9Saliguori#include <sys/uio.h>
3631db34f0b3Sblueswir1#include <unistd.h>
3632f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3633bf9298b9SaliguoriEOF
3634bf9298b9Saliguoriiovec=no
363552166aa0SJuan Quintelaif compile_prog "" "" ; then
3636bf9298b9Saliguori  iovec=yes
3637bf9298b9Saliguorifi
3638bf9298b9Saliguori
3639f652e6afSaurel32##########################################
3640ceb42de8Saliguori# preadv probe
3641ceb42de8Saliguoricat > $TMPC <<EOF
3642ceb42de8Saliguori#include <sys/types.h>
3643ceb42de8Saliguori#include <sys/uio.h>
3644ceb42de8Saliguori#include <unistd.h>
3645c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3646ceb42de8SaliguoriEOF
3647ceb42de8Saliguoripreadv=no
364852166aa0SJuan Quintelaif compile_prog "" "" ; then
3649ceb42de8Saliguori  preadv=yes
3650ceb42de8Saliguorifi
3651ceb42de8Saliguori
3652ceb42de8Saliguori##########################################
3653f652e6afSaurel32# fdt probe
3654e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3655e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3656e169e1e1SPeter Maydellfdt_required=no
3657e169e1e1SPeter Maydellfor target in $target_list; do
3658e169e1e1SPeter Maydell  case $target in
3659df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3660e169e1e1SPeter Maydell      fdt_required=yes
3661e169e1e1SPeter Maydell    ;;
3662e169e1e1SPeter Maydell  esac
3663e169e1e1SPeter Maydelldone
3664e169e1e1SPeter Maydell
3665e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3666e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3667e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3668e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3669e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3670e169e1e1SPeter Maydell  fi
3671e169e1e1SPeter Maydell  fdt=yes
3672e169e1e1SPeter Maydellfi
3673e169e1e1SPeter Maydell
36742df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3675b41af4baSJuan Quintela  fdt_libs="-lfdt"
367696ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
36776e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3678f652e6afSaurel32  cat > $TMPC << EOF
367931ce0adbSThomas Huth#include <libfdt.h>
368096ce6545SPeter Crosthwaite#include <libfdt_env.h>
36816e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3682f652e6afSaurel32EOF
368352166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3684a540f158SPeter Crosthwaite    # system DTC is good - use it
3685f652e6afSaurel32    fdt=yes
3686aef45d51SDaniel P. Berrange  else
3687aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3688aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3689aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3690aef45d51SDaniel P. Berrange      fi
3691aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3692a540f158SPeter Crosthwaite          fdt=yes
3693a540f158SPeter Crosthwaite          dtc_internal="yes"
3694a540f158SPeter Crosthwaite          mkdir -p dtc
3695cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3696a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3697a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
36982df87df7SJuan Quintela          fi
3699a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3700a540f158SPeter Crosthwaite          fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3701a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
3702aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
3703aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3704aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
3705a540f158SPeter Crosthwaite      else
3706a540f158SPeter Crosthwaite          # don't have and don't want
3707de3a354aSMichael Walle          fdt_libs=
37082df87df7SJuan Quintela          fdt=no
3709f652e6afSaurel32      fi
3710f652e6afSaurel32  fi
3711aef45d51SDaniel P. Berrangefi
3712f652e6afSaurel32
3713a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3714a540f158SPeter Crosthwaite
371520ff075bSMichael Walle##########################################
3716fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3717b1546f32SGerd Hoffmann
3718da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3719014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3720fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3721f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3722f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3723da076ffeSGerd Hoffmann    opengl=yes
3724925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3725925a0400SGerd Hoffmann        gtk_gl="yes"
3726925a0400SGerd Hoffmann    fi
3727cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
372820ff075bSMichael Walle  else
3729da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3730dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
373120ff075bSMichael Walle    fi
3732f676c67eSJeremy White    opengl_cflags=""
3733da076ffeSGerd Hoffmann    opengl_libs=""
3734da076ffeSGerd Hoffmann    opengl=no
373520ff075bSMichael Walle  fi
373620ff075bSMichael Wallefi
373720ff075bSMichael Walle
3738014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3739014cb152SGerd Hoffmann  cat > $TMPC << EOF
3740014cb152SGerd Hoffmann#include <epoxy/egl.h>
3741014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3742014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3743014cb152SGerd Hoffmann#endif
3744014cb152SGerd Hoffmannint main(void) { return 0; }
3745014cb152SGerd HoffmannEOF
3746014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3747014cb152SGerd Hoffmann    opengl_dmabuf=yes
3748014cb152SGerd Hoffmann  fi
3749014cb152SGerd Hoffmannfi
3750c9a12e75SChrysostomos Nanakos
3751c9a12e75SChrysostomos Nanakos
3752eb100396SBharata B Rao##########################################
3753eb100396SBharata B Rao# glusterfs probe
3754eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
375565d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3756e01bee08SBharata B Rao    glusterfs="yes"
375789138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
375889138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3759d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3760d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3761d85fa9ebSJeff Cody    fi
376265d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
37630c14fb47SBharata B Rao      glusterfs_discard="yes"
37640c14fb47SBharata B Rao    fi
37657c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3766df3a429aSNiels de Vos      glusterfs_fallocate="yes"
37677c815372SBharata B Rao      glusterfs_zerofill="yes"
37687c815372SBharata B Rao    fi
3769eb100396SBharata B Rao  else
3770eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
37718efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
37728efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3773eb100396SBharata B Rao    fi
3774e01bee08SBharata B Rao    glusterfs="no"
3775eb100396SBharata B Rao  fi
3776eb100396SBharata B Raofi
3777eb100396SBharata B Rao
377839386ac7Saurel32# Check for inotify functions when we are building linux-user
37793b3f24adSaurel32# emulator.  This is done because older glibc versions don't
37803b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
37813b3f24adSaurel32# don't provide them even if kernel supports them.
37823b3f24adSaurel32#
37833b3f24adSaurel32inotify=no
37843b3f24adSaurel32cat > $TMPC << EOF
37853b3f24adSaurel32#include <sys/inotify.h>
37863b3f24adSaurel32
37873b3f24adSaurel32int
37883b3f24adSaurel32main(void)
37893b3f24adSaurel32{
37903b3f24adSaurel32	/* try to start inotify */
37918690e420Saurel32	return inotify_init();
37923b3f24adSaurel32}
37933b3f24adSaurel32EOF
379452166aa0SJuan Quintelaif compile_prog "" "" ; then
37953b3f24adSaurel32  inotify=yes
37963b3f24adSaurel32fi
37973b3f24adSaurel32
3798c05c7a73SRiku Voipioinotify1=no
3799c05c7a73SRiku Voipiocat > $TMPC << EOF
3800c05c7a73SRiku Voipio#include <sys/inotify.h>
3801c05c7a73SRiku Voipio
3802c05c7a73SRiku Voipioint
3803c05c7a73SRiku Voipiomain(void)
3804c05c7a73SRiku Voipio{
3805c05c7a73SRiku Voipio    /* try to start inotify */
3806c05c7a73SRiku Voipio    return inotify_init1(0);
3807c05c7a73SRiku Voipio}
3808c05c7a73SRiku VoipioEOF
3809c05c7a73SRiku Voipioif compile_prog "" "" ; then
3810c05c7a73SRiku Voipio  inotify1=yes
3811c05c7a73SRiku Voipiofi
3812c05c7a73SRiku Voipio
3813099d6b0fSRiku Voipio# check if pipe2 is there
3814099d6b0fSRiku Voipiopipe2=no
3815099d6b0fSRiku Voipiocat > $TMPC << EOF
3816099d6b0fSRiku Voipio#include <unistd.h>
3817099d6b0fSRiku Voipio#include <fcntl.h>
3818099d6b0fSRiku Voipio
3819099d6b0fSRiku Voipioint main(void)
3820099d6b0fSRiku Voipio{
3821099d6b0fSRiku Voipio    int pipefd[2];
38229bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3823099d6b0fSRiku Voipio}
3824099d6b0fSRiku VoipioEOF
382552166aa0SJuan Quintelaif compile_prog "" "" ; then
3826099d6b0fSRiku Voipio  pipe2=yes
3827099d6b0fSRiku Voipiofi
3828099d6b0fSRiku Voipio
382940ff6d7eSKevin Wolf# check if accept4 is there
383040ff6d7eSKevin Wolfaccept4=no
383140ff6d7eSKevin Wolfcat > $TMPC << EOF
383240ff6d7eSKevin Wolf#include <sys/socket.h>
383340ff6d7eSKevin Wolf#include <stddef.h>
383440ff6d7eSKevin Wolf
383540ff6d7eSKevin Wolfint main(void)
383640ff6d7eSKevin Wolf{
383740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
383840ff6d7eSKevin Wolf    return 0;
383940ff6d7eSKevin Wolf}
384040ff6d7eSKevin WolfEOF
384140ff6d7eSKevin Wolfif compile_prog "" "" ; then
384240ff6d7eSKevin Wolf  accept4=yes
384340ff6d7eSKevin Wolffi
384440ff6d7eSKevin Wolf
38453ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
38463ce34dfbSvibisreenivasansplice=no
38473ce34dfbSvibisreenivasancat > $TMPC << EOF
38483ce34dfbSvibisreenivasan#include <unistd.h>
38493ce34dfbSvibisreenivasan#include <fcntl.h>
38503ce34dfbSvibisreenivasan#include <limits.h>
38513ce34dfbSvibisreenivasan
38523ce34dfbSvibisreenivasanint main(void)
38533ce34dfbSvibisreenivasan{
385466ea0f22SStefan Weil    int len, fd = 0;
38553ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
38563ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
38573ce34dfbSvibisreenivasan    return 0;
38583ce34dfbSvibisreenivasan}
38593ce34dfbSvibisreenivasanEOF
386052166aa0SJuan Quintelaif compile_prog "" "" ; then
38613ce34dfbSvibisreenivasan  splice=yes
38623ce34dfbSvibisreenivasanfi
38633ce34dfbSvibisreenivasan
3864dcc38d1cSMarcelo Tosatti##########################################
3865a99d57bbSWanlong Gao# libnuma probe
3866a99d57bbSWanlong Gao
3867a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3868a99d57bbSWanlong Gao  cat > $TMPC << EOF
3869a99d57bbSWanlong Gao#include <numa.h>
3870a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3871a99d57bbSWanlong GaoEOF
3872a99d57bbSWanlong Gao
3873a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3874a99d57bbSWanlong Gao    numa=yes
3875a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3876a99d57bbSWanlong Gao  else
3877a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3878a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3879a99d57bbSWanlong Gao    fi
3880a99d57bbSWanlong Gao    numa=no
3881a99d57bbSWanlong Gao  fi
3882a99d57bbSWanlong Gaofi
3883a99d57bbSWanlong Gao
38847b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
38857b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
38867b01cb97SAlexandre Derumier    exit 1
38877b01cb97SAlexandre Derumierfi
38887b01cb97SAlexandre Derumier
38895a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
38905a22ab71SYang Zhong# do not support it.
38915a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
38925a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
38935a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
38945a22ab71SYang Zhong    fi
38955a22ab71SYang Zhong    malloc_trim="no"
38965a22ab71SYang Zhongfi
38975a22ab71SYang Zhong
38985a22ab71SYang Zhong#######################################
38995a22ab71SYang Zhong# malloc_trim
39005a22ab71SYang Zhong
39015a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
39025a22ab71SYang Zhong    cat > $TMPC << EOF
39035a22ab71SYang Zhong#include <malloc.h>
39045a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
39055a22ab71SYang ZhongEOF
39065a22ab71SYang Zhong    if compile_prog "" "" ; then
39075a22ab71SYang Zhong        malloc_trim="yes"
39085a22ab71SYang Zhong    else
39095a22ab71SYang Zhong        malloc_trim="no"
39105a22ab71SYang Zhong    fi
39115a22ab71SYang Zhongfi
39125a22ab71SYang Zhong
3913a99d57bbSWanlong Gao##########################################
39142847b469SFam Zheng# tcmalloc probe
39152847b469SFam Zheng
39162847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
39172847b469SFam Zheng  cat > $TMPC << EOF
39182847b469SFam Zheng#include <stdlib.h>
39192847b469SFam Zhengint main(void) { malloc(1); return 0; }
39202847b469SFam ZhengEOF
39212847b469SFam Zheng
39222847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
39232847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
39242847b469SFam Zheng  else
39252847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
39262847b469SFam Zheng  fi
39272847b469SFam Zhengfi
39282847b469SFam Zheng
39292847b469SFam Zheng##########################################
39307b01cb97SAlexandre Derumier# jemalloc probe
39317b01cb97SAlexandre Derumier
39327b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
39337b01cb97SAlexandre Derumier  cat > $TMPC << EOF
39347b01cb97SAlexandre Derumier#include <stdlib.h>
39357b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
39367b01cb97SAlexandre DerumierEOF
39377b01cb97SAlexandre Derumier
39387b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
39397b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
39407b01cb97SAlexandre Derumier  else
39417b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
39427b01cb97SAlexandre Derumier  fi
39437b01cb97SAlexandre Derumierfi
39447b01cb97SAlexandre Derumier
39457b01cb97SAlexandre Derumier##########################################
3946dcc38d1cSMarcelo Tosatti# signalfd probe
3947dcc38d1cSMarcelo Tosattisignalfd="no"
3948dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3949dcc38d1cSMarcelo Tosatti#include <unistd.h>
3950dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3951dcc38d1cSMarcelo Tosatti#include <signal.h>
3952dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3953dcc38d1cSMarcelo TosattiEOF
3954dcc38d1cSMarcelo Tosatti
3955dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3956dcc38d1cSMarcelo Tosatti  signalfd=yes
3957dcc38d1cSMarcelo Tosattifi
3958dcc38d1cSMarcelo Tosatti
3959c2882b96SRiku Voipio# check if eventfd is supported
3960c2882b96SRiku Voipioeventfd=no
3961c2882b96SRiku Voipiocat > $TMPC << EOF
3962c2882b96SRiku Voipio#include <sys/eventfd.h>
3963c2882b96SRiku Voipio
3964c2882b96SRiku Voipioint main(void)
3965c2882b96SRiku Voipio{
396655cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3967c2882b96SRiku Voipio}
3968c2882b96SRiku VoipioEOF
3969c2882b96SRiku Voipioif compile_prog "" "" ; then
3970c2882b96SRiku Voipio  eventfd=yes
3971c2882b96SRiku Voipiofi
3972c2882b96SRiku Voipio
3973751bcc39SMarc-André Lureau# check if memfd is supported
3974751bcc39SMarc-André Lureaumemfd=no
3975751bcc39SMarc-André Lureaucat > $TMPC << EOF
397675e5b70eSPaolo Bonzini#include <sys/mman.h>
3977751bcc39SMarc-André Lureau
3978751bcc39SMarc-André Lureauint main(void)
3979751bcc39SMarc-André Lureau{
3980751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3981751bcc39SMarc-André Lureau}
3982751bcc39SMarc-André LureauEOF
3983751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3984751bcc39SMarc-André Lureau  memfd=yes
3985751bcc39SMarc-André Lureaufi
3986751bcc39SMarc-André Lureau
3987751bcc39SMarc-André Lureau
3988751bcc39SMarc-André Lureau
3989d0927938SUlrich Hecht# check for fallocate
3990d0927938SUlrich Hechtfallocate=no
3991d0927938SUlrich Hechtcat > $TMPC << EOF
3992d0927938SUlrich Hecht#include <fcntl.h>
3993d0927938SUlrich Hecht
3994d0927938SUlrich Hechtint main(void)
3995d0927938SUlrich Hecht{
3996d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3997d0927938SUlrich Hecht    return 0;
3998d0927938SUlrich Hecht}
3999d0927938SUlrich HechtEOF
40008fb03151SPeter Maydellif compile_prog "" "" ; then
4001d0927938SUlrich Hecht  fallocate=yes
4002d0927938SUlrich Hechtfi
4003d0927938SUlrich Hecht
40043d4fa43eSKusanagi Kouichi# check for fallocate hole punching
40053d4fa43eSKusanagi Kouichifallocate_punch_hole=no
40063d4fa43eSKusanagi Kouichicat > $TMPC << EOF
40073d4fa43eSKusanagi Kouichi#include <fcntl.h>
40083d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
40093d4fa43eSKusanagi Kouichi
40103d4fa43eSKusanagi Kouichiint main(void)
40113d4fa43eSKusanagi Kouichi{
40123d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
40133d4fa43eSKusanagi Kouichi    return 0;
40143d4fa43eSKusanagi Kouichi}
40153d4fa43eSKusanagi KouichiEOF
40163d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
40173d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
40183d4fa43eSKusanagi Kouichifi
40193d4fa43eSKusanagi Kouichi
4020b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4021b953f075SDenis V. Lunevfallocate_zero_range=no
4022b953f075SDenis V. Lunevcat > $TMPC << EOF
4023b953f075SDenis V. Lunev#include <fcntl.h>
4024b953f075SDenis V. Lunev#include <linux/falloc.h>
4025b953f075SDenis V. Lunev
4026b953f075SDenis V. Lunevint main(void)
4027b953f075SDenis V. Lunev{
4028b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4029b953f075SDenis V. Lunev    return 0;
4030b953f075SDenis V. Lunev}
4031b953f075SDenis V. LunevEOF
4032b953f075SDenis V. Lunevif compile_prog "" "" ; then
4033b953f075SDenis V. Lunev  fallocate_zero_range=yes
4034b953f075SDenis V. Lunevfi
4035b953f075SDenis V. Lunev
4036ed911435SKevin Wolf# check for posix_fallocate
4037ed911435SKevin Wolfposix_fallocate=no
4038ed911435SKevin Wolfcat > $TMPC << EOF
4039ed911435SKevin Wolf#include <fcntl.h>
4040ed911435SKevin Wolf
4041ed911435SKevin Wolfint main(void)
4042ed911435SKevin Wolf{
4043ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4044ed911435SKevin Wolf    return 0;
4045ed911435SKevin Wolf}
4046ed911435SKevin WolfEOF
4047ed911435SKevin Wolfif compile_prog "" "" ; then
4048ed911435SKevin Wolf    posix_fallocate=yes
4049ed911435SKevin Wolffi
4050ed911435SKevin Wolf
4051c727f47dSPeter Maydell# check for sync_file_range
4052c727f47dSPeter Maydellsync_file_range=no
4053c727f47dSPeter Maydellcat > $TMPC << EOF
4054c727f47dSPeter Maydell#include <fcntl.h>
4055c727f47dSPeter Maydell
4056c727f47dSPeter Maydellint main(void)
4057c727f47dSPeter Maydell{
4058c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4059c727f47dSPeter Maydell    return 0;
4060c727f47dSPeter Maydell}
4061c727f47dSPeter MaydellEOF
40628fb03151SPeter Maydellif compile_prog "" "" ; then
4063c727f47dSPeter Maydell  sync_file_range=yes
4064c727f47dSPeter Maydellfi
4065c727f47dSPeter Maydell
4066dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4067dace20dcSPeter Maydellfiemap=no
4068dace20dcSPeter Maydellcat > $TMPC << EOF
4069dace20dcSPeter Maydell#include <sys/ioctl.h>
4070dace20dcSPeter Maydell#include <linux/fs.h>
4071dace20dcSPeter Maydell#include <linux/fiemap.h>
4072dace20dcSPeter Maydell
4073dace20dcSPeter Maydellint main(void)
4074dace20dcSPeter Maydell{
4075dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4076dace20dcSPeter Maydell    return 0;
4077dace20dcSPeter Maydell}
4078dace20dcSPeter MaydellEOF
40798fb03151SPeter Maydellif compile_prog "" "" ; then
4080dace20dcSPeter Maydell  fiemap=yes
4081dace20dcSPeter Maydellfi
4082dace20dcSPeter Maydell
4083d0927938SUlrich Hecht# check for dup3
4084d0927938SUlrich Hechtdup3=no
4085d0927938SUlrich Hechtcat > $TMPC << EOF
4086d0927938SUlrich Hecht#include <unistd.h>
4087d0927938SUlrich Hecht
4088d0927938SUlrich Hechtint main(void)
4089d0927938SUlrich Hecht{
4090d0927938SUlrich Hecht    dup3(0, 0, 0);
4091d0927938SUlrich Hecht    return 0;
4092d0927938SUlrich Hecht}
4093d0927938SUlrich HechtEOF
409478f5d726SJan Kiszkaif compile_prog "" "" ; then
4095d0927938SUlrich Hecht  dup3=yes
4096d0927938SUlrich Hechtfi
4097d0927938SUlrich Hecht
40984e0c6529SAlex Bligh# check for ppoll support
40994e0c6529SAlex Blighppoll=no
41004e0c6529SAlex Blighcat > $TMPC << EOF
41014e0c6529SAlex Bligh#include <poll.h>
41024e0c6529SAlex Bligh
41034e0c6529SAlex Blighint main(void)
41044e0c6529SAlex Bligh{
41054e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
41064e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
41074e0c6529SAlex Bligh    return 0;
41084e0c6529SAlex Bligh}
41094e0c6529SAlex BlighEOF
41104e0c6529SAlex Blighif compile_prog "" "" ; then
41114e0c6529SAlex Bligh  ppoll=yes
41124e0c6529SAlex Blighfi
41134e0c6529SAlex Bligh
4114cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4115cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4116cd758dd0SAlex Blighcat > $TMPC << EOF
4117cd758dd0SAlex Bligh#include <sys/prctl.h>
4118cd758dd0SAlex Bligh
4119cd758dd0SAlex Blighint main(void)
4120cd758dd0SAlex Bligh{
4121cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4122cd758dd0SAlex Bligh    return 0;
4123cd758dd0SAlex Bligh}
4124cd758dd0SAlex BlighEOF
4125cd758dd0SAlex Blighif compile_prog "" "" ; then
4126cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4127cd758dd0SAlex Blighfi
4128cd758dd0SAlex Bligh
41293b6edd16SPeter Maydell# check for epoll support
41303b6edd16SPeter Maydellepoll=no
41313b6edd16SPeter Maydellcat > $TMPC << EOF
41323b6edd16SPeter Maydell#include <sys/epoll.h>
41333b6edd16SPeter Maydell
41343b6edd16SPeter Maydellint main(void)
41353b6edd16SPeter Maydell{
41363b6edd16SPeter Maydell    epoll_create(0);
41373b6edd16SPeter Maydell    return 0;
41383b6edd16SPeter Maydell}
41393b6edd16SPeter MaydellEOF
41408fb03151SPeter Maydellif compile_prog "" "" ; then
41413b6edd16SPeter Maydell  epoll=yes
41423b6edd16SPeter Maydellfi
41433b6edd16SPeter Maydell
4144227f0214SPeter Maydell# epoll_create1 is a later addition
4145227f0214SPeter Maydell# so we must check separately for its presence
41463b6edd16SPeter Maydellepoll_create1=no
41473b6edd16SPeter Maydellcat > $TMPC << EOF
41483b6edd16SPeter Maydell#include <sys/epoll.h>
41493b6edd16SPeter Maydell
41503b6edd16SPeter Maydellint main(void)
41513b6edd16SPeter Maydell{
415219e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
415319e83f6bSPeter Maydell     * a function being called. This is necessary so that on
415419e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
415519e83f6bSPeter Maydell     * the library but not declared in the header file we will
415619e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
415719e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
415819e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
415919e83f6bSPeter Maydell     */
4160c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
41613b6edd16SPeter Maydell}
41623b6edd16SPeter MaydellEOF
41638fb03151SPeter Maydellif compile_prog "" "" ; then
41643b6edd16SPeter Maydell  epoll_create1=yes
41653b6edd16SPeter Maydellfi
41663b6edd16SPeter Maydell
4167a8fd1abaSPeter Maydell# check for sendfile support
4168a8fd1abaSPeter Maydellsendfile=no
4169a8fd1abaSPeter Maydellcat > $TMPC << EOF
4170a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4171a8fd1abaSPeter Maydell
4172a8fd1abaSPeter Maydellint main(void)
4173a8fd1abaSPeter Maydell{
4174a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4175a8fd1abaSPeter Maydell}
4176a8fd1abaSPeter MaydellEOF
4177a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4178a8fd1abaSPeter Maydell  sendfile=yes
4179a8fd1abaSPeter Maydellfi
4180a8fd1abaSPeter Maydell
418151834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
418251834341SRiku Voipiotimerfd=no
418351834341SRiku Voipiocat > $TMPC << EOF
418451834341SRiku Voipio#include <sys/timerfd.h>
418551834341SRiku Voipio
418651834341SRiku Voipioint main(void)
418751834341SRiku Voipio{
418851834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
418951834341SRiku Voipio}
419051834341SRiku VoipioEOF
419151834341SRiku Voipioif compile_prog "" "" ; then
419251834341SRiku Voipio  timerfd=yes
419351834341SRiku Voipiofi
419451834341SRiku Voipio
41959af5c906SRiku Voipio# check for setns and unshare support
41969af5c906SRiku Voipiosetns=no
41979af5c906SRiku Voipiocat > $TMPC << EOF
41989af5c906SRiku Voipio#include <sched.h>
41999af5c906SRiku Voipio
42009af5c906SRiku Voipioint main(void)
42019af5c906SRiku Voipio{
42029af5c906SRiku Voipio    int ret;
42039af5c906SRiku Voipio    ret = setns(0, 0);
42049af5c906SRiku Voipio    ret = unshare(0);
42059af5c906SRiku Voipio    return ret;
42069af5c906SRiku Voipio}
42079af5c906SRiku VoipioEOF
42089af5c906SRiku Voipioif compile_prog "" "" ; then
42099af5c906SRiku Voipio  setns=yes
42109af5c906SRiku Voipiofi
42119af5c906SRiku Voipio
421238860a03SAleksandar Markovic# clock_adjtime probe
421338860a03SAleksandar Markovicclock_adjtime=no
421438860a03SAleksandar Markoviccat > $TMPC <<EOF
421538860a03SAleksandar Markovic#include <time.h>
421638860a03SAleksandar Markovic
421738860a03SAleksandar Markovicint main(void)
421838860a03SAleksandar Markovic{
421938860a03SAleksandar Markovic    return clock_adjtime(0, 0);
422038860a03SAleksandar Markovic}
422138860a03SAleksandar MarkovicEOF
422238860a03SAleksandar Markovicclock_adjtime=no
422338860a03SAleksandar Markovicif compile_prog "" "" ; then
422438860a03SAleksandar Markovic  clock_adjtime=yes
422538860a03SAleksandar Markovicfi
422638860a03SAleksandar Markovic
42275a03cd00SAleksandar Markovic# syncfs probe
42285a03cd00SAleksandar Markovicsyncfs=no
42295a03cd00SAleksandar Markoviccat > $TMPC <<EOF
42305a03cd00SAleksandar Markovic#include <unistd.h>
42315a03cd00SAleksandar Markovic
42325a03cd00SAleksandar Markovicint main(void)
42335a03cd00SAleksandar Markovic{
42345a03cd00SAleksandar Markovic    return syncfs(0);
42355a03cd00SAleksandar Markovic}
42365a03cd00SAleksandar MarkovicEOF
42375a03cd00SAleksandar Markovicsyncfs=no
42385a03cd00SAleksandar Markovicif compile_prog "" "" ; then
42395a03cd00SAleksandar Markovic  syncfs=yes
42405a03cd00SAleksandar Markovicfi
42415a03cd00SAleksandar Markovic
4242cc8ae6deSpbrook# Check if tools are available to build documentation.
4243a25dba17SJuan Quintelaif test "$docs" != "no" ; then
424401668d98SStefan Weil  if has makeinfo && has pod2man; then
4245a25dba17SJuan Quintela    docs=yes
424683a3ab8bSJuan Quintela  else
4247a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
424821684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
424983a3ab8bSJuan Quintela    fi
4250a25dba17SJuan Quintela    docs=no
425183a3ab8bSJuan Quintela  fi
4252cc8ae6deSpbrookfi
4253cc8ae6deSpbrook
4254f514f41cSStefan Weil# Search for bswap_32 function
42556ae9a1f4SJuan Quintelabyteswap_h=no
42566ae9a1f4SJuan Quintelacat > $TMPC << EOF
42576ae9a1f4SJuan Quintela#include <byteswap.h>
42586ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
42596ae9a1f4SJuan QuintelaEOF
426052166aa0SJuan Quintelaif compile_prog "" "" ; then
42616ae9a1f4SJuan Quintela  byteswap_h=yes
42626ae9a1f4SJuan Quintelafi
42636ae9a1f4SJuan Quintela
426475f13596SStefan Weil# Search for bswap32 function
42656ae9a1f4SJuan Quintelabswap_h=no
42666ae9a1f4SJuan Quintelacat > $TMPC << EOF
42676ae9a1f4SJuan Quintela#include <sys/endian.h>
42686ae9a1f4SJuan Quintela#include <sys/types.h>
42696ae9a1f4SJuan Quintela#include <machine/bswap.h>
42706ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
42716ae9a1f4SJuan QuintelaEOF
427252166aa0SJuan Quintelaif compile_prog "" "" ; then
42736ae9a1f4SJuan Quintela  bswap_h=yes
42746ae9a1f4SJuan Quintelafi
42756ae9a1f4SJuan Quintela
4276da93a1fdSaliguori##########################################
4277e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4278c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4279e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
42803c33ea96SPaolo Bonzini    libiscsi="yes"
4281ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4282ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4283c589b249SRonnie Sahlberg  else
4284c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4285e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4286c589b249SRonnie Sahlberg    fi
4287c589b249SRonnie Sahlberg    libiscsi="no"
4288c589b249SRonnie Sahlberg  fi
4289c589b249SRonnie Sahlbergfi
4290c589b249SRonnie Sahlberg
4291c589b249SRonnie Sahlberg##########################################
42928bacde8dSNatanael Copa# Do we need libm
42938bacde8dSNatanael Copacat > $TMPC << EOF
42948bacde8dSNatanael Copa#include <math.h>
4295f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
42968bacde8dSNatanael CopaEOF
42978bacde8dSNatanael Copaif compile_prog "" "" ; then
42988bacde8dSNatanael Copa  :
42998bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
43008bacde8dSNatanael Copa  LIBS="-lm $LIBS"
43018bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
43028bacde8dSNatanael Copaelse
430376ad07a4SPeter Maydell  error_exit "libm check failed"
43048bacde8dSNatanael Copafi
43058bacde8dSNatanael Copa
43068bacde8dSNatanael Copa##########################################
4307da93a1fdSaliguori# Do we need librt
43088bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
43098bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
43108bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
43118bacde8dSNatanael Copa# function in addition.
4312da93a1fdSaliguoricat > $TMPC <<EOF
4313da93a1fdSaliguori#include <signal.h>
4314da93a1fdSaliguori#include <time.h>
43158bacde8dSNatanael Copaint main(void) {
43168bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
43178bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
43188bacde8dSNatanael Copa}
4319da93a1fdSaliguoriEOF
4320da93a1fdSaliguori
432152166aa0SJuan Quintelaif compile_prog "" "" ; then
432207ffa4bdSJuan Quintela  :
43238bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
432418e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
432518e588b1SRick Liu  LIBS="$LIBS -lrt"
432618e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4327da93a1fdSaliguorifi
4328da93a1fdSaliguori
432931ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
433078723752SPeter Maydell        "$haiku" != "yes" ; then
43316362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
43326362a53fSJuan Quintelafi
43336362a53fSJuan Quintela
4334de5071c5SBlue Swirl##########################################
4335cd4ec0b4SGerd Hoffmann# spice probe
4336cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4337cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4338cd4ec0b4SGerd Hoffmann#include <spice.h>
4339cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4340cd4ec0b4SGerd HoffmannEOF
4341710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4342710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
434365d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
434465d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4345cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4346cd4ec0b4SGerd Hoffmann    spice="yes"
4347cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4348cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
43492e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
43502e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4351cd4ec0b4SGerd Hoffmann  else
4352cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
43538efc9363SHu Tao      feature_not_found "spice" \
43548efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4355cd4ec0b4SGerd Hoffmann    fi
4356cd4ec0b4SGerd Hoffmann    spice="no"
4357cd4ec0b4SGerd Hoffmann  fi
4358cd4ec0b4SGerd Hoffmannfi
4359cd4ec0b4SGerd Hoffmann
43607b02f544SMarc-André Lureau# check for smartcard support
43617b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
43627b02f544SMarc-André Lureau    if $pkg_config libcacard; then
43637b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
43647b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
43657b02f544SMarc-André Lureau        smartcard="yes"
4366111a38b0SRobert Relyea    else
43677b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
43687b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4369111a38b0SRobert Relyea        fi
43707b02f544SMarc-André Lureau        smartcard="no"
4371111a38b0SRobert Relyea    fi
4372111a38b0SRobert Relyeafi
4373111a38b0SRobert Relyea
43742b2325ffSGerd Hoffmann# check for libusb
43752b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
437665d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
43772b2325ffSGerd Hoffmann        libusb="yes"
4378ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4379ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
43802b2325ffSGerd Hoffmann    else
43812b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
43828efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
43832b2325ffSGerd Hoffmann        fi
43842b2325ffSGerd Hoffmann        libusb="no"
43852b2325ffSGerd Hoffmann    fi
43862b2325ffSGerd Hoffmannfi
43872b2325ffSGerd Hoffmann
438869354a83SHans de Goede# check for usbredirparser for usb network redirection support
438969354a83SHans de Goedeif test "$usb_redir" != "no" ; then
439065d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
439169354a83SHans de Goede        usb_redir="yes"
4392ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4393ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
439469354a83SHans de Goede    else
439569354a83SHans de Goede        if test "$usb_redir" = "yes"; then
439621684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
439769354a83SHans de Goede        fi
439869354a83SHans de Goede        usb_redir="no"
439969354a83SHans de Goede    fi
440069354a83SHans de Goedefi
440169354a83SHans de Goede
4402cd4ec0b4SGerd Hoffmann##########################################
4403d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4404d9840e25STomoki Sekiyama
4405d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4406d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4407690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4408d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4409d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4410690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4411d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4412d9840e25STomoki Sekiyama	  ;;
4413690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4414d9840e25STomoki Sekiyama  esac
4415d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4416d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4417d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4418d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4419d9840e25STomoki SekiyamaEOF
4420d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4421d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4422d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4423315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4424f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4425d9840e25STomoki Sekiyama  else
4426d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4427d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4428d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4429d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4430d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4431d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4432d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4433d9840e25STomoki Sekiyama    fi
4434d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4435d9840e25STomoki Sekiyama  fi
4436d9840e25STomoki Sekiyamafi
4437d9840e25STomoki Sekiyama
4438d9840e25STomoki Sekiyama##########################################
4439d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4440d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4441d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4442d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4443d9840e25STomoki Sekiyama
4444d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4445d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4446d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4447d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4448d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4449d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4450d9840e25STomoki Sekiyama    else
4451d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4452d9840e25STomoki Sekiyama    fi
4453d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4454d9840e25STomoki Sekiyama    win_sdk=""
4455d9840e25STomoki Sekiyama  fi
4456d9840e25STomoki Sekiyamafi
4457d9840e25STomoki Sekiyama
4458d9840e25STomoki Sekiyama##########################################
445950cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
446050cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
446150cbebb9SMichael Roth  cat > $TMPC << EOF
446250cbebb9SMichael Roth#include <windows.h>
446350cbebb9SMichael Roth#include <ntddscsi.h>
446450cbebb9SMichael Rothint main(void) {
446550cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
446650cbebb9SMichael Roth#error Missing required ioctl definitions
446750cbebb9SMichael Roth#endif
446850cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
446950cbebb9SMichael Roth  return addr.Lun;
447050cbebb9SMichael Roth}
447150cbebb9SMichael RothEOF
447250cbebb9SMichael Roth  if compile_prog "" "" ; then
447350cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4474c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
447550cbebb9SMichael Roth  fi
447650cbebb9SMichael Rothfi
447750cbebb9SMichael Roth
447850cbebb9SMichael Roth##########################################
44799d9e1521SGerd Hoffmann# virgl renderer probe
44809d9e1521SGerd Hoffmann
44819d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
44829d9e1521SGerd Hoffmann  cat > $TMPC << EOF
44839d9e1521SGerd Hoffmann#include <virglrenderer.h>
44849d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
44859d9e1521SGerd HoffmannEOF
44869d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
44879d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
44889d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
44899d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
44909d9e1521SGerd Hoffmann    virglrenderer="yes"
44919d9e1521SGerd Hoffmann  else
44929d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
44939d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
44949d9e1521SGerd Hoffmann    fi
44959d9e1521SGerd Hoffmann    virglrenderer="no"
44969d9e1521SGerd Hoffmann  fi
44979d9e1521SGerd Hoffmannfi
44989d9e1521SGerd Hoffmann
44999d9e1521SGerd Hoffmann##########################################
45008ca80760SRichard Henderson# capstone
45018ca80760SRichard Henderson
4502e219c499SRichard Hendersoncase "$capstone" in
4503e219c499SRichard Henderson  "" | yes)
45048ca80760SRichard Henderson    if $pkg_config capstone; then
4505e219c499SRichard Henderson      capstone=system
4506e219c499SRichard Henderson    elif test -e "${source_path}/.git" ; then
4507e219c499SRichard Henderson      capstone=git
4508e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4509e219c499SRichard Henderson      capstone=internal
4510e219c499SRichard Henderson    elif test -z "$capstone" ; then
4511e219c499SRichard Henderson      capstone=no
4512e219c499SRichard Henderson    else
4513e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4514e219c499SRichard Henderson    fi
4515e219c499SRichard Henderson    ;;
4516e219c499SRichard Henderson
4517e219c499SRichard Henderson  system)
4518e219c499SRichard Henderson    if ! $pkg_config capstone; then
4519e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4520e219c499SRichard Henderson    fi
4521e219c499SRichard Henderson    ;;
4522e219c499SRichard Hendersonesac
4523e219c499SRichard Henderson
4524e219c499SRichard Hendersoncase "$capstone" in
4525e219c499SRichard Henderson  git | internal)
4526e219c499SRichard Henderson    if test "$capstone" = git; then
4527e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4528e219c499SRichard Henderson    fi
4529e219c499SRichard Henderson    mkdir -p capstone
4530e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4531e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4532e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4533e219c499SRichard Henderson    else
4534e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4535e219c499SRichard Henderson    fi
4536e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4537e219c499SRichard Henderson    ;;
4538e219c499SRichard Henderson
4539e219c499SRichard Henderson  system)
45408ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
45418ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4542e219c499SRichard Henderson    ;;
4543e219c499SRichard Henderson
4544e219c499SRichard Henderson  no)
4545e219c499SRichard Henderson    ;;
4546e219c499SRichard Henderson  *)
4547e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4548e219c499SRichard Henderson    ;;
4549e219c499SRichard Hendersonesac
45508ca80760SRichard Henderson
45518ca80760SRichard Henderson##########################################
45525f6b9e8fSBlue Swirl# check if we have fdatasync
45535f6b9e8fSBlue Swirl
45545f6b9e8fSBlue Swirlfdatasync=no
45555f6b9e8fSBlue Swirlcat > $TMPC << EOF
45565f6b9e8fSBlue Swirl#include <unistd.h>
4557d1722a27SAlexandre Raymondint main(void) {
4558d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4559d1722a27SAlexandre Raymondreturn fdatasync(0);
4560d1722a27SAlexandre Raymond#else
4561e172fe11SStefan Weil#error Not supported
4562d1722a27SAlexandre Raymond#endif
4563d1722a27SAlexandre Raymond}
45645f6b9e8fSBlue SwirlEOF
45655f6b9e8fSBlue Swirlif compile_prog "" "" ; then
45665f6b9e8fSBlue Swirl    fdatasync=yes
45675f6b9e8fSBlue Swirlfi
45685f6b9e8fSBlue Swirl
456994a420b1SStefan Hajnoczi##########################################
4570e78815a5SAndreas Färber# check if we have madvise
4571e78815a5SAndreas Färber
4572e78815a5SAndreas Färbermadvise=no
4573e78815a5SAndreas Färbercat > $TMPC << EOF
4574e78815a5SAndreas Färber#include <sys/types.h>
4575e78815a5SAndreas Färber#include <sys/mman.h>
4576832ce9c2SScott Wood#include <stddef.h>
4577e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4578e78815a5SAndreas FärberEOF
4579e78815a5SAndreas Färberif compile_prog "" "" ; then
4580e78815a5SAndreas Färber    madvise=yes
4581e78815a5SAndreas Färberfi
4582e78815a5SAndreas Färber
4583e78815a5SAndreas Färber##########################################
4584e78815a5SAndreas Färber# check if we have posix_madvise
4585e78815a5SAndreas Färber
4586e78815a5SAndreas Färberposix_madvise=no
4587e78815a5SAndreas Färbercat > $TMPC << EOF
4588e78815a5SAndreas Färber#include <sys/mman.h>
4589832ce9c2SScott Wood#include <stddef.h>
4590e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4591e78815a5SAndreas FärberEOF
4592e78815a5SAndreas Färberif compile_prog "" "" ; then
4593e78815a5SAndreas Färber    posix_madvise=yes
4594e78815a5SAndreas Färberfi
4595e78815a5SAndreas Färber
4596e78815a5SAndreas Färber##########################################
45970a852417SPaul Durrant# check if we have posix_syslog
45980a852417SPaul Durrant
45990a852417SPaul Durrantposix_syslog=no
46000a852417SPaul Durrantcat > $TMPC << EOF
46010a852417SPaul Durrant#include <syslog.h>
46020a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
46030a852417SPaul DurrantEOF
46040a852417SPaul Durrantif compile_prog "" "" ; then
46050a852417SPaul Durrant    posix_syslog=yes
46060a852417SPaul Durrantfi
46070a852417SPaul Durrant
46080a852417SPaul Durrant##########################################
4609401bc051SPeter Maydell# check if we have sem_timedwait
4610401bc051SPeter Maydell
4611401bc051SPeter Maydellsem_timedwait=no
4612401bc051SPeter Maydellcat > $TMPC << EOF
4613401bc051SPeter Maydell#include <semaphore.h>
4614401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4615401bc051SPeter MaydellEOF
4616401bc051SPeter Maydellif compile_prog "" "" ; then
4617401bc051SPeter Maydell    sem_timedwait=yes
4618401bc051SPeter Maydellfi
4619401bc051SPeter Maydell
4620401bc051SPeter Maydell##########################################
462194a420b1SStefan Hajnoczi# check if trace backend exists
462294a420b1SStefan Hajnoczi
46235b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
462494a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
46255b808275SLluís Vilanova  error_exit "invalid trace backends" \
46265b808275SLluís Vilanova      "Please choose supported trace backends."
462794a420b1SStefan Hajnoczifi
462894a420b1SStefan Hajnoczi
46297e24e92aSStefan Hajnoczi##########################################
46307e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
46315b808275SLluís Vilanovaif have_backend "ust"; then
46327e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4633bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
46347e24e92aSStefan Hajnocziint main(void) { return 0; }
46357e24e92aSStefan HajnocziEOF
4636c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4637bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
463889138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
46397e24e92aSStefan Hajnoczi    else
4640c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4641bf15f63cSMohamad Gebai    fi
4642bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
464389138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4644bf15f63cSMohamad Gebai    else
4645bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4646bf15f63cSMohamad Gebai    fi
4647bf15f63cSMohamad Gebai
4648bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4649bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4650bf15f63cSMohamad Gebai  else
4651bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
46527e24e92aSStefan Hajnoczi  fi
46537e24e92aSStefan Hajnoczifi
4654b3d08c02SDaniel P. Berrange
4655b3d08c02SDaniel P. Berrange##########################################
4656b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
46575b808275SLluís Vilanovaif have_backend "dtrace"; then
4658b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
465976ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4660b3d08c02SDaniel P. Berrange  fi
4661c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4662c276b17dSDaniel P. Berrange  if has 'stap' ; then
4663c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4664c276b17dSDaniel P. Berrange  fi
4665b3d08c02SDaniel P. Berrangefi
4666b3d08c02SDaniel P. Berrange
46677e24e92aSStefan Hajnoczi##########################################
4668519175a2SAlex Barcelo# check and set a backend for coroutine
4669d0e2fce5SAneesh Kumar K.V
46707c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
467133c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
467233c53c54SDaniel P. Berrange# specific one.
46737c2acc70SPeter Maydell
46747c2acc70SPeter Maydellucontext_works=no
4675d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4676d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4677d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4678cdf84806SPeter Maydell#ifdef __stub_makecontext
4679cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4680cdf84806SPeter Maydell#endif
468175cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4682d0e2fce5SAneesh Kumar K.VEOF
4683d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
46847c2acc70SPeter Maydell    ucontext_works=yes
4685d0e2fce5SAneesh Kumar K.V  fi
4686519175a2SAlex Barcelofi
46877c2acc70SPeter Maydell
46887c2acc70SPeter Maydellif test "$coroutine" = ""; then
46897c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
46907c2acc70SPeter Maydell    coroutine=win32
46917c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
46927c2acc70SPeter Maydell    coroutine=ucontext
4693519175a2SAlex Barcelo  else
46947c2acc70SPeter Maydell    coroutine=sigaltstack
46957c2acc70SPeter Maydell  fi
46967c2acc70SPeter Maydellelse
46977c2acc70SPeter Maydell  case $coroutine in
46987c2acc70SPeter Maydell  windows)
46997c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
47007c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
47017c2acc70SPeter Maydell    fi
47027c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
47037c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
47047c2acc70SPeter Maydell    coroutine=win32
47057c2acc70SPeter Maydell    ;;
47067c2acc70SPeter Maydell  ucontext)
47077c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
47087c2acc70SPeter Maydell      feature_not_found "ucontext"
47097c2acc70SPeter Maydell    fi
47107c2acc70SPeter Maydell    ;;
471133c53c54SDaniel P. Berrange  sigaltstack)
47127c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
47137c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
47147c2acc70SPeter Maydell    fi
47157c2acc70SPeter Maydell    ;;
47167c2acc70SPeter Maydell  *)
471776ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
47187c2acc70SPeter Maydell    ;;
47197c2acc70SPeter Maydell  esac
4720d0e2fce5SAneesh Kumar K.Vfi
4721d0e2fce5SAneesh Kumar K.V
472270c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
472370c60c08SStefan Hajnoczi  coroutine_pool=yes
472470c60c08SStefan Hajnoczifi
472570c60c08SStefan Hajnoczi
47267d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
47277d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
47287d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
47297d992e4dSPeter Lieven  fi
47307d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
47317d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
47327d992e4dSPeter Lieven    coroutine_pool=no
47337d992e4dSPeter Lieven  fi
47347d992e4dSPeter Lievenfi
47357d992e4dSPeter Lieven
47367d992e4dSPeter Lieven
4737d0e2fce5SAneesh Kumar K.V##########################################
4738d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4739d2042378SAneesh Kumar K.V
47404e1797f9SStefan Weilopen_by_handle_at=no
4741d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4742d2042378SAneesh Kumar K.V#include <fcntl.h>
4743acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4744acc55ba8SStefan Weil# error missing definition
4745acc55ba8SStefan Weil#else
474675cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4747acc55ba8SStefan Weil#endif
4748d2042378SAneesh Kumar K.VEOF
4749d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4750d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4751d2042378SAneesh Kumar K.Vfi
4752d2042378SAneesh Kumar K.V
4753e06a765eSHarsh Prateek Bora########################################
4754e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4755e06a765eSHarsh Prateek Bora
4756e06a765eSHarsh Prateek Boralinux_magic_h=no
4757e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4758e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4759e06a765eSHarsh Prateek Boraint main(void) {
476075cafad7SStefan Weil  return 0;
4761e06a765eSHarsh Prateek Bora}
4762e06a765eSHarsh Prateek BoraEOF
4763e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4764e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4765e06a765eSHarsh Prateek Borafi
4766e06a765eSHarsh Prateek Bora
47678ab1bf12SLuiz Capitulino########################################
4768c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4769c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4770c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4771c95e3080SKevin Wolf# only a warning.
4772c95e3080SKevin Wolf#
4773c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4774c95e3080SKevin Wolf# the build doesn't fail anyway.
4775c95e3080SKevin Wolf
477606d71fa1SPeter Maydellpragma_disable_unused_but_set=no
477706d71fa1SPeter Maydellcat > $TMPC << EOF
4778e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
477906d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4780c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4781e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4782c95e3080SKevin Wolf
478306d71fa1SPeter Maydellint main(void) {
478406d71fa1SPeter Maydell    return 0;
478506d71fa1SPeter Maydell}
478606d71fa1SPeter MaydellEOF
478706d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4788cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4789c95e3080SKevin Wolfelse
4790c95e3080SKevin Wolf    werror=no
479106d71fa1SPeter Maydellfi
479206d71fa1SPeter Maydell
479306d71fa1SPeter Maydell########################################
4794541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
47953f4349dcSKevin Wolf
47963f4349dcSKevin Wolfvalgrind_h=no
47973f4349dcSKevin Wolfcat > $TMPC << EOF
47983f4349dcSKevin Wolf#include <valgrind/valgrind.h>
47993f4349dcSKevin Wolfint main(void) {
48003f4349dcSKevin Wolf  return 0;
48013f4349dcSKevin Wolf}
48023f4349dcSKevin WolfEOF
48033f4349dcSKevin Wolfif compile_prog "" "" ; then
48043f4349dcSKevin Wolf    valgrind_h=yes
48053f4349dcSKevin Wolffi
48063f4349dcSKevin Wolf
48073f4349dcSKevin Wolf########################################
48088ab1bf12SLuiz Capitulino# check if environ is declared
48098ab1bf12SLuiz Capitulino
48108ab1bf12SLuiz Capitulinohas_environ=no
48118ab1bf12SLuiz Capitulinocat > $TMPC << EOF
48128ab1bf12SLuiz Capitulino#include <unistd.h>
48138ab1bf12SLuiz Capitulinoint main(void) {
4814c075a723SBlue Swirl    environ = 0;
48158ab1bf12SLuiz Capitulino    return 0;
48168ab1bf12SLuiz Capitulino}
48178ab1bf12SLuiz CapitulinoEOF
48188ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
48198ab1bf12SLuiz Capitulino    has_environ=yes
48208ab1bf12SLuiz Capitulinofi
48218ab1bf12SLuiz Capitulino
482276a347e1SRichard Henderson########################################
482376a347e1SRichard Henderson# check if cpuid.h is usable.
482476a347e1SRichard Henderson
482576a347e1SRichard Hendersoncat > $TMPC << EOF
482676a347e1SRichard Henderson#include <cpuid.h>
482776a347e1SRichard Hendersonint main(void) {
4828774d566cSPeter Maydell    unsigned a, b, c, d;
4829774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4830774d566cSPeter Maydell
4831774d566cSPeter Maydell    if (max >= 1) {
4832774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4833774d566cSPeter Maydell    }
4834774d566cSPeter Maydell
4835774d566cSPeter Maydell    if (max >= 7) {
4836774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4837774d566cSPeter Maydell    }
4838774d566cSPeter Maydell
483976a347e1SRichard Henderson    return 0;
484076a347e1SRichard Henderson}
484176a347e1SRichard HendersonEOF
484276a347e1SRichard Hendersonif compile_prog "" "" ; then
484376a347e1SRichard Henderson    cpuid_h=yes
484476a347e1SRichard Hendersonfi
484576a347e1SRichard Henderson
48465dd89908SRichard Henderson##########################################
48475dd89908SRichard Henderson# avx2 optimization requirement check
48485dd89908SRichard Henderson#
48495dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
48505dd89908SRichard Henderson# since we won't be able to select the new routines.
48515dd89908SRichard Henderson
48525dd89908SRichard Hendersonif test $cpuid_h = yes; then
48535dd89908SRichard Henderson  cat > $TMPC << EOF
48545dd89908SRichard Henderson#pragma GCC push_options
48555dd89908SRichard Henderson#pragma GCC target("avx2")
48565dd89908SRichard Henderson#include <cpuid.h>
48575dd89908SRichard Henderson#include <immintrin.h>
48585dd89908SRichard Hendersonstatic int bar(void *a) {
48595dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
48605dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
48615dd89908SRichard Henderson}
48625dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
48635dd89908SRichard HendersonEOF
48645dd89908SRichard Henderson  if compile_object "" ; then
48655dd89908SRichard Henderson    avx2_opt="yes"
48665dd89908SRichard Henderson  fi
48675dd89908SRichard Hendersonfi
48685dd89908SRichard Henderson
4869f540166bSRichard Henderson########################################
4870f540166bSRichard Henderson# check if __[u]int128_t is usable.
4871f540166bSRichard Henderson
4872f540166bSRichard Hendersonint128=no
4873f540166bSRichard Hendersoncat > $TMPC << EOF
4874a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4875a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4876a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4877a00f66abSStefan Weil# endif
4878a00f66abSStefan Weil#endif
4879f540166bSRichard Henderson__int128_t a;
4880f540166bSRichard Henderson__uint128_t b;
4881f540166bSRichard Hendersonint main (void) {
4882f540166bSRichard Henderson  a = a + b;
4883f540166bSRichard Henderson  b = a * b;
4884464e3671SPeter Maydell  a = a * a;
4885f540166bSRichard Henderson  return 0;
4886f540166bSRichard Henderson}
4887f540166bSRichard HendersonEOF
4888f540166bSRichard Hendersonif compile_prog "" "" ; then
4889f540166bSRichard Henderson    int128=yes
4890f540166bSRichard Hendersonfi
489176a347e1SRichard Henderson
48927ebee43eSRichard Henderson#########################################
48937ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
48947ebee43eSRichard Henderson
48957ebee43eSRichard Hendersonatomic128=no
48967ebee43eSRichard Hendersonif test "$int128" = "yes"; then
48977ebee43eSRichard Henderson  cat > $TMPC << EOF
48987ebee43eSRichard Hendersonint main(void)
48997ebee43eSRichard Henderson{
49007ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
49017ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
49027ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
49037ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
49047ebee43eSRichard Henderson  return 0;
49057ebee43eSRichard Henderson}
49067ebee43eSRichard HendersonEOF
49077ebee43eSRichard Henderson  if compile_prog "" "" ; then
49087ebee43eSRichard Henderson    atomic128=yes
49097ebee43eSRichard Henderson  fi
49107ebee43eSRichard Hendersonfi
49117ebee43eSRichard Henderson
4912df79b996SRichard Henderson#########################################
4913df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4914df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4915df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4916df79b996SRichard Henderson
4917df79b996SRichard Hendersoncat > $TMPC << EOF
4918df79b996SRichard Henderson#include <stdint.h>
4919df79b996SRichard Hendersonint main(void)
4920df79b996SRichard Henderson{
4921df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4922df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4923df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4924df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4925df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4926df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4927df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4928df79b996SRichard Henderson#else
4929df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4930df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4931df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4932df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4933df79b996SRichard Henderson#endif
4934df79b996SRichard Henderson  return 0;
4935df79b996SRichard Henderson}
4936df79b996SRichard HendersonEOF
4937df79b996SRichard Hendersonif compile_prog "" "" ; then
4938df79b996SRichard Henderson  atomic64=yes
4939df79b996SRichard Hendersonfi
4940df79b996SRichard Henderson
49411e6e9acaSRichard Henderson########################################
49421e6e9acaSRichard Henderson# check if getauxval is available.
49431e6e9acaSRichard Henderson
49441e6e9acaSRichard Hendersongetauxval=no
49451e6e9acaSRichard Hendersoncat > $TMPC << EOF
49461e6e9acaSRichard Henderson#include <sys/auxv.h>
49471e6e9acaSRichard Hendersonint main(void) {
49481e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
49491e6e9acaSRichard Henderson}
49501e6e9acaSRichard HendersonEOF
49511e6e9acaSRichard Hendersonif compile_prog "" "" ; then
49521e6e9acaSRichard Henderson    getauxval=yes
49531e6e9acaSRichard Hendersonfi
49541e6e9acaSRichard Henderson
4955fd0e6053SJohn Snow########################################
4956fd0e6053SJohn Snow# check if ccache is interfering with
4957fd0e6053SJohn Snow# semantic analysis of macros
4958fd0e6053SJohn Snow
49595e4dfd3dSJohn Snowunset CCACHE_CPP2
4960fd0e6053SJohn Snowccache_cpp2=no
4961fd0e6053SJohn Snowcat > $TMPC << EOF
4962fd0e6053SJohn Snowstatic const int Z = 1;
4963fd0e6053SJohn Snow#define fn() ({ Z; })
4964fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4965fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4966fd0e6053SJohn Snow#define ID(X) (X)
4967fd0e6053SJohn Snowint main(int argc, char *argv[])
4968fd0e6053SJohn Snow{
4969fd0e6053SJohn Snow    int x = 0, y = 0;
4970fd0e6053SJohn Snow    x = ID(x);
4971fd0e6053SJohn Snow    x = fn();
4972fd0e6053SJohn Snow    fn();
4973fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4974fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4975fd0e6053SJohn Snow    return 0;
4976fd0e6053SJohn Snow}
4977fd0e6053SJohn SnowEOF
4978fd0e6053SJohn Snow
4979fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4980fd0e6053SJohn Snow    ccache_cpp2=yes
4981fd0e6053SJohn Snowfi
4982fd0e6053SJohn Snow
4983b553a042SJohn Snow#################################################
4984b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4985b553a042SJohn Snow
4986b553a042SJohn Snowif test "$fortify_source" != "no"; then
4987b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4988b553a042SJohn Snow    fortify_source="no";
4989e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4990cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4991b553a042SJohn Snow    fortify_source="no";
4992b553a042SJohn Snow  else
4993b553a042SJohn Snow    fortify_source="yes"
4994b553a042SJohn Snow  fi
4995b553a042SJohn Snowfi
4996b553a042SJohn Snow
4997d2042378SAneesh Kumar K.V##########################################
4998277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4999277abf15SJan Vesely
5000277abf15SJan Veselyhave_fsxattr=no
5001277abf15SJan Veselycat > $TMPC << EOF
5002277abf15SJan Vesely#include <linux/fs.h>
5003277abf15SJan Veselystruct fsxattr foo;
5004277abf15SJan Veselyint main(void) {
5005277abf15SJan Vesely  return 0;
5006277abf15SJan Vesely}
5007277abf15SJan VeselyEOF
5008277abf15SJan Veselyif compile_prog "" "" ; then
5009277abf15SJan Vesely    have_fsxattr=yes
5010277abf15SJan Veselyfi
5011277abf15SJan Vesely
5012b66e10e4SPeter Maydell##########################################
5013b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5014575b22b1SLaurent Vivierhave_rtnetlink=no
5015575b22b1SLaurent Viviercat > $TMPC << EOF
5016575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5017575b22b1SLaurent Vivierint main(void) {
5018575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5019575b22b1SLaurent Vivier}
5020575b22b1SLaurent VivierEOF
5021575b22b1SLaurent Vivierif compile_prog "" "" ; then
5022575b22b1SLaurent Vivier    have_rtnetlink=yes
5023575b22b1SLaurent Vivierfi
5024575b22b1SLaurent Vivier
50256a02c806SStefan Hajnoczi##########################################
50266a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
50276a02c806SStefan Hajnoczihave_af_vsock=no
50286a02c806SStefan Hajnoczicat > $TMPC << EOF
50296a02c806SStefan Hajnoczi#include <errno.h>
50306a02c806SStefan Hajnoczi#include <sys/types.h>
50316a02c806SStefan Hajnoczi#include <sys/socket.h>
50326a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
50336a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
50346a02c806SStefan Hajnoczi#endif
50356a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
50366a02c806SStefan Hajnocziint main(void) {
50376a02c806SStefan Hajnoczi    int sock, ret;
50386a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
50396a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
50406a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
50416a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
50426a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
50436a02c806SStefan Hajnoczi        return 0;
50446a02c806SStefan Hajnoczi    }
50456a02c806SStefan Hajnoczi    return -1;
50466a02c806SStefan Hajnoczi}
50476a02c806SStefan HajnocziEOF
50486a02c806SStefan Hajnocziif compile_prog "" "" ; then
50496a02c806SStefan Hajnoczi    have_af_vsock=yes
50506a02c806SStefan Hajnoczifi
50516a02c806SStefan Hajnoczi
5052f0d92b56SLongpeng(Mike)##########################################
5053f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5054f0d92b56SLongpeng(Mike)hava_afalg=no
5055f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5056f0d92b56SLongpeng(Mike)#include <errno.h>
5057f0d92b56SLongpeng(Mike)#include <sys/types.h>
5058f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5059f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5060f0d92b56SLongpeng(Mike)int main(void) {
5061f0d92b56SLongpeng(Mike)    int sock;
5062f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5063f0d92b56SLongpeng(Mike)    return sock;
5064f0d92b56SLongpeng(Mike)}
5065f0d92b56SLongpeng(Mike)EOF
5066f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5067f0d92b56SLongpeng(Mike)    have_afalg=yes
5068f0d92b56SLongpeng(Mike)fi
5069f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5070f0d92b56SLongpeng(Mike)then
5071f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5072f0d92b56SLongpeng(Mike)    then
5073f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5074f0d92b56SLongpeng(Mike)    fi
5075f0d92b56SLongpeng(Mike)fi
5076f0d92b56SLongpeng(Mike)
5077f0d92b56SLongpeng(Mike)
50786969ec6cSJames Clarke#################################################
5079c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5080d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5081c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5082c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5083c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5084c97d6d2cSSergio Andres Gomez Del RealEOF
5085c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5086c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5087c97d6d2cSSergio Andres Gomez Del Real  else
5088c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5089c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5090c97d6d2cSSergio Andres Gomez Del Real  fi
5091c97d6d2cSSergio Andres Gomez Del Realfi
5092c97d6d2cSSergio Andres Gomez Del Real
5093c97d6d2cSSergio Andres Gomez Del Real#################################################
50946969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
50956969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
50966969ec6cSJames Clarke# given. It does no harm to give it on other
50976969ec6cSJames Clarke# platforms too.
50986969ec6cSJames Clarke
50996969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
51006969ec6cSJames Clarke#       contains -Wmissing-prototypes
51016969ec6cSJames Clarkecat > $TMPC << EOF
51026969ec6cSJames Clarkeextern int foo(void);
51036969ec6cSJames Clarkeint foo(void) { return 0; }
51046969ec6cSJames ClarkeEOF
51056969ec6cSJames Clarkeif ! compile_object ""; then
51066969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
51076969ec6cSJames Clarkefi
51087ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
51097ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
51107ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
51117ecf44a5SPaolo Bonzini    break
51127ecf44a5SPaolo Bonzini  fi
51137ecf44a5SPaolo Bonzinidone
51147ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
51157ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
51166969ec6cSJames Clarkefi
51176969ec6cSJames Clarke
5118277abf15SJan Vesely##########################################
51194d04351fSChristopher Covington# check for sysmacros.h
51204d04351fSChristopher Covington
51214d04351fSChristopher Covingtonhave_sysmacros=no
51224d04351fSChristopher Covingtoncat > $TMPC << EOF
51234d04351fSChristopher Covington#include <sys/sysmacros.h>
51244d04351fSChristopher Covingtonint main(void) {
51254d04351fSChristopher Covington    return makedev(0, 0);
51264d04351fSChristopher Covington}
51274d04351fSChristopher CovingtonEOF
51284d04351fSChristopher Covingtonif compile_prog "" "" ; then
51294d04351fSChristopher Covington    have_sysmacros=yes
51304d04351fSChristopher Covingtonfi
51314d04351fSChristopher Covington
51324d04351fSChristopher Covington##########################################
5133da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5134da92c3ffSAshish Mittal# Check if libvxhs is installed
5135da92c3ffSAshish Mittal
5136da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5137da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5138da92c3ffSAshish Mittal#include <stdint.h>
5139da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5140da92c3ffSAshish Mittal
5141da92c3ffSAshish Mittalvoid *vxhs_callback;
5142da92c3ffSAshish Mittal
5143da92c3ffSAshish Mittalint main(void) {
5144da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5145da92c3ffSAshish Mittal    return 0;
5146da92c3ffSAshish Mittal}
5147da92c3ffSAshish MittalEOF
5148da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5149da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5150da92c3ffSAshish Mittal    vxhs=yes
5151da92c3ffSAshish Mittal  else
5152da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5153da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5154da92c3ffSAshish Mittal    fi
5155da92c3ffSAshish Mittal    vxhs=no
5156da92c3ffSAshish Mittal  fi
5157da92c3ffSAshish Mittalfi
5158da92c3ffSAshish Mittal
5159da92c3ffSAshish Mittal##########################################
516049e00a18SAndreas Grapentin# check for _Static_assert()
516149e00a18SAndreas Grapentin
516249e00a18SAndreas Grapentinhave_static_assert=no
516349e00a18SAndreas Grapentincat > $TMPC << EOF
516449e00a18SAndreas Grapentin_Static_assert(1, "success");
516549e00a18SAndreas Grapentinint main(void) {
516649e00a18SAndreas Grapentin    return 0;
516749e00a18SAndreas Grapentin}
516849e00a18SAndreas GrapentinEOF
516949e00a18SAndreas Grapentinif compile_prog "" "" ; then
517049e00a18SAndreas Grapentin    have_static_assert=yes
517149e00a18SAndreas Grapentinfi
517249e00a18SAndreas Grapentin
517349e00a18SAndreas Grapentin##########################################
5174e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5175e674605fSTomáš Golembiovský
5176e674605fSTomáš Golembiovskýhave_utmpx=no
5177e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5178e674605fSTomáš Golembiovský#include <utmpx.h>
5179e674605fSTomáš Golembiovskýstruct utmpx user_info;
5180e674605fSTomáš Golembiovskýint main(void) {
5181e674605fSTomáš Golembiovský    return 0;
5182e674605fSTomáš Golembiovský}
5183e674605fSTomáš GolembiovskýEOF
5184e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5185e674605fSTomáš Golembiovský    have_utmpx=yes
5186e674605fSTomáš Golembiovskýfi
5187e674605fSTomáš Golembiovský
5188e674605fSTomáš Golembiovský##########################################
5189e86ecd4bSJuan Quintela# End of CC checks
5190e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5191e86ecd4bSJuan Quintela
51921d728c39SBlue Swirlif test "$gcov" = "yes" ; then
51931d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
51941d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5195b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5196e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5197ce278618SPeter Maydellelif test "$debug" = "no"; then
5198ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5199e86ecd4bSJuan Quintelafi
5200a316e378SJuan Quintela
52016542aa9cSPeter Lieven##########################################
52026542aa9cSPeter Lieven# Do we have libnfs
52036542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5204b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
52056542aa9cSPeter Lieven    libnfs="yes"
52066542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
52076542aa9cSPeter Lieven  else
52086542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
52098efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
52106542aa9cSPeter Lieven    fi
52116542aa9cSPeter Lieven    libnfs="no"
52126542aa9cSPeter Lieven  fi
52136542aa9cSPeter Lievenfi
52141d728c39SBlue Swirl
52156ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
52166ca026cbSPeter Maydellif test "$werror" = "yes"; then
52176ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
52186ca026cbSPeter Maydellfi
52196ca026cbSPeter Maydell
5220e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5221e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
52221156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5223e86ecd4bSJuan Quintela    fi
5224e86ecd4bSJuan Quintelafi
5225e86ecd4bSJuan Quintela
522694dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
522794dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
522894dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
522994dd53c5SGerd Hoffmannelse
523094dd53c5SGerd Hoffmann    POD2MAN="pod2man"
523194dd53c5SGerd Hoffmannfi
523294dd53c5SGerd Hoffmann
5233952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5234952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5235952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5236e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5237952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5238952afb71SBlue Swirl        fi
5239952afb71SBlue Swirl    done
5240952afb71SBlue Swirlfi
5241952afb71SBlue Swirl
524210ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5243e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5244528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5245834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
52465a67135aSbellard
5247e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5248e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5249e0580342SKamil Rytarowski  ivshmem=yes
5250e0580342SKamil Rytarowskifi
5251e0580342SKamil Rytarowski
52524b1c11fdSDaniel P. Berrangetools=""
52534b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5254ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
52554b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
52564b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5257b1449edbSKamil Rytarowski  fi
5258b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5259a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
52604b1c11fdSDaniel P. Berrange  fi
52614b1c11fdSDaniel P. Berrangefi
52624b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5263b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5264b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5265983eef5aSMeador Inge      virtfs=yes
526617bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5267983eef5aSMeador Inge    else
5268983eef5aSMeador Inge      if test "$virtfs" = yes; then
5269b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5270983eef5aSMeador Inge      fi
527117500370SAndreas Färber      virtfs=no
5272983eef5aSMeador Inge    fi
5273fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5274fe8fc5aeSPaolo Bonzini      mpath=yes
5275fe8fc5aeSPaolo Bonzini    else
5276fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5277fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5278fe8fc5aeSPaolo Bonzini      fi
5279fe8fc5aeSPaolo Bonzini      mpath=no
5280fe8fc5aeSPaolo Bonzini    fi
5281b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5282b855f8d1SPaolo Bonzini  else
5283b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5284b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5285b855f8d1SPaolo Bonzini    fi
5286b855f8d1SPaolo Bonzini    virtfs=no
5287fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5288fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5289fe8fc5aeSPaolo Bonzini    fi
5290fe8fc5aeSPaolo Bonzini    mpath=no
529117bff52bSM. Mohan Kumar  fi
52926a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
52936a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
52946a021536SGerd Hoffmann  fi
5295ff69fd8cSLaurent Vivierfi
52969d6bc27bSMichael Roth
52979d6bc27bSMichael Roth# Probe for guest agent support/options
52989d6bc27bSMichael Roth
5299e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5300b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5301fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5302e8ef31a3SMichael Tokarev      guest_agent=yes
5303e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5304e8ef31a3SMichael Tokarev      guest_agent=no
5305e8ef31a3SMichael Tokarev  else
5306e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5307ca35f780SPaolo Bonzini  fi
53084b1c11fdSDaniel P. Berrangefi
5309ca35f780SPaolo Bonzini
53109d6bc27bSMichael Roth# Guest agent Window MSI  package
53119d6bc27bSMichael Roth
53129d6bc27bSMichael Rothif test "$guest_agent" != yes; then
53139d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
53149d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
53159d6bc27bSMichael Roth  fi
53169d6bc27bSMichael Roth  guest_agent_msi=no
53179d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
53189d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
53199d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
53209d6bc27bSMichael Roth  fi
53219d6bc27bSMichael Roth  guest_agent_msi=no
53229d6bc27bSMichael Rothelif ! has wixl; then
53239d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
53249d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
53259d6bc27bSMichael Roth  fi
53269d6bc27bSMichael Roth  guest_agent_msi=no
53271a34904eSMichael Rothelse
53281a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
53291a34904eSMichael Roth  # disabled explicitly
53301a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
53311a34904eSMichael Roth    guest_agent_msi=yes
53321a34904eSMichael Roth  fi
53339d6bc27bSMichael Rothfi
53349d6bc27bSMichael Roth
53351a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
53369d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
53379d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
53389d6bc27bSMichael Roth  fi
53399d6bc27bSMichael Roth
53409d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
53419d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
53429d6bc27bSMichael Roth  fi
53439d6bc27bSMichael Roth
53449d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
53459d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
53469d6bc27bSMichael Roth  fi
53479d6bc27bSMichael Roth
53489d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
534989138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
53509d6bc27bSMichael Roth  fi
53519d6bc27bSMichael Roth
535289138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
53539d6bc27bSMichael Roth
53549d6bc27bSMichael Roth  case "$cpu" in
53559d6bc27bSMichael Roth  x86_64)
53569d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
53579d6bc27bSMichael Roth    ;;
53589d6bc27bSMichael Roth  i386)
53599d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
53609d6bc27bSMichael Roth    ;;
53619d6bc27bSMichael Roth  *)
53629d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
53639d6bc27bSMichael Roth    ;;
53649d6bc27bSMichael Roth  esac
53659d6bc27bSMichael Rothfi
53669d6bc27bSMichael Roth
5367ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5368ca35f780SPaolo Bonziniroms=
5369ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5370ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5371ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5372e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5373c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5374c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5375c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5376e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5377e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5378ca35f780SPaolo Bonzini            roms="optionrom"
5379e57218b6SPeter Maydell            break
5380e57218b6SPeter Maydell        fi
5381e57218b6SPeter Maydell    done
5382ca35f780SPaolo Bonzinifi
5383d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
538439ac8455SDavid Gibson  roms="$roms spapr-rtas"
538539ac8455SDavid Gibsonfi
5386ca35f780SPaolo Bonzini
53879933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
53889933c305SChristian Borntraeger  roms="$roms s390-ccw"
53899933c305SChristian Borntraegerfi
53909933c305SChristian Borntraeger
5391964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
539292fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5393964c6fa1SRichard Henderson  textseg_addr=
5394964c6fa1SRichard Henderson  case "$cpu" in
5395479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5396479eb121SRichard Henderson      # ??? Rationale for choosing this address
5397964c6fa1SRichard Henderson      textseg_addr=0x60000000
5398964c6fa1SRichard Henderson      ;;
5399964c6fa1SRichard Henderson    mips)
5400479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5401479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5402479eb121SRichard Henderson      textseg_addr=0x60000000
5403964c6fa1SRichard Henderson      ;;
5404964c6fa1SRichard Henderson  esac
5405964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5406964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5407964c6fa1SRichard Henderson    int main(void) { return 0; }
5408964c6fa1SRichard HendersonEOF
5409964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5410964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5411964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5412964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5413964c6fa1SRichard Henderson      # at least.
541492fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
541592fe2ba8SPeter Maydell        error_exit \
541692fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
541792fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
541892fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
541992fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
542092fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
542192fe2ba8SPeter Maydell            "--disable-user option to configure."
542292fe2ba8SPeter Maydell      fi
542392fe2ba8SPeter Maydell
5424964c6fa1SRichard Henderson      $ld --verbose | sed \
5425964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5426964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5427964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5428964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5429964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5430964c6fa1SRichard Henderson    fi
5431964c6fa1SRichard Henderson  fi
5432964c6fa1SRichard Hendersonfi
5433964c6fa1SRichard Henderson
543411cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
543511cde1c8SBruno 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.
543611cde1c8SBruno Dominguezif has $cxx; then
543711cde1c8SBruno Dominguez    cat > $TMPC <<EOF
543811cde1c8SBruno Dominguezint c_function(void);
543911cde1c8SBruno Dominguezint main(void) { return c_function(); }
544011cde1c8SBruno DominguezEOF
544111cde1c8SBruno Dominguez
544211cde1c8SBruno Dominguez    compile_object
544311cde1c8SBruno Dominguez
544411cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
544511cde1c8SBruno Dominguezextern "C" {
544611cde1c8SBruno Dominguez   int c_function(void);
544711cde1c8SBruno Dominguez}
544811cde1c8SBruno Dominguezint c_function(void) { return 42; }
544911cde1c8SBruno DominguezEOF
545011cde1c8SBruno Dominguez
545111cde1c8SBruno Dominguez    update_cxxflags
545211cde1c8SBruno Dominguez
545311cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
545411cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
545511cde1c8SBruno Dominguez        :
545611cde1c8SBruno Dominguez    else
545711cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
545811cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
545911cde1c8SBruno Dominguez        cxx=
546011cde1c8SBruno Dominguez    fi
546111cde1c8SBruno Dominguezelse
546211cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
546311cde1c8SBruno Dominguez    cxx=
546411cde1c8SBruno Dominguezfi
546511cde1c8SBruno Dominguez
546602d34f62SCole Robinsonecho_version() {
546702d34f62SCole Robinson    if test "$1" = "yes" ; then
546802d34f62SCole Robinson        echo "($2)"
546902d34f62SCole Robinson    fi
547002d34f62SCole Robinson}
547102d34f62SCole Robinson
547250e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
547350e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
547450e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
54755ca9388aSGerd Hoffmann
54767d13299dSbellardecho "Install prefix    $prefix"
547789138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
54783d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
547989138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
548089138857SStefan Weilecho "library directory $(eval echo $libdir)"
548189138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
548289138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
548389138857SStefan Weilecho "include directory $(eval echo $includedir)"
548489138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
548511d9f695Sbellardif test "$mingw32" = "no" ; then
548689138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
548789138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
548843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
54895a699bbbSLaszlo Ersekelse
54905a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5491d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
549211d9f695Sbellardfi
54935a67135aSbellardecho "Source path       $source_path"
5494cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
5495aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
54967d13299dSbellardecho "C compiler        $cc"
549783469015Sbellardecho "Host C compiler   $host_cc"
549883f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
54993c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
550045d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
55010c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5502a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
55030c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
55047d13299dSbellardecho "make              $make"
55056a882643Spbrookecho "install           $install"
5506c886edfbSBlue Swirlecho "python            $python"
5507e2d8830eSBradif test "$slirp" = "yes" ; then
5508e2d8830eSBrad    echo "smbd              $smbd"
5509e2d8830eSBradfi
551017969268SFam Zhengecho "module support    $modules"
5511a98fd896Sbellardecho "host CPU          $cpu"
5512de83cd02Sbellardecho "host big endian   $bigendian"
551397a847bcSbellardecho "target list       $target_list"
55147d13299dSbellardecho "gprof enabled     $gprof"
551503b4fe7dSaliguoriecho "sparse enabled    $sparse"
55161625af87Saliguoriecho "strip binaries    $strip_opt"
551705c2a3e7Sbellardecho "profiler          $profiler"
551843ce4dfeSbellardecho "static build      $static"
55195b0753e0Sbellardif test "$darwin" = "yes" ; then
55205b0753e0Sbellard    echo "Cocoa support     $cocoa"
55215b0753e0Sbellardfi
552289138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
552389138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5524925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
552589138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5526a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5527ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5528b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
552991bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
553037788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
553189138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5532fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
55339a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
55344d3b6f6eSbalrogecho "curses support    $curses"
55359d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5536769ce76dSAlexander Grafecho "curl support      $curl"
553767b915a5Sbellardecho "mingw32 support   $mingw32"
55380c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5539b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5540b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5541983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5542fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
5543821601eaSJes Sorensenecho "VNC support       $vnc"
5544821601eaSJes Sorensenif test "$vnc" = "yes" ; then
55452f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
55462f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5547efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5548821601eaSJes Sorensenfi
55493142255cSblueswir1if test -n "$sparc_cpu"; then
55503142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
55513142255cSblueswir1fi
5552e37630caSaliguoriecho "xen support       $xen"
55533996e85cSPaul Durrantif test "$xen" = "yes" ; then
55543996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
555564a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
55563996e85cSPaul Durrantfi
55572e4d9fb1Saurel32echo "brlapi support    $brlapi"
5558a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5559a25dba17SJuan Quintelaecho "Documentation     $docs"
556040d6444eSAvi Kivityecho "PIE               $pie"
55618a16d273Sthsecho "vde support       $vde"
556258952137SVincenzo Maffioneecho "netmap support    $netmap"
55635c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5564758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
556577755340Sthsecho "Install blobs     $blobs"
5566b31a0277SJuan Quintelaecho "KVM support       $kvm"
5567b0cb0a66SVincent Palatinecho "HAX support       $hax"
5568c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
5569b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5570b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5571b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
55729195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5573b3f6ea7eSPaolo Bonzinifi
55745a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
5575b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5576f652e6afSaurel32echo "fdt support       $fdt"
5577ceb42de8Saliguoriecho "preadv support    $preadv"
55785f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5579e78815a5SAndreas Färberecho "madvise           $madvise"
5580e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
558147e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5582d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
55835e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5584fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5585e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
55865b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5587713572a7SMarc-André Lureauif have_backend "simple"; then
55889410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5589e00e36fbSStefan Weilfi
559089138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5591f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5592dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
55937b02f544SMarc-André Lureauecho "smartcard support $smartcard"
55942b2325ffSGerd Hoffmannecho "libusb            $libusb"
559569354a83SHans de Goedeecho "usb net redir     $usb_redir"
5596da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5597014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5598c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
55996542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5600d138cee9SMichael Rothecho "build guest agent $guest_agent"
5601d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
560250cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
56034c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5604f794573eSEduardo Otuboecho "seccomp support   $seccomp"
56057c2acc70SPeter Maydellecho "coroutine backend $coroutine"
560670c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
56077d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5608f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5609eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
56101d728c39SBlue Swirlecho "gcov              $gcov_tool"
56111d728c39SBlue Swirlecho "gcov enabled      $gcov"
5612ab214c29SStefan Bergerecho "TPM support       $tpm"
56130a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
56143b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
5615f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
56163556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5617ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5618607dacd0Sqiaonuohanecho "lzo support       $lzo"
5619607dacd0Sqiaonuohanecho "snappy support    $snappy"
56206b383c08SPeter Wuecho "bzip2 support     $bzip2"
5621a99d57bbSWanlong Gaoecho "NUMA host support $numa"
56222847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
56237b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
562499f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5625a6b1d4c0SChanglong Xieecho "replication support $replication"
5626da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
56278ca80760SRichard Hendersonecho "capstone          $capstone"
562867b915a5Sbellard
56291ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
563024b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5631e8cd23deSbellardfi
563297a847bcSbellard
5633898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5634898be3e0SPeter Maydell    echo
5635898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5636898be3e0SPeter Maydell    echo
5637898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5638898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5639898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5640898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5641898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5642898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5643898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5644898be3e0SPeter Maydellfi
5645898be3e0SPeter Maydell
5646898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5647898be3e0SPeter Maydell    echo
5648898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5649898be3e0SPeter Maydell    echo
5650c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5651c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5652898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5653898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5654898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5655898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5656898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5657898be3e0SPeter Maydellfi
5658898be3e0SPeter Maydell
565998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
566097a847bcSbellard
5661dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5662dbd99ae3SStefan Weil
566398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
566498ec69acSJuan Quintelaecho >> $config_host_mak
566598ec69acSJuan Quintela
5666e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
566799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
566899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
56693aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
56708bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
56710f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
567299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
567399d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
567422d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
56759afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
56763d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
56779afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5678e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
56795a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5680785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
56815a699bbbSLaszlo Ersekfi
5682f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5683f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
568411cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5685f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5686834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5687f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5688cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
5689aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5690f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
5691804edf29SJuan Quintela
569298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5693727e5283SPaolo Bonzini
5694f8393946Saurel32if test "$debug_tcg" = "yes" ; then
56952358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5696f8393946Saurel32fi
56971625af87Saliguoriif test "$strip_opt" = "yes" ; then
569852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
56991625af87Saliguorifi
57007d13299dSbellardif test "$bigendian" = "yes" ; then
5701e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
570297a847bcSbellardfi
570367b915a5Sbellardif test "$mingw32" = "yes" ; then
570498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
570589138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
57069fe6de94SBlue Swirl  version_major=${rc_version%%.*}
57079fe6de94SBlue Swirl  rc_version=${rc_version#*.}
57089fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
57099fe6de94SBlue Swirl  rc_version=${rc_version#*.}
57109fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
57119fe6de94SBlue Swirl  version_micro=0
57129fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
57139fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5714d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5715d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5716f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5717d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5718d9840e25STomoki Sekiyama  fi
571950cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
572050cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
572150cbebb9SMichael Roth  fi
57221a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
57239dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
57249dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
57259dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
57269dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
57279dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
57289dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
57299dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
57309dacf32dSYossi Hindin  fi
5731210fa556Spbrookelse
573235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5733210fa556Spbrookfi
5734128ab2ffSblueswir1
5735dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5736dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5737dffcb71cSMark McLoughlinfi
5738dffcb71cSMark McLoughlin
573983fb7adfSbellardif test "$darwin" = "yes" ; then
574098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
574183fb7adfSbellardfi
5742b29fe3edSmalc
5743ec530c81Sbellardif test "$solaris" = "yes" ; then
574498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5745ec530c81Sbellardfi
5746179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5747179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5748179cf400SAndreas Färberfi
574997a847bcSbellardif test "$static" = "yes" ; then
575098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
575197a847bcSbellardfi
57521ba16968SStefan Weilif test "$profiler" = "yes" ; then
57532358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
575405c2a3e7Sbellardfi
5755c20709aaSbellardif test "$slirp" = "yes" ; then
575698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5757e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5758c20709aaSbellardfi
57598a16d273Sthsif test "$vde" = "yes" ; then
576098ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5761e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
57628a16d273Sthsfi
576358952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
576458952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
576558952137SVincenzo Maffionefi
5766015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5767015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5768015a33bdSGongleifi
576947e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
577047e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
577147e98658SCorey Bryantfi
57722358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
57730c58ac1cSmalcfor drv in $audio_drv_list; do
577489138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
577598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
57760c58ac1cSmalcdone
5777b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5778b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5779b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5780b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5781b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
578267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
578367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
578467f86e8eSJuan Quintelafi
5785d5631638Smalcif test "$audio_win_int" = "yes" ; then
5786d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5787d5631638Smalcfi
5788b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5789b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5790821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5791821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5792821601eaSJes Sorensenfi
57932f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
579498ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
57952f9606b3Saliguorifi
5796821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
57972f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
57982f6f5c7aSCorentin Charyfi
5799821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5800efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5801efe556adSCorentin Charyfi
58026a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
58036a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
58046a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
58056a021536SGerd Hoffmannfi
580676655d6dSaliguoriif test "$fnmatch" = "yes" ; then
58072358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
580876655d6dSaliguorifi
5809dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5810dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5811dce512deSChristoph Hellwigfi
581289138857SStefan Weilqemu_version=$(head $source_path/VERSION)
581398ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
58142358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
581598ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
581698ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5817a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
581898ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5819cc8ae6deSpbrookfi
582017969268SFam Zhengif test "$modules" = "yes"; then
5821e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5822e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
582389138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
582417969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
582517969268SFam Zhengfi
58261ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
582798ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5828a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
58298ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
58308ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
583149ecc3faSbellardfi
583249ecc3faSbellardif test "$cocoa" = "yes" ; then
583398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
583449ecc3faSbellardfi
58354d3b6f6eSbalrogif test "$curses" = "yes" ; then
583698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5837ab4e5602SJan Kiszkafi
5838099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
58392358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5840099d6b0fSRiku Voipiofi
584140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
584240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
584340ff6d7eSKevin Wolffi
58443ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
58452358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
58463ce34dfbSvibisreenivasanfi
5847c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5848c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5849c2882b96SRiku Voipiofi
5850751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5851751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5852751bcc39SMarc-André Lureaufi
5853d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5854d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5855d0927938SUlrich Hechtfi
58563d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
58573d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
58583d4fa43eSKusanagi Kouichifi
5859b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5860b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5861b953f075SDenis V. Lunevfi
5862ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5863ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5864ed911435SKevin Wolffi
5865c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5866c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5867c727f47dSPeter Maydellfi
5868dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5869dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5870dace20dcSPeter Maydellfi
5871d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5872d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5873d0927938SUlrich Hechtfi
58744e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
58754e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
58764e0c6529SAlex Blighfi
5877cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5878cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5879cd758dd0SAlex Blighfi
58803b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
58813b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
58823b6edd16SPeter Maydellfi
58833b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
58843b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
58853b6edd16SPeter Maydellfi
5886a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5887a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5888a8fd1abaSPeter Maydellfi
588951834341SRiku Voipioif test "$timerfd" = "yes" ; then
589051834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
589151834341SRiku Voipiofi
58929af5c906SRiku Voipioif test "$setns" = "yes" ; then
58939af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
58949af5c906SRiku Voipiofi
589538860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
589638860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
589738860a03SAleksandar Markovicfi
58985a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
58995a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
59005a03cd00SAleksandar Markovicfi
59013b3f24adSaurel32if test "$inotify" = "yes" ; then
59022358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
59033b3f24adSaurel32fi
5904c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5905c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5906c05c7a73SRiku Voipiofi
5907401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
5908401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5909401bc051SPeter Maydellfi
59106ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
59116ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
59126ae9a1f4SJuan Quintelafi
59136ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
59146ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
59156ae9a1f4SJuan Quintelafi
5916769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5917d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5918b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
59196ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5920769ce76dSAlexander Graffi
59212e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
592298ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
59238eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
59242e4d9fb1Saurel32fi
5925fb599c9aSbalrogif test "$bluez" = "yes" ; then
592698ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5927ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5928fb599c9aSbalrogfi
5929d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
59309d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
59319d41401bSMichael S. Tsirkinfi
5932a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5933a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5934a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5935a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5936014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5937925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5938925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5939925a0400SGerd Hoffmann  fi
5940bbbf9bfbSStefan Weilfi
5941a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5942ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5943ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5944ddbb0d09SDaniel P. Berrangefi
5945b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5946b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5947b917da4cSDaniel P. Berrangefi
594891bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
594991bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
59501f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
59511f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
59521f923c70SLongpeng(Mike)  fi
595337788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
595437788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
595537788f25SDaniel P. Berrange  fi
595662893b67SDaniel P. Berrangefi
595791bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
595891bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5959becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5960fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5961fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5962fff2f982SDaniel P. Berrange  fi
5963ed754746SDaniel P. Berrangefi
59649a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
59659a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
59669a2fd434SDaniel P. Berrangefi
5967559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5968559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5969559607eaSDaniel P. Berrangefi
59706b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
59716b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
59726b39b063SEric Blakefi
5973277abf15SJan Vesely
5974277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5975277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5976277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5977277abf15SJan Vesely# if this macro is set.
5978277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5979277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5980277abf15SJan Veselyfi
5981bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5982bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5983a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5984a4ccabcfSAnthony Liguorifi
59859d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
59869d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
59879d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
59889d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
59899d9e1521SGerd Hoffmannfi
5990e37630caSaliguoriif test "$xen" = "yes" ; then
59916dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5992d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
599364a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
599464a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
599564a7ad6fSIan Campbell  fi
5996e37630caSaliguorifi
59975c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
59985c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
59995c6c3a6cSChristoph Hellwigfi
6000758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6001758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6002758e8e38SVenkateswararao Jujjuri (JV)fi
60034f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
60044f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
60054f26f2b6SAvi Kivityfi
6006983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6007758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6008758e8e38SVenkateswararao Jujjuri (JV)fi
6009fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6010fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
6011fe8fc5aeSPaolo Bonzinifi
60125e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
60135e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
60145e9be92dSNicholas Bellingerfi
6015e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
601603ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
601703ce5744SNikolay Nikolaevfi
6018fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6019fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6020fc0b9b0eSStefan Hajnoczifi
6021e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6022e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6023e6a74868SMarc-André Lureaufi
602477755340Sthsif test "$blobs" = "yes" ; then
602598ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
602677755340Sthsfi
6027bf9298b9Saliguoriif test "$iovec" = "yes" ; then
60282358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6029bf9298b9Saliguorifi
6030ceb42de8Saliguoriif test "$preadv" = "yes" ; then
60312358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6032ceb42de8Saliguorifi
6033f652e6afSaurel32if test "$fdt" = "yes" ; then
60343f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6035f652e6afSaurel32fi
6036dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6037dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6038dcc38d1cSMarcelo Tosattifi
6039b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6040b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
60419195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
60429195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
60439195b2c2SStefan Weil  fi
6044b3f6ea7eSPaolo Bonzinifi
60455f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
60465f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
60475f6b9e8fSBlue Swirlfi
6048e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6049e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6050e78815a5SAndreas Färberfi
6051e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6052e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6053e78815a5SAndreas Färberfi
605497a847bcSbellard
6055cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6056cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6057cd4ec0b4SGerd Hoffmannfi
6058cd4ec0b4SGerd Hoffmann
60597b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
60607b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
60617b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
60627b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6063111a38b0SRobert Relyeafi
6064111a38b0SRobert Relyea
60652b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
60662b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6067b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6068b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
60692b2325ffSGerd Hoffmannfi
60702b2325ffSGerd Hoffmann
607169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
607269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6073cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6074cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
607569354a83SHans de Goedefi
607669354a83SHans de Goede
6077da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6078da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6079da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6080014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6081014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6082014cb152SGerd Hoffmann  fi
608320ff075bSMichael Wallefi
608420ff075bSMichael Walle
60855a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
60865a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
60875a22ab71SYang Zhongfi
60885a22ab71SYang Zhong
608999f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
609099f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
609199f2dbd3SLiang Lifi
609299f2dbd3SLiang Li
6093607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6094607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6095607dacd0Sqiaonuohanfi
6096607dacd0Sqiaonuohan
6097607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6098607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6099607dacd0Sqiaonuohanfi
6100607dacd0Sqiaonuohan
61016b383c08SPeter Wuif test "$bzip2" = "yes" ; then
61026b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
61036b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
61046b383c08SPeter Wufi
61056b383c08SPeter Wu
6106c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6107d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
61086ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
61096ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6110c589b249SRonnie Sahlbergfi
6111c589b249SRonnie Sahlberg
61126542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
61134be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
61144be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
61156542aa9cSPeter Lievenfi
61166542aa9cSPeter Lieven
6117f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6118f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6119c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6120c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6121f794573eSEduardo Otubofi
6122f794573eSEduardo Otubo
612383fb7adfSbellard# XXX: suppress that
61247d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
61252358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
61267d3505c5Sbellardfi
61277d3505c5Sbellard
61284d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
61294d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
61304d9310f4SDaniel P. Berrangefi
61313556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
61323556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
61333556c233SPaolo Bonzinifi
6134f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6135d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
61366ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
61376ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6138f27aaf4bSChristian Brunnerfi
613920ff6c80SAnthony Liguori
61407c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
614170c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
614270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
614370c60c08SStefan Hajnoczielse
614470c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
614570c60c08SStefan Hajnoczifi
6146d0e2fce5SAneesh Kumar K.V
61477d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
61487d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
61497d992e4dSPeter Lievenfi
61507d992e4dSPeter Lieven
6151f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6152f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6153f0d92b56SLongpeng(Mike)fi
6154f0d92b56SLongpeng(Mike)
6155d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6156d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6157d2042378SAneesh Kumar K.Vfi
6158d2042378SAneesh Kumar K.V
6159e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6160e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6161e06a765eSHarsh Prateek Borafi
6162e06a765eSHarsh Prateek Bora
6163cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6164cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
616506d71fa1SPeter Maydellfi
616606d71fa1SPeter Maydell
61673f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
61683f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
61693f4349dcSKevin Wolffi
61703f4349dcSKevin Wolf
61718ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
61728ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
61738ab1bf12SLuiz Capitulinofi
61748ab1bf12SLuiz Capitulino
617576a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
617676a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
617776a347e1SRichard Hendersonfi
617876a347e1SRichard Henderson
6179f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6180f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6181f540166bSRichard Hendersonfi
6182f540166bSRichard Henderson
61837ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
61847ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
61857ebee43eSRichard Hendersonfi
61867ebee43eSRichard Henderson
6187df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6188df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6189df79b996SRichard Hendersonfi
6190df79b996SRichard Henderson
61911e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
61921e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
61931e6e9acaSRichard Hendersonfi
61941e6e9acaSRichard Henderson
6195eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6196d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
61976ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
61986ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6199eb100396SBharata B Raofi
6200eb100396SBharata B Rao
6201d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6202d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6203d85fa9ebSJeff Codyfi
6204d85fa9ebSJeff Cody
62050c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
62060c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
62070c14fb47SBharata B Raofi
62080c14fb47SBharata B Rao
6209df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6210df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6211df3a429aSNiels de Vosfi
6212df3a429aSNiels de Vos
62137c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
62147c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
62157c815372SBharata B Raofi
62167c815372SBharata B Rao
62170a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6218d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
62196ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
62206ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
62210a12ec87SRichard W.M. Jonesfi
62220a12ec87SRichard W.M. Jones
6223ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6224ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6225ed1701c6SDr. David Alan Gilbertfi
6226ed1701c6SDr. David Alan Gilbert
62273b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
62283b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6229f4ede81eSAmarnath Valluri  # TPM passthrough support?
62303b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
62313b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
62323b8acc11SPaolo Bonzini  fi
6233f4ede81eSAmarnath Valluri  # TPM emulator support?
6234f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6235f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6236f4ede81eSAmarnath Valluri  fi
62373b8acc11SPaolo Bonzinifi
62383b8acc11SPaolo Bonzini
62395b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
62405b808275SLluís Vilanovaif have_backend "nop"; then
62416d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
624222890ab5SPrerna Saxenafi
62435b808275SLluís Vilanovaif have_backend "simple"; then
62446d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
62456d8a764eSLluís  # Set the appropriate trace file.
6246953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
62479410b56cSPrerna Saxenafi
6248ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6249ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
62506d8a764eSLluísfi
62515b808275SLluís Vilanovaif have_backend "ust"; then
62526d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
62536d8a764eSLluísfi
62545b808275SLluís Vilanovaif have_backend "dtrace"; then
62556d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
62566d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
62576d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
62586d8a764eSLluís  fi
6259c276b17dSDaniel P. Berrangefi
62605b808275SLluís Vilanovaif have_backend "ftrace"; then
6261781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6262781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6263781e9545SEiichi Tsukata  else
626421684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6265781e9545SEiichi Tsukata  fi
6266781e9545SEiichi Tsukatafi
62670a852417SPaul Durrantif have_backend "syslog"; then
62680a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
62690a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
62700a852417SPaul Durrant  else
62710a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
62720a852417SPaul Durrant  fi
62730a852417SPaul Durrantfi
62749410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
62759410b56cSPrerna Saxena
62762da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
62772da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6278392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
62792da776dbSMichael R. Hinesfi
62802da776dbSMichael R. Hines
6281575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6282575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6283575b22b1SLaurent Vivierfi
6284575b22b1SLaurent Vivier
6285a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6286a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6287a6b1d4c0SChanglong Xiefi
6288a6b1d4c0SChanglong Xie
62896a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
62906a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
62916a02c806SStefan Hajnoczifi
62926a02c806SStefan Hajnoczi
62934d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
62944d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
62954d04351fSChristopher Covingtonfi
62964d04351fSChristopher Covington
629749e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
629849e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
629949e00a18SAndreas Grapentinfi
630049e00a18SAndreas Grapentin
6301e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6302e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6303e674605fSTomáš Golembiovskýfi
6304e674605fSTomáš Golembiovský
6305e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6306e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6307e0580342SKamil Rytarowskifi
6308e219c499SRichard Hendersonif test "$capstone" != "no" ; then
63098ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
63108ca80760SRichard Hendersonfi
6311e0580342SKamil Rytarowski
63125c312079SDr. David Alan Gilbert# Hold two types of flag:
63135c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
63145c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
63155c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
63165c312079SDr. David Alan Gilbert#                                     platform
63175c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
63185c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
63195c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
63205c312079SDr. David Alan Gilbertfi
63215c312079SDr. David Alan Gilbert
6322da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6323da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6324da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6325da92c3ffSAshish Mittalfi
6326da92c3ffSAshish Mittal
63275b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
63285b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
63295b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
63305b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
63315b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
63325b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6333c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
63345b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
633540d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
633640d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
63375b5e3037SPaolo Bonzinielse
63385b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
63395b5e3037SPaolo Bonzinifi
63405b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
63415b5e3037SPaolo Bonzini
634298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
634398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6344804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6345804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
63461901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
63471901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
63481901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
634921655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6350c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6351804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6352a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6353a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6354a31a8642SMichael S. Tsirkinfi
63552b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6356804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
635783f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
63583c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6359804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
636045d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6361cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
63625f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
63633dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6364804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6365804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
63669f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
63674852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
63689fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6369e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
637046eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6371a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
637211cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6373f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6374e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6375e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
637680fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
63772944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6378e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6379e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6380e39f0062SPaolo Bonzinifi
638142da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
638242da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
638342da6041SGerd Hoffmannelse
638442da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
638542da6041SGerd Hoffmannfi
6386e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
638746eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
63886969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6389e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
639073da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
63913e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6392409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6393804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
639417969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
639517969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6396957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
639790246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
639890246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
639994dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6400cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
64011d728c39SBlue Swirlif test "$gcov" = "yes" ; then
64021d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
64031d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
64041d728c39SBlue Swirlfi
6405804edf29SJuan Quintela
64066efd7517SPeter Maydell# use included Linux headers
64076efd7517SPeter Maydellif test "$linux" = "yes" ; then
6408a307beb6SAndreas Färber  mkdir -p linux-headers
64096efd7517SPeter Maydell  case "$cpu" in
6410c72b26ecSRichard Henderson  i386|x86_64|x32)
641108312a63SPeter Maydell    linux_arch=x86
64126efd7517SPeter Maydell    ;;
64136efd7517SPeter Maydell  ppcemb|ppc|ppc64)
641408312a63SPeter Maydell    linux_arch=powerpc
64156efd7517SPeter Maydell    ;;
64166efd7517SPeter Maydell  s390x)
641708312a63SPeter Maydell    linux_arch=s390
641808312a63SPeter Maydell    ;;
64191f080313SClaudio Fontana  aarch64)
64201f080313SClaudio Fontana    linux_arch=arm64
64211f080313SClaudio Fontana    ;;
6422222e7d11SSanjay Lal  mips64)
6423222e7d11SSanjay Lal    linux_arch=mips
6424222e7d11SSanjay Lal    ;;
642508312a63SPeter Maydell  *)
642608312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
642708312a63SPeter Maydell    linux_arch="$cpu"
64286efd7517SPeter Maydell    ;;
64296efd7517SPeter Maydell  esac
643008312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
643108312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
643208312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
643308312a63SPeter Maydell    fi
64346efd7517SPeter Maydellfi
64356efd7517SPeter Maydell
643697a847bcSbellardfor target in $target_list; do
643797a847bcSbellardtarget_dir="$target"
643825be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
643989138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
644097a847bcSbellardtarget_bigendian="no"
64411f3d3c8fSJuan Quintela
6442c1799a84SPaolo Bonzinicase "$target_name" in
6443722dd7beSMichael Weiser  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6444ea2d6a39SJuan Quintela  target_bigendian=yes
6445ea2d6a39SJuan Quintela  ;;
6446ea2d6a39SJuan Quintelaesac
644797a847bcSbellardtarget_softmmu="no"
6448997344f3Sbellardtarget_user_only="no"
6449831b7825Sthstarget_linux_user="no"
645084778508Sblueswir1target_bsd_user="no"
64519e407a85Spbrookcase "$target" in
6452c1799a84SPaolo Bonzini  ${target_name}-softmmu)
64539e407a85Spbrook    target_softmmu="yes"
64549e407a85Spbrook    ;;
6455c1799a84SPaolo Bonzini  ${target_name}-linux-user)
64569e407a85Spbrook    target_user_only="yes"
64579e407a85Spbrook    target_linux_user="yes"
64589e407a85Spbrook    ;;
6459c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
646084778508Sblueswir1    target_user_only="yes"
646184778508Sblueswir1    target_bsd_user="yes"
646284778508Sblueswir1    ;;
64639e407a85Spbrook  *)
646476ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
64659e407a85Spbrook    exit 1
64669e407a85Spbrook    ;;
64679e407a85Spbrookesac
6468831b7825Sths
646997a847bcSbellardmkdir -p $target_dir
647025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
647197a847bcSbellard
6472e5fe0c52Spbrookbflt="no"
6473ca759f9eSAlex Bennéemttcg="no"
647489138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
647556aebc89Spbrookgdb_xml_files=""
64767ba1e619Saliguori
6477c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
64786acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6479e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6480e73aae67SJuan Quintela
6481c1799a84SPaolo Bonzinicase "$target_name" in
64822408a527Saurel32  i386)
6483b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
64842408a527Saurel32  ;;
64852408a527Saurel32  x86_64)
64866acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6487b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
64882408a527Saurel32  ;;
64892408a527Saurel32  alpha)
64905ee4f3c2SRichard Henderson    mttcg="yes"
64912408a527Saurel32  ;;
64922408a527Saurel32  arm|armeb)
6493b498c8a0SJuan Quintela    TARGET_ARCH=arm
6494e5fe0c52Spbrook    bflt="yes"
6495ca759f9eSAlex Bennée    mttcg="yes"
649656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
64972408a527Saurel32  ;;
6498722dd7beSMichael Weiser  aarch64|aarch64_be)
6499722dd7beSMichael Weiser    TARGET_ARCH=aarch64
65006a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
65016a49fa95SAlexander Graf    bflt="yes"
6502ca759f9eSAlex Bennée    mttcg="yes"
65038f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
65046a49fa95SAlexander Graf  ;;
65052408a527Saurel32  cris)
65062408a527Saurel32  ;;
650761766fe9SRichard Henderson  hppa)
650861766fe9SRichard Henderson  ;;
6509613a22c9SMichael Walle  lm32)
6510613a22c9SMichael Walle  ;;
65112408a527Saurel32  m68k)
65120938cda5Saurel32    bflt="yes"
65135a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
65142408a527Saurel32  ;;
6515877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6516877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
651772b675caSEdgar E. Iglesias    bflt="yes"
651872b675caSEdgar E. Iglesias  ;;
65192408a527Saurel32  mips|mipsel)
6520b498c8a0SJuan Quintela    TARGET_ARCH=mips
652125be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
65222408a527Saurel32  ;;
65232408a527Saurel32  mipsn32|mipsn32el)
6524597e2cecSRichard Henderson    TARGET_ARCH=mips64
65256acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
652625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6527597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
65282408a527Saurel32  ;;
65292408a527Saurel32  mips64|mips64el)
6530b498c8a0SJuan Quintela    TARGET_ARCH=mips64
65316acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
653225be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
65332408a527Saurel32  ;;
6534d15a9c23SAnthony Green  moxie)
6535d15a9c23SAnthony Green  ;;
6536e671711cSMarek Vasut  nios2)
6537e671711cSMarek Vasut  ;;
65384a09d0bbSRichard Henderson  or1k)
6539e67db06eSJia Liu    TARGET_ARCH=openrisc
6540e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6541e67db06eSJia Liu  ;;
65422408a527Saurel32  ppc)
6543c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
65442408a527Saurel32  ;;
65452408a527Saurel32  ppcemb)
65466acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6547e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6548c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
65492408a527Saurel32  ;;
65502408a527Saurel32  ppc64)
65516acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6552e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6553f0b0685dSNikunj A Dadhania    mttcg=yes
65541438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
65552408a527Saurel32  ;;
65569c35126cSDoug Kwan  ppc64le)
65579c35126cSDoug Kwan    TARGET_ARCH=ppc64
65589c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
65599c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6560f0b0685dSNikunj A Dadhania    mttcg=yes
65611438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
65629c35126cSDoug Kwan  ;;
65632408a527Saurel32  ppc64abi32)
6564b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
65656acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6566e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
656725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
65681438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
65692408a527Saurel32  ;;
65702408a527Saurel32  sh4|sh4eb)
6571b498c8a0SJuan Quintela    TARGET_ARCH=sh4
65724dbed897Spbrook    bflt="yes"
65732408a527Saurel32  ;;
65742408a527Saurel32  sparc)
65752408a527Saurel32  ;;
65762408a527Saurel32  sparc64)
65776acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
65782408a527Saurel32  ;;
65792408a527Saurel32  sparc32plus)
6580b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
65816acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6582e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
658325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
65842408a527Saurel32  ;;
658524e804ecSAlexander Graf  s390x)
658686158a2aSChristian 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"
658724e804ecSAlexander Graf  ;;
6588444e06b1SChen Gang  tilegx)
6589444e06b1SChen Gang  ;;
65905ecaa4edSPeter Crosthwaite  tricore)
65915ecaa4edSPeter Crosthwaite  ;;
6592d2fbca94SGuan Xuetao  unicore32)
6593d2fbca94SGuan Xuetao  ;;
6594cfa550c6SMax Filippov  xtensa|xtensaeb)
6595cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6596cfa550c6SMax Filippov  ;;
65972408a527Saurel32  *)
659876ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
65992408a527Saurel32  ;;
66002408a527Saurel32esac
66015e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
66025e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
66035e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
66045e8861a0SPaolo Bonzinifi
66055e8861a0SPaolo Bonzini
66065e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
66075e8861a0SPaolo Bonzini
660899afc91dSDaniel P. Berrangeupper() {
660999afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
661099afc91dSDaniel P. Berrange}
661199afc91dSDaniel P. Berrange
661289138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
661325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6614c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
661525be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6616e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6617e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6618e6e91b9cSJuan Quintelafi
661925be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6620adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6621adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6622adfc3e91SStacey Sonfi
66233b6b7550SPaolo Bonzini
66243b6b7550SPaolo Bonziniif supported_xen_target $target; then
662525be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6626eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6627eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6628eb6fda0fSAnthony PERARD    fi
6629432d268cSJun Nakajimafi
66303b6b7550SPaolo Bonziniif supported_kvm_target $target; then
663125be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
66321ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6633d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6634e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
6635e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6636e6a74868SMarc-André Lureau        fi
6637d5970055SMichael S. Tsirkin    fi
6638c59249f9SJuan Quintelafi
66393b6b7550SPaolo Bonziniif supported_hax_target $target; then
6640b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6641b0cb0a66SVincent Palatinfi
6642c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
6643c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
6644c97d6d2cSSergio Andres Gomez Del Realfi
6645de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
664625be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
664797a847bcSbellardfi
664897a847bcSbellardif test "$target_softmmu" = "yes" ; then
664925be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6650ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6651ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6652ca759f9eSAlex Bennée  fi
6653de83cd02Sbellardfi
6654997344f3Sbellardif test "$target_user_only" = "yes" ; then
665525be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6656a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6657997344f3Sbellardfi
6658831b7825Sthsif test "$target_linux_user" = "yes" ; then
665925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6660831b7825Sthsfi
666156aebc89Spbrooklist=""
666256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
666356aebc89Spbrook  for x in $gdb_xml_files; do
666456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
666556aebc89Spbrook  done
666625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
66673d0f1517SJuan Quintelafi
6668de83cd02Sbellard
6669e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
667025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6671e5fe0c52Spbrookfi
667284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
667325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
667484778508Sblueswir1fi
66755b0753e0Sbellard
66764afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6677fa282484SJuan Quintela
66784afddb55SJuan Quintelacflags=""
6679fa282484SJuan Quintelaldflags=""
66809b8e111fSJuan Quintela
6681c765fcacSPeter Crosthwaitedisas_config() {
6682c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6683c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6684c765fcacSPeter Crosthwaite}
6685c765fcacSPeter Crosthwaite
668664656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
668764656024SJuan Quintela  case "$i" in
668864656024SJuan Quintela  alpha)
6689c765fcacSPeter Crosthwaite    disas_config "ALPHA"
669064656024SJuan Quintela  ;;
669182295d8aSRichard Henderson  aarch64)
669282295d8aSRichard Henderson    if test -n "${cxx}"; then
6693c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
669482295d8aSRichard Henderson    fi
669582295d8aSRichard Henderson  ;;
669664656024SJuan Quintela  arm)
6697c765fcacSPeter Crosthwaite    disas_config "ARM"
6698999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6699c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6700999b53ecSClaudio Fontana    fi
670164656024SJuan Quintela  ;;
670264656024SJuan Quintela  cris)
6703c765fcacSPeter Crosthwaite    disas_config "CRIS"
670464656024SJuan Quintela  ;;
6705429b31a2SRichard Henderson  hppa)
6706429b31a2SRichard Henderson    disas_config "HPPA"
6707429b31a2SRichard Henderson  ;;
6708c72b26ecSRichard Henderson  i386|x86_64|x32)
6709c765fcacSPeter Crosthwaite    disas_config "I386"
671064656024SJuan Quintela  ;;
671179368f49SMichael Walle  lm32)
6712c765fcacSPeter Crosthwaite    disas_config "LM32"
671379368f49SMichael Walle  ;;
671464656024SJuan Quintela  m68k)
6715c765fcacSPeter Crosthwaite    disas_config "M68K"
671664656024SJuan Quintela  ;;
6717877fdc12SEdgar E. Iglesias  microblaze*)
6718c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
671964656024SJuan Quintela  ;;
672064656024SJuan Quintela  mips*)
6721c765fcacSPeter Crosthwaite    disas_config "MIPS"
672264656024SJuan Quintela  ;;
6723d15a9c23SAnthony Green  moxie*)
6724c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6725d15a9c23SAnthony Green  ;;
6726e671711cSMarek Vasut  nios2)
6727e671711cSMarek Vasut    disas_config "NIOS2"
6728e671711cSMarek Vasut  ;;
67294a09d0bbSRichard Henderson  or1k)
6730c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6731e67db06eSJia Liu  ;;
673264656024SJuan Quintela  ppc*)
6733c765fcacSPeter Crosthwaite    disas_config "PPC"
673464656024SJuan Quintela  ;;
673524e804ecSAlexander Graf  s390*)
6736c765fcacSPeter Crosthwaite    disas_config "S390"
673764656024SJuan Quintela  ;;
673864656024SJuan Quintela  sh4)
6739c765fcacSPeter Crosthwaite    disas_config "SH4"
674064656024SJuan Quintela  ;;
674164656024SJuan Quintela  sparc*)
6742c765fcacSPeter Crosthwaite    disas_config "SPARC"
674364656024SJuan Quintela  ;;
6744cfa550c6SMax Filippov  xtensa*)
6745c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6746cfa550c6SMax Filippov  ;;
674764656024SJuan Quintela  esac
674864656024SJuan Quinteladone
67499195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6750c765fcacSPeter Crosthwaite  disas_config "TCI"
67519195b2c2SStefan Weilfi
675264656024SJuan Quintela
67536ee7126fSJuan Quintelacase "$ARCH" in
67546ee7126fSJuan Quintelaalpha)
67556ee7126fSJuan Quintela  # Ensure there's only a single GP
67566ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
67576ee7126fSJuan Quintela;;
67586ee7126fSJuan Quintelaesac
67596ee7126fSJuan Quintela
6760d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
676125be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6762d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6763d02c1db3SJuan Quintela    cflags="-p $cflags"
6764d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6765d02c1db3SJuan Quintela  fi
6766d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6767d02c1db3SJuan Quintela    ldflags="-p $ldflags"
676825be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6769d02c1db3SJuan Quintela  fi
6770d02c1db3SJuan Quintelafi
6771d02c1db3SJuan Quintela
67729b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6773964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6774fa282484SJuan Quintelafi
6775fa282484SJuan Quintela
6776e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
6777e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
6778e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
6779e9a3591fSChristian Borntraeger# header if
6780e9a3591fSChristian Borntraeger#  - we build on s390x
6781e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
6782e9a3591fSChristian Borntraeger#  - KVM is enabled
6783e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
6784e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6785e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
6786e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
6787e9a3591fSChristian Borntraeger    fi
6788e9a3591fSChristian Borntraegerfi
6789e9a3591fSChristian Borntraeger
679025be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
679125be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6792fa282484SJuan Quintela
679397a847bcSbellarddone # for target in $targets
67947d13299dSbellard
6795a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6796a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6797a540f158SPeter Crosthwaitefi
6798e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
6799e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
6800e219c499SRichard Hendersonfi
6801e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
6802e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
6803e219c499SRichard Hendersonfi
6804a540f158SPeter Crosthwaite
6805a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6806a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6807a99d57bbSWanlong Gaofi
6808a99d57bbSWanlong Gao
6809fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6810fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6811fd0e6053SJohn Snowfi
6812fd0e6053SJohn Snow
6813d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6814b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
6815b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
68169933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
68172d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
68182dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6819c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6820c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6821aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6822ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6823446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
68249933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
68252d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
68264652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
68273a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6828753d11f2SRichard Hendersonfor bios_file in \
6829753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6830225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
68315acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6832753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6833753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6834e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6835753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
68364e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6837753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6838753d11f2SRichard Hendersondo
683989138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
68407ea78b74SJan Kiszkadone
684189138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6842c2304b52SMarcel Apfelbaumdo
684389138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6844c2304b52SMarcel Apfelbaumdone
6845d1807a4fSPaolo Bonzinimkdir -p $DIRS
68467d13299dSbellardfor f in $FILES ; do
6847cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6848f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6849f9245e10SPeter Maydell    fi
68507d13299dSbellarddone
68511ad2134fSPaul Brook
6852c34ebfdcSAnthony Liguori# temporary config to build submodules
68532d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6854c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
685537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6856c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6857cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
68585f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6859c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6860c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
68613dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6862c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6863a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6864c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
68659f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
6866c34ebfdcSAnthony Liguoridone
6867c34ebfdcSAnthony Liguori
6868fe31017fSMarc-André Lureau# set up tests data directory
6869fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6870fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6871fe31017fSMarc-André Lureaufi
6872fe31017fSMarc-André Lureau
687376c7560aSMax Reitz# set up qemu-iotests in this build directory
687476c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
687576c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
687676c7560aSMax Reitz
687776c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
687876c7560aSMax Reitzecho >> "$iotests_common_env"
687976c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
688076c7560aSMax Reitz
688176c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
688276c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
688376c7560aSMax Reitzfi
688476c7560aSMax Reitz
6885dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6886dc655404SMichael S. Tsirkincat <<EOD >config.status
6887dc655404SMichael S. Tsirkin#!/bin/sh
6888dc655404SMichael S. Tsirkin# Generated by configure.
6889dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6890dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6891dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6892dc655404SMichael S. TsirkinEOD
6893dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6894dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6895cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6896dc655404SMichael S. Tsirkinchmod +x config.status
6897dc655404SMichael S. Tsirkin
68988cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6899