xref: /openbmc/qemu/configure (revision e52c6ba3)
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=""
438ed279a06SKlim Kireevlibxml2=""
439377529c0SPaolo Bonzini
440898be3e0SPeter Maydellsupported_cpu="no"
441898be3e0SPeter Maydellsupported_os="no"
442fb59dabdSPeter Maydellbogus_os="no"
4435a22ab71SYang Zhongmalloc_trim=""
444898be3e0SPeter Maydell
445ac0df51dSaliguori# parse CC options first
446ac0df51dSaliguorifor opt do
44789138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
448ac0df51dSaliguori  case "$opt" in
449ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
450ac0df51dSaliguori  ;;
4513d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
452ac0df51dSaliguori  ;;
45383f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
45483f73fceSTomoki Sekiyama  ;;
455ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
456ca4deeb1SPaolo Bonzini  ;;
4572ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4582ff6b91eSJuan Quintela  ;;
459de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
460f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
461e2a2ed06SJuan Quintela  ;;
46211cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
46311cde1c8SBruno Dominguez                      EXTRA_CXXFLAGS="$optarg"
46411cde1c8SBruno Dominguez  ;;
465a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
466f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
467e2a2ed06SJuan Quintela  ;;
4685bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4695bc62e01SGerd Hoffmann  ;;
4705bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4715bc62e01SGerd Hoffmann  ;;
472ac0df51dSaliguori  esac
473ac0df51dSaliguoridone
474ac0df51dSaliguori# OS specific
475ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
47693148aa5SStefan Weil# we can eliminate its usage altogether.
477ac0df51dSaliguori
478e49d021eSPeter Maydell# Preferred compiler:
479e49d021eSPeter Maydell#  ${CC} (if set)
480e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
481e49d021eSPeter Maydell#  system compiler
482e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
483e49d021eSPeter Maydell  cc="$host_cc"
484e49d021eSPeter Maydellelse
485b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
486e49d021eSPeter Maydellfi
487e49d021eSPeter Maydell
48883f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
48983f73fceSTomoki Sekiyama  cxx="c++"
49083f73fceSTomoki Sekiyamaelse
49183f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
49283f73fceSTomoki Sekiyamafi
49383f73fceSTomoki Sekiyama
494b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
495cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4965f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4973dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
498b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
499b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5009f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5014852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
502b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
503b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
50417884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
50517884d7bSSergei Trofimovichquery_pkg_config() {
50617884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
50717884d7bSSergei Trofimovich}
50817884d7bSSergei Trofimovichpkg_config=query_pkg_config
509b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
51047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
511ac0df51dSaliguori
51245d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
51345d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
51445d285abSPeter Maydell
515be17dc90SMichael S. Tsirkin# default flags for all hosts
5162d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5172d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5182d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5192d31515bSPeter Maydell# provides these semantics.)
5202d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
521f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
522c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
523be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
524244f1441SYang ZhongQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
5255bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
5265bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
527be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5285bc62e01SGerd Hoffmannfi
529be17dc90SMichael S. Tsirkin
530ca4deeb1SPaolo Bonzini# make source path absolute
53189138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
532ca4deeb1SPaolo Bonzini
533cab00a5aSMichael S. Tsirkin# running configure in the source tree?
534cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
535cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
536cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
537cab00a5aSMichael S. Tsirkinelse
538cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
539cab00a5aSMichael S. Tsirkinfi
540cab00a5aSMichael S. Tsirkin
541ac0df51dSaliguoricheck_define() {
542ac0df51dSaliguoricat > $TMPC <<EOF
543ac0df51dSaliguori#if !defined($1)
544fd786e1aSPeter Maydell#error $1 not defined
545ac0df51dSaliguori#endif
546ac0df51dSaliguoriint main(void) { return 0; }
547ac0df51dSaliguoriEOF
54852166aa0SJuan Quintela  compile_object
549ac0df51dSaliguori}
550ac0df51dSaliguori
551307119e7SGerd Hoffmanncheck_include() {
552307119e7SGerd Hoffmanncat > $TMPC <<EOF
553307119e7SGerd Hoffmann#include <$1>
554307119e7SGerd Hoffmannint main(void) { return 0; }
555307119e7SGerd HoffmannEOF
556307119e7SGerd Hoffmann  compile_object
557307119e7SGerd Hoffmann}
558307119e7SGerd Hoffmann
55993b25869SJohn Snowwrite_c_skeleton() {
56093b25869SJohn Snow    cat > $TMPC <<EOF
56193b25869SJohn Snowint main(void) { return 0; }
56293b25869SJohn SnowEOF
56393b25869SJohn Snow}
56493b25869SJohn Snow
565bbea4050SPeter Maydellif check_define __linux__ ; then
566bbea4050SPeter Maydell  targetos="Linux"
567bbea4050SPeter Maydellelif check_define _WIN32 ; then
568bbea4050SPeter Maydell  targetos='MINGW32'
569bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
570bbea4050SPeter Maydell  targetos='OpenBSD'
571bbea4050SPeter Maydellelif check_define __sun__ ; then
572bbea4050SPeter Maydell  targetos='SunOS'
573bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
574bbea4050SPeter Maydell  targetos='Haiku'
575951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
576951fedfcSPeter Maydell  targetos='FreeBSD'
577951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
578951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
579951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
580951fedfcSPeter Maydell  targetos='DragonFly'
581951fedfcSPeter Maydellelif check_define __NetBSD__; then
582951fedfcSPeter Maydell  targetos='NetBSD'
583951fedfcSPeter Maydellelif check_define __APPLE__; then
584951fedfcSPeter Maydell  targetos='Darwin'
585bbea4050SPeter Maydellelse
586951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
587951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
588951fedfcSPeter Maydell  # be the result of a missing compiler.
589951fedfcSPeter Maydell  targetos='bogus'
590951fedfcSPeter Maydell  bogus_os='yes'
591bbea4050SPeter Maydellfi
592bbea4050SPeter Maydell
593bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
594bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
595bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
596bbea4050SPeter Maydell# the correct CPU with the --cpu option.
597bbea4050SPeter Maydellcase $targetos in
598bbea4050SPeter MaydellDarwin)
599bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
600bbea4050SPeter Maydell  # run 64-bit userspace code.
601bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
602bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
603bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
604bbea4050SPeter Maydell    cpu="x86_64"
605bbea4050SPeter Maydell  fi
606bbea4050SPeter Maydell  ;;
607bbea4050SPeter MaydellSunOS)
60889138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
609bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
610bbea4050SPeter Maydell    cpu="x86_64"
611bbea4050SPeter Maydell  fi
612bbea4050SPeter Maydellesac
613bbea4050SPeter Maydell
6142ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6152ff6b91eSJuan Quintela  # command line argument
6162ff6b91eSJuan Quintela  :
6172ff6b91eSJuan Quintelaelif check_define __i386__ ; then
618ac0df51dSaliguori  cpu="i386"
619ac0df51dSaliguorielif check_define __x86_64__ ; then
620c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
621c72b26ecSRichard Henderson    cpu="x32"
622c72b26ecSRichard Henderson  else
623ac0df51dSaliguori    cpu="x86_64"
624c72b26ecSRichard Henderson  fi
6253aa9bd6cSblueswir1elif check_define __sparc__ ; then
6263aa9bd6cSblueswir1  if check_define __arch64__ ; then
6273aa9bd6cSblueswir1    cpu="sparc64"
6283aa9bd6cSblueswir1  else
6293aa9bd6cSblueswir1    cpu="sparc"
6303aa9bd6cSblueswir1  fi
631fdf7ed96Smalcelif check_define _ARCH_PPC ; then
632fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
633fdf7ed96Smalc    cpu="ppc64"
634ac0df51dSaliguori  else
635fdf7ed96Smalc    cpu="ppc"
636fdf7ed96Smalc  fi
637afa05235SAurelien Jarnoelif check_define __mips__ ; then
638afa05235SAurelien Jarno  cpu="mips"
639477ba620SAurelien Jarnoelif check_define __ia64__ ; then
640477ba620SAurelien Jarno  cpu="ia64"
641d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
642d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
643d66ed0eaSAurelien Jarno    cpu="s390x"
644d66ed0eaSAurelien Jarno  else
645d66ed0eaSAurelien Jarno    cpu="s390"
646d66ed0eaSAurelien Jarno  fi
64721d89f84SPeter Maydellelif check_define __arm__ ; then
64821d89f84SPeter Maydell  cpu="arm"
6491f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6501f080313SClaudio Fontana  cpu="aarch64"
651fdf7ed96Smalcelse
65289138857SStefan Weil  cpu=$(uname -m)
653ac0df51dSaliguorifi
654ac0df51dSaliguori
655359bc95dSPeter MaydellARCH=
656359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
657359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6587d13299dSbellardcase "$cpu" in
6596499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
660898be3e0SPeter Maydell    cpu="$cpu"
661898be3e0SPeter Maydell    supported_cpu="yes"
662898be3e0SPeter Maydell  ;;
6637d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
66497a847bcSbellard    cpu="i386"
665898be3e0SPeter Maydell    supported_cpu="yes"
6667d13299dSbellard  ;;
667aaa5fa14Saurel32  x86_64|amd64)
668aaa5fa14Saurel32    cpu="x86_64"
669898be3e0SPeter Maydell    supported_cpu="yes"
670aaa5fa14Saurel32  ;;
67121d89f84SPeter Maydell  armv*b|armv*l|arm)
67221d89f84SPeter Maydell    cpu="arm"
673898be3e0SPeter Maydell    supported_cpu="yes"
6747d13299dSbellard  ;;
6751f080313SClaudio Fontana  aarch64)
6761f080313SClaudio Fontana    cpu="aarch64"
677898be3e0SPeter Maydell    supported_cpu="yes"
6781f080313SClaudio Fontana  ;;
679afa05235SAurelien Jarno  mips*)
680afa05235SAurelien Jarno    cpu="mips"
681898be3e0SPeter Maydell    supported_cpu="yes"
682afa05235SAurelien Jarno  ;;
6833142255cSblueswir1  sparc|sun4[cdmuv])
684ae228531Sbellard    cpu="sparc"
6856499fd15SPeter Maydell    supported_cpu="yes"
686ae228531Sbellard  ;;
6877d13299dSbellard  *)
688359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
689359bc95dSPeter Maydell    ARCH=unknown
6907d13299dSbellard  ;;
6917d13299dSbellardesac
692359bc95dSPeter Maydellif test -z "$ARCH"; then
693359bc95dSPeter Maydell  ARCH="$cpu"
694359bc95dSPeter Maydellfi
695e2d52ad3SJuan Quintela
6967d13299dSbellard# OS specific
6970dbfc675SJuan Quintela
698adfc3e91SStacey Son# host *BSD for user mode
699adfc3e91SStacey SonHOST_VARIANT_DIR=""
700adfc3e91SStacey Son
7017d13299dSbellardcase $targetos in
70267b915a5SbellardMINGW32*)
70367b915a5Sbellard  mingw32="yes"
704b0cb0a66SVincent Palatin  hax="yes"
7053cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
706307119e7SGerd Hoffmann  if check_include dsound.h; then
7073cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
708307119e7SGerd Hoffmann  else
709307119e7SGerd Hoffmann    audio_drv_list=""
710307119e7SGerd Hoffmann  fi
711898be3e0SPeter Maydell  supported_os="yes"
71267b915a5Sbellard;;
7135c40d2bdSthsGNU/kFreeBSD)
714a167ba50SAurelien Jarno  bsd="yes"
7150c58ac1cSmalc  audio_drv_list="oss"
7160bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7175c40d2bdSths;;
7187d3505c5SbellardFreeBSD)
7197d3505c5Sbellard  bsd="yes"
7200db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7210c58ac1cSmalc  audio_drv_list="oss"
7220bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
723f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
724f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
725a7764f15SEd Maste  # needed for kinfo_getproc
726a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
72758952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
728adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
729898be3e0SPeter Maydell  supported_os="yes"
7307d3505c5Sbellard;;
731c5e97233Sblueswir1DragonFly)
732c5e97233Sblueswir1  bsd="yes"
7330db4a067SPaolo Bonzini  make="${MAKE-gmake}"
734c5e97233Sblueswir1  audio_drv_list="oss"
7350bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
736adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
737c5e97233Sblueswir1;;
7387d3505c5SbellardNetBSD)
7397d3505c5Sbellard  bsd="yes"
7400db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7410c58ac1cSmalc  audio_drv_list="oss"
7420bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7438ef92a88Sblueswir1  oss_lib="-lossaudio"
744adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
7453c2bdbc1SKamil Rytarowski  supported_os="yes"
7467d3505c5Sbellard;;
7477d3505c5SbellardOpenBSD)
7487d3505c5Sbellard  bsd="yes"
7490db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7504f6ab397SBrad Smith  audio_drv_list="sdl"
7510bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
752adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7537d3505c5Sbellard;;
75483fb7adfSbellardDarwin)
75583fb7adfSbellard  bsd="yes"
75683fb7adfSbellard  darwin="yes"
757b0cb0a66SVincent Palatin  hax="yes"
758c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
75917969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7601b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
761a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7620c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
7631b0f9cc2Saliguori  fi
764fd677642Sths  cocoa="yes"
7650c58ac1cSmalc  audio_drv_list="coreaudio"
76614382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
7670c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7687973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
769a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
770a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
771a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
772adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
773898be3e0SPeter Maydell  supported_os="yes"
77483fb7adfSbellard;;
775ec530c81SbellardSunOS)
776ec530c81Sbellard  solaris="yes"
7770db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7780db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
779e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7806b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7810c58ac1cSmalc    audio_drv_list="oss"
7826b4d2ba1Sths  fi
783c2de5c91Smalc  audio_possible_drivers="oss sdl"
784d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
785d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
786d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
787d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
788a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
789560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
790560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
791560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
792ec530c81Sbellard;;
793179cf400SAndreas FärberHaiku)
794179cf400SAndreas Färber  haiku="yes"
795179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
796179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
797179cf400SAndreas Färber;;
798898be3e0SPeter MaydellLinux)
7990c58ac1cSmalc  audio_drv_list="oss"
8000bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8015327cf48Sbellard  linux="yes"
802831b7825Sths  linux_user="yes"
803af2be207SJan Kiszka  kvm="yes"
804af2be207SJan Kiszka  vhost_net="yes"
8055e9be92dSNicholas Bellinger  vhost_scsi="yes"
806fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
807a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
808898be3e0SPeter Maydell  supported_os="yes"
809898be3e0SPeter Maydell;;
8107d13299dSbellardesac
8117d13299dSbellard
8127d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
813b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
81484778508Sblueswir1    bsd_user="yes"
8157d3505c5Sbellard  fi
81608de3949SAndreas Färberfi
8177d3505c5Sbellard
8180db4a067SPaolo Bonzini: ${make=${MAKE-make}}
8190db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
82052510f8bSStefan Weil: ${python=${PYTHON-python}}
821e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8220db4a067SPaolo Bonzini
8233c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8243c4a4d0dSPeter Maydellif has clang; then
8253c4a4d0dSPeter Maydell  objcc=clang
8263c4a4d0dSPeter Maydellelse
8273c4a4d0dSPeter Maydell  objcc="$cc"
8283c4a4d0dSPeter Maydellfi
8293c4a4d0dSPeter Maydell
8303457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8313457a3f8SJuan Quintela  EXESUF=".exe"
83217969268SFam Zheng  DSOSUF=".dll"
833a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
834e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
835e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
83678e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
83778e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
838f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
83993b25869SJohn Snow  write_c_skeleton;
840f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
841f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
842f7cf5d5bSStefan Weil  fi
843c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
844683035deSPaolo Bonzini  mandir="\${prefix}"
845528ae5b8SEduardo Habkost  datadir="\${prefix}"
846850da188SEduardo Habkost  qemu_docdir="\${prefix}"
847683035deSPaolo Bonzini  bindir="\${prefix}"
848683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8495a699bbbSLaszlo Ersek  local_statedir=
850683035deSPaolo Bonzini  confsuffix=""
851105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8523457a3f8SJuan Quintelafi
8533457a3f8SJuan Quintela
854487fefdbSAnthony Liguoriwerror=""
85585aa5189Sbellard
8567d13299dSbellardfor opt do
85789138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8587d13299dSbellard  case "$opt" in
8592efc3265Sbellard  --help|-h) show_help=yes
8602efc3265Sbellard  ;;
86199123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
86299123e13SMike Frysinger  ;;
863b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8647d13299dSbellard  ;;
865b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
86632ce6337Sbellard  ;;
867ca4deeb1SPaolo Bonzini  --source-path=*)
8687d13299dSbellard  ;;
869ac0df51dSaliguori  --cross-prefix=*)
8707d13299dSbellard  ;;
871ac0df51dSaliguori  --cc=*)
8727d13299dSbellard  ;;
873b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
87483469015Sbellard  ;;
87583f73fceSTomoki Sekiyama  --cxx=*)
87683f73fceSTomoki Sekiyama  ;;
877e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
878e007dbecSMichael S. Tsirkin  ;;
8793c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8803c4a4d0dSPeter Maydell  ;;
881b1a550a0Spbrook  --make=*) make="$optarg"
8827d13299dSbellard  ;;
8836a882643Spbrook  --install=*) install="$optarg"
8846a882643Spbrook  ;;
885c886edfbSBlue Swirl  --python=*) python="$optarg"
886c886edfbSBlue Swirl  ;;
8871d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
8881d728c39SBlue Swirl  ;;
889e2d8830eSBrad  --smbd=*) smbd="$optarg"
890e2d8830eSBrad  ;;
891e2a2ed06SJuan Quintela  --extra-cflags=*)
8927d13299dSbellard  ;;
89311cde1c8SBruno Dominguez  --extra-cxxflags=*)
89411cde1c8SBruno Dominguez  ;;
895e2a2ed06SJuan Quintela  --extra-ldflags=*)
8967d13299dSbellard  ;;
8975bc62e01SGerd Hoffmann  --enable-debug-info)
8985bc62e01SGerd Hoffmann  ;;
8995bc62e01SGerd Hoffmann  --disable-debug-info)
9005bc62e01SGerd Hoffmann  ;;
90117969268SFam Zheng  --enable-modules)
90217969268SFam Zheng      modules="yes"
90317969268SFam Zheng  ;;
9043aa88b31SStefan Hajnoczi  --disable-modules)
9053aa88b31SStefan Hajnoczi      modules="no"
9063aa88b31SStefan Hajnoczi  ;;
9072ff6b91eSJuan Quintela  --cpu=*)
9087d13299dSbellard  ;;
909b1a550a0Spbrook  --target-list=*) target_list="$optarg"
910de83cd02Sbellard  ;;
9115b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9125b808275SLluís Vilanova  ;;
9135b808275SLluís Vilanova  # XXX: backwards compatibility
9145b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
91594a420b1SStefan Hajnoczi  ;;
91674242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9179410b56cSPrerna Saxena  ;;
9187d13299dSbellard  --enable-gprof) gprof="yes"
9197d13299dSbellard  ;;
9201d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9211d728c39SBlue Swirl  ;;
92279427693SLoïc Minier  --static)
92379427693SLoïc Minier    static="yes"
92479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
92517884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
92643ce4dfeSbellard  ;;
9270b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9280b24e75fSPaolo Bonzini  ;;
9290b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9300b24e75fSPaolo Bonzini  ;;
9313aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9323aa5d2beSAlon Levy  ;;
9338bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9348bf188aaSMichael Tokarev  ;;
9350f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9360f94d6daSAlon Levy  ;;
937528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9380b24e75fSPaolo Bonzini  ;;
939023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
940023d3d67SEduardo Habkost  ;;
941850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9420b24e75fSPaolo Bonzini  ;;
943ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
94407381cc1SAnthony Liguori  ;;
945785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
946785c23aeSLuiz Capitulino  ;;
9473d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9483d5eecabSGerd Hoffmann  ;;
949785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
950023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
951023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
952023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
953023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
954023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
955023ddd74SMax Filippov    # lots of directory switches by default.
956023ddd74SMax Filippov  ;;
95797a847bcSbellard  --disable-sdl) sdl="no"
95897a847bcSbellard  ;;
959c4198157SJuan Quintela  --enable-sdl) sdl="yes"
960c4198157SJuan Quintela  ;;
96147c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
96247c03744SDave Airlie  ;;
9633556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9643556c233SPaolo Bonzini  ;;
9653556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9663556c233SPaolo Bonzini  ;;
967983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
968983eef5aSMeador Inge  ;;
969983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
970983eef5aSMeador Inge  ;;
971fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
972fe8fc5aeSPaolo Bonzini  ;;
973fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
974fe8fc5aeSPaolo Bonzini  ;;
975821601eaSJes Sorensen  --disable-vnc) vnc="no"
976821601eaSJes Sorensen  ;;
977821601eaSJes Sorensen  --enable-vnc) vnc="yes"
978821601eaSJes Sorensen  ;;
9792f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
9802f6a1ab0Sblueswir1  ;;
9810c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9820c58ac1cSmalc  ;;
98389138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
984b64ec4e4SFam Zheng  ;;
98589138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
986eb852011SMarkus Armbruster  ;;
987f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
988f8393946Saurel32  ;;
989f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
990f8393946Saurel32  ;;
991f3d08ee6SPaul Brook  --enable-debug)
992f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
993f3d08ee6SPaul Brook      debug_tcg="yes"
994f3d08ee6SPaul Brook      debug="yes"
995f3d08ee6SPaul Brook      strip_opt="no"
996b553a042SJohn Snow      fortify_source="no"
997f3d08ee6SPaul Brook  ;;
99803b4fe7dSaliguori  --enable-sparse) sparse="yes"
99903b4fe7dSaliguori  ;;
100003b4fe7dSaliguori  --disable-sparse) sparse="no"
100103b4fe7dSaliguori  ;;
10021625af87Saliguori  --disable-strip) strip_opt="no"
10031625af87Saliguori  ;;
10042f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
10052f9606b3Saliguori  ;;
1006ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1007ea784e3bSJuan Quintela  ;;
10082f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
10092f6f5c7aSCorentin Chary  ;;
10102f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
10112f6f5c7aSCorentin Chary  ;;
1012efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1013efe556adSCorentin Chary  ;;
1014efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1015efe556adSCorentin Chary  ;;
1016443f1376Sbellard  --disable-slirp) slirp="no"
1017c20709aaSbellard  ;;
1018e0e6c8c0Saliguori  --disable-vde) vde="no"
10198a16d273Sths  ;;
1020dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1021dfb278bdSJuan Quintela  ;;
102258952137SVincenzo Maffione  --disable-netmap) netmap="no"
102358952137SVincenzo Maffione  ;;
102458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
102558952137SVincenzo Maffione  ;;
1026e37630caSaliguori  --disable-xen) xen="no"
1027e37630caSaliguori  ;;
1028fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1029fc321b4bSJuan Quintela  ;;
1030eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1031eb6fda0fSAnthony PERARD  ;;
1032eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1033eb6fda0fSAnthony PERARD  ;;
103464a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
103564a7ad6fSIan Campbell  ;;
103664a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
103764a7ad6fSIan Campbell  ;;
10382e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10392e4d9fb1Saurel32  ;;
10404ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10414ffcedb6SJuan Quintela  ;;
1042fb599c9aSbalrog  --disable-bluez) bluez="no"
1043fb599c9aSbalrog  ;;
1044a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1045a20a6f46SJuan Quintela  ;;
10467ba1e619Saliguori  --disable-kvm) kvm="no"
10477ba1e619Saliguori  ;;
1048b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1049b31a0277SJuan Quintela  ;;
1050b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1051180fb750Szhanghailiang  ;;
1052b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1053180fb750Szhanghailiang  ;;
1054c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1055c97d6d2cSSergio Andres Gomez Del Real  ;;
1056c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1057c97d6d2cSSergio Andres Gomez Del Real  ;;
10589195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
10599195b2c2SStefan Weil  ;;
10609195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
10619195b2c2SStefan Weil  ;;
106247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
106347e98658SCorey Bryant  ;;
106447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
106547e98658SCorey Bryant  ;;
1066b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1067b3f6ea7eSPaolo Bonzini  ;;
1068b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1069b3f6ea7eSPaolo Bonzini  ;;
10705a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
10715a22ab71SYang Zhong  ;;
10725a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
10735a22ab71SYang Zhong  ;;
1074cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1075cd4ec0b4SGerd Hoffmann  ;;
1076cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1077cd4ec0b4SGerd Hoffmann  ;;
1078c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1079c589b249SRonnie Sahlberg  ;;
1080c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1081c589b249SRonnie Sahlberg  ;;
10826542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
10836542aa9cSPeter Lieven  ;;
10846542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
10856542aa9cSPeter Lieven  ;;
108605c2a3e7Sbellard  --enable-profiler) profiler="yes"
108705c2a3e7Sbellard  ;;
108814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
108914821030SPavel Borzenkov  ;;
1090c2de5c91Smalc  --enable-cocoa)
1091c2de5c91Smalc      cocoa="yes" ;
109289138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
10935b0753e0Sbellard  ;;
1094cad25d69Spbrook  --disable-system) softmmu="no"
10950a8e90f4Spbrook  ;;
1096cad25d69Spbrook  --enable-system) softmmu="yes"
10970a8e90f4Spbrook  ;;
10980953a80fSZachary Amsden  --disable-user)
10990953a80fSZachary Amsden      linux_user="no" ;
11000953a80fSZachary Amsden      bsd_user="no" ;
11010953a80fSZachary Amsden  ;;
11020953a80fSZachary Amsden  --enable-user) ;;
1103831b7825Sths  --disable-linux-user) linux_user="no"
11040a8e90f4Spbrook  ;;
1105831b7825Sths  --enable-linux-user) linux_user="yes"
1106831b7825Sths  ;;
110784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
110884778508Sblueswir1  ;;
110984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
111084778508Sblueswir1  ;;
111140d6444eSAvi Kivity  --enable-pie) pie="yes"
111234005a00SKirill A. Shutemov  ;;
111340d6444eSAvi Kivity  --disable-pie) pie="no"
111434005a00SKirill A. Shutemov  ;;
111585aa5189Sbellard  --enable-werror) werror="yes"
111685aa5189Sbellard  ;;
111785aa5189Sbellard  --disable-werror) werror="no"
111885aa5189Sbellard  ;;
111963678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
112063678e17SSteven Noonan  ;;
112163678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
112263678e17SSteven Noonan  ;;
11234d3b6f6eSbalrog  --disable-curses) curses="no"
11244d3b6f6eSbalrog  ;;
1125c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1126c584a6d0SJuan Quintela  ;;
1127769ce76dSAlexander Graf  --disable-curl) curl="no"
1128769ce76dSAlexander Graf  ;;
1129788c8196SJuan Quintela  --enable-curl) curl="yes"
1130788c8196SJuan Quintela  ;;
11312df87df7SJuan Quintela  --disable-fdt) fdt="no"
11322df87df7SJuan Quintela  ;;
11332df87df7SJuan Quintela  --enable-fdt) fdt="yes"
11342df87df7SJuan Quintela  ;;
11355c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
11365c6c3a6cSChristoph Hellwig  ;;
11375c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
11385c6c3a6cSChristoph Hellwig  ;;
1139758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1140758e8e38SVenkateswararao Jujjuri (JV)  ;;
1141758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1142758e8e38SVenkateswararao Jujjuri (JV)  ;;
114377755340Sths  --disable-blobs) blobs="no"
114477755340Sths  ;;
11454a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
11464a19f1ecSpbrook  ;;
1147519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1148519175a2SAlex Barcelo  ;;
114970c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
115070c60c08SStefan Hajnoczi  ;;
115170c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
115270c60c08SStefan Hajnoczi  ;;
11537d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
11547d992e4dSPeter Lieven  ;;
1155f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1156f0d92b56SLongpeng(Mike)  ;;
1157f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1158f0d92b56SLongpeng(Mike)  ;;
1159a25dba17SJuan Quintela  --disable-docs) docs="no"
116070ec5dc0SAnthony Liguori  ;;
1161a25dba17SJuan Quintela  --enable-docs) docs="yes"
116283a3ab8bSJuan Quintela  ;;
1163d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1164d5970055SMichael S. Tsirkin  ;;
1165d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1166d5970055SMichael S. Tsirkin  ;;
11675e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
11685e9be92dSNicholas Bellinger  ;;
11695e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
11705e9be92dSNicholas Bellinger  ;;
1171fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1172fc0b9b0eSStefan Hajnoczi  ;;
1173fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1174fc0b9b0eSStefan Hajnoczi  ;;
1175da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
117620ff075bSMichael Walle  ;;
1177da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
117820ff075bSMichael Walle  ;;
1179f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1180f27aaf4bSChristian Brunner  ;;
1181f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1182f27aaf4bSChristian Brunner  ;;
11838c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
11848c84cf11SSergei Trofimovich  ;;
11858c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
11868c84cf11SSergei Trofimovich  ;;
11877b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1188111a38b0SRobert Relyea  ;;
11897b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1190111a38b0SRobert Relyea  ;;
11912b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
11922b2325ffSGerd Hoffmann  ;;
11932b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
11942b2325ffSGerd Hoffmann  ;;
119569354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
119669354a83SHans de Goede  ;;
119769354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
119869354a83SHans de Goede  ;;
11991ece9905SAlon Levy  --disable-zlib-test) zlib="no"
12001ece9905SAlon Levy  ;;
1201b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1202b25c9dffSStefan Weil  ;;
1203607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1204607dacd0Sqiaonuohan  ;;
1205b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1206b25c9dffSStefan Weil  ;;
1207607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1208607dacd0Sqiaonuohan  ;;
12096b383c08SPeter Wu  --disable-bzip2) bzip2="no"
12106b383c08SPeter Wu  ;;
12116b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
12126b383c08SPeter Wu  ;;
1213d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1214d138cee9SMichael Roth  ;;
1215d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1216d138cee9SMichael Roth  ;;
12179dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
12189dacf32dSYossi Hindin  ;;
12199dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
12209dacf32dSYossi Hindin  ;;
1221d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1222d9840e25STomoki Sekiyama  ;;
1223d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1224d9840e25STomoki Sekiyama  ;;
1225d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1226d9840e25STomoki Sekiyama  ;;
1227d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1228d9840e25STomoki Sekiyama  ;;
1229d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1230d9840e25STomoki Sekiyama  ;;
1231d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1232d9840e25STomoki Sekiyama  ;;
12334b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
12344b1c11fdSDaniel P. Berrange  ;;
12354b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
12364b1c11fdSDaniel P. Berrange  ;;
1237f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1238f794573eSEduardo Otubo  ;;
1239f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1240f794573eSEduardo Otubo  ;;
1241eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1242eb100396SBharata B Rao  ;;
1243eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1244eb100396SBharata B Rao  ;;
124552b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
124652b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1247583f6e7bSStefan Hajnoczi  ;;
1248cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1249cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1250cb6414dfSFam Zheng  ;;
1251315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1252315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1253315d3184SFam Zheng  ;;
1254a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1255a4ccabcfSAnthony Liguori  ;;
1256a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1257a4ccabcfSAnthony Liguori  ;;
1258a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1259a1c5e949SDaniel P. Berrange  ;;
1260ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1261ddbb0d09SDaniel P. Berrange  ;;
1262ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1263ddbb0d09SDaniel P. Berrange  ;;
126491bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
126591bfcdb0SDaniel P. Berrange  ;;
126691bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
126791bfcdb0SDaniel P. Berrange  ;;
126891bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
126991bfcdb0SDaniel P. Berrange  ;;
127091bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
127191bfcdb0SDaniel P. Berrange  ;;
12722da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
12732da776dbSMichael R. Hines  ;;
12742da776dbSMichael R. Hines  --disable-rdma) rdma="no"
12752da776dbSMichael R. Hines  ;;
1276528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1277528de90aSDaniel P. Berrange  ;;
1278bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1279bbbf9bfbSStefan Weil  ;;
1280bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1281bbbf9bfbSStefan Weil  ;;
12829d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
12839d9e1521SGerd Hoffmann  ;;
12849d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
12859d9e1521SGerd Hoffmann  ;;
1286e91c793cSCole Robinson  --disable-tpm) tpm="no"
1287e91c793cSCole Robinson  ;;
1288ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1289ab214c29SStefan Berger  ;;
12900a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
12910a12ec87SRichard W.M. Jones  ;;
12920a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
12930a12ec87SRichard W.M. Jones  ;;
1294ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1295ed1701c6SDr. David Alan Gilbert  ;;
1296ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1297ed1701c6SDr. David Alan Gilbert  ;;
1298a99d57bbSWanlong Gao  --disable-numa) numa="no"
1299a99d57bbSWanlong Gao  ;;
1300a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1301a99d57bbSWanlong Gao  ;;
1302ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1303ed279a06SKlim Kireev  ;;
1304ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1305ed279a06SKlim Kireev  ;;
13062847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
13072847b469SFam Zheng  ;;
13082847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
13092847b469SFam Zheng  ;;
13107b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
13117b01cb97SAlexandre Derumier  ;;
13127b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
13137b01cb97SAlexandre Derumier  ;;
1314a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1315a6b1d4c0SChanglong Xie  ;;
1316a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1317a6b1d4c0SChanglong Xie  ;;
1318da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1319da92c3ffSAshish Mittal  ;;
1320da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1321da92c3ffSAshish Mittal  ;;
1322e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1323e6a74868SMarc-André Lureau  ;;
1324e6a74868SMarc-André Lureau  --enable-vhost-user)
1325e6a74868SMarc-André Lureau      vhost_user="yes"
1326e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1327e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1328e6a74868SMarc-André Lureau      fi
1329e6a74868SMarc-André Lureau  ;;
13308ca80760SRichard Henderson  --disable-capstone) capstone="no"
13318ca80760SRichard Henderson  ;;
13328ca80760SRichard Henderson  --enable-capstone) capstone="yes"
13338ca80760SRichard Henderson  ;;
1334e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1335e219c499SRichard Henderson  ;;
1336e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1337e219c499SRichard Henderson  ;;
1338cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1339cc84d63aSDaniel P. Berrange  ;;
1340f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1341f62bbee5SDaniel P. Berrange  ;;
1342f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1343f62bbee5SDaniel P. Berrange  ;;
13442d2ad6d0SFam Zheng  *)
13452d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
13462d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
13472d2ad6d0SFam Zheng      exit 1
13487f1559c6Sbalrog  ;;
13497d13299dSbellard  esac
13507d13299dSbellarddone
13517d13299dSbellard
1352e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1353e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1354e6a74868SMarc-André Lureau        vhost_user="no"
1355e6a74868SMarc-André Lureau    else
1356e6a74868SMarc-André Lureau        vhost_user="yes"
1357e6a74868SMarc-André Lureau    fi
1358e6a74868SMarc-André Lureaufi
1359e6a74868SMarc-André Lureau
136040293e58Sbellardcase "$cpu" in
1361e3608d66SRichard Henderson    ppc)
1362e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1363e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1364e3608d66SRichard Henderson           ;;
1365e3608d66SRichard Henderson    ppc64)
1366e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1367e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1368e3608d66SRichard Henderson           ;;
13699b9c37c3SRichard Henderson    sparc)
1370f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1371f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
13723142255cSblueswir1           ;;
1373ed968ff1SJuan Quintela    sparc64)
137479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1375f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
13763142255cSblueswir1           ;;
137776d83bdeSths    s390)
1378061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
137928d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
138028d7cc49SRichard Henderson           ;;
138128d7cc49SRichard Henderson    s390x)
1382061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
138328d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
138476d83bdeSths           ;;
138540293e58Sbellard    i386)
138679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
13870c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
13882b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
138940293e58Sbellard           ;;
139040293e58Sbellard    x86_64)
13917ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
13927ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
13937ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
13947ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
13950c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
13962b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1397379f6698SPaul Brook           ;;
1398c72b26ecSRichard Henderson    x32)
1399c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1400c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1401c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1402c72b26ecSRichard Henderson           ;;
140330163d89SPeter Maydell    # No special flags required for other host CPUs
14043142255cSblueswir1esac
14053142255cSblueswir1
140679f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
140779f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
140879f3b12fSPeter Crosthwaite
1409affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1410affc88ccSPeter Maydell# support, even if we're using TCI.
1411affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1412affc88ccSPeter Maydell  bsd_user="no"
1413affc88ccSPeter Maydell  linux_user="no"
1414affc88ccSPeter Maydellfi
1415affc88ccSPeter Maydell
141660e0df25SPeter Maydelldefault_target_list=""
141760e0df25SPeter Maydell
14186e92f823SPeter Maydellmak_wilds=""
14196e92f823SPeter Maydell
142060e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
14216e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
142260e0df25SPeter Maydellfi
142360e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
14246e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
142560e0df25SPeter Maydellfi
142660e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
14276e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
142860e0df25SPeter Maydellfi
142960e0df25SPeter Maydell
14306e92f823SPeter Maydellfor config in $mak_wilds; do
14316e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
14326e92f823SPeter Maydelldone
14336e92f823SPeter Maydell
1434c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
143564a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1436c53eeaf7SStefan Hajnoczi
1437af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1438af5db58eSpbrookcat << EOF
1439af5db58eSpbrook
1440af5db58eSpbrookUsage: configure [options]
1441af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1442af5db58eSpbrook
144308fb77edSStefan WeilStandard options:
144408fb77edSStefan Weil  --help                   print this message
144508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
144608fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
144708fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
144808fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
144908fb77edSStefan Weil$(echo Available targets: $default_target_list | \
145008fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
145108fb77edSStefan Weil
145208fb77edSStefan WeilAdvanced options (experts only):
145308fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
145408fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
145508fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
145608fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
145708fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
145808fb77edSStefan Weil                           build time
145908fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
146008fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
146108fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
146211cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
146308fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
146408fb77edSStefan Weil  --make=MAKE              use specified make [$make]
146508fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
146608fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
146708fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
146808fb77edSStefan Weil  --static                 enable static build [$static]
146908fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
147008fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
147108fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
147208fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
147308fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
147408fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
147508fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
14763d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1477e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
147808fb77edSStefan Weil  --enable-debug           enable common debug build options
147908fb77edSStefan Weil  --disable-strip          disable stripping binaries
148008fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
148163678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
148208fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
148308fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
148408fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
148508fb77edSStefan Weil  --block-drv-rw-whitelist=L
148608fb77edSStefan Weil                           set block driver read-write whitelist
148708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
148808fb77edSStefan Weil  --block-drv-ro-whitelist=L
148908fb77edSStefan Weil                           set block driver read-only whitelist
149008fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
14915b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1492c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
149308fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
149408fb77edSStefan Weil                           Default:trace-<pid>
1495c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1496c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
14975a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1498c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1499c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
150008fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
150133c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
150208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
150308fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1504c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1505c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1506c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1507a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1508c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1509c12d66aaSLin Ma  --enable-profiler        profiler support
1510c12d66aaSLin Ma  --enable-xen-pv-domain-build
1511c12d66aaSLin Ma                           xen pv domain builder
1512c12d66aaSLin Ma  --enable-debug-stack-usage
1513c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1514c23f23b9SMichael Tokarev
1515c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1516c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1517c23f23b9SMichael Tokarev
1518c23f23b9SMichael Tokarev  system          all system emulation targets
1519c23f23b9SMichael Tokarev  user            supported user emulation targets
1520c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1521c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1522c23f23b9SMichael Tokarev  docs            build documentation
1523c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1524c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1525c23f23b9SMichael Tokarev  pie             Position Independent Executables
1526c23f23b9SMichael Tokarev  modules         modules support
1527c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1528c23f23b9SMichael Tokarev  debug-info      debugging information
1529c23f23b9SMichael Tokarev  sparse          sparse checker
1530c23f23b9SMichael Tokarev
1531ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
153291bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
153391bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1534c23f23b9SMichael Tokarev  sdl             SDL UI
1535c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1536c23f23b9SMichael Tokarev  gtk             gtk UI
1537c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1538c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1539c23f23b9SMichael Tokarev  curses          curses UI
1540c23f23b9SMichael Tokarev  vnc             VNC UI support
1541c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1542c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1543c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1544c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1545c23f23b9SMichael Tokarev  virtfs          VirtFS
1546fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1547c23f23b9SMichael Tokarev  xen             xen backend driver support
1548c23f23b9SMichael Tokarev  xen-pci-passthrough
1549c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1550c23f23b9SMichael Tokarev  curl            curl connectivity
1551c23f23b9SMichael Tokarev  fdt             fdt device tree
1552c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1553c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1554b0cb0a66SVincent Palatin  hax             HAX acceleration support
1555c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1556c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1557c23f23b9SMichael Tokarev  vde             support for vde network
1558c23f23b9SMichael Tokarev  netmap          support for netmap network
1559c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1560c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1561c23f23b9SMichael Tokarev  attr            attr and xattr support
1562c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1563c23f23b9SMichael Tokarev  spice           spice
1564c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1565c23f23b9SMichael Tokarev  libiscsi        iscsi support
1566c23f23b9SMichael Tokarev  libnfs          nfs support
15677b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1568c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1569ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1570c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1571c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1572c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1573c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1574c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1575c23f23b9SMichael Tokarev  seccomp         seccomp support
1576c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1577c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1578c23f23b9SMichael Tokarev  tpm             TPM support
1579c23f23b9SMichael Tokarev  libssh2         ssh block device support
1580c23f23b9SMichael Tokarev  numa            libnuma support
1581ed279a06SKlim Kireev  libxml2         for Parallels image format
1582c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
15837b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1584a6b1d4c0SChanglong Xie  replication     replication support
1585c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1586c12d66aaSLin Ma  opengl          opengl support
1587c12d66aaSLin Ma  virglrenderer   virgl rendering support
1588c12d66aaSLin Ma  xfsctl          xfsctl support
1589c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1590c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1591da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1592f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1593e6a74868SMarc-André Lureau  vhost-user      vhost-user support
15948ca80760SRichard Henderson  capstone        capstone disassembler support
159508fb77edSStefan Weil
159608fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1597af5db58eSpbrookEOF
15982d2ad6d0SFam Zhengexit 0
1599af5db58eSpbrookfi
1600af5db58eSpbrook
1601c53eeaf7SStefan Hajnocziif ! has $python; then
1602c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1603c53eeaf7SStefan Hajnoczifi
1604c53eeaf7SStefan Hajnoczi
1605c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1606c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1607c53eeaf7SStefan Hajnocziif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1608c53eeaf7SStefan Hajnoczi  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1609c53eeaf7SStefan Hajnoczi      "Note that Python 3 or later is not yet supported." \
1610c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1611c53eeaf7SStefan Hajnoczifi
1612c53eeaf7SStefan Hajnoczi
1613c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1614c53eeaf7SStefan Hajnoczipython="$python -B"
1615c53eeaf7SStefan Hajnoczi
16169aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
16179aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
16189aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
16199aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
16209aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
16219aae6e54SDaniel Henrique Barbozaif compile_object ; then
16229aae6e54SDaniel Henrique Barboza  : C compiler works ok
16239aae6e54SDaniel Henrique Barbozaelse
16249aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
16259aae6e54SDaniel Henrique Barbozafi
16269aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
16279aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
16289aae6e54SDaniel Henrique Barbozafi
16299aae6e54SDaniel Henrique Barboza
1630359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1631359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1632359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1633359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1634359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1635359bc95dSPeter Maydell    else
163676ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1637359bc95dSPeter Maydell    fi
1638359bc95dSPeter Maydellfi
1639359bc95dSPeter Maydell
16409c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
16419c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
16429c83ffd8SPeter Maydellif test -z "$werror" ; then
16439c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1644e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
16459c83ffd8SPeter Maydell        werror="yes"
16469c83ffd8SPeter Maydell    else
16479c83ffd8SPeter Maydell        werror="no"
16489c83ffd8SPeter Maydell    fi
16499c83ffd8SPeter Maydellfi
16509c83ffd8SPeter Maydell
1651fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1652fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1653fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1654fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1655fb59dabdSPeter Maydell    # host OS we should stop now.
1656951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1657fb59dabdSPeter Maydellfi
1658fb59dabdSPeter Maydell
16598d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
16608d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1661ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1662435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1663b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
166471429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
16656ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
16666ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
16676ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
16686ca026cbSPeter Maydell# so it's too error prone.
166993b25869SJohn Snow
167093b25869SJohn Snowcc_has_warning_flag() {
167193b25869SJohn Snow    write_c_skeleton;
167293b25869SJohn Snow
1673a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1674a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1675a1d29d6cSPeter Maydell    # warning options).
167693b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
167793b25869SJohn Snow    compile_prog "-Werror $optflag" ""
167893b25869SJohn Snow}
167993b25869SJohn Snow
168093b25869SJohn Snowfor flag in $gcc_flags; do
168193b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16828d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16838d05095cSPaolo Bonzini    fi
16848d05095cSPaolo Bonzinidone
16858d05095cSPaolo Bonzini
168663678e17SSteven Noonanif test "$stack_protector" != "no"; then
1687fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1688fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1689fccd35a0SRodrigo Rebello{
1690fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1691fccd35a0SRodrigo Rebello    while (*c) {
1692fccd35a0SRodrigo Rebello        *p++ = *c++;
1693fccd35a0SRodrigo Rebello    }
1694fccd35a0SRodrigo Rebello    return 0;
1695fccd35a0SRodrigo Rebello}
1696fccd35a0SRodrigo RebelloEOF
169763678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16983b463a3fSMiroslav Rezanina  sp_on=0
169963678e17SSteven Noonan  for flag in $gcc_flags; do
1700590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1701590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1702590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1703590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
170463678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
17053b463a3fSMiroslav Rezanina      sp_on=1
170663678e17SSteven Noonan      break
170763678e17SSteven Noonan    fi
170863678e17SSteven Noonan  done
17093b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
17103b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
17113b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
17123b463a3fSMiroslav Rezanina    fi
17133b463a3fSMiroslav Rezanina  fi
171437746c5eSMarc-André Lureaufi
171537746c5eSMarc-André Lureau
171620bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
171720bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
171820bc94a2SPaolo Bonzinicat > $TMPC << EOF
171920bc94a2SPaolo Bonzinistruct {
172020bc94a2SPaolo Bonzini  int a[2];
172120bc94a2SPaolo Bonzini} x = {0};
172220bc94a2SPaolo BonziniEOF
172320bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
172420bc94a2SPaolo Bonzini  :
172520bc94a2SPaolo Bonzinielse
172620bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
172720bc94a2SPaolo Bonzinifi
172820bc94a2SPaolo Bonzini
1729cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1730cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1731cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1732cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1733cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1734cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1735cbdd1999SPaolo Bonziniint main(void) { return 0; }
1736cbdd1999SPaolo Bonzini#else
1737cbdd1999SPaolo Bonzini#error No bug in this compiler.
1738cbdd1999SPaolo Bonzini#endif
1739cbdd1999SPaolo BonziniEOF
1740cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1741cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1742cbdd1999SPaolo Bonzinifi
1743cbdd1999SPaolo Bonzini
174440d6444eSAvi Kivityif test "$static" = "yes" ; then
1745aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1746aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1747aa0d1f44SPaolo Bonzini  fi
174840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
174976ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
175040d6444eSAvi Kivity  else
175140d6444eSAvi Kivity    pie="no"
175240d6444eSAvi Kivity  fi
175340d6444eSAvi Kivityfi
175440d6444eSAvi Kivity
1755768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1756768b7855SEmilio G. Cota  cat > $TMPC << EOF
1757768b7855SEmilio G. Cotastatic __thread int tls_var;
1758768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1759768b7855SEmilio G. CotaEOF
1760768b7855SEmilio G. Cota
1761768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1762768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1763768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1764768b7855SEmilio G. Cotafi
1765768b7855SEmilio G. Cota
176640d6444eSAvi Kivityif test "$pie" = ""; then
176740d6444eSAvi Kivity  case "$cpu-$targetos" in
1768c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
176940d6444eSAvi Kivity      ;;
177040d6444eSAvi Kivity    *)
177140d6444eSAvi Kivity      pie="no"
177240d6444eSAvi Kivity      ;;
177340d6444eSAvi Kivity  esac
177440d6444eSAvi Kivityfi
177540d6444eSAvi Kivity
177640d6444eSAvi Kivityif test "$pie" != "no" ; then
177740d6444eSAvi Kivity  cat > $TMPC << EOF
177821d4a791SAvi Kivity
177921d4a791SAvi Kivity#ifdef __linux__
178021d4a791SAvi Kivity#  define THREAD __thread
178121d4a791SAvi Kivity#else
178221d4a791SAvi Kivity#  define THREAD
178321d4a791SAvi Kivity#endif
178421d4a791SAvi Kivity
178521d4a791SAvi Kivitystatic THREAD int tls_var;
178621d4a791SAvi Kivity
178721d4a791SAvi Kivityint main(void) { return tls_var; }
178821d4a791SAvi Kivity
178940d6444eSAvi KivityEOF
179040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
179140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
179240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
179340d6444eSAvi Kivity    pie="yes"
179440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
179540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
179640d6444eSAvi Kivity    fi
179740d6444eSAvi Kivity  else
179840d6444eSAvi Kivity    if test "$pie" = "yes"; then
179976ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
180040d6444eSAvi Kivity    else
180140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
180240d6444eSAvi Kivity      pie="no"
180340d6444eSAvi Kivity    fi
180440d6444eSAvi Kivity  fi
180546eef33bSBrad
1806e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
180746eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
180846eef33bSBrad    LDFLAGS_NOPIE="-nopie"
180946eef33bSBrad  fi
181040d6444eSAvi Kivityfi
181140d6444eSAvi Kivity
181209dada40SPaolo Bonzini##########################################
181309dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
181409dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
181509dada40SPaolo Bonzini# specification is necessary
181609dada40SPaolo Bonzini
181709dada40SPaolo Bonziniif test "$cpu" = "i386"; then
181809dada40SPaolo Bonzini  cat > $TMPC << EOF
181909dada40SPaolo Bonzinistatic int sfaa(int *ptr)
182009dada40SPaolo Bonzini{
182109dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
182209dada40SPaolo Bonzini}
182309dada40SPaolo Bonzini
182409dada40SPaolo Bonziniint main(void)
182509dada40SPaolo Bonzini{
182609dada40SPaolo Bonzini  int val = 42;
18271405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
182809dada40SPaolo Bonzini  sfaa(&val);
182909dada40SPaolo Bonzini  return val;
183009dada40SPaolo Bonzini}
183109dada40SPaolo BonziniEOF
183209dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
183309dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
183409dada40SPaolo Bonzini  fi
183509dada40SPaolo Bonzinifi
183609dada40SPaolo Bonzini
183709dada40SPaolo Bonzini#########################################
1838ec530c81Sbellard# Solaris specific configure tool chain decisions
183909dada40SPaolo Bonzini
1840ec530c81Sbellardif test "$solaris" = "yes" ; then
18416792aa11SLoïc Minier  if has $install; then
18426792aa11SLoïc Minier    :
18436792aa11SLoïc Minier  else
184476ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
184576ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
184676ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1847ec530c81Sbellard  fi
184889138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
184976ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
185076ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
185176ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1852ec530c81Sbellard  fi
18536792aa11SLoïc Minier  if has ar; then
18546792aa11SLoïc Minier    :
18556792aa11SLoïc Minier  else
1856ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
185776ad07a4SPeter Maydell      error_exit "No path includes ar" \
185876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1859ec530c81Sbellard    fi
186076ad07a4SPeter Maydell    error_exit "No path includes ar"
1861ec530c81Sbellard  fi
1862ec530c81Sbellardfi
1863ec530c81Sbellard
1864afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1865d880a3baSPaolo Bonzini    for target in $default_target_list; do
1866d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1867d880a3baSPaolo Bonzini            target_list="$target_list $target"
1868d880a3baSPaolo Bonzini    done
1869d880a3baSPaolo Bonzini    target_list="${target_list# }"
1870121afa9eSAnthony Liguorielse
187189138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1872d880a3baSPaolo Bonzini    for target in $target_list; do
187325b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
187425b48338SPeter Maydell        # friendly error message than if we let it fall through.
187525b48338SPeter Maydell        case " $default_target_list " in
187625b48338SPeter Maydell            *" $target "*)
187725b48338SPeter Maydell                ;;
187825b48338SPeter Maydell            *)
187925b48338SPeter Maydell                error_exit "Unknown target name '$target'"
188025b48338SPeter Maydell                ;;
188125b48338SPeter Maydell        esac
1882d880a3baSPaolo Bonzini        supported_target $target || exit 1
188325b48338SPeter Maydell    done
1884d880a3baSPaolo Bonzinifi
188525b48338SPeter Maydell
1886f55fe278SPaolo Bonzini# see if system emulation was really requested
1887f55fe278SPaolo Bonzinicase " $target_list " in
1888f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1889f55fe278SPaolo Bonzini  ;;
1890f55fe278SPaolo Bonzini  *) softmmu=no
1891f55fe278SPaolo Bonzini  ;;
1892f55fe278SPaolo Bonziniesac
18935327cf48Sbellard
1894249247c9SJuan Quintelafeature_not_found() {
1895249247c9SJuan Quintela  feature=$1
189621684af0SStewart Smith  remedy=$2
1897249247c9SJuan Quintela
189876ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
189921684af0SStewart Smith      "configure was not able to find it." \
190021684af0SStewart Smith      "$remedy"
1901249247c9SJuan Quintela}
1902249247c9SJuan Quintela
19037d13299dSbellard# ---
19047d13299dSbellard# big/little endian test
19057d13299dSbellardcat > $TMPC << EOF
190661cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
190761cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
190861cc919fSMike Frysingerextern int foo(short *, short *);
190961cc919fSMike Frysingerint main(int argc, char *argv[]) {
191061cc919fSMike Frysinger    return foo(big_endian, little_endian);
19117d13299dSbellard}
19127d13299dSbellardEOF
19137d13299dSbellard
191461cc919fSMike Frysingerif compile_object ; then
191561cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
191661cc919fSMike Frysinger        bigendian="yes"
191761cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
191861cc919fSMike Frysinger        bigendian="no"
19197d13299dSbellard    else
19207d13299dSbellard        echo big/little test failed
19217d13299dSbellard    fi
19227d13299dSbellardelse
192361cc919fSMike Frysinger    echo big/little test failed
19247d13299dSbellardfi
19257d13299dSbellard
1926b0a47e79SJuan Quintela##########################################
1927a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1928a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1929a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1930a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1931a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1932a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1933a30878e7SPeter Maydell    fi
1934a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1935a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1936a30878e7SPeter Maydell    fi
1937a30878e7SPeter Maydell    gtk=no
1938a30878e7SPeter Maydell    sdl=no
1939a30878e7SPeter Maydellfi
1940a30878e7SPeter Maydell
19416b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
19426b39b063SEric Blakecat > $TMPC << EOF
19436b39b063SEric Blake#include <stdint.h>
19446b39b063SEric Blake#include <stdio.h>
19456b39b063SEric Blakeint main(int argc, char *argv[]) {
19466b39b063SEric Blake    return printf("%zu", SIZE_MAX);
19476b39b063SEric Blake}
19486b39b063SEric BlakeEOF
19496b39b063SEric Blakehave_broken_size_max=no
19506b39b063SEric Blakeif ! compile_object -Werror ; then
19516b39b063SEric Blake    have_broken_size_max=yes
19526b39b063SEric Blakefi
19536b39b063SEric Blake
1954a30878e7SPeter Maydell##########################################
1955015a33bdSGonglei# L2TPV3 probe
1956015a33bdSGonglei
1957015a33bdSGongleicat > $TMPC <<EOF
1958015a33bdSGonglei#include <sys/socket.h>
1959bff6cb72SMichael Tokarev#include <linux/ip.h>
1960015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1961015a33bdSGongleiEOF
1962015a33bdSGongleiif compile_prog "" "" ; then
1963015a33bdSGonglei  l2tpv3=yes
1964015a33bdSGongleielse
1965015a33bdSGonglei  l2tpv3=no
1966015a33bdSGongleifi
1967015a33bdSGonglei
1968015a33bdSGonglei##########################################
19694d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
19704d9310f4SDaniel P. Berrange
19714d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
19724d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
19734d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
19744d9310f4SDaniel P. Berrange    #
19754d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
19764d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
19774d9310f4SDaniel P. Berrange    #
19784d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
19794d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
19804d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
19814d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
19824d9310f4SDaniel P. Berrange    # that for you.
19834d9310f4SDaniel P. Berrange    #
19844d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
19854d9310f4SDaniel P. Berrange    # are not in fact redundant.
19864d9310f4SDaniel P. Berrangecat > $TMPC << EOF
19874d9310f4SDaniel P. Berrange#include <unistd.h>
19884d9310f4SDaniel P. Berrange#include <time.h>
19894d9310f4SDaniel P. Berrange#undef localtime_r
19904d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
19914d9310f4SDaniel P. BerrangeEOF
19924d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
19934d9310f4SDaniel P. Berrange        localtime_r="yes"
19944d9310f4SDaniel P. Berrange    else
19954d9310f4SDaniel P. Berrange        localtime_r="no"
19964d9310f4SDaniel P. Berrange    fi
19974d9310f4SDaniel P. Berrangefi
19984d9310f4SDaniel P. Berrange
19994d9310f4SDaniel P. Berrange##########################################
2000779ab5e3SStefan Weil# pkg-config probe
2001779ab5e3SStefan Weil
2002779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
200376ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2004779ab5e3SStefan Weilfi
2005779ab5e3SStefan Weil
2006779ab5e3SStefan Weil##########################################
2007b0a47e79SJuan Quintela# NPTL probe
2008b0a47e79SJuan Quintela
200924cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2010bd0c5661Spbrook  cat > $TMPC <<EOF
2011bd0c5661Spbrook#include <sched.h>
201230813ceaSpbrook#include <linux/futex.h>
2013182eacc0SStefan Weilint main(void) {
2014bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2015bd0c5661Spbrook#error bork
2016bd0c5661Spbrook#endif
2017182eacc0SStefan Weil  return 0;
2018bd0c5661Spbrook}
2019bd0c5661SpbrookEOF
202024cb36a6SPeter Maydell  if ! compile_object ; then
202121684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2022b0a47e79SJuan Quintela  fi
2023bd0c5661Spbrookfi
2024bd0c5661Spbrook
202599f2dbd3SLiang Li#########################################
2026ac62922eSbalrog# zlib check
2027ac62922eSbalrog
20281ece9905SAlon Levyif test "$zlib" != "no" ; then
2029ac62922eSbalrog    cat > $TMPC << EOF
2030ac62922eSbalrog#include <zlib.h>
2031ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
2032ac62922eSbalrogEOF
203352166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
2034ac62922eSbalrog        :
2035ac62922eSbalrog    else
203676ad07a4SPeter Maydell        error_exit "zlib check failed" \
203776ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
2038ac62922eSbalrog    fi
20391ece9905SAlon Levyfi
2040eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
2041ac62922eSbalrog
2042ac62922eSbalrog##########################################
2043607dacd0Sqiaonuohan# lzo check
2044607dacd0Sqiaonuohan
2045607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2046607dacd0Sqiaonuohan    cat > $TMPC << EOF
2047607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2048607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2049607dacd0SqiaonuohanEOF
2050607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2051607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2052b25c9dffSStefan Weil        lzo="yes"
2053b25c9dffSStefan Weil    else
2054b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2055b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2056b25c9dffSStefan Weil        fi
2057b25c9dffSStefan Weil        lzo="no"
2058b25c9dffSStefan Weil    fi
2059607dacd0Sqiaonuohanfi
2060607dacd0Sqiaonuohan
2061607dacd0Sqiaonuohan##########################################
2062607dacd0Sqiaonuohan# snappy check
2063607dacd0Sqiaonuohan
2064607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2065607dacd0Sqiaonuohan    cat > $TMPC << EOF
2066607dacd0Sqiaonuohan#include <snappy-c.h>
2067607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2068607dacd0SqiaonuohanEOF
2069607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2070607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2071b25c9dffSStefan Weil        snappy="yes"
2072b25c9dffSStefan Weil    else
2073b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2074b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2075b25c9dffSStefan Weil        fi
2076b25c9dffSStefan Weil        snappy="no"
2077b25c9dffSStefan Weil    fi
2078607dacd0Sqiaonuohanfi
2079607dacd0Sqiaonuohan
2080607dacd0Sqiaonuohan##########################################
20816b383c08SPeter Wu# bzip2 check
20826b383c08SPeter Wu
20836b383c08SPeter Wuif test "$bzip2" != "no" ; then
20846b383c08SPeter Wu    cat > $TMPC << EOF
20856b383c08SPeter Wu#include <bzlib.h>
20866b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
20876b383c08SPeter WuEOF
20886b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
20896b383c08SPeter Wu        bzip2="yes"
20906b383c08SPeter Wu    else
20916b383c08SPeter Wu        if test "$bzip2" = "yes"; then
20926b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
20936b383c08SPeter Wu        fi
20946b383c08SPeter Wu        bzip2="no"
20956b383c08SPeter Wu    fi
20966b383c08SPeter Wufi
20976b383c08SPeter Wu
20986b383c08SPeter Wu##########################################
2099f794573eSEduardo Otubo# libseccomp check
2100f794573eSEduardo Otubo
2101f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2102693e5910SAndrew Jones    case "$cpu" in
2103693e5910SAndrew Jones    i386|x86_64)
2104ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2105693e5910SAndrew Jones        ;;
21065ce43972SJames Hogan    mips)
21075ce43972SJames Hogan        libseccomp_minver="2.2.0"
21085ce43972SJames Hogan        ;;
2109693e5910SAndrew Jones    arm|aarch64)
2110693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2111693e5910SAndrew Jones        ;;
21123aa35fcfSThomas Huth    ppc|ppc64|s390x)
21133e684455SMichael Strosaker        libseccomp_minver="2.3.0"
21143e684455SMichael Strosaker        ;;
2115693e5910SAndrew Jones    *)
2116693e5910SAndrew Jones        libseccomp_minver=""
2117693e5910SAndrew Jones        ;;
2118693e5910SAndrew Jones    esac
2119693e5910SAndrew Jones
2120693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2121693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2122c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2123c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2124f794573eSEduardo Otubo        seccomp="yes"
2125f794573eSEduardo Otubo    else
2126f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2127693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2128693e5910SAndrew Jones                feature_not_found "libseccomp" \
2129693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2130693e5910SAndrew Jones            else
2131693e5910SAndrew Jones                feature_not_found "libseccomp" \
2132693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2133693e5910SAndrew Jones            fi
2134896848f0SEduardo Otubo        fi
2135e84d5956SYann E. MORIN        seccomp="no"
2136f794573eSEduardo Otubo    fi
2137f794573eSEduardo Otubofi
2138f794573eSEduardo Otubo##########################################
2139e37630caSaliguori# xen probe
2140e37630caSaliguori
2141fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2142c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2143c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2144c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2145c1cdd9d5SJuergen Gross
2146c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2147c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2148c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2149c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2150c1cdd9d5SJuergen Gross    xen=yes
2151c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2152c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
2153c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2154c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2155c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2156c1cdd9d5SJuergen Gross  else
2157c1cdd9d5SJuergen Gross
2158b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2159d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2160d5b93ddfSAnthony PERARD
216150ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
216250ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
216350ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
216450ced5b3SStefan Weil
216550ced5b3SStefan Weil    # Xen (any)
216650ced5b3SStefan Weil    cat > $TMPC <<EOF
216750ced5b3SStefan Weil#include <xenctrl.h>
216850ced5b3SStefan Weilint main(void) {
216950ced5b3SStefan Weil  return 0;
217050ced5b3SStefan Weil}
217150ced5b3SStefan WeilEOF
217250ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
217350ced5b3SStefan Weil      # Xen not found
217450ced5b3SStefan Weil      if test "$xen" = "yes" ; then
217521684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
217650ced5b3SStefan Weil      fi
217750ced5b3SStefan Weil      xen=no
217850ced5b3SStefan Weil
2179d5b93ddfSAnthony PERARD    # Xen unstable
218069deef08SPeter Maydell    elif
218169deef08SPeter Maydell        cat > $TMPC <<EOF &&
21825ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21835ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
21845ba3d756SIgor Druzhininint main(void) {
21855ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
21865ba3d756SIgor Druzhinin
21875ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
21885ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
21895ba3d756SIgor Druzhinin
21905ba3d756SIgor Druzhinin  return 0;
21915ba3d756SIgor Druzhinin}
21925ba3d756SIgor DruzhininEOF
21935ba3d756SIgor Druzhinin        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
21945ba3d756SIgor Druzhinin      then
21955ba3d756SIgor Druzhinin      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
21965ba3d756SIgor Druzhinin      xen_ctrl_version=41000
21975ba3d756SIgor Druzhinin      xen=yes
21985ba3d756SIgor Druzhinin    elif
21995ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2200da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2201da8090ccSPaul Durrant#define __XEN_TOOLS__
2202da8090ccSPaul Durrant#include <xendevicemodel.h>
2203da8090ccSPaul Durrantint main(void) {
2204da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2205da8090ccSPaul Durrant
2206da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2207da8090ccSPaul Durrant  xendevicemodel_close(xd);
2208da8090ccSPaul Durrant
2209da8090ccSPaul Durrant  return 0;
2210da8090ccSPaul Durrant}
2211da8090ccSPaul DurrantEOF
2212da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2213da8090ccSPaul Durrant      then
2214da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2215f1167ee6SJuergen Gross      xen_ctrl_version=40900
2216da8090ccSPaul Durrant      xen=yes
2217da8090ccSPaul Durrant    elif
2218da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
22195eeb39c2SIan Campbell/*
22205eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
22215eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2222b6eb9b45SPaulina Szubarczyk *
2223b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2224b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2225b6eb9b45SPaulina Szubarczyk */
2226b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2227b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2228b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2229b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2230b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2231b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2232b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2233b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2234b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2235b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2236b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2237b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2238b6eb9b45SPaulina Szubarczyk#endif
2239b6eb9b45SPaulina Szubarczykint main(void) {
2240b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2241b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2242b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2243b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2244b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2245b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2246b6eb9b45SPaulina Szubarczyk
2247b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2248b6eb9b45SPaulina Szubarczyk
2249b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2250b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2251b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2252b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2253b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2254b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2255b6eb9b45SPaulina Szubarczyk
2256b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2257b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2258b6eb9b45SPaulina Szubarczyk
2259b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2260b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2261b6eb9b45SPaulina Szubarczyk
2262b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2263b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2264b6eb9b45SPaulina Szubarczyk
2265b6eb9b45SPaulina Szubarczyk  return 0;
2266b6eb9b45SPaulina Szubarczyk}
2267b6eb9b45SPaulina SzubarczykEOF
2268b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2269b6eb9b45SPaulina Szubarczyk      then
2270f1167ee6SJuergen Gross      xen_ctrl_version=40800
2271b6eb9b45SPaulina Szubarczyk      xen=yes
2272b6eb9b45SPaulina Szubarczyk    elif
2273b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2274b6eb9b45SPaulina Szubarczyk/*
2275b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2276b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
22775eeb39c2SIan Campbell */
22785eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
22795eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
22805eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
22815eeb39c2SIan Campbell#include <xenctrl.h>
22825eeb39c2SIan Campbell#include <xenstore.h>
22835eeb39c2SIan Campbell#include <xenevtchn.h>
22845eeb39c2SIan Campbell#include <xengnttab.h>
22855eeb39c2SIan Campbell#include <xenforeignmemory.h>
22865eeb39c2SIan Campbell#include <stdint.h>
22875eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
22885eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
22895eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
22905eeb39c2SIan Campbell#endif
22915eeb39c2SIan Campbellint main(void) {
22925eeb39c2SIan Campbell  xc_interface *xc = NULL;
22935eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
22945eeb39c2SIan Campbell  xenevtchn_handle *xe;
22955eeb39c2SIan Campbell  xengnttab_handle *xg;
22965eeb39c2SIan Campbell  xen_domain_handle_t handle;
22975eeb39c2SIan Campbell
22985eeb39c2SIan Campbell  xs_daemon_open();
22995eeb39c2SIan Campbell
23005eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
23015eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
23025eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23035eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23045eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
23055eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
23065eeb39c2SIan Campbell
23075eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
23085eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
23095eeb39c2SIan Campbell
23105eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
23115eeb39c2SIan Campbell  xenevtchn_fd(xe);
23125eeb39c2SIan Campbell
23135eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
23145eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
23155eeb39c2SIan Campbell
23165eeb39c2SIan Campbell  return 0;
23175eeb39c2SIan Campbell}
23185eeb39c2SIan CampbellEOF
23195eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
23205eeb39c2SIan Campbell      then
2321f1167ee6SJuergen Gross      xen_ctrl_version=40701
23225eeb39c2SIan Campbell      xen=yes
23235eeb39c2SIan Campbell    elif
23245eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2325e37630caSaliguori#include <xenctrl.h>
2326cdadde39SRoger Pau Monne#include <stdint.h>
2327cdadde39SRoger Pau Monneint main(void) {
2328cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2329cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2330cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2331cdadde39SRoger Pau Monne  return 0;
2332cdadde39SRoger Pau Monne}
2333cdadde39SRoger Pau MonneEOF
2334cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2335cdadde39SRoger Pau Monne      then
2336f1167ee6SJuergen Gross      xen_ctrl_version=40700
2337cdadde39SRoger Pau Monne      xen=yes
2338cdadde39SRoger Pau Monne
2339cdadde39SRoger Pau Monne    # Xen 4.6
2340cdadde39SRoger Pau Monne    elif
2341cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2342cdadde39SRoger Pau Monne#include <xenctrl.h>
2343e108a3c1SAnthony PERARD#include <xenstore.h>
2344d5b93ddfSAnthony PERARD#include <stdint.h>
2345d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2346d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2347d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2348d5b93ddfSAnthony PERARD#endif
2349d5b93ddfSAnthony PERARDint main(void) {
2350d5b93ddfSAnthony PERARD  xc_interface *xc;
2351d5b93ddfSAnthony PERARD  xs_daemon_open();
2352d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2353d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2354d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2355b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23568688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2357d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
235820a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2359d8b441a3SJan Beulich  return 0;
2360d8b441a3SJan Beulich}
2361d8b441a3SJan BeulichEOF
2362d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2363d8b441a3SJan Beulich      then
2364f1167ee6SJuergen Gross      xen_ctrl_version=40600
2365d8b441a3SJan Beulich      xen=yes
2366d8b441a3SJan Beulich
2367d8b441a3SJan Beulich    # Xen 4.5
2368d8b441a3SJan Beulich    elif
2369d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2370d8b441a3SJan Beulich#include <xenctrl.h>
2371d8b441a3SJan Beulich#include <xenstore.h>
2372d8b441a3SJan Beulich#include <stdint.h>
2373d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2374d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2375d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2376d8b441a3SJan Beulich#endif
2377d8b441a3SJan Beulichint main(void) {
2378d8b441a3SJan Beulich  xc_interface *xc;
2379d8b441a3SJan Beulich  xs_daemon_open();
2380d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2381d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2382d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2383d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2384d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23853996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
23863996e85cSPaul Durrant  return 0;
23873996e85cSPaul Durrant}
23883996e85cSPaul DurrantEOF
23893996e85cSPaul Durrant        compile_prog "" "$xen_libs"
23903996e85cSPaul Durrant      then
2391f1167ee6SJuergen Gross      xen_ctrl_version=40500
23923996e85cSPaul Durrant      xen=yes
23933996e85cSPaul Durrant
23943996e85cSPaul Durrant    elif
23953996e85cSPaul Durrant        cat > $TMPC <<EOF &&
23963996e85cSPaul Durrant#include <xenctrl.h>
23973996e85cSPaul Durrant#include <xenstore.h>
23983996e85cSPaul Durrant#include <stdint.h>
23993996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
24003996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
24013996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
24023996e85cSPaul Durrant#endif
24033996e85cSPaul Durrantint main(void) {
24043996e85cSPaul Durrant  xc_interface *xc;
24053996e85cSPaul Durrant  xs_daemon_open();
24063996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
24073996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
24083996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
24093996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
24103996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
24118688e065SStefano Stabellini  return 0;
24128688e065SStefano Stabellini}
24138688e065SStefano StabelliniEOF
24148688e065SStefano Stabellini        compile_prog "" "$xen_libs"
241569deef08SPeter Maydell      then
2416f1167ee6SJuergen Gross      xen_ctrl_version=40200
24178688e065SStefano Stabellini      xen=yes
24188688e065SStefano Stabellini
2419e37630caSaliguori    else
2420fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2421edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2422edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2423fc321b4bSJuan Quintela      fi
2424fc321b4bSJuan Quintela      xen=no
2425e37630caSaliguori    fi
2426d5b93ddfSAnthony PERARD
2427d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2428f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
24295eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
24305eeb39c2SIan Campbell      fi
2431d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2432d5b93ddfSAnthony PERARD    fi
2433e37630caSaliguori  fi
2434c1cdd9d5SJuergen Grossfi
2435e37630caSaliguori
2436eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2437edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2438eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2439eb6fda0fSAnthony PERARD  else
2440eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
244176ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
244276ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2443eb6fda0fSAnthony PERARD    fi
2444eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2445eb6fda0fSAnthony PERARD  fi
2446eb6fda0fSAnthony PERARDfi
2447eb6fda0fSAnthony PERARD
244864a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
244964a7ad6fSIan Campbell   test "$xen" != "yes"; then
245064a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
245164a7ad6fSIan Campbell	       "which requires Xen support."
245264a7ad6fSIan Campbellfi
245364a7ad6fSIan Campbell
2454e37630caSaliguori##########################################
2455dfffc653SJuan Quintela# Sparse probe
2456dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
24570dba6195SLoïc Minier  if has cgcc; then
2458dfffc653SJuan Quintela    sparse=yes
2459dfffc653SJuan Quintela  else
2460dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
246121684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2462dfffc653SJuan Quintela    fi
2463dfffc653SJuan Quintela    sparse=no
2464dfffc653SJuan Quintela  fi
2465dfffc653SJuan Quintelafi
2466dfffc653SJuan Quintela
2467dfffc653SJuan Quintela##########################################
2468f676c67eSJeremy White# X11 probe
2469f676c67eSJeremy Whitex11_cflags=
2470f676c67eSJeremy Whitex11_libs=-lX11
2471f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
247289138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
247389138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2474f676c67eSJeremy Whitefi
2475f676c67eSJeremy White
2476f676c67eSJeremy White##########################################
2477a4ccabcfSAnthony Liguori# GTK probe
2478a4ccabcfSAnthony Liguori
24799e04c683SStefan Weilif test "$gtkabi" = ""; then
24805fe309ffSGerd Hoffmann    # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
24815fe309ffSGerd Hoffmann    # Use 2.0 as a fallback if that is available.
24825fe309ffSGerd Hoffmann    if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
24839e04c683SStefan Weil        gtkabi=3.0
24845fe309ffSGerd Hoffmann    elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
24859e04c683SStefan Weil        gtkabi=2.0
24865fe309ffSGerd Hoffmann    else
24875fe309ffSGerd Hoffmann        gtkabi=3.0
24889e04c683SStefan Weil    fi
24899e04c683SStefan Weilfi
24909e04c683SStefan Weil
2491a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2492528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
24930a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2494528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2495528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2496bbbf9bfbSStefan Weil    else
2497bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2498bbbf9bfbSStefan Weil    fi
2499bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
250089138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
250189138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
250289138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
25030a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2504f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2505f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
25060a337ed0SGerd Hoffmann        fi
2507bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2508bbbf9bfbSStefan Weil        gtk="yes"
2509bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
25105fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2511bbbf9bfbSStefan Weil    else
2512bbbf9bfbSStefan Weil        gtk="no"
2513bbbf9bfbSStefan Weil    fi
2514bbbf9bfbSStefan Weilfi
2515bbbf9bfbSStefan Weil
2516ddbb0d09SDaniel P. Berrange
2517ddbb0d09SDaniel P. Berrange##########################################
2518ddbb0d09SDaniel P. Berrange# GNUTLS probe
2519ddbb0d09SDaniel P. Berrange
252037371299SPeter Maydellgnutls_works() {
252137371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
252237371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
252337371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
252437371299SPeter Maydell    # builds doesn't work:
252537371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
252637371299SPeter Maydell    #
252737371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
252837371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
252937371299SPeter Maydell        return 1
253037371299SPeter Maydell    fi
253137371299SPeter Maydell
253237371299SPeter Maydell    write_c_skeleton
253337371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
253437371299SPeter Maydell}
253537371299SPeter Maydell
253662893b67SDaniel P. Berrangegnutls_gcrypt=no
2537ed754746SDaniel P. Berrangegnutls_nettle=no
2538ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
253937371299SPeter Maydell    if gnutls_works; then
254089138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
254189138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2542ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2543ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2544ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2545ddbb0d09SDaniel P. Berrange        gnutls="yes"
2546ddbb0d09SDaniel P. Berrange
2547b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2548b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2549b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2550b917da4cSDaniel P. Berrange	else
2551b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2552b917da4cSDaniel P. Berrange	fi
2553b917da4cSDaniel P. Berrange
255462893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
255562893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2556ed754746SDaniel P. Berrange	    gnutls_nettle=yes
255762893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
255889138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2559ed754746SDaniel P. Berrange		*gcrypt*)
2560ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2561ed754746SDaniel P. Berrange		    gnutls_nettle=no
2562ed754746SDaniel P. Berrange		    ;;
2563ed754746SDaniel P. Berrange		*nettle*)
2564ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2565ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2566ed754746SDaniel P. Berrange		    ;;
2567ed754746SDaniel P. Berrange		*)
2568ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2569ed754746SDaniel P. Berrange		    gnutls_nettle=no
2570ed754746SDaniel P. Berrange		    ;;
257162893b67SDaniel P. Berrange	    esac
257262893b67SDaniel P. Berrange	else
257362893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2574ed754746SDaniel P. Berrange	    gnutls_nettle=no
257562893b67SDaniel P. Berrange	fi
2576ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2577ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2578ddbb0d09SDaniel P. Berrange    else
2579ddbb0d09SDaniel P. Berrange        gnutls="no"
2580b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2581ddbb0d09SDaniel P. Berrange    fi
2582ddbb0d09SDaniel P. Berrangeelse
2583b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2584ddbb0d09SDaniel P. Berrangefi
2585ddbb0d09SDaniel P. Berrange
258691bfcdb0SDaniel P. Berrange
258791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
258891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
258991bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
259091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
259191bfcdb0SDaniel P. Berrangethen
259291bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
259391bfcdb0SDaniel P. Berrange    then
259491bfcdb0SDaniel P. Berrange        gcrypt="no"
259591bfcdb0SDaniel P. Berrange    fi
259691bfcdb0SDaniel P. Berrangefi
259791bfcdb0SDaniel P. Berrange
259891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
259991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
260091bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
260191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
260291bfcdb0SDaniel P. Berrangethen
260391bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
260491bfcdb0SDaniel P. Berrange    then
260591bfcdb0SDaniel P. Berrange        nettle="no"
260691bfcdb0SDaniel P. Berrange    fi
260791bfcdb0SDaniel P. Berrangefi
260891bfcdb0SDaniel P. Berrange
260991bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
261091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
261191bfcdb0SDaniel P. Berrange    then
261291bfcdb0SDaniel P. Berrange	return 1
261391bfcdb0SDaniel P. Berrange    fi
261491bfcdb0SDaniel P. Berrange
261591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
261691bfcdb0SDaniel P. Berrange    then
261789138857SStefan Weil	host=$(libgcrypt-config --host)
261891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
261991bfcdb0SDaniel P. Berrange	then
262091bfcdb0SDaniel P. Berrange	    return 1
262191bfcdb0SDaniel P. Berrange	fi
262291bfcdb0SDaniel P. Berrange    fi
262391bfcdb0SDaniel P. Berrange
262491bfcdb0SDaniel P. Berrange    return 0
262591bfcdb0SDaniel P. Berrange}
262691bfcdb0SDaniel P. Berrange
262791bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
262891bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
262989138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
263089138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
263191bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
263291bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
263391bfcdb0SDaniel P. Berrange        # turn breaks static builds...
263491bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
263591bfcdb0SDaniel P. Berrange        then
263691bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
263791bfcdb0SDaniel P. Berrange        fi
263862893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
263962893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
264062893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
264191bfcdb0SDaniel P. Berrange        gcrypt="yes"
264291bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
264391bfcdb0SDaniel P. Berrange           nettle="no"
264491bfcdb0SDaniel P. Berrange        fi
264537788f25SDaniel P. Berrange
264637788f25SDaniel P. Berrange        cat > $TMPC << EOF
264737788f25SDaniel P. Berrange#include <gcrypt.h>
264837788f25SDaniel P. Berrangeint main(void) {
264937788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
265037788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
265137788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
265237788f25SDaniel P. Berrange return 0;
265337788f25SDaniel P. Berrange}
265437788f25SDaniel P. BerrangeEOF
265537788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
265637788f25SDaniel P. Berrange            gcrypt_kdf=yes
265737788f25SDaniel P. Berrange        fi
26581f923c70SLongpeng(Mike)
26591f923c70SLongpeng(Mike)        cat > $TMPC << EOF
26601f923c70SLongpeng(Mike)#include <gcrypt.h>
26611f923c70SLongpeng(Mike)int main(void) {
26621f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
26631f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
26641f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
26651f923c70SLongpeng(Mike)  return 0;
26661f923c70SLongpeng(Mike)}
26671f923c70SLongpeng(Mike)EOF
26681f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
26691f923c70SLongpeng(Mike)            gcrypt_hmac=yes
26701f923c70SLongpeng(Mike)        fi
267162893b67SDaniel P. Berrange    else
267291bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
267362893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
267491bfcdb0SDaniel P. Berrange        else
267591bfcdb0SDaniel P. Berrange            gcrypt="no"
267691bfcdb0SDaniel P. Berrange        fi
267762893b67SDaniel P. Berrange    fi
267862893b67SDaniel P. Berrangefi
267962893b67SDaniel P. Berrange
2680ddbb0d09SDaniel P. Berrange
268191bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2682ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
268389138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
268489138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
268589138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2686ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2687ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2688ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
268991bfcdb0SDaniel P. Berrange        nettle="yes"
2690fff2f982SDaniel P. Berrange
2691fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
26929e87a691SSteven Luo#include <stddef.h>
2693fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2694fff2f982SDaniel P. Berrangeint main(void) {
2695fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2696fff2f982SDaniel P. Berrange     return 0;
2697fff2f982SDaniel P. Berrange}
2698fff2f982SDaniel P. BerrangeEOF
2699fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2700fff2f982SDaniel P. Berrange            nettle_kdf=yes
2701fff2f982SDaniel P. Berrange        fi
2702ed754746SDaniel P. Berrange    else
270391bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2704ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
270591bfcdb0SDaniel P. Berrange        else
270691bfcdb0SDaniel P. Berrange            nettle="no"
2707ed754746SDaniel P. Berrange        fi
2708ed754746SDaniel P. Berrange    fi
270991bfcdb0SDaniel P. Berrangefi
271091bfcdb0SDaniel P. Berrange
271191bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
271291bfcdb0SDaniel P. Berrangethen
271391bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
271491bfcdb0SDaniel P. Berrangefi
2715ed754746SDaniel P. Berrange
27169a2fd434SDaniel P. Berrange##########################################
27179a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
27189a2fd434SDaniel P. Berrange
27199a2fd434SDaniel P. Berrangetasn1=yes
272090246037SDaniel P. Berrangetasn1_cflags=""
272190246037SDaniel P. Berrangetasn1_libs=""
27229a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
272389138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
272489138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
27259a2fd434SDaniel P. Berrangeelse
27269a2fd434SDaniel P. Berrange    tasn1=no
27279a2fd434SDaniel P. Berrangefi
27289a2fd434SDaniel P. Berrange
2729ed754746SDaniel P. Berrange
2730bbbf9bfbSStefan Weil##########################################
2731559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2732559607eaSDaniel P. Berrange
2733559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2734559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2735559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2736559607eaSDaniel P. Berrangefi
2737559607eaSDaniel P. Berrange
2738559607eaSDaniel P. Berrange##########################################
2739bbbf9bfbSStefan Weil# VTE probe
2740bbbf9bfbSStefan Weil
2741bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2742bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2743c6feff9eSCole Robinson      vteminversion="0.32.0"
2744c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2745c6feff9eSCole Robinson        vtepackage="vte-2.91"
2746c6feff9eSCole Robinson      else
2747528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2748c6feff9eSCole Robinson      fi
2749528de90aSDaniel P. Berrange    else
2750528de90aSDaniel P. Berrange      vtepackage="vte"
2751c6feff9eSCole Robinson      vteminversion="0.24.0"
2752528de90aSDaniel P. Berrange    fi
2753c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
275489138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
275589138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
275689138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2757bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2758bbbf9bfbSStefan Weil        vte="yes"
2759bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
27609e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2761c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
27629e04c683SStefan Weil        else
27639e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
27649e04c683SStefan Weil        fi
2765bbbf9bfbSStefan Weil    else
2766bbbf9bfbSStefan Weil        vte="no"
2767a4ccabcfSAnthony Liguori    fi
2768a4ccabcfSAnthony Liguorifi
2769a4ccabcfSAnthony Liguori
2770a4ccabcfSAnthony Liguori##########################################
277111d9f695Sbellard# SDL probe
277211d9f695Sbellard
27733ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
27743ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
277547c03744SDave Airlie
2776ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
27778f4ea9cdSGerd Hoffmann    if $pkg_config --exists "sdl2"; then
2778ee8466d0SCole Robinson        sdlabi=2.0
27798f4ea9cdSGerd Hoffmann    elif $pkg_config --exists "sdl"; then
2780ee8466d0SCole Robinson        sdlabi=1.2
27818f4ea9cdSGerd Hoffmann    else
27828f4ea9cdSGerd Hoffmann        sdlabi=2.0
2783ee8466d0SCole Robinson    fi
2784ee8466d0SCole Robinsonfi
2785ee8466d0SCole Robinson
278647c03744SDave Airlieif test $sdlabi = "2.0"; then
278747c03744SDave Airlie    sdl_config=$sdl2_config
278847c03744SDave Airlie    sdlname=sdl2
278947c03744SDave Airlie    sdlconfigname=sdl2_config
2790e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
279147c03744SDave Airlie    sdlname=sdl
279247c03744SDave Airlie    sdlconfigname=sdl_config
2793e07047cfSCole Robinsonelse
2794e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
27953ec87ffeSPaolo Bonzinifi
27963ec87ffeSPaolo Bonzini
279789138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
279847c03744SDave Airlie  sdl_config=$sdlconfigname
279947c03744SDave Airliefi
280047c03744SDave Airlie
280147c03744SDave Airlieif $pkg_config $sdlname --exists; then
280247c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
280389138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
28043ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
28053ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
280689138857SStefan Weil  sdlversion=$($sdlconfig --version)
2807a0dfd8a4SLoïc Minierelse
2808a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
28098f4ea9cdSGerd Hoffmann    feature_not_found "sdl" "Install SDL2-devel"
2810a0dfd8a4SLoïc Minier  fi
2811a0dfd8a4SLoïc Minier  sdl=no
28129316f803SPaolo Bonzinifi
281329e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
28143ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
28153ec87ffeSPaolo Bonzinifi
281611d9f695Sbellard
28179316f803SPaolo Bonzinisdl_too_old=no
2818c4198157SJuan Quintelaif test "$sdl" != "no" ; then
281911d9f695Sbellard  cat > $TMPC << EOF
282011d9f695Sbellard#include <SDL.h>
282111d9f695Sbellard#undef main /* We don't want SDL to override our main() */
282211d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
282311d9f695SbellardEOF
282489138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
282574f42e18STeLeMan  if test "$static" = "yes" ; then
28265f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
28275f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
28285f37e6d4SThomas Huth    else
282989138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
28305f37e6d4SThomas Huth    fi
283174f42e18STeLeMan  else
283289138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
283374f42e18STeLeMan  fi
283452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
283589138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
283611d9f695Sbellard      sdl_too_old=yes
283711d9f695Sbellard    else
283811d9f695Sbellard      sdl=yes
283911d9f695Sbellard    fi
28407c1f25b4Sbellard
284167c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
28421ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
284367c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
284489138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
284589138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
284611d9f695Sbellard      fi
284752166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
28481ac88f28SJuan Quintela	:
28491ac88f28SJuan Quintela      else
28501ac88f28SJuan Quintela        sdl=no
28517c1f25b4Sbellard      fi
28527c1f25b4Sbellard    fi # static link
2853c4198157SJuan Quintela  else # sdl not found
2854c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
285521684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2856c4198157SJuan Quintela    fi
2857c4198157SJuan Quintela    sdl=no
28587c1f25b4Sbellard  fi # sdl compile test
2859fd677642Sthsfi
286011d9f695Sbellard
28615368a422Saliguoriif test "$sdl" = "yes" ; then
28625368a422Saliguori  cat > $TMPC <<EOF
28635368a422Saliguori#include <SDL.h>
28645368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
28655368a422Saliguori#include <X11/XKBlib.h>
28665368a422Saliguori#else
28675368a422Saliguori#error No x11 support
28685368a422Saliguori#endif
28695368a422Saliguoriint main(void) { return 0; }
28705368a422SaliguoriEOF
2871f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2872f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2873f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
28745368a422Saliguori  fi
28755368a422Saliguorifi
28765368a422Saliguori
28778f28f3fbSths##########################################
28782da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28792da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28802da776dbSMichael R. Hines  cat > $TMPC <<EOF
28812da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28822da776dbSMichael R. Hinesint main(void) { return 0; }
28832da776dbSMichael R. HinesEOF
28842da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
28852da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28862da776dbSMichael R. Hines    rdma="yes"
28872da776dbSMichael R. Hines  else
28882da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28892da776dbSMichael R. Hines        error_exit \
28902da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28912da776dbSMichael R. Hines            " Your options:" \
28922da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28932da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28942da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28952da776dbSMichael R. Hines    fi
28962da776dbSMichael R. Hines    rdma="no"
28972da776dbSMichael R. Hines  fi
28982da776dbSMichael R. Hinesfi
28992da776dbSMichael R. Hines
290095c6bff3SBenoît Canet
290195c6bff3SBenoît Canet##########################################
29022f9606b3Saliguori# VNC SASL detection
2903821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
29042f9606b3Saliguori  cat > $TMPC <<EOF
29052f9606b3Saliguori#include <sasl/sasl.h>
29062f9606b3Saliguori#include <stdio.h>
29072f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
29082f9606b3SaliguoriEOF
29092f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
29102f9606b3Saliguori  vnc_sasl_cflags=""
29112f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
291252166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2913ea784e3bSJuan Quintela    vnc_sasl=yes
2914fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2915ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
29162f9606b3Saliguori  else
2917ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
291821684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2919ea784e3bSJuan Quintela    fi
2920ea784e3bSJuan Quintela    vnc_sasl=no
29212f9606b3Saliguori  fi
29222f9606b3Saliguorifi
29232f9606b3Saliguori
29242f9606b3Saliguori##########################################
29252f6f5c7aSCorentin Chary# VNC JPEG detection
2926821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
29272f6f5c7aSCorentin Charycat > $TMPC <<EOF
29282f6f5c7aSCorentin Chary#include <stdio.h>
29292f6f5c7aSCorentin Chary#include <jpeglib.h>
29302f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
29312f6f5c7aSCorentin CharyEOF
29322f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
29332f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
29342f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
29352f6f5c7aSCorentin Chary    vnc_jpeg=yes
29362f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2937ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
29382f6f5c7aSCorentin Chary  else
29392f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
294021684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
29412f6f5c7aSCorentin Chary    fi
29422f6f5c7aSCorentin Chary    vnc_jpeg=no
29432f6f5c7aSCorentin Chary  fi
29442f6f5c7aSCorentin Charyfi
29452f6f5c7aSCorentin Chary
29462f6f5c7aSCorentin Chary##########################################
2947efe556adSCorentin Chary# VNC PNG detection
2948821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2949efe556adSCorentin Charycat > $TMPC <<EOF
2950efe556adSCorentin Chary//#include <stdio.h>
2951efe556adSCorentin Chary#include <png.h>
2952832ce9c2SScott Wood#include <stddef.h>
2953efe556adSCorentin Charyint main(void) {
2954efe556adSCorentin Chary    png_structp png_ptr;
2955efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
29567edc3fedSPeter Maydell    return png_ptr != 0;
2957efe556adSCorentin Chary}
2958efe556adSCorentin CharyEOF
295965d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
296089138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
296189138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
29629af8025eSBrad  else
2963efe556adSCorentin Chary    vnc_png_cflags=""
2964efe556adSCorentin Chary    vnc_png_libs="-lpng"
29659af8025eSBrad  fi
2966efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2967efe556adSCorentin Chary    vnc_png=yes
2968efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
29699af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2970efe556adSCorentin Chary  else
2971efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
297221684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2973efe556adSCorentin Chary    fi
2974efe556adSCorentin Chary    vnc_png=no
2975efe556adSCorentin Chary  fi
2976efe556adSCorentin Charyfi
2977efe556adSCorentin Chary
2978efe556adSCorentin Chary##########################################
29796a021536SGerd Hoffmann# xkbcommon probe
29806a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
29816a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
29826a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
29836a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
29846a021536SGerd Hoffmann    xkbcommon=yes
29856a021536SGerd Hoffmann  else
29866a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
29876a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
29886a021536SGerd Hoffmann    fi
29896a021536SGerd Hoffmann    xkbcommon=no
29906a021536SGerd Hoffmann  fi
29916a021536SGerd Hoffmannfi
29926a021536SGerd Hoffmann
29936a021536SGerd Hoffmann##########################################
299476655d6dSaliguori# fnmatch() probe, used for ACL routines
299576655d6dSaliguorifnmatch="no"
299676655d6dSaliguoricat > $TMPC << EOF
299776655d6dSaliguori#include <fnmatch.h>
299876655d6dSaliguoriint main(void)
299976655d6dSaliguori{
300076655d6dSaliguori    fnmatch("foo", "foo", 0);
300176655d6dSaliguori    return 0;
300276655d6dSaliguori}
300376655d6dSaliguoriEOF
300452166aa0SJuan Quintelaif compile_prog "" "" ; then
300576655d6dSaliguori   fnmatch="yes"
300676655d6dSaliguorifi
300776655d6dSaliguori
300876655d6dSaliguori##########################################
3009c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3010dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3011dce512deSChristoph Hellwig  cat > $TMPC << EOF
3012ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3013dce512deSChristoph Hellwig#include <xfs/xfs.h>
3014dce512deSChristoph Hellwigint main(void)
3015dce512deSChristoph Hellwig{
3016dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3017dce512deSChristoph Hellwig    return 0;
3018dce512deSChristoph Hellwig}
3019dce512deSChristoph HellwigEOF
3020dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3021dce512deSChristoph Hellwig    xfs="yes"
3022dce512deSChristoph Hellwig  else
3023dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
302421684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3025dce512deSChristoph Hellwig    fi
3026dce512deSChristoph Hellwig    xfs=no
3027dce512deSChristoph Hellwig  fi
3028dce512deSChristoph Hellwigfi
3029dce512deSChristoph Hellwig
3030dce512deSChristoph Hellwig##########################################
30318a16d273Sths# vde libraries probe
3032dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
30334baae0acSJuan Quintela  vde_libs="-lvdeplug"
30348a16d273Sths  cat > $TMPC << EOF
30358a16d273Sths#include <libvdeplug.h>
30364a7f0e06Spbrookint main(void)
30374a7f0e06Spbrook{
30384a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3039fea08e08SPeter Maydell    char s[] = "";
3040fea08e08SPeter Maydell    vde_open(s, s, &a);
30414a7f0e06Spbrook    return 0;
30424a7f0e06Spbrook}
30438a16d273SthsEOF
304452166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
30454baae0acSJuan Quintela    vde=yes
3046dfb278bdSJuan Quintela  else
3047dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
304821684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3049dfb278bdSJuan Quintela    fi
3050dfb278bdSJuan Quintela    vde=no
30518a16d273Sths  fi
30528a16d273Sthsfi
30538a16d273Sths
30548a16d273Sths##########################################
30550a985b37SVincenzo Maffione# netmap support probe
30560a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
30570a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
30580a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
30590a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
30600a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
306158952137SVincenzo Maffioneif test "$netmap" != "no" ; then
306258952137SVincenzo Maffione  cat > $TMPC << EOF
306358952137SVincenzo Maffione#include <inttypes.h>
306458952137SVincenzo Maffione#include <net/if.h>
306558952137SVincenzo Maffione#include <net/netmap.h>
306658952137SVincenzo Maffione#include <net/netmap_user.h>
30670a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
30680a985b37SVincenzo Maffione#error
30690a985b37SVincenzo Maffione#endif
307058952137SVincenzo Maffioneint main(void) { return 0; }
307158952137SVincenzo MaffioneEOF
307258952137SVincenzo Maffione  if compile_prog "" "" ; then
307358952137SVincenzo Maffione    netmap=yes
307458952137SVincenzo Maffione  else
307558952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
307658952137SVincenzo Maffione      feature_not_found "netmap"
307758952137SVincenzo Maffione    fi
307858952137SVincenzo Maffione    netmap=no
307958952137SVincenzo Maffione  fi
308058952137SVincenzo Maffionefi
308158952137SVincenzo Maffione
308258952137SVincenzo Maffione##########################################
308347e98658SCorey Bryant# libcap-ng library probe
308447e98658SCorey Bryantif test "$cap_ng" != "no" ; then
308547e98658SCorey Bryant  cap_libs="-lcap-ng"
308647e98658SCorey Bryant  cat > $TMPC << EOF
308747e98658SCorey Bryant#include <cap-ng.h>
308847e98658SCorey Bryantint main(void)
308947e98658SCorey Bryant{
309047e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
309147e98658SCorey Bryant    return 0;
309247e98658SCorey Bryant}
309347e98658SCorey BryantEOF
309447e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
309547e98658SCorey Bryant    cap_ng=yes
309647e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
309747e98658SCorey Bryant  else
309847e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
309921684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
310047e98658SCorey Bryant    fi
310147e98658SCorey Bryant    cap_ng=no
310247e98658SCorey Bryant  fi
310347e98658SCorey Bryantfi
310447e98658SCorey Bryant
310547e98658SCorey Bryant##########################################
3106c2de5c91Smalc# Sound support libraries probe
31078f28f3fbSths
3108c2de5c91Smalcaudio_drv_probe()
3109c2de5c91Smalc{
3110c2de5c91Smalc    drv=$1
3111c2de5c91Smalc    hdr=$2
3112c2de5c91Smalc    lib=$3
3113c2de5c91Smalc    exp=$4
3114c2de5c91Smalc    cfl=$5
31158f28f3fbSths        cat > $TMPC << EOF
3116c2de5c91Smalc#include <$hdr>
3117c2de5c91Smalcint main(void) { $exp }
31188f28f3fbSthsEOF
311952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
31208f28f3fbSths        :
31218f28f3fbSths    else
312276ad07a4SPeter Maydell        error_exit "$drv check failed" \
312376ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
31248f28f3fbSths    fi
3125c2de5c91Smalc}
3126c2de5c91Smalc
312789138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3128c2de5c91Smalcfor drv in $audio_drv_list; do
3129c2de5c91Smalc    case $drv in
3130c2de5c91Smalc    alsa)
3131c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3132e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3133b1149911SFam Zheng    alsa_libs="-lasound"
3134c2de5c91Smalc    ;;
3135c2de5c91Smalc
3136b8e59f18Smalc    pa)
3137e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3138e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3139b1149911SFam Zheng    pulse_libs="-lpulse"
314067f86e8eSJuan Quintela    audio_pt_int="yes"
3141b8e59f18Smalc    ;;
3142b8e59f18Smalc
3143373967b2SGerd Hoffmann    sdl)
3144373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3145373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3146373967b2SGerd Hoffmann    fi
3147373967b2SGerd Hoffmann    ;;
3148373967b2SGerd Hoffmann
3149997e690aSJuan Quintela    coreaudio)
3150b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3151997e690aSJuan Quintela    ;;
3152997e690aSJuan Quintela
3153a4bf6780SJuan Quintela    dsound)
3154b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3155d5631638Smalc      audio_win_int="yes"
3156a4bf6780SJuan Quintela    ;;
3157a4bf6780SJuan Quintela
3158a4bf6780SJuan Quintela    oss)
3159b1149911SFam Zheng      oss_libs="$oss_lib"
3160a4bf6780SJuan Quintela    ;;
3161a4bf6780SJuan Quintela
3162373967b2SGerd Hoffmann    wav)
3163373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
31642f6a1ab0Sblueswir1    ;;
31652f6a1ab0Sblueswir1
3166e4c63a6aSmalc    *)
31671c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
316876ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
316976ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3170e4c63a6aSmalc    }
3171e4c63a6aSmalc    ;;
3172c2de5c91Smalc    esac
3173c2de5c91Smalcdone
31748f28f3fbSths
31754d3b6f6eSbalrog##########################################
31762e4d9fb1Saurel32# BrlAPI probe
31772e4d9fb1Saurel32
31784ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3179eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
31802e4d9fb1Saurel32  cat > $TMPC << EOF
31812e4d9fb1Saurel32#include <brlapi.h>
3182832ce9c2SScott Wood#include <stddef.h>
31832e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
31842e4d9fb1Saurel32EOF
318552166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
31862e4d9fb1Saurel32    brlapi=yes
31874ffcedb6SJuan Quintela  else
31884ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
318921684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
31904ffcedb6SJuan Quintela    fi
31914ffcedb6SJuan Quintela    brlapi=no
3192eb82284fSJuan Quintela  fi
3193eb82284fSJuan Quintelafi
31942e4d9fb1Saurel32
31952e4d9fb1Saurel32##########################################
31964d3b6f6eSbalrog# curses probe
3197a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3198e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
31998ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
32008ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3201e095e2f3SStefan Weil  else
32027c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
32038ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3204e095e2f3SStefan Weil  fi
3205c584a6d0SJuan Quintela  curses_found=no
32064d3b6f6eSbalrog  cat > $TMPC << EOF
32078ddc5bf9SSamuel Thibault#include <locale.h>
32084d3b6f6eSbalrog#include <curses.h>
32098ddc5bf9SSamuel Thibault#include <wchar.h>
3210ef9a2524SStefan Weilint main(void) {
32118ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
32128ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3213ef9a2524SStefan Weil  resize_term(0, 0);
32148ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
32158ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
32167c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3217271f37abSKamil Rytarowski  return 0;
3218ef9a2524SStefan Weil}
32194d3b6f6eSbalrogEOF
3220ecbe251fSVadim Evard  IFS=:
32218ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3222b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3223b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
32247c703002SSamuel Thibault    IFS=:
32258ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3226ecbe251fSVadim Evard      unset IFS
32278ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3228c584a6d0SJuan Quintela        curses_found=yes
32298ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
32304f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
32314f78ef9aSJuan Quintela        break
32324d3b6f6eSbalrog      fi
32334f78ef9aSJuan Quintela    done
32347c703002SSamuel Thibault    if test "$curses_found" = yes ; then
32357c703002SSamuel Thibault      break
32367c703002SSamuel Thibault    fi
32378ddc5bf9SSamuel Thibault  done
3238ecbe251fSVadim Evard  unset IFS
3239c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3240c584a6d0SJuan Quintela    curses=yes
3241c584a6d0SJuan Quintela  else
3242c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
324321684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3244c584a6d0SJuan Quintela    fi
3245c584a6d0SJuan Quintela    curses=no
3246c584a6d0SJuan Quintela  fi
32474f78ef9aSJuan Quintelafi
32484d3b6f6eSbalrog
3249414f0dabSblueswir1##########################################
3250769ce76dSAlexander Graf# curl probe
3251a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
325265d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3253a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
32544e2b0658SPaolo Bonzini  else
32554e2b0658SPaolo Bonzini    curlconfig=curl-config
32564e2b0658SPaolo Bonzini  fi
3257769ce76dSAlexander Graf  cat > $TMPC << EOF
3258769ce76dSAlexander Graf#include <curl/curl.h>
32590b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3260769ce76dSAlexander GrafEOF
326189138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
326289138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3263b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3264769ce76dSAlexander Graf    curl=yes
3265788c8196SJuan Quintela  else
3266788c8196SJuan Quintela    if test "$curl" = "yes" ; then
326721684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3268788c8196SJuan Quintela    fi
3269788c8196SJuan Quintela    curl=no
3270769ce76dSAlexander Graf  fi
3271769ce76dSAlexander Graffi # test "$curl"
3272769ce76dSAlexander Graf
3273769ce76dSAlexander Graf##########################################
3274fb599c9aSbalrog# bluez support probe
3275a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3276e820e3f4Sbalrog  cat > $TMPC << EOF
3277e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3278e820e3f4Sbalrogint main(void) { return bt_error(0); }
3279e820e3f4SbalrogEOF
328089138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
328189138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
328252166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3283a20a6f46SJuan Quintela    bluez=yes
3284e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3285e820e3f4Sbalrog  else
3286a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
328721684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3288a20a6f46SJuan Quintela    fi
3289e820e3f4Sbalrog    bluez="no"
3290e820e3f4Sbalrog  fi
3291fb599c9aSbalrogfi
3292fb599c9aSbalrog
3293fb599c9aSbalrog##########################################
3294e18df141SAnthony Liguori# glib support probe
3295a52d28afSPaolo Bonzini
3296ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3297ad04d8cbSPeter Maydell    glib_req_ver=2.30
3298ad04d8cbSPeter Maydellelse
3299f40685c6SJohn Snow    glib_req_ver=2.22
3300ad04d8cbSPeter Maydellfi
3301aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3302aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3303aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3304aa0d1f44SPaolo Bonzinifi
3305e26110cfSFam Zheng
33064eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
33074eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
33084eaf7202SSameeh Jubran
33094eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
33104eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
33114eaf7202SSameeh Jubranfi
33124eaf7202SSameeh Jubran
3313aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3314e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
331589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
331689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
33174a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
331814015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3319957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3320e18df141SAnthony Liguori    else
3321e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3322e26110cfSFam Zheng    fi
3323e26110cfSFam Zhengdone
3324e26110cfSFam Zheng
3325977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3326977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3327977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3328977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3329977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3330977a82abSDaniel P. Berrange#include <glib.h>
3331977a82abSDaniel P. Berrange#include <unistd.h>
3332977a82abSDaniel P. Berrange
3333977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3334977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3335977a82abSDaniel P. Berrange
3336977a82abSDaniel P. Berrangeint main(void) {
3337977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3338977a82abSDaniel P. Berrange   return 0;
3339977a82abSDaniel P. Berrange}
3340977a82abSDaniel P. BerrangeEOF
3341977a82abSDaniel P. Berrange
33425919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3343977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3344977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3345977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3346977a82abSDaniel P. Berrange	       "build target"
3347977a82abSDaniel P. Berrangefi
3348977a82abSDaniel P. Berrange
33499d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
33509d41401bSMichael S. Tsirkinglib_subprocess=yes
3351a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
33529d41401bSMichael S. Tsirkin    glib_subprocess=no
33539d41401bSMichael S. Tsirkinfi
33549d41401bSMichael S. Tsirkin
3355bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3356bbbf2e04SJohn Snowcat > $TMPC << EOF
3357bbbf2e04SJohn Snow#include <glib.h>
3358bbbf2e04SJohn Snowint main(void) { return 0; }
3359bbbf2e04SJohn SnowEOF
3360bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3361bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3362bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3363bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3364bbbf2e04SJohn Snow    fi
3365bbbf2e04SJohn Snowfi
3366bbbf2e04SJohn Snow
3367e26110cfSFam Zheng##########################################
3368e26110cfSFam Zheng# SHA command probe for modules
3369e26110cfSFam Zhengif test "$modules" = yes; then
3370e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3371e26110cfSFam Zheng    for c in $shacmd_probe; do
33728ccefb91SFam Zheng        if has $c; then
3373e26110cfSFam Zheng            shacmd="$c"
3374e26110cfSFam Zheng            break
3375e26110cfSFam Zheng        fi
3376e26110cfSFam Zheng    done
3377e26110cfSFam Zheng    if test "$shacmd" = ""; then
3378e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3379e26110cfSFam Zheng    fi
3380e18df141SAnthony Liguorifi
3381e18df141SAnthony Liguori
3382e18df141SAnthony Liguori##########################################
3383e2134eb9SGerd Hoffmann# pixman support probe
3384e2134eb9SGerd Hoffmann
338574880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
338674880fe2SRobert Schiele  pixman_cflags=
338774880fe2SRobert Schiele  pixman_libs=
338835c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
338989138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
339089138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3391e2134eb9SGerd Hoffmannelse
3392c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3393c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3394e2134eb9SGerd Hoffmannfi
3395e2134eb9SGerd Hoffmann
3396e2134eb9SGerd Hoffmann##########################################
3397fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3398fe8fc5aeSPaolo Bonzini
3399fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
3400fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3401fe8fc5aeSPaolo Bonzini#include <libudev.h>
3402fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3403fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3404fe8fc5aeSPaolo Bonziniint logsink;
3405b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3406b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3407b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3408b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3409b3f1c8c4SPaolo Bonzinistruct udev *udev;
3410b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3411b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3412b3f1c8c4SPaolo Bonzini
3413fe8fc5aeSPaolo Bonziniint main(void) {
3414b3f1c8c4SPaolo Bonzini    udev = udev_new();
3415b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3416fe8fc5aeSPaolo Bonzini    return 0;
3417fe8fc5aeSPaolo Bonzini}
3418fe8fc5aeSPaolo BonziniEOF
3419fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3420fe8fc5aeSPaolo Bonzini    mpathpersist=yes
3421fe8fc5aeSPaolo Bonzini  else
3422fe8fc5aeSPaolo Bonzini    mpathpersist=no
3423fe8fc5aeSPaolo Bonzini  fi
3424fe8fc5aeSPaolo Bonzinielse
3425fe8fc5aeSPaolo Bonzini  mpathpersist=no
3426fe8fc5aeSPaolo Bonzinifi
3427fe8fc5aeSPaolo Bonzini
3428fe8fc5aeSPaolo Bonzini##########################################
342917bff52bSM. Mohan Kumar# libcap probe
343017bff52bSM. Mohan Kumar
343117bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
343217bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
343317bff52bSM. Mohan Kumar#include <stdio.h>
343417bff52bSM. Mohan Kumar#include <sys/capability.h>
3435cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
343617bff52bSM. Mohan KumarEOF
343717bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
343817bff52bSM. Mohan Kumar    cap=yes
343917bff52bSM. Mohan Kumar  else
344017bff52bSM. Mohan Kumar    cap=no
344117bff52bSM. Mohan Kumar  fi
344217bff52bSM. Mohan Kumarfi
344317bff52bSM. Mohan Kumar
344417bff52bSM. Mohan Kumar##########################################
3445e5d355d1Saliguori# pthread probe
34464b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
34473c529d93Saliguori
3448e5d355d1Saliguoripthread=no
3449414f0dabSblueswir1cat > $TMPC << EOF
34503c529d93Saliguori#include <pthread.h>
34517a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
34527a42bbe4SStefan Weilint main(void) {
34537a42bbe4SStefan Weil  pthread_t thread;
34547a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
34557a42bbe4SStefan Weil  return 0;
34567a42bbe4SStefan Weil}
3457414f0dabSblueswir1EOF
3458bd00d539SAndreas Färberif compile_prog "" "" ; then
3459bd00d539SAndreas Färber  pthread=yes
3460bd00d539SAndreas Färberelse
3461de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
346252166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3463e5d355d1Saliguori      pthread=yes
3464e3c56761SPeter Portante      found=no
3465e3c56761SPeter Portante      for lib_entry in $LIBS; do
3466e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3467e3c56761SPeter Portante          found=yes
3468e3c56761SPeter Portante          break
3469e3c56761SPeter Portante        fi
3470e3c56761SPeter Portante      done
3471e3c56761SPeter Portante      if test "$found" = "no"; then
34725572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
347314ab3aa7SMarc-André Lureau        libs_qga="$pthread_lib $libs_qga"
3474e3c56761SPeter Portante      fi
3475409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3476de65fe0fSSebastian Herbszt      break
3477414f0dabSblueswir1    fi
3478de65fe0fSSebastian Herbszt  done
3479bd00d539SAndreas Färberfi
3480414f0dabSblueswir1
34814617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
348276ad07a4SPeter Maydell  error_exit "pthread check failed" \
348376ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3484e5d355d1Saliguorifi
3485e5d355d1Saliguori
34865c312079SDr. David Alan Gilbert# check for pthread_setname_np
34875c312079SDr. David Alan Gilbertpthread_setname_np=no
34885c312079SDr. David Alan Gilbertcat > $TMPC << EOF
34895c312079SDr. David Alan Gilbert#include <pthread.h>
34905c312079SDr. David Alan Gilbert
34915c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
34925c312079SDr. David Alan Gilbertint main(void)
34935c312079SDr. David Alan Gilbert{
34945c312079SDr. David Alan Gilbert    pthread_t thread;
34955c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
34965c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
34975c312079SDr. David Alan Gilbert    return 0;
34985c312079SDr. David Alan Gilbert}
34995c312079SDr. David Alan GilbertEOF
35005c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
35015c312079SDr. David Alan Gilbert  pthread_setname_np=yes
35025c312079SDr. David Alan Gilbertfi
35035c312079SDr. David Alan Gilbert
3504bf9298b9Saliguori##########################################
3505f27aaf4bSChristian Brunner# rbd probe
3506f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3507f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3508f27aaf4bSChristian Brunner#include <stdio.h>
3509ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3510f27aaf4bSChristian Brunnerint main(void) {
3511ad32e9c0SJosh Durgin    rados_t cluster;
3512ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3513f27aaf4bSChristian Brunner    return 0;
3514f27aaf4bSChristian Brunner}
3515f27aaf4bSChristian BrunnerEOF
3516ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3517f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3518f27aaf4bSChristian Brunner    rbd=yes
3519f27aaf4bSChristian Brunner  else
3520f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
352121684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3522f27aaf4bSChristian Brunner    fi
3523f27aaf4bSChristian Brunner    rbd=no
3524f27aaf4bSChristian Brunner  fi
3525f27aaf4bSChristian Brunnerfi
3526f27aaf4bSChristian Brunner
3527f27aaf4bSChristian Brunner##########################################
35280a12ec87SRichard W.M. Jones# libssh2 probe
35294fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
35300a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
353165d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
353289138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
353389138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
35340a12ec87SRichard W.M. Jones    libssh2=yes
35350a12ec87SRichard W.M. Jones  else
35360a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
35374fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
35380a12ec87SRichard W.M. Jones    fi
35390a12ec87SRichard W.M. Jones    libssh2=no
35400a12ec87SRichard W.M. Jones  fi
35410a12ec87SRichard W.M. Jonesfi
35420a12ec87SRichard W.M. Jones
35430a12ec87SRichard W.M. Jones##########################################
35449a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
35459a2d462eSRichard W.M. Jones
35469a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
35479a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
35489a2d462eSRichard W.M. Jones#include <stdio.h>
35499a2d462eSRichard W.M. Jones#include <libssh2.h>
35509a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
35519a2d462eSRichard W.M. Jonesint main(void) {
35529a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
35539a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
35549a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
35559a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
35569a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
35579a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
35589a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
35599a2d462eSRichard W.M. Jones    return 0;
35609a2d462eSRichard W.M. Jones}
35619a2d462eSRichard W.M. JonesEOF
35629a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
35639a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
35649a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
35659a2d462eSRichard W.M. Jones  fi
35669a2d462eSRichard W.M. Jonesfi
35679a2d462eSRichard W.M. Jones
35689a2d462eSRichard W.M. Jones##########################################
35695c6c3a6cSChristoph Hellwig# linux-aio probe
35705c6c3a6cSChristoph Hellwig
35715c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
35725c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
35735c6c3a6cSChristoph Hellwig#include <libaio.h>
35745c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3575832ce9c2SScott Wood#include <stddef.h>
35765c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
35775c6c3a6cSChristoph HellwigEOF
35785c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
35795c6c3a6cSChristoph Hellwig    linux_aio=yes
35805c6c3a6cSChristoph Hellwig  else
35815c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
358221684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
35835c6c3a6cSChristoph Hellwig    fi
35843cfcae3cSLuiz Capitulino    linux_aio=no
35855c6c3a6cSChristoph Hellwig  fi
35865c6c3a6cSChristoph Hellwigfi
35875c6c3a6cSChristoph Hellwig
35885c6c3a6cSChristoph Hellwig##########################################
35893b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
35903b8acc11SPaolo Bonzini
35913b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
35923b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
35933b8acc11SPaolo Bonzinielse
35943b8acc11SPaolo Bonzini  tpm_passthrough=no
35953b8acc11SPaolo Bonzinifi
35963b8acc11SPaolo Bonzini
3597f4ede81eSAmarnath Valluri# TPM emulator is for all posix systems
3598f4ede81eSAmarnath Valluriif test "$mingw32" != "yes"; then
3599f4ede81eSAmarnath Valluri  tpm_emulator=$tpm
3600f4ede81eSAmarnath Vallurielse
3601f4ede81eSAmarnath Valluri  tpm_emulator=no
3602f4ede81eSAmarnath Vallurifi
36033b8acc11SPaolo Bonzini##########################################
3604758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3605758e8e38SVenkateswararao Jujjuri (JV)
3606758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3607758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3608758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3609758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3610f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3611f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3612f2338fb4SPavel Borzenkov#else
36134f26f2b6SAvi Kivity#include <sys/xattr.h>
3614f2338fb4SPavel Borzenkov#endif
3615758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3616758e8e38SVenkateswararao Jujjuri (JV)EOF
36174f26f2b6SAvi Kivity  if compile_prog "" "" ; then
36184f26f2b6SAvi Kivity    attr=yes
36194f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3620f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3621758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3622758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
36234f26f2b6SAvi Kivity    libattr=yes
3624758e8e38SVenkateswararao Jujjuri (JV)  else
3625758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
362621684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3627758e8e38SVenkateswararao Jujjuri (JV)    fi
3628758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3629758e8e38SVenkateswararao Jujjuri (JV)  fi
3630758e8e38SVenkateswararao Jujjuri (JV)fi
3631758e8e38SVenkateswararao Jujjuri (JV)
3632758e8e38SVenkateswararao Jujjuri (JV)##########################################
3633bf9298b9Saliguori# iovec probe
3634bf9298b9Saliguoricat > $TMPC <<EOF
3635db34f0b3Sblueswir1#include <sys/types.h>
3636bf9298b9Saliguori#include <sys/uio.h>
3637db34f0b3Sblueswir1#include <unistd.h>
3638f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3639bf9298b9SaliguoriEOF
3640bf9298b9Saliguoriiovec=no
364152166aa0SJuan Quintelaif compile_prog "" "" ; then
3642bf9298b9Saliguori  iovec=yes
3643bf9298b9Saliguorifi
3644bf9298b9Saliguori
3645f652e6afSaurel32##########################################
3646ceb42de8Saliguori# preadv probe
3647ceb42de8Saliguoricat > $TMPC <<EOF
3648ceb42de8Saliguori#include <sys/types.h>
3649ceb42de8Saliguori#include <sys/uio.h>
3650ceb42de8Saliguori#include <unistd.h>
3651c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3652ceb42de8SaliguoriEOF
3653ceb42de8Saliguoripreadv=no
365452166aa0SJuan Quintelaif compile_prog "" "" ; then
3655ceb42de8Saliguori  preadv=yes
3656ceb42de8Saliguorifi
3657ceb42de8Saliguori
3658ceb42de8Saliguori##########################################
3659f652e6afSaurel32# fdt probe
3660e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3661e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3662e169e1e1SPeter Maydellfdt_required=no
3663e169e1e1SPeter Maydellfor target in $target_list; do
3664e169e1e1SPeter Maydell  case $target in
3665df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3666e169e1e1SPeter Maydell      fdt_required=yes
3667e169e1e1SPeter Maydell    ;;
3668e169e1e1SPeter Maydell  esac
3669e169e1e1SPeter Maydelldone
3670e169e1e1SPeter Maydell
3671e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3672e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3673e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3674e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3675e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3676e169e1e1SPeter Maydell  fi
3677e169e1e1SPeter Maydell  fdt=yes
3678e169e1e1SPeter Maydellfi
3679e169e1e1SPeter Maydell
36802df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3681b41af4baSJuan Quintela  fdt_libs="-lfdt"
368296ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
36836e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3684f652e6afSaurel32  cat > $TMPC << EOF
368531ce0adbSThomas Huth#include <libfdt.h>
368696ce6545SPeter Crosthwaite#include <libfdt_env.h>
36876e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3688f652e6afSaurel32EOF
368952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3690a540f158SPeter Crosthwaite    # system DTC is good - use it
3691f652e6afSaurel32    fdt=yes
3692aef45d51SDaniel P. Berrange  else
3693aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3694aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3695aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3696aef45d51SDaniel P. Berrange      fi
3697aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3698a540f158SPeter Crosthwaite          fdt=yes
3699a540f158SPeter Crosthwaite          dtc_internal="yes"
3700a540f158SPeter Crosthwaite          mkdir -p dtc
3701cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3702a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3703a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
37042df87df7SJuan Quintela          fi
3705a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3706a540f158SPeter Crosthwaite          fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3707a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
3708aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
3709aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3710aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
3711a540f158SPeter Crosthwaite      else
3712a540f158SPeter Crosthwaite          # don't have and don't want
3713de3a354aSMichael Walle          fdt_libs=
37142df87df7SJuan Quintela          fdt=no
3715f652e6afSaurel32      fi
3716f652e6afSaurel32  fi
3717aef45d51SDaniel P. Berrangefi
3718f652e6afSaurel32
3719a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3720a540f158SPeter Crosthwaite
372120ff075bSMichael Walle##########################################
3722fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3723b1546f32SGerd Hoffmann
3724da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3725014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3726fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3727f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3728f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3729da076ffeSGerd Hoffmann    opengl=yes
3730925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3731925a0400SGerd Hoffmann        gtk_gl="yes"
3732925a0400SGerd Hoffmann    fi
3733cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
373420ff075bSMichael Walle  else
3735da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3736dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
373720ff075bSMichael Walle    fi
3738f676c67eSJeremy White    opengl_cflags=""
3739da076ffeSGerd Hoffmann    opengl_libs=""
3740da076ffeSGerd Hoffmann    opengl=no
374120ff075bSMichael Walle  fi
374220ff075bSMichael Wallefi
374320ff075bSMichael Walle
3744014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3745014cb152SGerd Hoffmann  cat > $TMPC << EOF
3746014cb152SGerd Hoffmann#include <epoxy/egl.h>
3747014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3748014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3749014cb152SGerd Hoffmann#endif
3750014cb152SGerd Hoffmannint main(void) { return 0; }
3751014cb152SGerd HoffmannEOF
3752014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3753014cb152SGerd Hoffmann    opengl_dmabuf=yes
3754014cb152SGerd Hoffmann  fi
3755014cb152SGerd Hoffmannfi
3756c9a12e75SChrysostomos Nanakos
3757ed279a06SKlim Kireev##########################################
3758ed279a06SKlim Kireev# libxml2 probe
3759ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3760ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3761ed279a06SKlim Kireev        libxml2="yes"
3762ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3763ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3764ed279a06SKlim Kireev    else
3765ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3766ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3767ed279a06SKlim Kireev        fi
3768ed279a06SKlim Kireev        libxml2="no"
3769ed279a06SKlim Kireev    fi
3770ed279a06SKlim Kireevfi
3771c9a12e75SChrysostomos Nanakos
3772eb100396SBharata B Rao##########################################
3773eb100396SBharata B Rao# glusterfs probe
3774eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
377565d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3776e01bee08SBharata B Rao    glusterfs="yes"
377789138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
377889138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3779d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3780d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3781d85fa9ebSJeff Cody    fi
378265d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
37830c14fb47SBharata B Rao      glusterfs_discard="yes"
37840c14fb47SBharata B Rao    fi
37857c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3786df3a429aSNiels de Vos      glusterfs_fallocate="yes"
37877c815372SBharata B Rao      glusterfs_zerofill="yes"
37887c815372SBharata B Rao    fi
3789eb100396SBharata B Rao  else
3790eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
37918efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
37928efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3793eb100396SBharata B Rao    fi
3794e01bee08SBharata B Rao    glusterfs="no"
3795eb100396SBharata B Rao  fi
3796eb100396SBharata B Raofi
3797eb100396SBharata B Rao
379839386ac7Saurel32# Check for inotify functions when we are building linux-user
37993b3f24adSaurel32# emulator.  This is done because older glibc versions don't
38003b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
38013b3f24adSaurel32# don't provide them even if kernel supports them.
38023b3f24adSaurel32#
38033b3f24adSaurel32inotify=no
38043b3f24adSaurel32cat > $TMPC << EOF
38053b3f24adSaurel32#include <sys/inotify.h>
38063b3f24adSaurel32
38073b3f24adSaurel32int
38083b3f24adSaurel32main(void)
38093b3f24adSaurel32{
38103b3f24adSaurel32	/* try to start inotify */
38118690e420Saurel32	return inotify_init();
38123b3f24adSaurel32}
38133b3f24adSaurel32EOF
381452166aa0SJuan Quintelaif compile_prog "" "" ; then
38153b3f24adSaurel32  inotify=yes
38163b3f24adSaurel32fi
38173b3f24adSaurel32
3818c05c7a73SRiku Voipioinotify1=no
3819c05c7a73SRiku Voipiocat > $TMPC << EOF
3820c05c7a73SRiku Voipio#include <sys/inotify.h>
3821c05c7a73SRiku Voipio
3822c05c7a73SRiku Voipioint
3823c05c7a73SRiku Voipiomain(void)
3824c05c7a73SRiku Voipio{
3825c05c7a73SRiku Voipio    /* try to start inotify */
3826c05c7a73SRiku Voipio    return inotify_init1(0);
3827c05c7a73SRiku Voipio}
3828c05c7a73SRiku VoipioEOF
3829c05c7a73SRiku Voipioif compile_prog "" "" ; then
3830c05c7a73SRiku Voipio  inotify1=yes
3831c05c7a73SRiku Voipiofi
3832c05c7a73SRiku Voipio
3833099d6b0fSRiku Voipio# check if pipe2 is there
3834099d6b0fSRiku Voipiopipe2=no
3835099d6b0fSRiku Voipiocat > $TMPC << EOF
3836099d6b0fSRiku Voipio#include <unistd.h>
3837099d6b0fSRiku Voipio#include <fcntl.h>
3838099d6b0fSRiku Voipio
3839099d6b0fSRiku Voipioint main(void)
3840099d6b0fSRiku Voipio{
3841099d6b0fSRiku Voipio    int pipefd[2];
38429bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3843099d6b0fSRiku Voipio}
3844099d6b0fSRiku VoipioEOF
384552166aa0SJuan Quintelaif compile_prog "" "" ; then
3846099d6b0fSRiku Voipio  pipe2=yes
3847099d6b0fSRiku Voipiofi
3848099d6b0fSRiku Voipio
384940ff6d7eSKevin Wolf# check if accept4 is there
385040ff6d7eSKevin Wolfaccept4=no
385140ff6d7eSKevin Wolfcat > $TMPC << EOF
385240ff6d7eSKevin Wolf#include <sys/socket.h>
385340ff6d7eSKevin Wolf#include <stddef.h>
385440ff6d7eSKevin Wolf
385540ff6d7eSKevin Wolfint main(void)
385640ff6d7eSKevin Wolf{
385740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
385840ff6d7eSKevin Wolf    return 0;
385940ff6d7eSKevin Wolf}
386040ff6d7eSKevin WolfEOF
386140ff6d7eSKevin Wolfif compile_prog "" "" ; then
386240ff6d7eSKevin Wolf  accept4=yes
386340ff6d7eSKevin Wolffi
386440ff6d7eSKevin Wolf
38653ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
38663ce34dfbSvibisreenivasansplice=no
38673ce34dfbSvibisreenivasancat > $TMPC << EOF
38683ce34dfbSvibisreenivasan#include <unistd.h>
38693ce34dfbSvibisreenivasan#include <fcntl.h>
38703ce34dfbSvibisreenivasan#include <limits.h>
38713ce34dfbSvibisreenivasan
38723ce34dfbSvibisreenivasanint main(void)
38733ce34dfbSvibisreenivasan{
387466ea0f22SStefan Weil    int len, fd = 0;
38753ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
38763ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
38773ce34dfbSvibisreenivasan    return 0;
38783ce34dfbSvibisreenivasan}
38793ce34dfbSvibisreenivasanEOF
388052166aa0SJuan Quintelaif compile_prog "" "" ; then
38813ce34dfbSvibisreenivasan  splice=yes
38823ce34dfbSvibisreenivasanfi
38833ce34dfbSvibisreenivasan
3884dcc38d1cSMarcelo Tosatti##########################################
3885a99d57bbSWanlong Gao# libnuma probe
3886a99d57bbSWanlong Gao
3887a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3888a99d57bbSWanlong Gao  cat > $TMPC << EOF
3889a99d57bbSWanlong Gao#include <numa.h>
3890a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3891a99d57bbSWanlong GaoEOF
3892a99d57bbSWanlong Gao
3893a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3894a99d57bbSWanlong Gao    numa=yes
3895a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3896a99d57bbSWanlong Gao  else
3897a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3898a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3899a99d57bbSWanlong Gao    fi
3900a99d57bbSWanlong Gao    numa=no
3901a99d57bbSWanlong Gao  fi
3902a99d57bbSWanlong Gaofi
3903a99d57bbSWanlong Gao
39047b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
39057b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
39067b01cb97SAlexandre Derumier    exit 1
39077b01cb97SAlexandre Derumierfi
39087b01cb97SAlexandre Derumier
39095a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
39105a22ab71SYang Zhong# do not support it.
39115a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
39125a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
39135a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
39145a22ab71SYang Zhong    fi
39155a22ab71SYang Zhong    malloc_trim="no"
39165a22ab71SYang Zhongfi
39175a22ab71SYang Zhong
39185a22ab71SYang Zhong#######################################
39195a22ab71SYang Zhong# malloc_trim
39205a22ab71SYang Zhong
39215a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
39225a22ab71SYang Zhong    cat > $TMPC << EOF
39235a22ab71SYang Zhong#include <malloc.h>
39245a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
39255a22ab71SYang ZhongEOF
39265a22ab71SYang Zhong    if compile_prog "" "" ; then
39275a22ab71SYang Zhong        malloc_trim="yes"
39285a22ab71SYang Zhong    else
39295a22ab71SYang Zhong        malloc_trim="no"
39305a22ab71SYang Zhong    fi
39315a22ab71SYang Zhongfi
39325a22ab71SYang Zhong
3933a99d57bbSWanlong Gao##########################################
39342847b469SFam Zheng# tcmalloc probe
39352847b469SFam Zheng
39362847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
39372847b469SFam Zheng  cat > $TMPC << EOF
39382847b469SFam Zheng#include <stdlib.h>
39392847b469SFam Zhengint main(void) { malloc(1); return 0; }
39402847b469SFam ZhengEOF
39412847b469SFam Zheng
39422847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
39432847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
39442847b469SFam Zheng  else
39452847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
39462847b469SFam Zheng  fi
39472847b469SFam Zhengfi
39482847b469SFam Zheng
39492847b469SFam Zheng##########################################
39507b01cb97SAlexandre Derumier# jemalloc probe
39517b01cb97SAlexandre Derumier
39527b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
39537b01cb97SAlexandre Derumier  cat > $TMPC << EOF
39547b01cb97SAlexandre Derumier#include <stdlib.h>
39557b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
39567b01cb97SAlexandre DerumierEOF
39577b01cb97SAlexandre Derumier
39587b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
39597b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
39607b01cb97SAlexandre Derumier  else
39617b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
39627b01cb97SAlexandre Derumier  fi
39637b01cb97SAlexandre Derumierfi
39647b01cb97SAlexandre Derumier
39657b01cb97SAlexandre Derumier##########################################
3966dcc38d1cSMarcelo Tosatti# signalfd probe
3967dcc38d1cSMarcelo Tosattisignalfd="no"
3968dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3969dcc38d1cSMarcelo Tosatti#include <unistd.h>
3970dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3971dcc38d1cSMarcelo Tosatti#include <signal.h>
3972dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3973dcc38d1cSMarcelo TosattiEOF
3974dcc38d1cSMarcelo Tosatti
3975dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3976dcc38d1cSMarcelo Tosatti  signalfd=yes
3977dcc38d1cSMarcelo Tosattifi
3978dcc38d1cSMarcelo Tosatti
3979c2882b96SRiku Voipio# check if eventfd is supported
3980c2882b96SRiku Voipioeventfd=no
3981c2882b96SRiku Voipiocat > $TMPC << EOF
3982c2882b96SRiku Voipio#include <sys/eventfd.h>
3983c2882b96SRiku Voipio
3984c2882b96SRiku Voipioint main(void)
3985c2882b96SRiku Voipio{
398655cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3987c2882b96SRiku Voipio}
3988c2882b96SRiku VoipioEOF
3989c2882b96SRiku Voipioif compile_prog "" "" ; then
3990c2882b96SRiku Voipio  eventfd=yes
3991c2882b96SRiku Voipiofi
3992c2882b96SRiku Voipio
3993751bcc39SMarc-André Lureau# check if memfd is supported
3994751bcc39SMarc-André Lureaumemfd=no
3995751bcc39SMarc-André Lureaucat > $TMPC << EOF
399675e5b70eSPaolo Bonzini#include <sys/mman.h>
3997751bcc39SMarc-André Lureau
3998751bcc39SMarc-André Lureauint main(void)
3999751bcc39SMarc-André Lureau{
4000751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4001751bcc39SMarc-André Lureau}
4002751bcc39SMarc-André LureauEOF
4003751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4004751bcc39SMarc-André Lureau  memfd=yes
4005751bcc39SMarc-André Lureaufi
4006751bcc39SMarc-André Lureau
4007751bcc39SMarc-André Lureau
4008751bcc39SMarc-André Lureau
4009d0927938SUlrich Hecht# check for fallocate
4010d0927938SUlrich Hechtfallocate=no
4011d0927938SUlrich Hechtcat > $TMPC << EOF
4012d0927938SUlrich Hecht#include <fcntl.h>
4013d0927938SUlrich Hecht
4014d0927938SUlrich Hechtint main(void)
4015d0927938SUlrich Hecht{
4016d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4017d0927938SUlrich Hecht    return 0;
4018d0927938SUlrich Hecht}
4019d0927938SUlrich HechtEOF
40208fb03151SPeter Maydellif compile_prog "" "" ; then
4021d0927938SUlrich Hecht  fallocate=yes
4022d0927938SUlrich Hechtfi
4023d0927938SUlrich Hecht
40243d4fa43eSKusanagi Kouichi# check for fallocate hole punching
40253d4fa43eSKusanagi Kouichifallocate_punch_hole=no
40263d4fa43eSKusanagi Kouichicat > $TMPC << EOF
40273d4fa43eSKusanagi Kouichi#include <fcntl.h>
40283d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
40293d4fa43eSKusanagi Kouichi
40303d4fa43eSKusanagi Kouichiint main(void)
40313d4fa43eSKusanagi Kouichi{
40323d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
40333d4fa43eSKusanagi Kouichi    return 0;
40343d4fa43eSKusanagi Kouichi}
40353d4fa43eSKusanagi KouichiEOF
40363d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
40373d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
40383d4fa43eSKusanagi Kouichifi
40393d4fa43eSKusanagi Kouichi
4040b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4041b953f075SDenis V. Lunevfallocate_zero_range=no
4042b953f075SDenis V. Lunevcat > $TMPC << EOF
4043b953f075SDenis V. Lunev#include <fcntl.h>
4044b953f075SDenis V. Lunev#include <linux/falloc.h>
4045b953f075SDenis V. Lunev
4046b953f075SDenis V. Lunevint main(void)
4047b953f075SDenis V. Lunev{
4048b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4049b953f075SDenis V. Lunev    return 0;
4050b953f075SDenis V. Lunev}
4051b953f075SDenis V. LunevEOF
4052b953f075SDenis V. Lunevif compile_prog "" "" ; then
4053b953f075SDenis V. Lunev  fallocate_zero_range=yes
4054b953f075SDenis V. Lunevfi
4055b953f075SDenis V. Lunev
4056ed911435SKevin Wolf# check for posix_fallocate
4057ed911435SKevin Wolfposix_fallocate=no
4058ed911435SKevin Wolfcat > $TMPC << EOF
4059ed911435SKevin Wolf#include <fcntl.h>
4060ed911435SKevin Wolf
4061ed911435SKevin Wolfint main(void)
4062ed911435SKevin Wolf{
4063ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4064ed911435SKevin Wolf    return 0;
4065ed911435SKevin Wolf}
4066ed911435SKevin WolfEOF
4067ed911435SKevin Wolfif compile_prog "" "" ; then
4068ed911435SKevin Wolf    posix_fallocate=yes
4069ed911435SKevin Wolffi
4070ed911435SKevin Wolf
4071c727f47dSPeter Maydell# check for sync_file_range
4072c727f47dSPeter Maydellsync_file_range=no
4073c727f47dSPeter Maydellcat > $TMPC << EOF
4074c727f47dSPeter Maydell#include <fcntl.h>
4075c727f47dSPeter Maydell
4076c727f47dSPeter Maydellint main(void)
4077c727f47dSPeter Maydell{
4078c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4079c727f47dSPeter Maydell    return 0;
4080c727f47dSPeter Maydell}
4081c727f47dSPeter MaydellEOF
40828fb03151SPeter Maydellif compile_prog "" "" ; then
4083c727f47dSPeter Maydell  sync_file_range=yes
4084c727f47dSPeter Maydellfi
4085c727f47dSPeter Maydell
4086dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4087dace20dcSPeter Maydellfiemap=no
4088dace20dcSPeter Maydellcat > $TMPC << EOF
4089dace20dcSPeter Maydell#include <sys/ioctl.h>
4090dace20dcSPeter Maydell#include <linux/fs.h>
4091dace20dcSPeter Maydell#include <linux/fiemap.h>
4092dace20dcSPeter Maydell
4093dace20dcSPeter Maydellint main(void)
4094dace20dcSPeter Maydell{
4095dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4096dace20dcSPeter Maydell    return 0;
4097dace20dcSPeter Maydell}
4098dace20dcSPeter MaydellEOF
40998fb03151SPeter Maydellif compile_prog "" "" ; then
4100dace20dcSPeter Maydell  fiemap=yes
4101dace20dcSPeter Maydellfi
4102dace20dcSPeter Maydell
4103d0927938SUlrich Hecht# check for dup3
4104d0927938SUlrich Hechtdup3=no
4105d0927938SUlrich Hechtcat > $TMPC << EOF
4106d0927938SUlrich Hecht#include <unistd.h>
4107d0927938SUlrich Hecht
4108d0927938SUlrich Hechtint main(void)
4109d0927938SUlrich Hecht{
4110d0927938SUlrich Hecht    dup3(0, 0, 0);
4111d0927938SUlrich Hecht    return 0;
4112d0927938SUlrich Hecht}
4113d0927938SUlrich HechtEOF
411478f5d726SJan Kiszkaif compile_prog "" "" ; then
4115d0927938SUlrich Hecht  dup3=yes
4116d0927938SUlrich Hechtfi
4117d0927938SUlrich Hecht
41184e0c6529SAlex Bligh# check for ppoll support
41194e0c6529SAlex Blighppoll=no
41204e0c6529SAlex Blighcat > $TMPC << EOF
41214e0c6529SAlex Bligh#include <poll.h>
41224e0c6529SAlex Bligh
41234e0c6529SAlex Blighint main(void)
41244e0c6529SAlex Bligh{
41254e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
41264e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
41274e0c6529SAlex Bligh    return 0;
41284e0c6529SAlex Bligh}
41294e0c6529SAlex BlighEOF
41304e0c6529SAlex Blighif compile_prog "" "" ; then
41314e0c6529SAlex Bligh  ppoll=yes
41324e0c6529SAlex Blighfi
41334e0c6529SAlex Bligh
4134cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4135cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4136cd758dd0SAlex Blighcat > $TMPC << EOF
4137cd758dd0SAlex Bligh#include <sys/prctl.h>
4138cd758dd0SAlex Bligh
4139cd758dd0SAlex Blighint main(void)
4140cd758dd0SAlex Bligh{
4141cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4142cd758dd0SAlex Bligh    return 0;
4143cd758dd0SAlex Bligh}
4144cd758dd0SAlex BlighEOF
4145cd758dd0SAlex Blighif compile_prog "" "" ; then
4146cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4147cd758dd0SAlex Blighfi
4148cd758dd0SAlex Bligh
41493b6edd16SPeter Maydell# check for epoll support
41503b6edd16SPeter Maydellepoll=no
41513b6edd16SPeter Maydellcat > $TMPC << EOF
41523b6edd16SPeter Maydell#include <sys/epoll.h>
41533b6edd16SPeter Maydell
41543b6edd16SPeter Maydellint main(void)
41553b6edd16SPeter Maydell{
41563b6edd16SPeter Maydell    epoll_create(0);
41573b6edd16SPeter Maydell    return 0;
41583b6edd16SPeter Maydell}
41593b6edd16SPeter MaydellEOF
41608fb03151SPeter Maydellif compile_prog "" "" ; then
41613b6edd16SPeter Maydell  epoll=yes
41623b6edd16SPeter Maydellfi
41633b6edd16SPeter Maydell
4164227f0214SPeter Maydell# epoll_create1 is a later addition
4165227f0214SPeter Maydell# so we must check separately for its presence
41663b6edd16SPeter Maydellepoll_create1=no
41673b6edd16SPeter Maydellcat > $TMPC << EOF
41683b6edd16SPeter Maydell#include <sys/epoll.h>
41693b6edd16SPeter Maydell
41703b6edd16SPeter Maydellint main(void)
41713b6edd16SPeter Maydell{
417219e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
417319e83f6bSPeter Maydell     * a function being called. This is necessary so that on
417419e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
417519e83f6bSPeter Maydell     * the library but not declared in the header file we will
417619e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
417719e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
417819e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
417919e83f6bSPeter Maydell     */
4180c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
41813b6edd16SPeter Maydell}
41823b6edd16SPeter MaydellEOF
41838fb03151SPeter Maydellif compile_prog "" "" ; then
41843b6edd16SPeter Maydell  epoll_create1=yes
41853b6edd16SPeter Maydellfi
41863b6edd16SPeter Maydell
4187a8fd1abaSPeter Maydell# check for sendfile support
4188a8fd1abaSPeter Maydellsendfile=no
4189a8fd1abaSPeter Maydellcat > $TMPC << EOF
4190a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4191a8fd1abaSPeter Maydell
4192a8fd1abaSPeter Maydellint main(void)
4193a8fd1abaSPeter Maydell{
4194a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4195a8fd1abaSPeter Maydell}
4196a8fd1abaSPeter MaydellEOF
4197a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4198a8fd1abaSPeter Maydell  sendfile=yes
4199a8fd1abaSPeter Maydellfi
4200a8fd1abaSPeter Maydell
420151834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
420251834341SRiku Voipiotimerfd=no
420351834341SRiku Voipiocat > $TMPC << EOF
420451834341SRiku Voipio#include <sys/timerfd.h>
420551834341SRiku Voipio
420651834341SRiku Voipioint main(void)
420751834341SRiku Voipio{
420851834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
420951834341SRiku Voipio}
421051834341SRiku VoipioEOF
421151834341SRiku Voipioif compile_prog "" "" ; then
421251834341SRiku Voipio  timerfd=yes
421351834341SRiku Voipiofi
421451834341SRiku Voipio
42159af5c906SRiku Voipio# check for setns and unshare support
42169af5c906SRiku Voipiosetns=no
42179af5c906SRiku Voipiocat > $TMPC << EOF
42189af5c906SRiku Voipio#include <sched.h>
42199af5c906SRiku Voipio
42209af5c906SRiku Voipioint main(void)
42219af5c906SRiku Voipio{
42229af5c906SRiku Voipio    int ret;
42239af5c906SRiku Voipio    ret = setns(0, 0);
42249af5c906SRiku Voipio    ret = unshare(0);
42259af5c906SRiku Voipio    return ret;
42269af5c906SRiku Voipio}
42279af5c906SRiku VoipioEOF
42289af5c906SRiku Voipioif compile_prog "" "" ; then
42299af5c906SRiku Voipio  setns=yes
42309af5c906SRiku Voipiofi
42319af5c906SRiku Voipio
423238860a03SAleksandar Markovic# clock_adjtime probe
423338860a03SAleksandar Markovicclock_adjtime=no
423438860a03SAleksandar Markoviccat > $TMPC <<EOF
423538860a03SAleksandar Markovic#include <time.h>
423638860a03SAleksandar Markovic
423738860a03SAleksandar Markovicint main(void)
423838860a03SAleksandar Markovic{
423938860a03SAleksandar Markovic    return clock_adjtime(0, 0);
424038860a03SAleksandar Markovic}
424138860a03SAleksandar MarkovicEOF
424238860a03SAleksandar Markovicclock_adjtime=no
424338860a03SAleksandar Markovicif compile_prog "" "" ; then
424438860a03SAleksandar Markovic  clock_adjtime=yes
424538860a03SAleksandar Markovicfi
424638860a03SAleksandar Markovic
42475a03cd00SAleksandar Markovic# syncfs probe
42485a03cd00SAleksandar Markovicsyncfs=no
42495a03cd00SAleksandar Markoviccat > $TMPC <<EOF
42505a03cd00SAleksandar Markovic#include <unistd.h>
42515a03cd00SAleksandar Markovic
42525a03cd00SAleksandar Markovicint main(void)
42535a03cd00SAleksandar Markovic{
42545a03cd00SAleksandar Markovic    return syncfs(0);
42555a03cd00SAleksandar Markovic}
42565a03cd00SAleksandar MarkovicEOF
42575a03cd00SAleksandar Markovicsyncfs=no
42585a03cd00SAleksandar Markovicif compile_prog "" "" ; then
42595a03cd00SAleksandar Markovic  syncfs=yes
42605a03cd00SAleksandar Markovicfi
42615a03cd00SAleksandar Markovic
4262cc8ae6deSpbrook# Check if tools are available to build documentation.
4263a25dba17SJuan Quintelaif test "$docs" != "no" ; then
426401668d98SStefan Weil  if has makeinfo && has pod2man; then
4265a25dba17SJuan Quintela    docs=yes
426683a3ab8bSJuan Quintela  else
4267a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
426821684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
426983a3ab8bSJuan Quintela    fi
4270a25dba17SJuan Quintela    docs=no
427183a3ab8bSJuan Quintela  fi
4272cc8ae6deSpbrookfi
4273cc8ae6deSpbrook
4274f514f41cSStefan Weil# Search for bswap_32 function
42756ae9a1f4SJuan Quintelabyteswap_h=no
42766ae9a1f4SJuan Quintelacat > $TMPC << EOF
42776ae9a1f4SJuan Quintela#include <byteswap.h>
42786ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
42796ae9a1f4SJuan QuintelaEOF
428052166aa0SJuan Quintelaif compile_prog "" "" ; then
42816ae9a1f4SJuan Quintela  byteswap_h=yes
42826ae9a1f4SJuan Quintelafi
42836ae9a1f4SJuan Quintela
428475f13596SStefan Weil# Search for bswap32 function
42856ae9a1f4SJuan Quintelabswap_h=no
42866ae9a1f4SJuan Quintelacat > $TMPC << EOF
42876ae9a1f4SJuan Quintela#include <sys/endian.h>
42886ae9a1f4SJuan Quintela#include <sys/types.h>
42896ae9a1f4SJuan Quintela#include <machine/bswap.h>
42906ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
42916ae9a1f4SJuan QuintelaEOF
429252166aa0SJuan Quintelaif compile_prog "" "" ; then
42936ae9a1f4SJuan Quintela  bswap_h=yes
42946ae9a1f4SJuan Quintelafi
42956ae9a1f4SJuan Quintela
4296da93a1fdSaliguori##########################################
4297e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4298c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4299e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
43003c33ea96SPaolo Bonzini    libiscsi="yes"
4301ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4302ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4303c589b249SRonnie Sahlberg  else
4304c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4305e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4306c589b249SRonnie Sahlberg    fi
4307c589b249SRonnie Sahlberg    libiscsi="no"
4308c589b249SRonnie Sahlberg  fi
4309c589b249SRonnie Sahlbergfi
4310c589b249SRonnie Sahlberg
4311c589b249SRonnie Sahlberg##########################################
43128bacde8dSNatanael Copa# Do we need libm
43138bacde8dSNatanael Copacat > $TMPC << EOF
43148bacde8dSNatanael Copa#include <math.h>
4315f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
43168bacde8dSNatanael CopaEOF
43178bacde8dSNatanael Copaif compile_prog "" "" ; then
43188bacde8dSNatanael Copa  :
43198bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
43208bacde8dSNatanael Copa  LIBS="-lm $LIBS"
43218bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
43228bacde8dSNatanael Copaelse
432376ad07a4SPeter Maydell  error_exit "libm check failed"
43248bacde8dSNatanael Copafi
43258bacde8dSNatanael Copa
43268bacde8dSNatanael Copa##########################################
4327da93a1fdSaliguori# Do we need librt
43288bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
43298bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
43308bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
43318bacde8dSNatanael Copa# function in addition.
4332da93a1fdSaliguoricat > $TMPC <<EOF
4333da93a1fdSaliguori#include <signal.h>
4334da93a1fdSaliguori#include <time.h>
43358bacde8dSNatanael Copaint main(void) {
43368bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
43378bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
43388bacde8dSNatanael Copa}
4339da93a1fdSaliguoriEOF
4340da93a1fdSaliguori
434152166aa0SJuan Quintelaif compile_prog "" "" ; then
434207ffa4bdSJuan Quintela  :
43438bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
434418e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
434518e588b1SRick Liu  LIBS="$LIBS -lrt"
434618e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4347da93a1fdSaliguorifi
4348da93a1fdSaliguori
434931ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
435078723752SPeter Maydell        "$haiku" != "yes" ; then
43516362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
43526362a53fSJuan Quintelafi
43536362a53fSJuan Quintela
4354de5071c5SBlue Swirl##########################################
4355cd4ec0b4SGerd Hoffmann# spice probe
4356cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4357cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4358cd4ec0b4SGerd Hoffmann#include <spice.h>
4359cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4360cd4ec0b4SGerd HoffmannEOF
4361710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4362710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
436365d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
436465d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4365cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4366cd4ec0b4SGerd Hoffmann    spice="yes"
4367cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4368cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
43692e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
43702e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4371cd4ec0b4SGerd Hoffmann  else
4372cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
43738efc9363SHu Tao      feature_not_found "spice" \
43748efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4375cd4ec0b4SGerd Hoffmann    fi
4376cd4ec0b4SGerd Hoffmann    spice="no"
4377cd4ec0b4SGerd Hoffmann  fi
4378cd4ec0b4SGerd Hoffmannfi
4379cd4ec0b4SGerd Hoffmann
43807b02f544SMarc-André Lureau# check for smartcard support
43817b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
43827b02f544SMarc-André Lureau    if $pkg_config libcacard; then
43837b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
43847b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
43857b02f544SMarc-André Lureau        smartcard="yes"
4386111a38b0SRobert Relyea    else
43877b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
43887b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4389111a38b0SRobert Relyea        fi
43907b02f544SMarc-André Lureau        smartcard="no"
4391111a38b0SRobert Relyea    fi
4392111a38b0SRobert Relyeafi
4393111a38b0SRobert Relyea
43942b2325ffSGerd Hoffmann# check for libusb
43952b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
439665d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
43972b2325ffSGerd Hoffmann        libusb="yes"
4398ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4399ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
44002b2325ffSGerd Hoffmann    else
44012b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
44028efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
44032b2325ffSGerd Hoffmann        fi
44042b2325ffSGerd Hoffmann        libusb="no"
44052b2325ffSGerd Hoffmann    fi
44062b2325ffSGerd Hoffmannfi
44072b2325ffSGerd Hoffmann
440869354a83SHans de Goede# check for usbredirparser for usb network redirection support
440969354a83SHans de Goedeif test "$usb_redir" != "no" ; then
441065d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
441169354a83SHans de Goede        usb_redir="yes"
4412ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4413ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
441469354a83SHans de Goede    else
441569354a83SHans de Goede        if test "$usb_redir" = "yes"; then
441621684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
441769354a83SHans de Goede        fi
441869354a83SHans de Goede        usb_redir="no"
441969354a83SHans de Goede    fi
442069354a83SHans de Goedefi
442169354a83SHans de Goede
4422cd4ec0b4SGerd Hoffmann##########################################
4423d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4424d9840e25STomoki Sekiyama
4425d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4426d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4427690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4428d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4429d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4430690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4431d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4432d9840e25STomoki Sekiyama	  ;;
4433690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4434d9840e25STomoki Sekiyama  esac
4435d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4436d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4437d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4438d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4439d9840e25STomoki SekiyamaEOF
4440d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4441d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4442d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4443315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4444f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4445d9840e25STomoki Sekiyama  else
4446d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4447d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4448d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4449d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4450d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4451d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4452d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4453d9840e25STomoki Sekiyama    fi
4454d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4455d9840e25STomoki Sekiyama  fi
4456d9840e25STomoki Sekiyamafi
4457d9840e25STomoki Sekiyama
4458d9840e25STomoki Sekiyama##########################################
4459d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4460d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4461d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4462d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4463d9840e25STomoki Sekiyama
4464d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4465d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4466d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4467d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4468d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4469d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4470d9840e25STomoki Sekiyama    else
4471d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4472d9840e25STomoki Sekiyama    fi
4473d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4474d9840e25STomoki Sekiyama    win_sdk=""
4475d9840e25STomoki Sekiyama  fi
4476d9840e25STomoki Sekiyamafi
4477d9840e25STomoki Sekiyama
4478d9840e25STomoki Sekiyama##########################################
447950cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
448050cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
448150cbebb9SMichael Roth  cat > $TMPC << EOF
448250cbebb9SMichael Roth#include <windows.h>
448350cbebb9SMichael Roth#include <ntddscsi.h>
448450cbebb9SMichael Rothint main(void) {
448550cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
448650cbebb9SMichael Roth#error Missing required ioctl definitions
448750cbebb9SMichael Roth#endif
448850cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
448950cbebb9SMichael Roth  return addr.Lun;
449050cbebb9SMichael Roth}
449150cbebb9SMichael RothEOF
449250cbebb9SMichael Roth  if compile_prog "" "" ; then
449350cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4494c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
449550cbebb9SMichael Roth  fi
449650cbebb9SMichael Rothfi
449750cbebb9SMichael Roth
449850cbebb9SMichael Roth##########################################
44999d9e1521SGerd Hoffmann# virgl renderer probe
45009d9e1521SGerd Hoffmann
45019d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
45029d9e1521SGerd Hoffmann  cat > $TMPC << EOF
45039d9e1521SGerd Hoffmann#include <virglrenderer.h>
45049d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
45059d9e1521SGerd HoffmannEOF
45069d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
45079d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
45089d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
45099d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
45109d9e1521SGerd Hoffmann    virglrenderer="yes"
45119d9e1521SGerd Hoffmann  else
45129d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
45139d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
45149d9e1521SGerd Hoffmann    fi
45159d9e1521SGerd Hoffmann    virglrenderer="no"
45169d9e1521SGerd Hoffmann  fi
45179d9e1521SGerd Hoffmannfi
45189d9e1521SGerd Hoffmann
45199d9e1521SGerd Hoffmann##########################################
45208ca80760SRichard Henderson# capstone
45218ca80760SRichard Henderson
4522e219c499SRichard Hendersoncase "$capstone" in
4523e219c499SRichard Henderson  "" | yes)
45248ca80760SRichard Henderson    if $pkg_config capstone; then
4525e219c499SRichard Henderson      capstone=system
4526e219c499SRichard Henderson    elif test -e "${source_path}/.git" ; then
4527e219c499SRichard Henderson      capstone=git
4528e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
4529e219c499SRichard Henderson      capstone=internal
4530e219c499SRichard Henderson    elif test -z "$capstone" ; then
4531e219c499SRichard Henderson      capstone=no
4532e219c499SRichard Henderson    else
4533e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
4534e219c499SRichard Henderson    fi
4535e219c499SRichard Henderson    ;;
4536e219c499SRichard Henderson
4537e219c499SRichard Henderson  system)
4538e219c499SRichard Henderson    if ! $pkg_config capstone; then
4539e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
4540e219c499SRichard Henderson    fi
4541e219c499SRichard Henderson    ;;
4542e219c499SRichard Hendersonesac
4543e219c499SRichard Henderson
4544e219c499SRichard Hendersoncase "$capstone" in
4545e219c499SRichard Henderson  git | internal)
4546e219c499SRichard Henderson    if test "$capstone" = git; then
4547e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4548e219c499SRichard Henderson    fi
4549e219c499SRichard Henderson    mkdir -p capstone
4550e219c499SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4551e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
4552e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
4553e219c499SRichard Henderson    else
4554e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
4555e219c499SRichard Henderson    fi
4556e219c499SRichard Henderson    LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4557e219c499SRichard Henderson    ;;
4558e219c499SRichard Henderson
4559e219c499SRichard Henderson  system)
45608ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
45618ca80760SRichard Henderson    LIBS="$($pkg_config --libs capstone) $LIBS"
4562e219c499SRichard Henderson    ;;
4563e219c499SRichard Henderson
4564e219c499SRichard Henderson  no)
4565e219c499SRichard Henderson    ;;
4566e219c499SRichard Henderson  *)
4567e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
4568e219c499SRichard Henderson    ;;
4569e219c499SRichard Hendersonesac
45708ca80760SRichard Henderson
45718ca80760SRichard Henderson##########################################
45725f6b9e8fSBlue Swirl# check if we have fdatasync
45735f6b9e8fSBlue Swirl
45745f6b9e8fSBlue Swirlfdatasync=no
45755f6b9e8fSBlue Swirlcat > $TMPC << EOF
45765f6b9e8fSBlue Swirl#include <unistd.h>
4577d1722a27SAlexandre Raymondint main(void) {
4578d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4579d1722a27SAlexandre Raymondreturn fdatasync(0);
4580d1722a27SAlexandre Raymond#else
4581e172fe11SStefan Weil#error Not supported
4582d1722a27SAlexandre Raymond#endif
4583d1722a27SAlexandre Raymond}
45845f6b9e8fSBlue SwirlEOF
45855f6b9e8fSBlue Swirlif compile_prog "" "" ; then
45865f6b9e8fSBlue Swirl    fdatasync=yes
45875f6b9e8fSBlue Swirlfi
45885f6b9e8fSBlue Swirl
458994a420b1SStefan Hajnoczi##########################################
4590e78815a5SAndreas Färber# check if we have madvise
4591e78815a5SAndreas Färber
4592e78815a5SAndreas Färbermadvise=no
4593e78815a5SAndreas Färbercat > $TMPC << EOF
4594e78815a5SAndreas Färber#include <sys/types.h>
4595e78815a5SAndreas Färber#include <sys/mman.h>
4596832ce9c2SScott Wood#include <stddef.h>
4597e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4598e78815a5SAndreas FärberEOF
4599e78815a5SAndreas Färberif compile_prog "" "" ; then
4600e78815a5SAndreas Färber    madvise=yes
4601e78815a5SAndreas Färberfi
4602e78815a5SAndreas Färber
4603e78815a5SAndreas Färber##########################################
4604e78815a5SAndreas Färber# check if we have posix_madvise
4605e78815a5SAndreas Färber
4606e78815a5SAndreas Färberposix_madvise=no
4607e78815a5SAndreas Färbercat > $TMPC << EOF
4608e78815a5SAndreas Färber#include <sys/mman.h>
4609832ce9c2SScott Wood#include <stddef.h>
4610e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4611e78815a5SAndreas FärberEOF
4612e78815a5SAndreas Färberif compile_prog "" "" ; then
4613e78815a5SAndreas Färber    posix_madvise=yes
4614e78815a5SAndreas Färberfi
4615e78815a5SAndreas Färber
4616e78815a5SAndreas Färber##########################################
46170a852417SPaul Durrant# check if we have posix_syslog
46180a852417SPaul Durrant
46190a852417SPaul Durrantposix_syslog=no
46200a852417SPaul Durrantcat > $TMPC << EOF
46210a852417SPaul Durrant#include <syslog.h>
46220a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
46230a852417SPaul DurrantEOF
46240a852417SPaul Durrantif compile_prog "" "" ; then
46250a852417SPaul Durrant    posix_syslog=yes
46260a852417SPaul Durrantfi
46270a852417SPaul Durrant
46280a852417SPaul Durrant##########################################
4629401bc051SPeter Maydell# check if we have sem_timedwait
4630401bc051SPeter Maydell
4631401bc051SPeter Maydellsem_timedwait=no
4632401bc051SPeter Maydellcat > $TMPC << EOF
4633401bc051SPeter Maydell#include <semaphore.h>
4634401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4635401bc051SPeter MaydellEOF
4636401bc051SPeter Maydellif compile_prog "" "" ; then
4637401bc051SPeter Maydell    sem_timedwait=yes
4638401bc051SPeter Maydellfi
4639401bc051SPeter Maydell
4640401bc051SPeter Maydell##########################################
464194a420b1SStefan Hajnoczi# check if trace backend exists
464294a420b1SStefan Hajnoczi
46435b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
464494a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
46455b808275SLluís Vilanova  error_exit "invalid trace backends" \
46465b808275SLluís Vilanova      "Please choose supported trace backends."
464794a420b1SStefan Hajnoczifi
464894a420b1SStefan Hajnoczi
46497e24e92aSStefan Hajnoczi##########################################
46507e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
46515b808275SLluís Vilanovaif have_backend "ust"; then
46527e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4653bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
46547e24e92aSStefan Hajnocziint main(void) { return 0; }
46557e24e92aSStefan HajnocziEOF
4656c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4657bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
465889138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
46597e24e92aSStefan Hajnoczi    else
4660c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4661bf15f63cSMohamad Gebai    fi
4662bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
466389138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4664bf15f63cSMohamad Gebai    else
4665bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4666bf15f63cSMohamad Gebai    fi
4667bf15f63cSMohamad Gebai
4668bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4669bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4670bf15f63cSMohamad Gebai  else
4671bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
46727e24e92aSStefan Hajnoczi  fi
46737e24e92aSStefan Hajnoczifi
4674b3d08c02SDaniel P. Berrange
4675b3d08c02SDaniel P. Berrange##########################################
4676b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
46775b808275SLluís Vilanovaif have_backend "dtrace"; then
4678b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
467976ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4680b3d08c02SDaniel P. Berrange  fi
4681c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4682c276b17dSDaniel P. Berrange  if has 'stap' ; then
4683c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4684c276b17dSDaniel P. Berrange  fi
4685b3d08c02SDaniel P. Berrangefi
4686b3d08c02SDaniel P. Berrange
46877e24e92aSStefan Hajnoczi##########################################
4688519175a2SAlex Barcelo# check and set a backend for coroutine
4689d0e2fce5SAneesh Kumar K.V
46907c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
469133c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
469233c53c54SDaniel P. Berrange# specific one.
46937c2acc70SPeter Maydell
46947c2acc70SPeter Maydellucontext_works=no
4695d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4696d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4697d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4698cdf84806SPeter Maydell#ifdef __stub_makecontext
4699cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4700cdf84806SPeter Maydell#endif
470175cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4702d0e2fce5SAneesh Kumar K.VEOF
4703d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
47047c2acc70SPeter Maydell    ucontext_works=yes
4705d0e2fce5SAneesh Kumar K.V  fi
4706519175a2SAlex Barcelofi
47077c2acc70SPeter Maydell
47087c2acc70SPeter Maydellif test "$coroutine" = ""; then
47097c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
47107c2acc70SPeter Maydell    coroutine=win32
47117c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
47127c2acc70SPeter Maydell    coroutine=ucontext
4713519175a2SAlex Barcelo  else
47147c2acc70SPeter Maydell    coroutine=sigaltstack
47157c2acc70SPeter Maydell  fi
47167c2acc70SPeter Maydellelse
47177c2acc70SPeter Maydell  case $coroutine in
47187c2acc70SPeter Maydell  windows)
47197c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
47207c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
47217c2acc70SPeter Maydell    fi
47227c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
47237c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
47247c2acc70SPeter Maydell    coroutine=win32
47257c2acc70SPeter Maydell    ;;
47267c2acc70SPeter Maydell  ucontext)
47277c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
47287c2acc70SPeter Maydell      feature_not_found "ucontext"
47297c2acc70SPeter Maydell    fi
47307c2acc70SPeter Maydell    ;;
473133c53c54SDaniel P. Berrange  sigaltstack)
47327c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
47337c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
47347c2acc70SPeter Maydell    fi
47357c2acc70SPeter Maydell    ;;
47367c2acc70SPeter Maydell  *)
473776ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
47387c2acc70SPeter Maydell    ;;
47397c2acc70SPeter Maydell  esac
4740d0e2fce5SAneesh Kumar K.Vfi
4741d0e2fce5SAneesh Kumar K.V
474270c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
474370c60c08SStefan Hajnoczi  coroutine_pool=yes
474470c60c08SStefan Hajnoczifi
474570c60c08SStefan Hajnoczi
47467d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
47477d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
47487d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
47497d992e4dSPeter Lieven  fi
47507d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
47517d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
47527d992e4dSPeter Lieven    coroutine_pool=no
47537d992e4dSPeter Lieven  fi
47547d992e4dSPeter Lievenfi
47557d992e4dSPeter Lieven
47567d992e4dSPeter Lieven
4757d0e2fce5SAneesh Kumar K.V##########################################
4758d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4759d2042378SAneesh Kumar K.V
47604e1797f9SStefan Weilopen_by_handle_at=no
4761d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4762d2042378SAneesh Kumar K.V#include <fcntl.h>
4763acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4764acc55ba8SStefan Weil# error missing definition
4765acc55ba8SStefan Weil#else
476675cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4767acc55ba8SStefan Weil#endif
4768d2042378SAneesh Kumar K.VEOF
4769d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4770d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4771d2042378SAneesh Kumar K.Vfi
4772d2042378SAneesh Kumar K.V
4773e06a765eSHarsh Prateek Bora########################################
4774e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4775e06a765eSHarsh Prateek Bora
4776e06a765eSHarsh Prateek Boralinux_magic_h=no
4777e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4778e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4779e06a765eSHarsh Prateek Boraint main(void) {
478075cafad7SStefan Weil  return 0;
4781e06a765eSHarsh Prateek Bora}
4782e06a765eSHarsh Prateek BoraEOF
4783e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4784e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4785e06a765eSHarsh Prateek Borafi
4786e06a765eSHarsh Prateek Bora
47878ab1bf12SLuiz Capitulino########################################
4788c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4789c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4790c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4791c95e3080SKevin Wolf# only a warning.
4792c95e3080SKevin Wolf#
4793c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4794c95e3080SKevin Wolf# the build doesn't fail anyway.
4795c95e3080SKevin Wolf
479606d71fa1SPeter Maydellpragma_disable_unused_but_set=no
479706d71fa1SPeter Maydellcat > $TMPC << EOF
4798e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
479906d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4800c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4801e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4802c95e3080SKevin Wolf
480306d71fa1SPeter Maydellint main(void) {
480406d71fa1SPeter Maydell    return 0;
480506d71fa1SPeter Maydell}
480606d71fa1SPeter MaydellEOF
480706d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4808cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4809c95e3080SKevin Wolfelse
4810c95e3080SKevin Wolf    werror=no
481106d71fa1SPeter Maydellfi
481206d71fa1SPeter Maydell
481306d71fa1SPeter Maydell########################################
4814541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
48153f4349dcSKevin Wolf
48163f4349dcSKevin Wolfvalgrind_h=no
48173f4349dcSKevin Wolfcat > $TMPC << EOF
48183f4349dcSKevin Wolf#include <valgrind/valgrind.h>
48193f4349dcSKevin Wolfint main(void) {
48203f4349dcSKevin Wolf  return 0;
48213f4349dcSKevin Wolf}
48223f4349dcSKevin WolfEOF
48233f4349dcSKevin Wolfif compile_prog "" "" ; then
48243f4349dcSKevin Wolf    valgrind_h=yes
48253f4349dcSKevin Wolffi
48263f4349dcSKevin Wolf
48273f4349dcSKevin Wolf########################################
48288ab1bf12SLuiz Capitulino# check if environ is declared
48298ab1bf12SLuiz Capitulino
48308ab1bf12SLuiz Capitulinohas_environ=no
48318ab1bf12SLuiz Capitulinocat > $TMPC << EOF
48328ab1bf12SLuiz Capitulino#include <unistd.h>
48338ab1bf12SLuiz Capitulinoint main(void) {
4834c075a723SBlue Swirl    environ = 0;
48358ab1bf12SLuiz Capitulino    return 0;
48368ab1bf12SLuiz Capitulino}
48378ab1bf12SLuiz CapitulinoEOF
48388ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
48398ab1bf12SLuiz Capitulino    has_environ=yes
48408ab1bf12SLuiz Capitulinofi
48418ab1bf12SLuiz Capitulino
484276a347e1SRichard Henderson########################################
484376a347e1SRichard Henderson# check if cpuid.h is usable.
484476a347e1SRichard Henderson
484576a347e1SRichard Hendersoncat > $TMPC << EOF
484676a347e1SRichard Henderson#include <cpuid.h>
484776a347e1SRichard Hendersonint main(void) {
4848774d566cSPeter Maydell    unsigned a, b, c, d;
4849774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4850774d566cSPeter Maydell
4851774d566cSPeter Maydell    if (max >= 1) {
4852774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4853774d566cSPeter Maydell    }
4854774d566cSPeter Maydell
4855774d566cSPeter Maydell    if (max >= 7) {
4856774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4857774d566cSPeter Maydell    }
4858774d566cSPeter Maydell
485976a347e1SRichard Henderson    return 0;
486076a347e1SRichard Henderson}
486176a347e1SRichard HendersonEOF
486276a347e1SRichard Hendersonif compile_prog "" "" ; then
486376a347e1SRichard Henderson    cpuid_h=yes
486476a347e1SRichard Hendersonfi
486576a347e1SRichard Henderson
48665dd89908SRichard Henderson##########################################
48675dd89908SRichard Henderson# avx2 optimization requirement check
48685dd89908SRichard Henderson#
48695dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
48705dd89908SRichard Henderson# since we won't be able to select the new routines.
48715dd89908SRichard Henderson
48725dd89908SRichard Hendersonif test $cpuid_h = yes; then
48735dd89908SRichard Henderson  cat > $TMPC << EOF
48745dd89908SRichard Henderson#pragma GCC push_options
48755dd89908SRichard Henderson#pragma GCC target("avx2")
48765dd89908SRichard Henderson#include <cpuid.h>
48775dd89908SRichard Henderson#include <immintrin.h>
48785dd89908SRichard Hendersonstatic int bar(void *a) {
48795dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
48805dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
48815dd89908SRichard Henderson}
48825dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
48835dd89908SRichard HendersonEOF
48845dd89908SRichard Henderson  if compile_object "" ; then
48855dd89908SRichard Henderson    avx2_opt="yes"
48865dd89908SRichard Henderson  fi
48875dd89908SRichard Hendersonfi
48885dd89908SRichard Henderson
4889f540166bSRichard Henderson########################################
4890f540166bSRichard Henderson# check if __[u]int128_t is usable.
4891f540166bSRichard Henderson
4892f540166bSRichard Hendersonint128=no
4893f540166bSRichard Hendersoncat > $TMPC << EOF
4894a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4895a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4896a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4897a00f66abSStefan Weil# endif
4898a00f66abSStefan Weil#endif
4899f540166bSRichard Henderson__int128_t a;
4900f540166bSRichard Henderson__uint128_t b;
4901f540166bSRichard Hendersonint main (void) {
4902f540166bSRichard Henderson  a = a + b;
4903f540166bSRichard Henderson  b = a * b;
4904464e3671SPeter Maydell  a = a * a;
4905f540166bSRichard Henderson  return 0;
4906f540166bSRichard Henderson}
4907f540166bSRichard HendersonEOF
4908f540166bSRichard Hendersonif compile_prog "" "" ; then
4909f540166bSRichard Henderson    int128=yes
4910f540166bSRichard Hendersonfi
491176a347e1SRichard Henderson
49127ebee43eSRichard Henderson#########################################
49137ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
49147ebee43eSRichard Henderson
49157ebee43eSRichard Hendersonatomic128=no
49167ebee43eSRichard Hendersonif test "$int128" = "yes"; then
49177ebee43eSRichard Henderson  cat > $TMPC << EOF
49187ebee43eSRichard Hendersonint main(void)
49197ebee43eSRichard Henderson{
49207ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
49217ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
49227ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
49237ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
49247ebee43eSRichard Henderson  return 0;
49257ebee43eSRichard Henderson}
49267ebee43eSRichard HendersonEOF
49277ebee43eSRichard Henderson  if compile_prog "" "" ; then
49287ebee43eSRichard Henderson    atomic128=yes
49297ebee43eSRichard Henderson  fi
49307ebee43eSRichard Hendersonfi
49317ebee43eSRichard Henderson
4932df79b996SRichard Henderson#########################################
4933df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4934df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4935df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4936df79b996SRichard Henderson
4937df79b996SRichard Hendersoncat > $TMPC << EOF
4938df79b996SRichard Henderson#include <stdint.h>
4939df79b996SRichard Hendersonint main(void)
4940df79b996SRichard Henderson{
4941df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4942df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4943df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4944df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4945df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4946df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4947df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4948df79b996SRichard Henderson#else
4949df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4950df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4951df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4952df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4953df79b996SRichard Henderson#endif
4954df79b996SRichard Henderson  return 0;
4955df79b996SRichard Henderson}
4956df79b996SRichard HendersonEOF
4957df79b996SRichard Hendersonif compile_prog "" "" ; then
4958df79b996SRichard Henderson  atomic64=yes
4959df79b996SRichard Hendersonfi
4960df79b996SRichard Henderson
49611e6e9acaSRichard Henderson########################################
49621e6e9acaSRichard Henderson# check if getauxval is available.
49631e6e9acaSRichard Henderson
49641e6e9acaSRichard Hendersongetauxval=no
49651e6e9acaSRichard Hendersoncat > $TMPC << EOF
49661e6e9acaSRichard Henderson#include <sys/auxv.h>
49671e6e9acaSRichard Hendersonint main(void) {
49681e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
49691e6e9acaSRichard Henderson}
49701e6e9acaSRichard HendersonEOF
49711e6e9acaSRichard Hendersonif compile_prog "" "" ; then
49721e6e9acaSRichard Henderson    getauxval=yes
49731e6e9acaSRichard Hendersonfi
49741e6e9acaSRichard Henderson
4975fd0e6053SJohn Snow########################################
4976fd0e6053SJohn Snow# check if ccache is interfering with
4977fd0e6053SJohn Snow# semantic analysis of macros
4978fd0e6053SJohn Snow
49795e4dfd3dSJohn Snowunset CCACHE_CPP2
4980fd0e6053SJohn Snowccache_cpp2=no
4981fd0e6053SJohn Snowcat > $TMPC << EOF
4982fd0e6053SJohn Snowstatic const int Z = 1;
4983fd0e6053SJohn Snow#define fn() ({ Z; })
4984fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4985fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4986fd0e6053SJohn Snow#define ID(X) (X)
4987fd0e6053SJohn Snowint main(int argc, char *argv[])
4988fd0e6053SJohn Snow{
4989fd0e6053SJohn Snow    int x = 0, y = 0;
4990fd0e6053SJohn Snow    x = ID(x);
4991fd0e6053SJohn Snow    x = fn();
4992fd0e6053SJohn Snow    fn();
4993fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4994fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4995fd0e6053SJohn Snow    return 0;
4996fd0e6053SJohn Snow}
4997fd0e6053SJohn SnowEOF
4998fd0e6053SJohn Snow
4999fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5000fd0e6053SJohn Snow    ccache_cpp2=yes
5001fd0e6053SJohn Snowfi
5002fd0e6053SJohn Snow
5003b553a042SJohn Snow#################################################
5004b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5005b553a042SJohn Snow
5006b553a042SJohn Snowif test "$fortify_source" != "no"; then
5007b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5008b553a042SJohn Snow    fortify_source="no";
5009e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5010cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5011b553a042SJohn Snow    fortify_source="no";
5012b553a042SJohn Snow  else
5013b553a042SJohn Snow    fortify_source="yes"
5014b553a042SJohn Snow  fi
5015b553a042SJohn Snowfi
5016b553a042SJohn Snow
5017d2042378SAneesh Kumar K.V##########################################
5018277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5019277abf15SJan Vesely
5020277abf15SJan Veselyhave_fsxattr=no
5021277abf15SJan Veselycat > $TMPC << EOF
5022277abf15SJan Vesely#include <linux/fs.h>
5023277abf15SJan Veselystruct fsxattr foo;
5024277abf15SJan Veselyint main(void) {
5025277abf15SJan Vesely  return 0;
5026277abf15SJan Vesely}
5027277abf15SJan VeselyEOF
5028277abf15SJan Veselyif compile_prog "" "" ; then
5029277abf15SJan Vesely    have_fsxattr=yes
5030277abf15SJan Veselyfi
5031277abf15SJan Vesely
5032b66e10e4SPeter Maydell##########################################
5033b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5034575b22b1SLaurent Vivierhave_rtnetlink=no
5035575b22b1SLaurent Viviercat > $TMPC << EOF
5036575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5037575b22b1SLaurent Vivierint main(void) {
5038575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5039575b22b1SLaurent Vivier}
5040575b22b1SLaurent VivierEOF
5041575b22b1SLaurent Vivierif compile_prog "" "" ; then
5042575b22b1SLaurent Vivier    have_rtnetlink=yes
5043575b22b1SLaurent Vivierfi
5044575b22b1SLaurent Vivier
50456a02c806SStefan Hajnoczi##########################################
50466a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
50476a02c806SStefan Hajnoczihave_af_vsock=no
50486a02c806SStefan Hajnoczicat > $TMPC << EOF
50496a02c806SStefan Hajnoczi#include <errno.h>
50506a02c806SStefan Hajnoczi#include <sys/types.h>
50516a02c806SStefan Hajnoczi#include <sys/socket.h>
50526a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
50536a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
50546a02c806SStefan Hajnoczi#endif
50556a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
50566a02c806SStefan Hajnocziint main(void) {
50576a02c806SStefan Hajnoczi    int sock, ret;
50586a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
50596a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
50606a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
50616a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
50626a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
50636a02c806SStefan Hajnoczi        return 0;
50646a02c806SStefan Hajnoczi    }
50656a02c806SStefan Hajnoczi    return -1;
50666a02c806SStefan Hajnoczi}
50676a02c806SStefan HajnocziEOF
50686a02c806SStefan Hajnocziif compile_prog "" "" ; then
50696a02c806SStefan Hajnoczi    have_af_vsock=yes
50706a02c806SStefan Hajnoczifi
50716a02c806SStefan Hajnoczi
5072f0d92b56SLongpeng(Mike)##########################################
5073f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
5074f0d92b56SLongpeng(Mike)hava_afalg=no
5075f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5076f0d92b56SLongpeng(Mike)#include <errno.h>
5077f0d92b56SLongpeng(Mike)#include <sys/types.h>
5078f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5079f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5080f0d92b56SLongpeng(Mike)int main(void) {
5081f0d92b56SLongpeng(Mike)    int sock;
5082f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5083f0d92b56SLongpeng(Mike)    return sock;
5084f0d92b56SLongpeng(Mike)}
5085f0d92b56SLongpeng(Mike)EOF
5086f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5087f0d92b56SLongpeng(Mike)    have_afalg=yes
5088f0d92b56SLongpeng(Mike)fi
5089f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5090f0d92b56SLongpeng(Mike)then
5091f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5092f0d92b56SLongpeng(Mike)    then
5093f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5094f0d92b56SLongpeng(Mike)    fi
5095f0d92b56SLongpeng(Mike)fi
5096f0d92b56SLongpeng(Mike)
5097f0d92b56SLongpeng(Mike)
50986969ec6cSJames Clarke#################################################
5099c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5100d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5101c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5102c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5103c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5104c97d6d2cSSergio Andres Gomez Del RealEOF
5105c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5106c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5107c97d6d2cSSergio Andres Gomez Del Real  else
5108c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5109c97d6d2cSSergio Andres Gomez Del Real    LDFLAGS="-framework Hypervisor $LDFLAGS"
5110c97d6d2cSSergio Andres Gomez Del Real  fi
5111c97d6d2cSSergio Andres Gomez Del Realfi
5112c97d6d2cSSergio Andres Gomez Del Real
5113c97d6d2cSSergio Andres Gomez Del Real#################################################
51146969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
51156969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
51166969ec6cSJames Clarke# given. It does no harm to give it on other
51176969ec6cSJames Clarke# platforms too.
51186969ec6cSJames Clarke
51196969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
51206969ec6cSJames Clarke#       contains -Wmissing-prototypes
51216969ec6cSJames Clarkecat > $TMPC << EOF
51226969ec6cSJames Clarkeextern int foo(void);
51236969ec6cSJames Clarkeint foo(void) { return 0; }
51246969ec6cSJames ClarkeEOF
51256969ec6cSJames Clarkeif ! compile_object ""; then
51266969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
51276969ec6cSJames Clarkefi
51287ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
51297ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
51307ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
51317ecf44a5SPaolo Bonzini    break
51327ecf44a5SPaolo Bonzini  fi
51337ecf44a5SPaolo Bonzinidone
51347ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
51357ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
51366969ec6cSJames Clarkefi
51376969ec6cSJames Clarke
5138277abf15SJan Vesely##########################################
51394d04351fSChristopher Covington# check for sysmacros.h
51404d04351fSChristopher Covington
51414d04351fSChristopher Covingtonhave_sysmacros=no
51424d04351fSChristopher Covingtoncat > $TMPC << EOF
51434d04351fSChristopher Covington#include <sys/sysmacros.h>
51444d04351fSChristopher Covingtonint main(void) {
51454d04351fSChristopher Covington    return makedev(0, 0);
51464d04351fSChristopher Covington}
51474d04351fSChristopher CovingtonEOF
51484d04351fSChristopher Covingtonif compile_prog "" "" ; then
51494d04351fSChristopher Covington    have_sysmacros=yes
51504d04351fSChristopher Covingtonfi
51514d04351fSChristopher Covington
51524d04351fSChristopher Covington##########################################
5153da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
5154da92c3ffSAshish Mittal# Check if libvxhs is installed
5155da92c3ffSAshish Mittal
5156da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
5157da92c3ffSAshish Mittal  cat > $TMPC <<EOF
5158da92c3ffSAshish Mittal#include <stdint.h>
5159da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
5160da92c3ffSAshish Mittal
5161da92c3ffSAshish Mittalvoid *vxhs_callback;
5162da92c3ffSAshish Mittal
5163da92c3ffSAshish Mittalint main(void) {
5164da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
5165da92c3ffSAshish Mittal    return 0;
5166da92c3ffSAshish Mittal}
5167da92c3ffSAshish MittalEOF
5168da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
5169da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
5170da92c3ffSAshish Mittal    vxhs=yes
5171da92c3ffSAshish Mittal  else
5172da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
5173da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
5174da92c3ffSAshish Mittal    fi
5175da92c3ffSAshish Mittal    vxhs=no
5176da92c3ffSAshish Mittal  fi
5177da92c3ffSAshish Mittalfi
5178da92c3ffSAshish Mittal
5179da92c3ffSAshish Mittal##########################################
518049e00a18SAndreas Grapentin# check for _Static_assert()
518149e00a18SAndreas Grapentin
518249e00a18SAndreas Grapentinhave_static_assert=no
518349e00a18SAndreas Grapentincat > $TMPC << EOF
518449e00a18SAndreas Grapentin_Static_assert(1, "success");
518549e00a18SAndreas Grapentinint main(void) {
518649e00a18SAndreas Grapentin    return 0;
518749e00a18SAndreas Grapentin}
518849e00a18SAndreas GrapentinEOF
518949e00a18SAndreas Grapentinif compile_prog "" "" ; then
519049e00a18SAndreas Grapentin    have_static_assert=yes
519149e00a18SAndreas Grapentinfi
519249e00a18SAndreas Grapentin
519349e00a18SAndreas Grapentin##########################################
5194e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5195e674605fSTomáš Golembiovský
5196e674605fSTomáš Golembiovskýhave_utmpx=no
5197e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5198e674605fSTomáš Golembiovský#include <utmpx.h>
5199e674605fSTomáš Golembiovskýstruct utmpx user_info;
5200e674605fSTomáš Golembiovskýint main(void) {
5201e674605fSTomáš Golembiovský    return 0;
5202e674605fSTomáš Golembiovský}
5203e674605fSTomáš GolembiovskýEOF
5204e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5205e674605fSTomáš Golembiovský    have_utmpx=yes
5206e674605fSTomáš Golembiovskýfi
5207e674605fSTomáš Golembiovský
5208e674605fSTomáš Golembiovský##########################################
5209e86ecd4bSJuan Quintela# End of CC checks
5210e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5211e86ecd4bSJuan Quintela
52121d728c39SBlue Swirlif test "$gcov" = "yes" ; then
52131d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
52141d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5215b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5216e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
521790654868SMarc-André Lureauelif test "$debug" = "yes"; then
521890654868SMarc-André Lureau  if compile_prog "-Og" ""; then
521990654868SMarc-André Lureau      CFLAGS="-Og $CFLAGS"
522090654868SMarc-André Lureau  elif compile_prog "-O1" ""; then
522190654868SMarc-André Lureau      CFLAGS="-O1 $CFLAGS"
522290654868SMarc-André Lureau  fi
522390654868SMarc-André Lureau  # Workaround GCC false-positive Wuninitialized bugs with Og or O1:
522490654868SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
522590654868SMarc-André Lureau  if cc_has_warning_flag "-Wno-maybe-uninitialized"; then
522690654868SMarc-André Lureau      CFLAGS="-Wno-maybe-uninitialized $CFLAGS"
522790654868SMarc-André Lureau  fi
522890654868SMarc-André Lureauelse
5229ce278618SPeter Maydell    CFLAGS="-O2 $CFLAGS"
5230e86ecd4bSJuan Quintelafi
5231a316e378SJuan Quintela
52326542aa9cSPeter Lieven##########################################
52336542aa9cSPeter Lieven# Do we have libnfs
52346542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5235b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
52366542aa9cSPeter Lieven    libnfs="yes"
52376542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
52386542aa9cSPeter Lieven  else
52396542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
52408efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
52416542aa9cSPeter Lieven    fi
52426542aa9cSPeter Lieven    libnfs="no"
52436542aa9cSPeter Lieven  fi
52446542aa9cSPeter Lievenfi
52451d728c39SBlue Swirl
52466ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
52476ca026cbSPeter Maydellif test "$werror" = "yes"; then
52486ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
52496ca026cbSPeter Maydellfi
52506ca026cbSPeter Maydell
5251e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5252e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
52531156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5254e86ecd4bSJuan Quintela    fi
5255e86ecd4bSJuan Quintelafi
5256e86ecd4bSJuan Quintela
525794dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
525894dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
525994dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
526094dd53c5SGerd Hoffmannelse
526194dd53c5SGerd Hoffmann    POD2MAN="pod2man"
526294dd53c5SGerd Hoffmannfi
526394dd53c5SGerd Hoffmann
5264952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5265952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5266952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5267e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5268952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5269952afb71SBlue Swirl        fi
5270952afb71SBlue Swirl    done
5271952afb71SBlue Swirlfi
5272952afb71SBlue Swirl
527310ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5274e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5275528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5276834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
52775a67135aSbellard
5278e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5279e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5280e0580342SKamil Rytarowski  ivshmem=yes
5281e0580342SKamil Rytarowskifi
5282e0580342SKamil Rytarowski
52834b1c11fdSDaniel P. Berrangetools=""
52844b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5285ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
52864b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
52874b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5288b1449edbSKamil Rytarowski  fi
5289b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5290a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
52914b1c11fdSDaniel P. Berrange  fi
52924b1c11fdSDaniel P. Berrangefi
52934b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5294b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5295b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5296983eef5aSMeador Inge      virtfs=yes
529717bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5298983eef5aSMeador Inge    else
5299983eef5aSMeador Inge      if test "$virtfs" = yes; then
5300b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5301983eef5aSMeador Inge      fi
530217500370SAndreas Färber      virtfs=no
5303983eef5aSMeador Inge    fi
5304fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5305fe8fc5aeSPaolo Bonzini      mpath=yes
5306fe8fc5aeSPaolo Bonzini    else
5307fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5308fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5309fe8fc5aeSPaolo Bonzini      fi
5310fe8fc5aeSPaolo Bonzini      mpath=no
5311fe8fc5aeSPaolo Bonzini    fi
5312b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5313b855f8d1SPaolo Bonzini  else
5314b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5315b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5316b855f8d1SPaolo Bonzini    fi
5317b855f8d1SPaolo Bonzini    virtfs=no
5318fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5319fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5320fe8fc5aeSPaolo Bonzini    fi
5321fe8fc5aeSPaolo Bonzini    mpath=no
532217bff52bSM. Mohan Kumar  fi
53236a021536SGerd Hoffmann  if test "$xkbcommon" = "yes"; then
53246a021536SGerd Hoffmann    tools="qemu-keymap\$(EXESUF) $tools"
53256a021536SGerd Hoffmann  fi
5326ff69fd8cSLaurent Vivierfi
53279d6bc27bSMichael Roth
53289d6bc27bSMichael Roth# Probe for guest agent support/options
53299d6bc27bSMichael Roth
5330e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5331b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5332fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5333e8ef31a3SMichael Tokarev      guest_agent=yes
5334e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5335e8ef31a3SMichael Tokarev      guest_agent=no
5336e8ef31a3SMichael Tokarev  else
5337e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5338ca35f780SPaolo Bonzini  fi
53394b1c11fdSDaniel P. Berrangefi
5340ca35f780SPaolo Bonzini
53419d6bc27bSMichael Roth# Guest agent Window MSI  package
53429d6bc27bSMichael Roth
53439d6bc27bSMichael Rothif test "$guest_agent" != yes; then
53449d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
53459d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
53469d6bc27bSMichael Roth  fi
53479d6bc27bSMichael Roth  guest_agent_msi=no
53489d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
53499d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
53509d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
53519d6bc27bSMichael Roth  fi
53529d6bc27bSMichael Roth  guest_agent_msi=no
53539d6bc27bSMichael Rothelif ! has wixl; then
53549d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
53559d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
53569d6bc27bSMichael Roth  fi
53579d6bc27bSMichael Roth  guest_agent_msi=no
53581a34904eSMichael Rothelse
53591a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
53601a34904eSMichael Roth  # disabled explicitly
53611a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
53621a34904eSMichael Roth    guest_agent_msi=yes
53631a34904eSMichael Roth  fi
53649d6bc27bSMichael Rothfi
53659d6bc27bSMichael Roth
53661a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
53679d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
53689d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
53699d6bc27bSMichael Roth  fi
53709d6bc27bSMichael Roth
53719d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
53729d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
53739d6bc27bSMichael Roth  fi
53749d6bc27bSMichael Roth
53759d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
53769d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
53779d6bc27bSMichael Roth  fi
53789d6bc27bSMichael Roth
53799d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
538089138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
53819d6bc27bSMichael Roth  fi
53829d6bc27bSMichael Roth
538389138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
53849d6bc27bSMichael Roth
53859d6bc27bSMichael Roth  case "$cpu" in
53869d6bc27bSMichael Roth  x86_64)
53879d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
53889d6bc27bSMichael Roth    ;;
53899d6bc27bSMichael Roth  i386)
53909d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
53919d6bc27bSMichael Roth    ;;
53929d6bc27bSMichael Roth  *)
53939d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
53949d6bc27bSMichael Roth    ;;
53959d6bc27bSMichael Roth  esac
53969d6bc27bSMichael Rothfi
53979d6bc27bSMichael Roth
5398ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5399ca35f780SPaolo Bonziniroms=
5400ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5401ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5402ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5403e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5404c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5405c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5406c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5407e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5408e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5409ca35f780SPaolo Bonzini            roms="optionrom"
5410e57218b6SPeter Maydell            break
5411e57218b6SPeter Maydell        fi
5412e57218b6SPeter Maydell    done
5413ca35f780SPaolo Bonzinifi
5414d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
541539ac8455SDavid Gibson  roms="$roms spapr-rtas"
541639ac8455SDavid Gibsonfi
5417ca35f780SPaolo Bonzini
54189933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
54199933c305SChristian Borntraeger  roms="$roms s390-ccw"
54209933c305SChristian Borntraegerfi
54219933c305SChristian Borntraeger
5422964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
542392fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5424964c6fa1SRichard Henderson  textseg_addr=
5425964c6fa1SRichard Henderson  case "$cpu" in
5426479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5427479eb121SRichard Henderson      # ??? Rationale for choosing this address
5428964c6fa1SRichard Henderson      textseg_addr=0x60000000
5429964c6fa1SRichard Henderson      ;;
5430964c6fa1SRichard Henderson    mips)
5431479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5432479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5433479eb121SRichard Henderson      textseg_addr=0x60000000
5434964c6fa1SRichard Henderson      ;;
5435964c6fa1SRichard Henderson  esac
5436964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5437964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5438964c6fa1SRichard Henderson    int main(void) { return 0; }
5439964c6fa1SRichard HendersonEOF
5440964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5441964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5442964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5443964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5444964c6fa1SRichard Henderson      # at least.
544592fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
544692fe2ba8SPeter Maydell        error_exit \
544792fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
544892fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
544992fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
545092fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
545192fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
545292fe2ba8SPeter Maydell            "--disable-user option to configure."
545392fe2ba8SPeter Maydell      fi
545492fe2ba8SPeter Maydell
5455964c6fa1SRichard Henderson      $ld --verbose | sed \
5456964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5457964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5458964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5459964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5460964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5461964c6fa1SRichard Henderson    fi
5462964c6fa1SRichard Henderson  fi
5463964c6fa1SRichard Hendersonfi
5464964c6fa1SRichard Henderson
546511cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
546611cde1c8SBruno 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.
546711cde1c8SBruno Dominguezif has $cxx; then
546811cde1c8SBruno Dominguez    cat > $TMPC <<EOF
546911cde1c8SBruno Dominguezint c_function(void);
547011cde1c8SBruno Dominguezint main(void) { return c_function(); }
547111cde1c8SBruno DominguezEOF
547211cde1c8SBruno Dominguez
547311cde1c8SBruno Dominguez    compile_object
547411cde1c8SBruno Dominguez
547511cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
547611cde1c8SBruno Dominguezextern "C" {
547711cde1c8SBruno Dominguez   int c_function(void);
547811cde1c8SBruno Dominguez}
547911cde1c8SBruno Dominguezint c_function(void) { return 42; }
548011cde1c8SBruno DominguezEOF
548111cde1c8SBruno Dominguez
548211cde1c8SBruno Dominguez    update_cxxflags
548311cde1c8SBruno Dominguez
548411cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
548511cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
548611cde1c8SBruno Dominguez        :
548711cde1c8SBruno Dominguez    else
548811cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
548911cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
549011cde1c8SBruno Dominguez        cxx=
549111cde1c8SBruno Dominguez    fi
549211cde1c8SBruno Dominguezelse
549311cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
549411cde1c8SBruno Dominguez    cxx=
549511cde1c8SBruno Dominguezfi
549611cde1c8SBruno Dominguez
549702d34f62SCole Robinsonecho_version() {
549802d34f62SCole Robinson    if test "$1" = "yes" ; then
549902d34f62SCole Robinson        echo "($2)"
550002d34f62SCole Robinson    fi
550102d34f62SCole Robinson}
550202d34f62SCole Robinson
550350e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
550450e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
550550e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
55065ca9388aSGerd Hoffmann
55077d13299dSbellardecho "Install prefix    $prefix"
550889138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
55093d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
551089138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
551189138857SStefan Weilecho "library directory $(eval echo $libdir)"
551289138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
551389138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
551489138857SStefan Weilecho "include directory $(eval echo $includedir)"
551589138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
551611d9f695Sbellardif test "$mingw32" = "no" ; then
551789138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
551889138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
551943ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
55205a699bbbSLaszlo Ersekelse
55215a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5522d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
552311d9f695Sbellardfi
55245a67135aSbellardecho "Source path       $source_path"
5525cc84d63aSDaniel P. Berrangeecho "GIT binary        $git"
5526aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
55277d13299dSbellardecho "C compiler        $cc"
552883469015Sbellardecho "Host C compiler   $host_cc"
552983f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
55303c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
553145d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
55320c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5533a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
55340c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
55357d13299dSbellardecho "make              $make"
55366a882643Spbrookecho "install           $install"
5537c886edfbSBlue Swirlecho "python            $python"
5538e2d8830eSBradif test "$slirp" = "yes" ; then
5539e2d8830eSBrad    echo "smbd              $smbd"
5540e2d8830eSBradfi
554117969268SFam Zhengecho "module support    $modules"
5542a98fd896Sbellardecho "host CPU          $cpu"
5543de83cd02Sbellardecho "host big endian   $bigendian"
554497a847bcSbellardecho "target list       $target_list"
55457d13299dSbellardecho "gprof enabled     $gprof"
554603b4fe7dSaliguoriecho "sparse enabled    $sparse"
55471625af87Saliguoriecho "strip binaries    $strip_opt"
554805c2a3e7Sbellardecho "profiler          $profiler"
554943ce4dfeSbellardecho "static build      $static"
55505b0753e0Sbellardif test "$darwin" = "yes" ; then
55515b0753e0Sbellard    echo "Cocoa support     $cocoa"
55525b0753e0Sbellardfi
555389138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
555489138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5555925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
555689138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5557a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5558ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5559b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
556091bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
556137788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
556289138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5563fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
55649a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
55654d3b6f6eSbalrogecho "curses support    $curses"
55669d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5567769ce76dSAlexander Grafecho "curl support      $curl"
556867b915a5Sbellardecho "mingw32 support   $mingw32"
55690c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5570b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5571b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5572983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5573fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
5574821601eaSJes Sorensenecho "VNC support       $vnc"
5575821601eaSJes Sorensenif test "$vnc" = "yes" ; then
55762f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
55772f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5578efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5579821601eaSJes Sorensenfi
55803142255cSblueswir1if test -n "$sparc_cpu"; then
55813142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
55823142255cSblueswir1fi
5583e37630caSaliguoriecho "xen support       $xen"
55843996e85cSPaul Durrantif test "$xen" = "yes" ; then
55853996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
558664a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
55873996e85cSPaul Durrantfi
55882e4d9fb1Saurel32echo "brlapi support    $brlapi"
5589a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5590a25dba17SJuan Quintelaecho "Documentation     $docs"
559140d6444eSAvi Kivityecho "PIE               $pie"
55928a16d273Sthsecho "vde support       $vde"
559358952137SVincenzo Maffioneecho "netmap support    $netmap"
55945c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5595758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
559677755340Sthsecho "Install blobs     $blobs"
5597b31a0277SJuan Quintelaecho "KVM support       $kvm"
5598b0cb0a66SVincent Palatinecho "HAX support       $hax"
5599c97d6d2cSSergio Andres Gomez Del Realecho "HVF support       $hvf"
5600b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5601b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5602b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
56039195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5604b3f6ea7eSPaolo Bonzinifi
56055a22ab71SYang Zhongecho "malloc trim support $malloc_trim"
5606b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5607f652e6afSaurel32echo "fdt support       $fdt"
5608ceb42de8Saliguoriecho "preadv support    $preadv"
56095f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5610e78815a5SAndreas Färberecho "madvise           $madvise"
5611e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
561247e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5613d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
56145e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5615fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5616e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
56175b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5618713572a7SMarc-André Lureauif have_backend "simple"; then
56199410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5620e00e36fbSStefan Weilfi
562189138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5622f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5623dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
56247b02f544SMarc-André Lureauecho "smartcard support $smartcard"
56252b2325ffSGerd Hoffmannecho "libusb            $libusb"
562669354a83SHans de Goedeecho "usb net redir     $usb_redir"
5627da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5628014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5629c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
56306542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5631d138cee9SMichael Rothecho "build guest agent $guest_agent"
5632d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
563350cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
56344c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5635f794573eSEduardo Otuboecho "seccomp support   $seccomp"
56367c2acc70SPeter Maydellecho "coroutine backend $coroutine"
563770c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
56387d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5639f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5640eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
56411d728c39SBlue Swirlecho "gcov              $gcov_tool"
56421d728c39SBlue Swirlecho "gcov enabled      $gcov"
5643ab214c29SStefan Bergerecho "TPM support       $tpm"
56440a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
56453b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
5646f4ede81eSAmarnath Valluriecho "TPM emulator      $tpm_emulator"
56473556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5648ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5649607dacd0Sqiaonuohanecho "lzo support       $lzo"
5650607dacd0Sqiaonuohanecho "snappy support    $snappy"
56516b383c08SPeter Wuecho "bzip2 support     $bzip2"
5652a99d57bbSWanlong Gaoecho "NUMA host support $numa"
5653ed279a06SKlim Kireevecho "libxml2           $libxml2"
56542847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
56557b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
565699f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5657a6b1d4c0SChanglong Xieecho "replication support $replication"
5658da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
56598ca80760SRichard Hendersonecho "capstone          $capstone"
566067b915a5Sbellard
56611ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
566224b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5663e8cd23deSbellardfi
566497a847bcSbellard
5665b7715af2SDaniel P. Berrangeif test "$gtkabi" = "2.0"; then
5666b7715af2SDaniel P. Berrange    echo
5667b7715af2SDaniel P. Berrange    echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
5668b7715af2SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using GTK 3.0"
5669b7715af2SDaniel P. Berrangefi
5670b7715af2SDaniel P. Berrange
5671*e52c6ba3SDaniel P. Berrangeif test "$sdlabi" = "1.2"; then
5672*e52c6ba3SDaniel P. Berrange    echo
5673*e52c6ba3SDaniel P. Berrange    echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
5674*e52c6ba3SDaniel P. Berrange    echo "WARNING: future releases. Please switch to using SDL 2.0"
5675*e52c6ba3SDaniel P. Berrangefi
5676*e52c6ba3SDaniel P. Berrange
5677898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5678898be3e0SPeter Maydell    echo
5679898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5680898be3e0SPeter Maydell    echo
5681898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5682898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5683898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5684898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5685898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5686898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5687898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5688898be3e0SPeter Maydellfi
5689898be3e0SPeter Maydell
5690898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5691898be3e0SPeter Maydell    echo
5692898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5693898be3e0SPeter Maydell    echo
5694c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5695c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5696898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5697898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5698898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5699898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5700898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5701898be3e0SPeter Maydellfi
5702898be3e0SPeter Maydell
570398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
570497a847bcSbellard
5705dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5706dbd99ae3SStefan Weil
570798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
570898ec69acSJuan Quintelaecho >> $config_host_mak
570998ec69acSJuan Quintela
5710e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
571199d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
571299d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
57133aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
57148bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
57150f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
571699d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
571799d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
571822d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
57199afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
57203d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
57219afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5722e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
57235a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5724785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
57255a699bbbSLaszlo Ersekfi
5726f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5727f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
572811cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5729f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5730834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5731f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5732cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
5733aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5734f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
5735804edf29SJuan Quintela
573698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5737727e5283SPaolo Bonzini
5738f8393946Saurel32if test "$debug_tcg" = "yes" ; then
57392358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5740f8393946Saurel32fi
57411625af87Saliguoriif test "$strip_opt" = "yes" ; then
574252ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
57431625af87Saliguorifi
57447d13299dSbellardif test "$bigendian" = "yes" ; then
5745e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
574697a847bcSbellardfi
574767b915a5Sbellardif test "$mingw32" = "yes" ; then
574898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
574989138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
57509fe6de94SBlue Swirl  version_major=${rc_version%%.*}
57519fe6de94SBlue Swirl  rc_version=${rc_version#*.}
57529fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
57539fe6de94SBlue Swirl  rc_version=${rc_version#*.}
57549fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
57559fe6de94SBlue Swirl  version_micro=0
57569fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
57579fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5758d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5759d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5760f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5761d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5762d9840e25STomoki Sekiyama  fi
576350cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
576450cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
576550cbebb9SMichael Roth  fi
57661a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
57679dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
57689dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
57699dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
57709dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
57719dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
57729dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
57739dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
57749dacf32dSYossi Hindin  fi
5775210fa556Spbrookelse
577635f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5777210fa556Spbrookfi
5778128ab2ffSblueswir1
5779dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5780dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5781dffcb71cSMark McLoughlinfi
5782dffcb71cSMark McLoughlin
578383fb7adfSbellardif test "$darwin" = "yes" ; then
578498ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
578583fb7adfSbellardfi
5786b29fe3edSmalc
5787ec530c81Sbellardif test "$solaris" = "yes" ; then
578898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5789ec530c81Sbellardfi
5790179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5791179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5792179cf400SAndreas Färberfi
579397a847bcSbellardif test "$static" = "yes" ; then
579498ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
579597a847bcSbellardfi
57961ba16968SStefan Weilif test "$profiler" = "yes" ; then
57972358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
579805c2a3e7Sbellardfi
5799c20709aaSbellardif test "$slirp" = "yes" ; then
580098ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5801e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5802c20709aaSbellardfi
58038a16d273Sthsif test "$vde" = "yes" ; then
580498ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5805e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
58068a16d273Sthsfi
580758952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
580858952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
580958952137SVincenzo Maffionefi
5810015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5811015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5812015a33bdSGongleifi
581347e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
581447e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
581547e98658SCorey Bryantfi
58162358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
58170c58ac1cSmalcfor drv in $audio_drv_list; do
581889138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
581998ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
58200c58ac1cSmalcdone
5821b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5822b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5823b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5824b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5825b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
582667f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
582767f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
582867f86e8eSJuan Quintelafi
5829d5631638Smalcif test "$audio_win_int" = "yes" ; then
5830d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5831d5631638Smalcfi
5832b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5833b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5834821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5835821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5836821601eaSJes Sorensenfi
58372f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
583898ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
58392f9606b3Saliguorifi
5840821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
58412f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
58422f6f5c7aSCorentin Charyfi
5843821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5844efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5845efe556adSCorentin Charyfi
58466a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
58476a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
58486a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
58496a021536SGerd Hoffmannfi
585076655d6dSaliguoriif test "$fnmatch" = "yes" ; then
58512358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
585276655d6dSaliguorifi
5853dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5854dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5855dce512deSChristoph Hellwigfi
585689138857SStefan Weilqemu_version=$(head $source_path/VERSION)
585798ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
58582358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
585998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
586098ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5861a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
586298ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5863cc8ae6deSpbrookfi
586417969268SFam Zhengif test "$modules" = "yes"; then
5865e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5866e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
586789138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
586817969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
586917969268SFam Zhengfi
58701ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
587198ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5872a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
58738ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
58748ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
587549ecc3faSbellardfi
587649ecc3faSbellardif test "$cocoa" = "yes" ; then
587798ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
587849ecc3faSbellardfi
58794d3b6f6eSbalrogif test "$curses" = "yes" ; then
588098ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5881ab4e5602SJan Kiszkafi
5882099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
58832358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5884099d6b0fSRiku Voipiofi
588540ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
588640ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
588740ff6d7eSKevin Wolffi
58883ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
58892358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
58903ce34dfbSvibisreenivasanfi
5891c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5892c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5893c2882b96SRiku Voipiofi
5894751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5895751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5896751bcc39SMarc-André Lureaufi
5897d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5898d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5899d0927938SUlrich Hechtfi
59003d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
59013d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
59023d4fa43eSKusanagi Kouichifi
5903b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5904b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5905b953f075SDenis V. Lunevfi
5906ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5907ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5908ed911435SKevin Wolffi
5909c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5910c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5911c727f47dSPeter Maydellfi
5912dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5913dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5914dace20dcSPeter Maydellfi
5915d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5916d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5917d0927938SUlrich Hechtfi
59184e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
59194e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
59204e0c6529SAlex Blighfi
5921cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5922cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5923cd758dd0SAlex Blighfi
59243b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
59253b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
59263b6edd16SPeter Maydellfi
59273b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
59283b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
59293b6edd16SPeter Maydellfi
5930a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5931a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5932a8fd1abaSPeter Maydellfi
593351834341SRiku Voipioif test "$timerfd" = "yes" ; then
593451834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
593551834341SRiku Voipiofi
59369af5c906SRiku Voipioif test "$setns" = "yes" ; then
59379af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
59389af5c906SRiku Voipiofi
593938860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
594038860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
594138860a03SAleksandar Markovicfi
59425a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
59435a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
59445a03cd00SAleksandar Markovicfi
59453b3f24adSaurel32if test "$inotify" = "yes" ; then
59462358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
59473b3f24adSaurel32fi
5948c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5949c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5950c05c7a73SRiku Voipiofi
5951401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
5952401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5953401bc051SPeter Maydellfi
59546ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
59556ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
59566ae9a1f4SJuan Quintelafi
59576ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
59586ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
59596ae9a1f4SJuan Quintelafi
5960769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5961d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5962b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
59636ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5964769ce76dSAlexander Graffi
59652e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
596698ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
59678eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
59682e4d9fb1Saurel32fi
5969fb599c9aSbalrogif test "$bluez" = "yes" ; then
597098ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5971ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5972fb599c9aSbalrogfi
5973d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
59749d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
59759d41401bSMichael S. Tsirkinfi
5976a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5977a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5978a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5979a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5980014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5981925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5982925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5983925a0400SGerd Hoffmann  fi
5984bbbf9bfbSStefan Weilfi
5985a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5986ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5987ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5988ddbb0d09SDaniel P. Berrangefi
5989b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5990b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5991b917da4cSDaniel P. Berrangefi
599291bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
599391bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
59941f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
59951f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
59961f923c70SLongpeng(Mike)  fi
599737788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
599837788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
599937788f25SDaniel P. Berrange  fi
600062893b67SDaniel P. Berrangefi
600191bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
600291bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6003becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6004fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
6005fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6006fff2f982SDaniel P. Berrange  fi
6007ed754746SDaniel P. Berrangefi
60089a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
60099a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
60109a2fd434SDaniel P. Berrangefi
6011559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6012559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6013559607eaSDaniel P. Berrangefi
60146b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
60156b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
60166b39b063SEric Blakefi
6017277abf15SJan Vesely
6018277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6019277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6020277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6021277abf15SJan Vesely# if this macro is set.
6022277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6023277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6024277abf15SJan Veselyfi
6025bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6026bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6027a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6028a4ccabcfSAnthony Liguorifi
60299d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
60309d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
60319d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
60329d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
60339d9e1521SGerd Hoffmannfi
6034e37630caSaliguoriif test "$xen" = "yes" ; then
60356dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6036d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
603764a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
603864a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
603964a7ad6fSIan Campbell  fi
6040e37630caSaliguorifi
60415c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
60425c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
60435c6c3a6cSChristoph Hellwigfi
6044758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6045758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6046758e8e38SVenkateswararao Jujjuri (JV)fi
60474f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
60484f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
60494f26f2b6SAvi Kivityfi
6050983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6051758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6052758e8e38SVenkateswararao Jujjuri (JV)fi
6053fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6054fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
6055fe8fc5aeSPaolo Bonzinifi
60565e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
60575e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
60585e9be92dSNicholas Bellingerfi
6059e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
606003ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
606103ce5744SNikolay Nikolaevfi
6062fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6063fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6064fc0b9b0eSStefan Hajnoczifi
6065e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6066e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6067e6a74868SMarc-André Lureaufi
606877755340Sthsif test "$blobs" = "yes" ; then
606998ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
607077755340Sthsfi
6071bf9298b9Saliguoriif test "$iovec" = "yes" ; then
60722358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6073bf9298b9Saliguorifi
6074ceb42de8Saliguoriif test "$preadv" = "yes" ; then
60752358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6076ceb42de8Saliguorifi
6077f652e6afSaurel32if test "$fdt" = "yes" ; then
60783f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
6079f652e6afSaurel32fi
6080dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6081dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6082dcc38d1cSMarcelo Tosattifi
6083b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
6084b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
60859195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
60869195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
60879195b2c2SStefan Weil  fi
6088b3f6ea7eSPaolo Bonzinifi
60895f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
60905f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
60915f6b9e8fSBlue Swirlfi
6092e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6093e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6094e78815a5SAndreas Färberfi
6095e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6096e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6097e78815a5SAndreas Färberfi
609897a847bcSbellard
6099cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6100cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
6101cd4ec0b4SGerd Hoffmannfi
6102cd4ec0b4SGerd Hoffmann
61037b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
61047b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
61057b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
61067b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6107111a38b0SRobert Relyeafi
6108111a38b0SRobert Relyea
61092b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
61102b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6111b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6112b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
61132b2325ffSGerd Hoffmannfi
61142b2325ffSGerd Hoffmann
611569354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
611669354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6117cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6118cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
611969354a83SHans de Goedefi
612069354a83SHans de Goede
6121da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6122da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6123da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6124014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6125014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6126014cb152SGerd Hoffmann  fi
612720ff075bSMichael Wallefi
612820ff075bSMichael Walle
61295a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
61305a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
61315a22ab71SYang Zhongfi
61325a22ab71SYang Zhong
613399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
613499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
613599f2dbd3SLiang Lifi
613699f2dbd3SLiang Li
6137607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6138607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6139607dacd0Sqiaonuohanfi
6140607dacd0Sqiaonuohan
6141607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6142607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6143607dacd0Sqiaonuohanfi
6144607dacd0Sqiaonuohan
61456b383c08SPeter Wuif test "$bzip2" = "yes" ; then
61466b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
61476b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
61486b383c08SPeter Wufi
61496b383c08SPeter Wu
6150c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6151d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
61526ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
61536ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6154c589b249SRonnie Sahlbergfi
6155c589b249SRonnie Sahlberg
61566542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
61574be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
61584be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
61596542aa9cSPeter Lievenfi
61606542aa9cSPeter Lieven
6161f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6162f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6163c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6164c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6165f794573eSEduardo Otubofi
6166f794573eSEduardo Otubo
616783fb7adfSbellard# XXX: suppress that
61687d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
61692358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
61707d3505c5Sbellardfi
61717d3505c5Sbellard
61724d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
61734d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
61744d9310f4SDaniel P. Berrangefi
61753556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
61763556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
61773556c233SPaolo Bonzinifi
6178f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6179d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
61806ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
61816ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6182f27aaf4bSChristian Brunnerfi
618320ff6c80SAnthony Liguori
61847c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
618570c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
618670c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
618770c60c08SStefan Hajnoczielse
618870c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
618970c60c08SStefan Hajnoczifi
6190d0e2fce5SAneesh Kumar K.V
61917d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
61927d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
61937d992e4dSPeter Lievenfi
61947d992e4dSPeter Lieven
6195f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6196f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6197f0d92b56SLongpeng(Mike)fi
6198f0d92b56SLongpeng(Mike)
6199d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6200d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6201d2042378SAneesh Kumar K.Vfi
6202d2042378SAneesh Kumar K.V
6203e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6204e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6205e06a765eSHarsh Prateek Borafi
6206e06a765eSHarsh Prateek Bora
6207cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
6208cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
620906d71fa1SPeter Maydellfi
621006d71fa1SPeter Maydell
62113f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
62123f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
62133f4349dcSKevin Wolffi
62143f4349dcSKevin Wolf
62158ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
62168ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
62178ab1bf12SLuiz Capitulinofi
62188ab1bf12SLuiz Capitulino
621976a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
622076a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
622176a347e1SRichard Hendersonfi
622276a347e1SRichard Henderson
6223f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6224f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6225f540166bSRichard Hendersonfi
6226f540166bSRichard Henderson
62277ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
62287ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
62297ebee43eSRichard Hendersonfi
62307ebee43eSRichard Henderson
6231df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6232df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6233df79b996SRichard Hendersonfi
6234df79b996SRichard Henderson
62351e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
62361e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
62371e6e9acaSRichard Hendersonfi
62381e6e9acaSRichard Henderson
6239eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6240d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
62416ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
62426ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6243eb100396SBharata B Raofi
6244eb100396SBharata B Rao
6245d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6246d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6247d85fa9ebSJeff Codyfi
6248d85fa9ebSJeff Cody
62490c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
62500c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
62510c14fb47SBharata B Raofi
62520c14fb47SBharata B Rao
6253df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6254df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6255df3a429aSNiels de Vosfi
6256df3a429aSNiels de Vos
62577c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
62587c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
62597c815372SBharata B Raofi
62607c815372SBharata B Rao
62610a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6262d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
62636ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
62646ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
62650a12ec87SRichard W.M. Jonesfi
62660a12ec87SRichard W.M. Jones
6267ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6268ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6269ed1701c6SDr. David Alan Gilbertfi
6270ed1701c6SDr. David Alan Gilbert
62713b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
62723b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6273f4ede81eSAmarnath Valluri  # TPM passthrough support?
62743b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
62753b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
62763b8acc11SPaolo Bonzini  fi
6277f4ede81eSAmarnath Valluri  # TPM emulator support?
6278f4ede81eSAmarnath Valluri  if test "$tpm_emulator" = "yes"; then
6279f4ede81eSAmarnath Valluri    echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6280f4ede81eSAmarnath Valluri  fi
62813b8acc11SPaolo Bonzinifi
62823b8acc11SPaolo Bonzini
62835b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
62845b808275SLluís Vilanovaif have_backend "nop"; then
62856d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
628622890ab5SPrerna Saxenafi
62875b808275SLluís Vilanovaif have_backend "simple"; then
62886d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
62896d8a764eSLluís  # Set the appropriate trace file.
6290953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
62919410b56cSPrerna Saxenafi
6292ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6293ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
62946d8a764eSLluísfi
62955b808275SLluís Vilanovaif have_backend "ust"; then
62966d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
62976d8a764eSLluísfi
62985b808275SLluís Vilanovaif have_backend "dtrace"; then
62996d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
63006d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
63016d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
63026d8a764eSLluís  fi
6303c276b17dSDaniel P. Berrangefi
63045b808275SLluís Vilanovaif have_backend "ftrace"; then
6305781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6306781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6307781e9545SEiichi Tsukata  else
630821684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6309781e9545SEiichi Tsukata  fi
6310781e9545SEiichi Tsukatafi
63110a852417SPaul Durrantif have_backend "syslog"; then
63120a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
63130a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
63140a852417SPaul Durrant  else
63150a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
63160a852417SPaul Durrant  fi
63170a852417SPaul Durrantfi
63189410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
63199410b56cSPrerna Saxena
63202da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
63212da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6322392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
63232da776dbSMichael R. Hinesfi
63242da776dbSMichael R. Hines
6325575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6326575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6327575b22b1SLaurent Vivierfi
6328575b22b1SLaurent Vivier
6329ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6330ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6331ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6332ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6333ed279a06SKlim Kireevfi
6334ed279a06SKlim Kireev
6335a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6336a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6337a6b1d4c0SChanglong Xiefi
6338a6b1d4c0SChanglong Xie
63396a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
63406a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
63416a02c806SStefan Hajnoczifi
63426a02c806SStefan Hajnoczi
63434d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
63444d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
63454d04351fSChristopher Covingtonfi
63464d04351fSChristopher Covington
634749e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
634849e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
634949e00a18SAndreas Grapentinfi
635049e00a18SAndreas Grapentin
6351e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6352e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6353e674605fSTomáš Golembiovskýfi
6354e674605fSTomáš Golembiovský
6355e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6356e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6357e0580342SKamil Rytarowskifi
6358e219c499SRichard Hendersonif test "$capstone" != "no" ; then
63598ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
63608ca80760SRichard Hendersonfi
6361e0580342SKamil Rytarowski
63625c312079SDr. David Alan Gilbert# Hold two types of flag:
63635c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
63645c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
63655c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
63665c312079SDr. David Alan Gilbert#                                     platform
63675c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
63685c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
63695c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
63705c312079SDr. David Alan Gilbertfi
63715c312079SDr. David Alan Gilbert
6372da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6373da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6374da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6375da92c3ffSAshish Mittalfi
6376da92c3ffSAshish Mittal
63775b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
63785b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
63795b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
63805b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
63815b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
63825b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6383c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
63845b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
638540d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
638640d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
63875b5e3037SPaolo Bonzinielse
63885b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
63895b5e3037SPaolo Bonzinifi
63905b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
63915b5e3037SPaolo Bonzini
639298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
639398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6394804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6395804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
63961901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
63971901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
63981901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
639921655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6400c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6401804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6402a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6403a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6404a31a8642SMichael S. Tsirkinfi
64052b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6406804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
640783f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
64083c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6409804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
641045d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6411cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
64125f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
64133dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6414804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6415804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
64169f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
64174852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
64189fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6419e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
642046eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6421a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
642211cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6423f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6424e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6425e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
642680fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
64272944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6428e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6429e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6430e39f0062SPaolo Bonzinifi
643142da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
643242da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
643342da6041SGerd Hoffmannelse
643442da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
643542da6041SGerd Hoffmannfi
6436e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
643746eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
64386969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6439e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
644073da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
64413e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6442409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6443804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
644417969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
644517969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6446957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
644790246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
644890246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
644994dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6450cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
64511d728c39SBlue Swirlif test "$gcov" = "yes" ; then
64521d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
64531d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
64541d728c39SBlue Swirlfi
6455804edf29SJuan Quintela
64566efd7517SPeter Maydell# use included Linux headers
64576efd7517SPeter Maydellif test "$linux" = "yes" ; then
6458a307beb6SAndreas Färber  mkdir -p linux-headers
64596efd7517SPeter Maydell  case "$cpu" in
6460c72b26ecSRichard Henderson  i386|x86_64|x32)
646108312a63SPeter Maydell    linux_arch=x86
64626efd7517SPeter Maydell    ;;
64636efd7517SPeter Maydell  ppcemb|ppc|ppc64)
646408312a63SPeter Maydell    linux_arch=powerpc
64656efd7517SPeter Maydell    ;;
64666efd7517SPeter Maydell  s390x)
646708312a63SPeter Maydell    linux_arch=s390
646808312a63SPeter Maydell    ;;
64691f080313SClaudio Fontana  aarch64)
64701f080313SClaudio Fontana    linux_arch=arm64
64711f080313SClaudio Fontana    ;;
6472222e7d11SSanjay Lal  mips64)
6473222e7d11SSanjay Lal    linux_arch=mips
6474222e7d11SSanjay Lal    ;;
647508312a63SPeter Maydell  *)
647608312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
647708312a63SPeter Maydell    linux_arch="$cpu"
64786efd7517SPeter Maydell    ;;
64796efd7517SPeter Maydell  esac
648008312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
648108312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
648208312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
648308312a63SPeter Maydell    fi
64846efd7517SPeter Maydellfi
64856efd7517SPeter Maydell
648697a847bcSbellardfor target in $target_list; do
648797a847bcSbellardtarget_dir="$target"
648825be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
648989138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
649097a847bcSbellardtarget_bigendian="no"
64911f3d3c8fSJuan Quintela
6492c1799a84SPaolo Bonzinicase "$target_name" in
6493722dd7beSMichael Weiser  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6494ea2d6a39SJuan Quintela  target_bigendian=yes
6495ea2d6a39SJuan Quintela  ;;
6496ea2d6a39SJuan Quintelaesac
649797a847bcSbellardtarget_softmmu="no"
6498997344f3Sbellardtarget_user_only="no"
6499831b7825Sthstarget_linux_user="no"
650084778508Sblueswir1target_bsd_user="no"
65019e407a85Spbrookcase "$target" in
6502c1799a84SPaolo Bonzini  ${target_name}-softmmu)
65039e407a85Spbrook    target_softmmu="yes"
65049e407a85Spbrook    ;;
6505c1799a84SPaolo Bonzini  ${target_name}-linux-user)
65069e407a85Spbrook    target_user_only="yes"
65079e407a85Spbrook    target_linux_user="yes"
65089e407a85Spbrook    ;;
6509c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
651084778508Sblueswir1    target_user_only="yes"
651184778508Sblueswir1    target_bsd_user="yes"
651284778508Sblueswir1    ;;
65139e407a85Spbrook  *)
651476ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
65159e407a85Spbrook    exit 1
65169e407a85Spbrook    ;;
65179e407a85Spbrookesac
6518831b7825Sths
651997a847bcSbellardmkdir -p $target_dir
652025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
652197a847bcSbellard
6522e5fe0c52Spbrookbflt="no"
6523ca759f9eSAlex Bennéemttcg="no"
652489138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
652556aebc89Spbrookgdb_xml_files=""
65267ba1e619Saliguori
6527c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
65286acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6529e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6530e73aae67SJuan Quintela
6531c1799a84SPaolo Bonzinicase "$target_name" in
65322408a527Saurel32  i386)
6533b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
65342408a527Saurel32  ;;
65352408a527Saurel32  x86_64)
65366acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6537b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
65382408a527Saurel32  ;;
65392408a527Saurel32  alpha)
65405ee4f3c2SRichard Henderson    mttcg="yes"
65412408a527Saurel32  ;;
65422408a527Saurel32  arm|armeb)
6543b498c8a0SJuan Quintela    TARGET_ARCH=arm
6544e5fe0c52Spbrook    bflt="yes"
6545ca759f9eSAlex Bennée    mttcg="yes"
654656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
65472408a527Saurel32  ;;
6548722dd7beSMichael Weiser  aarch64|aarch64_be)
6549722dd7beSMichael Weiser    TARGET_ARCH=aarch64
65506a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
65516a49fa95SAlexander Graf    bflt="yes"
6552ca759f9eSAlex Bennée    mttcg="yes"
65538f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
65546a49fa95SAlexander Graf  ;;
65552408a527Saurel32  cris)
65562408a527Saurel32  ;;
655761766fe9SRichard Henderson  hppa)
655861766fe9SRichard Henderson  ;;
6559613a22c9SMichael Walle  lm32)
6560613a22c9SMichael Walle  ;;
65612408a527Saurel32  m68k)
65620938cda5Saurel32    bflt="yes"
65635a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
65642408a527Saurel32  ;;
6565877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6566877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
656772b675caSEdgar E. Iglesias    bflt="yes"
656872b675caSEdgar E. Iglesias  ;;
65692408a527Saurel32  mips|mipsel)
6570b498c8a0SJuan Quintela    TARGET_ARCH=mips
657125be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
65722408a527Saurel32  ;;
65732408a527Saurel32  mipsn32|mipsn32el)
6574597e2cecSRichard Henderson    TARGET_ARCH=mips64
65756acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
657625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6577597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
65782408a527Saurel32  ;;
65792408a527Saurel32  mips64|mips64el)
6580b498c8a0SJuan Quintela    TARGET_ARCH=mips64
65816acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
658225be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
65832408a527Saurel32  ;;
6584d15a9c23SAnthony Green  moxie)
6585d15a9c23SAnthony Green  ;;
6586e671711cSMarek Vasut  nios2)
6587e671711cSMarek Vasut  ;;
65884a09d0bbSRichard Henderson  or1k)
6589e67db06eSJia Liu    TARGET_ARCH=openrisc
6590e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6591e67db06eSJia Liu  ;;
65922408a527Saurel32  ppc)
6593c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
65942408a527Saurel32  ;;
65952408a527Saurel32  ppcemb)
65966acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6597e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6598c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
65992408a527Saurel32  ;;
66002408a527Saurel32  ppc64)
66016acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6602e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6603f0b0685dSNikunj A Dadhania    mttcg=yes
66041438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
66052408a527Saurel32  ;;
66069c35126cSDoug Kwan  ppc64le)
66079c35126cSDoug Kwan    TARGET_ARCH=ppc64
66089c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
66099c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6610f0b0685dSNikunj A Dadhania    mttcg=yes
66111438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
66129c35126cSDoug Kwan  ;;
66132408a527Saurel32  ppc64abi32)
6614b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
66156acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6616e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
661725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
66181438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
66192408a527Saurel32  ;;
66202408a527Saurel32  sh4|sh4eb)
6621b498c8a0SJuan Quintela    TARGET_ARCH=sh4
66224dbed897Spbrook    bflt="yes"
66232408a527Saurel32  ;;
66242408a527Saurel32  sparc)
66252408a527Saurel32  ;;
66262408a527Saurel32  sparc64)
66276acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
66282408a527Saurel32  ;;
66292408a527Saurel32  sparc32plus)
6630b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
66316acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6632e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
663325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
66342408a527Saurel32  ;;
663524e804ecSAlexander Graf  s390x)
663686158a2aSChristian 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"
663724e804ecSAlexander Graf  ;;
6638444e06b1SChen Gang  tilegx)
6639444e06b1SChen Gang  ;;
66405ecaa4edSPeter Crosthwaite  tricore)
66415ecaa4edSPeter Crosthwaite  ;;
6642d2fbca94SGuan Xuetao  unicore32)
6643d2fbca94SGuan Xuetao  ;;
6644cfa550c6SMax Filippov  xtensa|xtensaeb)
6645cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6646cfa550c6SMax Filippov  ;;
66472408a527Saurel32  *)
664876ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
66492408a527Saurel32  ;;
66502408a527Saurel32esac
66515e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
66525e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
66535e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
66545e8861a0SPaolo Bonzinifi
66555e8861a0SPaolo Bonzini
66565e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
66575e8861a0SPaolo Bonzini
665899afc91dSDaniel P. Berrangeupper() {
665999afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
666099afc91dSDaniel P. Berrange}
666199afc91dSDaniel P. Berrange
666289138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
666325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6664c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
666525be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6666e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6667e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6668e6e91b9cSJuan Quintelafi
666925be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6670adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6671adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6672adfc3e91SStacey Sonfi
66733b6b7550SPaolo Bonzini
66743b6b7550SPaolo Bonziniif supported_xen_target $target; then
667525be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6676eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6677eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6678eb6fda0fSAnthony PERARD    fi
6679432d268cSJun Nakajimafi
66803b6b7550SPaolo Bonziniif supported_kvm_target $target; then
668125be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
66821ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6683d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6684e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
6685e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6686e6a74868SMarc-André Lureau        fi
6687d5970055SMichael S. Tsirkin    fi
6688c59249f9SJuan Quintelafi
66893b6b7550SPaolo Bonziniif supported_hax_target $target; then
6690b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6691b0cb0a66SVincent Palatinfi
6692c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
6693c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
6694c97d6d2cSSergio Andres Gomez Del Realfi
6695de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
669625be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
669797a847bcSbellardfi
669897a847bcSbellardif test "$target_softmmu" = "yes" ; then
669925be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6700ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6701ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6702ca759f9eSAlex Bennée  fi
6703de83cd02Sbellardfi
6704997344f3Sbellardif test "$target_user_only" = "yes" ; then
670525be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6706a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6707997344f3Sbellardfi
6708831b7825Sthsif test "$target_linux_user" = "yes" ; then
670925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6710831b7825Sthsfi
671156aebc89Spbrooklist=""
671256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
671356aebc89Spbrook  for x in $gdb_xml_files; do
671456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
671556aebc89Spbrook  done
671625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
67173d0f1517SJuan Quintelafi
6718de83cd02Sbellard
6719e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
672025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6721e5fe0c52Spbrookfi
672284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
672325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
672484778508Sblueswir1fi
67255b0753e0Sbellard
67264afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6727fa282484SJuan Quintela
67284afddb55SJuan Quintelacflags=""
6729fa282484SJuan Quintelaldflags=""
67309b8e111fSJuan Quintela
6731c765fcacSPeter Crosthwaitedisas_config() {
6732c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6733c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6734c765fcacSPeter Crosthwaite}
6735c765fcacSPeter Crosthwaite
673664656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
673764656024SJuan Quintela  case "$i" in
673864656024SJuan Quintela  alpha)
6739c765fcacSPeter Crosthwaite    disas_config "ALPHA"
674064656024SJuan Quintela  ;;
674182295d8aSRichard Henderson  aarch64)
674282295d8aSRichard Henderson    if test -n "${cxx}"; then
6743c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
674482295d8aSRichard Henderson    fi
674582295d8aSRichard Henderson  ;;
674664656024SJuan Quintela  arm)
6747c765fcacSPeter Crosthwaite    disas_config "ARM"
6748999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6749c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6750999b53ecSClaudio Fontana    fi
675164656024SJuan Quintela  ;;
675264656024SJuan Quintela  cris)
6753c765fcacSPeter Crosthwaite    disas_config "CRIS"
675464656024SJuan Quintela  ;;
6755429b31a2SRichard Henderson  hppa)
6756429b31a2SRichard Henderson    disas_config "HPPA"
6757429b31a2SRichard Henderson  ;;
6758c72b26ecSRichard Henderson  i386|x86_64|x32)
6759c765fcacSPeter Crosthwaite    disas_config "I386"
676064656024SJuan Quintela  ;;
676179368f49SMichael Walle  lm32)
6762c765fcacSPeter Crosthwaite    disas_config "LM32"
676379368f49SMichael Walle  ;;
676464656024SJuan Quintela  m68k)
6765c765fcacSPeter Crosthwaite    disas_config "M68K"
676664656024SJuan Quintela  ;;
6767877fdc12SEdgar E. Iglesias  microblaze*)
6768c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
676964656024SJuan Quintela  ;;
677064656024SJuan Quintela  mips*)
6771c765fcacSPeter Crosthwaite    disas_config "MIPS"
677264656024SJuan Quintela  ;;
6773d15a9c23SAnthony Green  moxie*)
6774c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6775d15a9c23SAnthony Green  ;;
6776e671711cSMarek Vasut  nios2)
6777e671711cSMarek Vasut    disas_config "NIOS2"
6778e671711cSMarek Vasut  ;;
67794a09d0bbSRichard Henderson  or1k)
6780c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6781e67db06eSJia Liu  ;;
678264656024SJuan Quintela  ppc*)
6783c765fcacSPeter Crosthwaite    disas_config "PPC"
678464656024SJuan Quintela  ;;
678524e804ecSAlexander Graf  s390*)
6786c765fcacSPeter Crosthwaite    disas_config "S390"
678764656024SJuan Quintela  ;;
678864656024SJuan Quintela  sh4)
6789c765fcacSPeter Crosthwaite    disas_config "SH4"
679064656024SJuan Quintela  ;;
679164656024SJuan Quintela  sparc*)
6792c765fcacSPeter Crosthwaite    disas_config "SPARC"
679364656024SJuan Quintela  ;;
6794cfa550c6SMax Filippov  xtensa*)
6795c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6796cfa550c6SMax Filippov  ;;
679764656024SJuan Quintela  esac
679864656024SJuan Quinteladone
67999195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6800c765fcacSPeter Crosthwaite  disas_config "TCI"
68019195b2c2SStefan Weilfi
680264656024SJuan Quintela
68036ee7126fSJuan Quintelacase "$ARCH" in
68046ee7126fSJuan Quintelaalpha)
68056ee7126fSJuan Quintela  # Ensure there's only a single GP
68066ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
68076ee7126fSJuan Quintela;;
68086ee7126fSJuan Quintelaesac
68096ee7126fSJuan Quintela
6810d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
681125be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6812d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6813d02c1db3SJuan Quintela    cflags="-p $cflags"
6814d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6815d02c1db3SJuan Quintela  fi
6816d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6817d02c1db3SJuan Quintela    ldflags="-p $ldflags"
681825be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6819d02c1db3SJuan Quintela  fi
6820d02c1db3SJuan Quintelafi
6821d02c1db3SJuan Quintela
68229b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6823964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6824fa282484SJuan Quintelafi
6825fa282484SJuan Quintela
6826e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
6827e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
6828e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
6829e9a3591fSChristian Borntraeger# header if
6830e9a3591fSChristian Borntraeger#  - we build on s390x
6831e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
6832e9a3591fSChristian Borntraeger#  - KVM is enabled
6833e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
6834e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6835e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
6836e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
6837e9a3591fSChristian Borntraeger    fi
6838e9a3591fSChristian Borntraegerfi
6839e9a3591fSChristian Borntraeger
684025be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
684125be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6842fa282484SJuan Quintela
684397a847bcSbellarddone # for target in $targets
68447d13299dSbellard
6845a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6846a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6847a540f158SPeter Crosthwaitefi
6848e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
6849e219c499SRichard Henderson  echo "config-host.h: subdir-capstone" >> $config_host_mak
6850e219c499SRichard Hendersonfi
6851e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
6852e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
6853e219c499SRichard Hendersonfi
6854a540f158SPeter Crosthwaite
6855a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6856a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6857a99d57bbSWanlong Gaofi
6858a99d57bbSWanlong Gao
6859fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6860fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6861fd0e6053SJohn Snowfi
6862fd0e6053SJohn Snow
6863d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6864b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
6865b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
68669933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
68672d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
68682dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6869c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6870c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6871aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6872ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6873446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
68749933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
68752d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
68764652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
68773a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6878753d11f2SRichard Hendersonfor bios_file in \
6879753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6880225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
68815acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6882753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6883753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6884e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6885753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
68864e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6887753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6888753d11f2SRichard Hendersondo
688989138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
68907ea78b74SJan Kiszkadone
689189138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6892c2304b52SMarcel Apfelbaumdo
689389138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6894c2304b52SMarcel Apfelbaumdone
6895d1807a4fSPaolo Bonzinimkdir -p $DIRS
68967d13299dSbellardfor f in $FILES ; do
6897cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6898f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6899f9245e10SPeter Maydell    fi
69007d13299dSbellarddone
69011ad2134fSPaul Brook
6902c34ebfdcSAnthony Liguori# temporary config to build submodules
69032d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6904c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
690537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6906c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6907cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
69085f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6909c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6910c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
69113dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6912c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6913a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6914c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
69159f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
6916c34ebfdcSAnthony Liguoridone
6917c34ebfdcSAnthony Liguori
6918fe31017fSMarc-André Lureau# set up tests data directory
6919fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6920fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6921fe31017fSMarc-André Lureaufi
6922fe31017fSMarc-André Lureau
692376c7560aSMax Reitz# set up qemu-iotests in this build directory
692476c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
692576c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
692676c7560aSMax Reitz
692776c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
692876c7560aSMax Reitzecho >> "$iotests_common_env"
692976c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
693076c7560aSMax Reitz
693176c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
693276c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
693376c7560aSMax Reitzfi
693476c7560aSMax Reitz
6935dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6936dc655404SMichael S. Tsirkincat <<EOD >config.status
6937dc655404SMichael S. Tsirkin#!/bin/sh
6938dc655404SMichael S. Tsirkin# Generated by configure.
6939dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6940dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6941dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6942dc655404SMichael S. TsirkinEOD
6943dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6944dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6945cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6946dc655404SMichael S. Tsirkinchmod +x config.status
6947dc655404SMichael S. Tsirkin
69488cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6949