xref: /openbmc/qemu/configure (revision c12b6d70e384c769ca372e15ffd19b3e9f563662)
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
214d880a3baSPaolo Bonzinisupported_target() {
215d880a3baSPaolo Bonzini    case "$1" in
216d880a3baSPaolo Bonzini        *-softmmu)
217d880a3baSPaolo Bonzini            ;;
218d880a3baSPaolo Bonzini        *-linux-user)
219d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
220d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
221d880a3baSPaolo Bonzini                return 1
222d880a3baSPaolo Bonzini            fi
223d880a3baSPaolo Bonzini            ;;
224d880a3baSPaolo Bonzini        *-bsd-user)
225d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
226d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
227d880a3baSPaolo Bonzini                return 1
228d880a3baSPaolo Bonzini            fi
229d880a3baSPaolo Bonzini            ;;
230d880a3baSPaolo Bonzini        *)
231d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
232d880a3baSPaolo Bonzini            return 1
233d880a3baSPaolo Bonzini            ;;
234d880a3baSPaolo Bonzini    esac
235b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
236b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
237b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
238b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
239b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
240b3f6ea7eSPaolo Bonzini    return 1
241d880a3baSPaolo Bonzini}
242d880a3baSPaolo Bonzini
243e9a3591fSChristian Borntraeger
244e9a3591fSChristian Borntraegerld_has() {
245e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
246e9a3591fSChristian Borntraeger}
247e9a3591fSChristian Borntraeger
2487d13299dSbellard# default parameters
24989138857SStefan Weilsource_path=$(dirname "$0")
2502ff6b91eSJuan Quintelacpu=""
251a31a8642SMichael S. Tsirkiniasl="iasl"
2521e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
25343ce4dfeSbellardstatic="no"
2547d13299dSbellardcross_prefix=""
2550c58ac1cSmalcaudio_drv_list=""
256b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
257b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
258e49d021eSPeter Maydellhost_cc="cc"
25973da375eSJuan Quintelalibs_softmmu=""
2603e2e0e6bSJuan Quintelalibs_tools=""
26167f86e8eSJuan Quintelaaudio_pt_int=""
262d5631638Smalcaudio_win_int=""
2632b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
264957f1f99SMichael Rothlibs_qga=""
2655bc62e01SGerd Hoffmanndebug_info="yes"
26663678e17SSteven Noonanstack_protector=""
267ac0df51dSaliguori
268afb63ebdSStefan Weil# Don't accept a target_list environment variable.
269afb63ebdSStefan Weilunset target_list
270377529c0SPaolo Bonzini
271377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
272377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
273377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
274377529c0SPaolo Bonzini#              unless --disable-foo is given
275377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
276377529c0SPaolo Bonzini#              feature will searched for,
277377529c0SPaolo Bonzini#              if not found, configure exits with error
278377529c0SPaolo Bonzini#
279377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
280377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
281377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
282377529c0SPaolo Bonzini
283377529c0SPaolo Bonzinibluez=""
284377529c0SPaolo Bonzinibrlapi=""
285377529c0SPaolo Bonzinicurl=""
286377529c0SPaolo Bonzinicurses=""
287377529c0SPaolo Bonzinidocs=""
288377529c0SPaolo Bonzinifdt=""
28958952137SVincenzo Maffionenetmap="no"
290e2134eb9SGerd Hoffmannpixman=""
291377529c0SPaolo Bonzinisdl=""
292ee8466d0SCole Robinsonsdlabi=""
293983eef5aSMeador Ingevirtfs=""
294821601eaSJes Sorensenvnc="yes"
295377529c0SPaolo Bonzinisparse="no"
296377529c0SPaolo Bonzinivde=""
297377529c0SPaolo Bonzinivnc_sasl=""
298377529c0SPaolo Bonzinivnc_jpeg=""
299377529c0SPaolo Bonzinivnc_png=""
300377529c0SPaolo Bonzinixen=""
301d5b93ddfSAnthony PERARDxen_ctrl_version=""
30264a7ad6fSIan Campbellxen_pv_domain_build="no"
303eb6fda0fSAnthony PERARDxen_pci_passthrough=""
304377529c0SPaolo Bonzinilinux_aio=""
30547e98658SCorey Bryantcap_ng=""
306377529c0SPaolo Bonziniattr=""
3074f26f2b6SAvi Kivitylibattr=""
308377529c0SPaolo Bonzinixfs=""
309b3f6ea7eSPaolo Bonzinitcg="yes"
310377529c0SPaolo Bonzini
311d41a75a2SBradvhost_net="no"
3125e9be92dSNicholas Bellingervhost_scsi="no"
313fc0b9b0eSStefan Hajnoczivhost_vsock="no"
314e6a74868SMarc-André Lureauvhost_user=""
315d41a75a2SBradkvm="no"
316b0cb0a66SVincent Palatinhax="no"
3172da776dbSMichael R. Hinesrdma=""
318377529c0SPaolo Bonzinigprof="no"
319377529c0SPaolo Bonzinidebug_tcg="no"
320377529c0SPaolo Bonzinidebug="no"
321b553a042SJohn Snowfortify_source=""
322377529c0SPaolo Bonzinistrip_opt="yes"
3239195b2c2SStefan Weiltcg_interpreter="no"
324377529c0SPaolo Bonzinibigendian="no"
325377529c0SPaolo Bonzinimingw32="no"
3261d728c39SBlue Swirlgcov="no"
3271d728c39SBlue Swirlgcov_tool="gcov"
328377529c0SPaolo BonziniEXESUF=""
32917969268SFam ZhengDSOSUF=".so"
33017969268SFam ZhengLDFLAGS_SHARED="-shared"
33117969268SFam Zhengmodules="no"
332377529c0SPaolo Bonziniprefix="/usr/local"
333377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
334528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
335850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
336377529c0SPaolo Bonzinibindir="\${prefix}/bin"
3373aa5d2beSAlon Levylibdir="\${prefix}/lib"
3388bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
3390f94d6daSAlon Levyincludedir="\${prefix}/include"
340377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
341785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
342377529c0SPaolo Bonziniconfsuffix="/qemu"
343377529c0SPaolo Bonzinislirp="yes"
344377529c0SPaolo Bonzinioss_lib=""
345377529c0SPaolo Bonzinibsd="no"
346377529c0SPaolo Bonzinilinux="no"
347377529c0SPaolo Bonzinisolaris="no"
348377529c0SPaolo Bonziniprofiler="no"
349377529c0SPaolo Bonzinicocoa="no"
350377529c0SPaolo Bonzinisoftmmu="yes"
351377529c0SPaolo Bonzinilinux_user="no"
352377529c0SPaolo Bonzinibsd_user="no"
353377529c0SPaolo Bonziniblobs="yes"
354377529c0SPaolo Bonzinipkgversion=""
35540d6444eSAvi Kivitypie=""
3563556c233SPaolo Bonziniqom_cast_debug="yes"
357baf86d6bSPaolo Bonzinitrace_backends="log"
358377529c0SPaolo Bonzinitrace_file="trace"
359377529c0SPaolo Bonzinispice=""
360377529c0SPaolo Bonzinirbd=""
3617b02f544SMarc-André Lureausmartcard=""
3622b2325ffSGerd Hoffmannlibusb=""
36369354a83SHans de Goedeusb_redir=""
364da076ffeSGerd Hoffmannopengl=""
365014cb152SGerd Hoffmannopengl_dmabuf="no"
3665dd89908SRichard Hendersoncpuid_h="no"
36799f2dbd3SLiang Liavx2_opt="no"
3681ece9905SAlon Levyzlib="yes"
369b25c9dffSStefan Weillzo=""
370b25c9dffSStefan Weilsnappy=""
3716b383c08SPeter Wubzip2=""
372e8ef31a3SMichael Tokarevguest_agent=""
373d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
37450cbebb9SMichael Rothguest_agent_ntddscsi="no"
3759dacf32dSYossi Hindinguest_agent_msi=""
376d9840e25STomoki Sekiyamavss_win32_sdk=""
377d9840e25STomoki Sekiyamawin_sdk="no"
3784b1c11fdSDaniel P. Berrangewant_tools="yes"
379c589b249SRonnie Sahlberglibiscsi=""
3806542aa9cSPeter Lievenlibnfs=""
381519175a2SAlex Barcelocoroutine=""
38270c60c08SStefan Hajnoczicoroutine_pool=""
3837d992e4dSPeter Lievendebug_stack_usage="no"
384f0d92b56SLongpeng(Mike)crypto_afalg="no"
385f794573eSEduardo Otuboseccomp=""
386eb100396SBharata B Raoglusterfs=""
387d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
3880c14fb47SBharata B Raoglusterfs_discard="no"
389df3a429aSNiels de Vosglusterfs_fallocate="no"
3907c815372SBharata B Raoglusterfs_zerofill="no"
391a4ccabcfSAnthony Liguorigtk=""
3929e04c683SStefan Weilgtkabi=""
393925a0400SGerd Hoffmanngtk_gl="no"
394a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
395ddbb0d09SDaniel P. Berrangegnutls=""
396b917da4cSDaniel P. Berrangegnutls_rnd=""
39791bfcdb0SDaniel P. Berrangenettle=""
398fff2f982SDaniel P. Berrangenettle_kdf="no"
39991bfcdb0SDaniel P. Berrangegcrypt=""
4001f923c70SLongpeng(Mike)gcrypt_hmac="no"
40137788f25SDaniel P. Berrangegcrypt_kdf="no"
402bbbf9bfbSStefan Weilvte=""
4039d9e1521SGerd Hoffmannvirglrenderer=""
404e91c793cSCole Robinsontpm="yes"
4050a12ec87SRichard W.M. Joneslibssh2=""
406ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
407a99d57bbSWanlong Gaonuma=""
4082847b469SFam Zhengtcmalloc="no"
4097b01cb97SAlexandre Derumierjemalloc="no"
410a6b1d4c0SChanglong Xiereplication="yes"
411da92c3ffSAshish Mittalvxhs=""
412377529c0SPaolo Bonzini
413898be3e0SPeter Maydellsupported_cpu="no"
414898be3e0SPeter Maydellsupported_os="no"
415fb59dabdSPeter Maydellbogus_os="no"
416898be3e0SPeter Maydell
417ac0df51dSaliguori# parse CC options first
418ac0df51dSaliguorifor opt do
41989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
420ac0df51dSaliguori  case "$opt" in
421ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
422ac0df51dSaliguori  ;;
4233d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
424ac0df51dSaliguori  ;;
42583f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
42683f73fceSTomoki Sekiyama  ;;
427ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
428ca4deeb1SPaolo Bonzini  ;;
4292ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4302ff6b91eSJuan Quintela  ;;
431de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
432f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
433e2a2ed06SJuan Quintela  ;;
43411cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
43511cde1c8SBruno Dominguez                      EXTRA_CXXFLAGS="$optarg"
43611cde1c8SBruno Dominguez  ;;
437a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
438f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
439e2a2ed06SJuan Quintela  ;;
4405bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4415bc62e01SGerd Hoffmann  ;;
4425bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4435bc62e01SGerd Hoffmann  ;;
444ac0df51dSaliguori  esac
445ac0df51dSaliguoridone
446ac0df51dSaliguori# OS specific
447ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
44893148aa5SStefan Weil# we can eliminate its usage altogether.
449ac0df51dSaliguori
450e49d021eSPeter Maydell# Preferred compiler:
451e49d021eSPeter Maydell#  ${CC} (if set)
452e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
453e49d021eSPeter Maydell#  system compiler
454e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
455e49d021eSPeter Maydell  cc="$host_cc"
456e49d021eSPeter Maydellelse
457b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
458e49d021eSPeter Maydellfi
459e49d021eSPeter Maydell
46083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
46183f73fceSTomoki Sekiyama  cxx="c++"
46283f73fceSTomoki Sekiyamaelse
46383f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
46483f73fceSTomoki Sekiyamafi
46583f73fceSTomoki Sekiyama
466b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
467cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4685f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4693dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
470b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
471b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
4724852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
473b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
474b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
47517884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
47617884d7bSSergei Trofimovichquery_pkg_config() {
47717884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
47817884d7bSSergei Trofimovich}
47917884d7bSSergei Trofimovichpkg_config=query_pkg_config
480b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
48147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
482ac0df51dSaliguori
48345d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
48445d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
48545d285abSPeter Maydell
486be17dc90SMichael S. Tsirkin# default flags for all hosts
4872d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
4882d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
4892d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
4902d31515bSPeter Maydell# provides these semantics.)
4912d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
492f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
493c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
494be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
495244f1441SYang ZhongQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
4965bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
4975bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
498be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
4995bc62e01SGerd Hoffmannfi
500be17dc90SMichael S. Tsirkin
501ca4deeb1SPaolo Bonzini# make source path absolute
50289138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
503ca4deeb1SPaolo Bonzini
504cab00a5aSMichael S. Tsirkin# running configure in the source tree?
505cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
506cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
507cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
508cab00a5aSMichael S. Tsirkinelse
509cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
510cab00a5aSMichael S. Tsirkinfi
511cab00a5aSMichael S. Tsirkin
512ac0df51dSaliguoricheck_define() {
513ac0df51dSaliguoricat > $TMPC <<EOF
514ac0df51dSaliguori#if !defined($1)
515fd786e1aSPeter Maydell#error $1 not defined
516ac0df51dSaliguori#endif
517ac0df51dSaliguoriint main(void) { return 0; }
518ac0df51dSaliguoriEOF
51952166aa0SJuan Quintela  compile_object
520ac0df51dSaliguori}
521ac0df51dSaliguori
522307119e7SGerd Hoffmanncheck_include() {
523307119e7SGerd Hoffmanncat > $TMPC <<EOF
524307119e7SGerd Hoffmann#include <$1>
525307119e7SGerd Hoffmannint main(void) { return 0; }
526307119e7SGerd HoffmannEOF
527307119e7SGerd Hoffmann  compile_object
528307119e7SGerd Hoffmann}
529307119e7SGerd Hoffmann
53093b25869SJohn Snowwrite_c_skeleton() {
53193b25869SJohn Snow    cat > $TMPC <<EOF
53293b25869SJohn Snowint main(void) { return 0; }
53393b25869SJohn SnowEOF
53493b25869SJohn Snow}
53593b25869SJohn Snow
536bbea4050SPeter Maydellif check_define __linux__ ; then
537bbea4050SPeter Maydell  targetos="Linux"
538bbea4050SPeter Maydellelif check_define _WIN32 ; then
539bbea4050SPeter Maydell  targetos='MINGW32'
540bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
541bbea4050SPeter Maydell  targetos='OpenBSD'
542bbea4050SPeter Maydellelif check_define __sun__ ; then
543bbea4050SPeter Maydell  targetos='SunOS'
544bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
545bbea4050SPeter Maydell  targetos='Haiku'
546951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
547951fedfcSPeter Maydell  targetos='FreeBSD'
548951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
549951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
550951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
551951fedfcSPeter Maydell  targetos='DragonFly'
552951fedfcSPeter Maydellelif check_define __NetBSD__; then
553951fedfcSPeter Maydell  targetos='NetBSD'
554951fedfcSPeter Maydellelif check_define __APPLE__; then
555951fedfcSPeter Maydell  targetos='Darwin'
556bbea4050SPeter Maydellelse
557951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
558951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
559951fedfcSPeter Maydell  # be the result of a missing compiler.
560951fedfcSPeter Maydell  targetos='bogus'
561951fedfcSPeter Maydell  bogus_os='yes'
562bbea4050SPeter Maydellfi
563bbea4050SPeter Maydell
564bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
565bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
566bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
567bbea4050SPeter Maydell# the correct CPU with the --cpu option.
568bbea4050SPeter Maydellcase $targetos in
569bbea4050SPeter MaydellDarwin)
570bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
571bbea4050SPeter Maydell  # run 64-bit userspace code.
572bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
573bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
574bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
575bbea4050SPeter Maydell    cpu="x86_64"
576bbea4050SPeter Maydell  fi
577bbea4050SPeter Maydell  ;;
578bbea4050SPeter MaydellSunOS)
57989138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
580bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
581bbea4050SPeter Maydell    cpu="x86_64"
582bbea4050SPeter Maydell  fi
583bbea4050SPeter Maydellesac
584bbea4050SPeter Maydell
5852ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
5862ff6b91eSJuan Quintela  # command line argument
5872ff6b91eSJuan Quintela  :
5882ff6b91eSJuan Quintelaelif check_define __i386__ ; then
589ac0df51dSaliguori  cpu="i386"
590ac0df51dSaliguorielif check_define __x86_64__ ; then
591c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
592c72b26ecSRichard Henderson    cpu="x32"
593c72b26ecSRichard Henderson  else
594ac0df51dSaliguori    cpu="x86_64"
595c72b26ecSRichard Henderson  fi
5963aa9bd6cSblueswir1elif check_define __sparc__ ; then
5973aa9bd6cSblueswir1  if check_define __arch64__ ; then
5983aa9bd6cSblueswir1    cpu="sparc64"
5993aa9bd6cSblueswir1  else
6003aa9bd6cSblueswir1    cpu="sparc"
6013aa9bd6cSblueswir1  fi
602fdf7ed96Smalcelif check_define _ARCH_PPC ; then
603fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
604fdf7ed96Smalc    cpu="ppc64"
605ac0df51dSaliguori  else
606fdf7ed96Smalc    cpu="ppc"
607fdf7ed96Smalc  fi
608afa05235SAurelien Jarnoelif check_define __mips__ ; then
609afa05235SAurelien Jarno  cpu="mips"
610477ba620SAurelien Jarnoelif check_define __ia64__ ; then
611477ba620SAurelien Jarno  cpu="ia64"
612d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
613d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
614d66ed0eaSAurelien Jarno    cpu="s390x"
615d66ed0eaSAurelien Jarno  else
616d66ed0eaSAurelien Jarno    cpu="s390"
617d66ed0eaSAurelien Jarno  fi
61821d89f84SPeter Maydellelif check_define __arm__ ; then
61921d89f84SPeter Maydell  cpu="arm"
6201f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6211f080313SClaudio Fontana  cpu="aarch64"
622fdf7ed96Smalcelse
62389138857SStefan Weil  cpu=$(uname -m)
624ac0df51dSaliguorifi
625ac0df51dSaliguori
626359bc95dSPeter MaydellARCH=
627359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
628359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6297d13299dSbellardcase "$cpu" in
6306499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
631898be3e0SPeter Maydell    cpu="$cpu"
632898be3e0SPeter Maydell    supported_cpu="yes"
633898be3e0SPeter Maydell  ;;
6347d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
63597a847bcSbellard    cpu="i386"
636898be3e0SPeter Maydell    supported_cpu="yes"
6377d13299dSbellard  ;;
638aaa5fa14Saurel32  x86_64|amd64)
639aaa5fa14Saurel32    cpu="x86_64"
640898be3e0SPeter Maydell    supported_cpu="yes"
641aaa5fa14Saurel32  ;;
64221d89f84SPeter Maydell  armv*b|armv*l|arm)
64321d89f84SPeter Maydell    cpu="arm"
644898be3e0SPeter Maydell    supported_cpu="yes"
6457d13299dSbellard  ;;
6461f080313SClaudio Fontana  aarch64)
6471f080313SClaudio Fontana    cpu="aarch64"
648898be3e0SPeter Maydell    supported_cpu="yes"
6491f080313SClaudio Fontana  ;;
650afa05235SAurelien Jarno  mips*)
651afa05235SAurelien Jarno    cpu="mips"
652898be3e0SPeter Maydell    supported_cpu="yes"
653afa05235SAurelien Jarno  ;;
6543142255cSblueswir1  sparc|sun4[cdmuv])
655ae228531Sbellard    cpu="sparc"
6566499fd15SPeter Maydell    supported_cpu="yes"
657ae228531Sbellard  ;;
6587d13299dSbellard  *)
659359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
660359bc95dSPeter Maydell    ARCH=unknown
6617d13299dSbellard  ;;
6627d13299dSbellardesac
663359bc95dSPeter Maydellif test -z "$ARCH"; then
664359bc95dSPeter Maydell  ARCH="$cpu"
665359bc95dSPeter Maydellfi
666e2d52ad3SJuan Quintela
6677d13299dSbellard# OS specific
6680dbfc675SJuan Quintela
669adfc3e91SStacey Son# host *BSD for user mode
670adfc3e91SStacey SonHOST_VARIANT_DIR=""
671adfc3e91SStacey Son
6727d13299dSbellardcase $targetos in
67367b915a5SbellardMINGW32*)
67467b915a5Sbellard  mingw32="yes"
675b0cb0a66SVincent Palatin  hax="yes"
6763cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
677307119e7SGerd Hoffmann  if check_include dsound.h; then
6783cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
679307119e7SGerd Hoffmann  else
680307119e7SGerd Hoffmann    audio_drv_list=""
681307119e7SGerd Hoffmann  fi
682898be3e0SPeter Maydell  supported_os="yes"
68367b915a5Sbellard;;
6845c40d2bdSthsGNU/kFreeBSD)
685a167ba50SAurelien Jarno  bsd="yes"
6860c58ac1cSmalc  audio_drv_list="oss"
6870bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
6885c40d2bdSths;;
6897d3505c5SbellardFreeBSD)
6907d3505c5Sbellard  bsd="yes"
6910db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6920c58ac1cSmalc  audio_drv_list="oss"
6930bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
694f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
695f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
696a7764f15SEd Maste  # needed for kinfo_getproc
697a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
69858952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
699adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
700898be3e0SPeter Maydell  supported_os="yes"
7017d3505c5Sbellard;;
702c5e97233Sblueswir1DragonFly)
703c5e97233Sblueswir1  bsd="yes"
7040db4a067SPaolo Bonzini  make="${MAKE-gmake}"
705c5e97233Sblueswir1  audio_drv_list="oss"
7060bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
707adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
708c5e97233Sblueswir1;;
7097d3505c5SbellardNetBSD)
7107d3505c5Sbellard  bsd="yes"
7110db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7120c58ac1cSmalc  audio_drv_list="oss"
7130bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7148ef92a88Sblueswir1  oss_lib="-lossaudio"
715adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
7163c2bdbc1SKamil Rytarowski  supported_os="yes"
7177d3505c5Sbellard;;
7187d3505c5SbellardOpenBSD)
7197d3505c5Sbellard  bsd="yes"
7200db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7214f6ab397SBrad Smith  audio_drv_list="sdl"
7220bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
723adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7247d3505c5Sbellard;;
72583fb7adfSbellardDarwin)
72683fb7adfSbellard  bsd="yes"
72783fb7adfSbellard  darwin="yes"
728b0cb0a66SVincent Palatin  hax="yes"
72917969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7301b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
731a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7320c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
7331b0f9cc2Saliguori  fi
734fd677642Sths  cocoa="yes"
7350c58ac1cSmalc  audio_drv_list="coreaudio"
73614382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
7370c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7387973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
739a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
740a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
741a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
742adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
743898be3e0SPeter Maydell  supported_os="yes"
74483fb7adfSbellard;;
745ec530c81SbellardSunOS)
746ec530c81Sbellard  solaris="yes"
7470db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7480db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
749fa58948dSBlue Swirl  ld="gld"
750e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7516b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7520c58ac1cSmalc    audio_drv_list="oss"
7536b4d2ba1Sths  fi
754c2de5c91Smalc  audio_possible_drivers="oss sdl"
755d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
756d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
757d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
758d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
759a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
760560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
761560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
762560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
763ec530c81Sbellard;;
764179cf400SAndreas FärberHaiku)
765179cf400SAndreas Färber  haiku="yes"
766179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
767179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
768179cf400SAndreas Färber;;
769898be3e0SPeter MaydellLinux)
7700c58ac1cSmalc  audio_drv_list="oss"
7710bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7725327cf48Sbellard  linux="yes"
773831b7825Sths  linux_user="yes"
774af2be207SJan Kiszka  kvm="yes"
775af2be207SJan Kiszka  vhost_net="yes"
7765e9be92dSNicholas Bellinger  vhost_scsi="yes"
777fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
778a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
779898be3e0SPeter Maydell  supported_os="yes"
780898be3e0SPeter Maydell;;
7817d13299dSbellardesac
7827d13299dSbellard
7837d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
784b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
78584778508Sblueswir1    bsd_user="yes"
7867d3505c5Sbellard  fi
78708de3949SAndreas Färberfi
7887d3505c5Sbellard
7890db4a067SPaolo Bonzini: ${make=${MAKE-make}}
7900db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
79152510f8bSStefan Weil: ${python=${PYTHON-python}}
792e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
7930db4a067SPaolo Bonzini
7943c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7953c4a4d0dSPeter Maydellif has clang; then
7963c4a4d0dSPeter Maydell  objcc=clang
7973c4a4d0dSPeter Maydellelse
7983c4a4d0dSPeter Maydell  objcc="$cc"
7993c4a4d0dSPeter Maydellfi
8003c4a4d0dSPeter Maydell
8013457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8023457a3f8SJuan Quintela  EXESUF=".exe"
80317969268SFam Zheng  DSOSUF=".dll"
804a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
805e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
806e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
80778e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
80878e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
809f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
81093b25869SJohn Snow  write_c_skeleton;
811f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
812f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
813f7cf5d5bSStefan Weil  fi
814c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
815683035deSPaolo Bonzini  mandir="\${prefix}"
816528ae5b8SEduardo Habkost  datadir="\${prefix}"
817850da188SEduardo Habkost  qemu_docdir="\${prefix}"
818683035deSPaolo Bonzini  bindir="\${prefix}"
819683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8205a699bbbSLaszlo Ersek  local_statedir=
821683035deSPaolo Bonzini  confsuffix=""
822161a56a9SVinzenz Feenstra  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -liphlpapi -lnetapi32 $libs_qga"
8233457a3f8SJuan Quintelafi
8243457a3f8SJuan Quintela
825487fefdbSAnthony Liguoriwerror=""
82685aa5189Sbellard
8277d13299dSbellardfor opt do
82889138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8297d13299dSbellard  case "$opt" in
8302efc3265Sbellard  --help|-h) show_help=yes
8312efc3265Sbellard  ;;
83299123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
83399123e13SMike Frysinger  ;;
834b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8357d13299dSbellard  ;;
836b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
83732ce6337Sbellard  ;;
838ca4deeb1SPaolo Bonzini  --source-path=*)
8397d13299dSbellard  ;;
840ac0df51dSaliguori  --cross-prefix=*)
8417d13299dSbellard  ;;
842ac0df51dSaliguori  --cc=*)
8437d13299dSbellard  ;;
844b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
84583469015Sbellard  ;;
84683f73fceSTomoki Sekiyama  --cxx=*)
84783f73fceSTomoki Sekiyama  ;;
848e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
849e007dbecSMichael S. Tsirkin  ;;
8503c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8513c4a4d0dSPeter Maydell  ;;
852b1a550a0Spbrook  --make=*) make="$optarg"
8537d13299dSbellard  ;;
8546a882643Spbrook  --install=*) install="$optarg"
8556a882643Spbrook  ;;
856c886edfbSBlue Swirl  --python=*) python="$optarg"
857c886edfbSBlue Swirl  ;;
8581d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
8591d728c39SBlue Swirl  ;;
860e2d8830eSBrad  --smbd=*) smbd="$optarg"
861e2d8830eSBrad  ;;
862e2a2ed06SJuan Quintela  --extra-cflags=*)
8637d13299dSbellard  ;;
86411cde1c8SBruno Dominguez  --extra-cxxflags=*)
86511cde1c8SBruno Dominguez  ;;
866e2a2ed06SJuan Quintela  --extra-ldflags=*)
8677d13299dSbellard  ;;
8685bc62e01SGerd Hoffmann  --enable-debug-info)
8695bc62e01SGerd Hoffmann  ;;
8705bc62e01SGerd Hoffmann  --disable-debug-info)
8715bc62e01SGerd Hoffmann  ;;
87217969268SFam Zheng  --enable-modules)
87317969268SFam Zheng      modules="yes"
87417969268SFam Zheng  ;;
8753aa88b31SStefan Hajnoczi  --disable-modules)
8763aa88b31SStefan Hajnoczi      modules="no"
8773aa88b31SStefan Hajnoczi  ;;
8782ff6b91eSJuan Quintela  --cpu=*)
8797d13299dSbellard  ;;
880b1a550a0Spbrook  --target-list=*) target_list="$optarg"
881de83cd02Sbellard  ;;
8825b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8835b808275SLluís Vilanova  ;;
8845b808275SLluís Vilanova  # XXX: backwards compatibility
8855b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
88694a420b1SStefan Hajnoczi  ;;
88774242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8889410b56cSPrerna Saxena  ;;
8897d13299dSbellard  --enable-gprof) gprof="yes"
8907d13299dSbellard  ;;
8911d728c39SBlue Swirl  --enable-gcov) gcov="yes"
8921d728c39SBlue Swirl  ;;
89379427693SLoïc Minier  --static)
89479427693SLoïc Minier    static="yes"
89579427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
89617884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
89743ce4dfeSbellard  ;;
8980b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
8990b24e75fSPaolo Bonzini  ;;
9000b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9010b24e75fSPaolo Bonzini  ;;
9023aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9033aa5d2beSAlon Levy  ;;
9048bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9058bf188aaSMichael Tokarev  ;;
9060f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9070f94d6daSAlon Levy  ;;
908528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9090b24e75fSPaolo Bonzini  ;;
910023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
911023d3d67SEduardo Habkost  ;;
912850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9130b24e75fSPaolo Bonzini  ;;
914ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
91507381cc1SAnthony Liguori  ;;
916785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
917785c23aeSLuiz Capitulino  ;;
918785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
919023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
920023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
921023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
922023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
923023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
924023ddd74SMax Filippov    # lots of directory switches by default.
925023ddd74SMax Filippov  ;;
926e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
927e2134eb9SGerd Hoffmann  ;;
92874880fe2SRobert Schiele  --without-pixman) pixman="none"
92974880fe2SRobert Schiele  ;;
93097a847bcSbellard  --disable-sdl) sdl="no"
93197a847bcSbellard  ;;
932c4198157SJuan Quintela  --enable-sdl) sdl="yes"
933c4198157SJuan Quintela  ;;
93447c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
93547c03744SDave Airlie  ;;
9363556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9373556c233SPaolo Bonzini  ;;
9383556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9393556c233SPaolo Bonzini  ;;
940983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
941983eef5aSMeador Inge  ;;
942983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
943983eef5aSMeador Inge  ;;
944821601eaSJes Sorensen  --disable-vnc) vnc="no"
945821601eaSJes Sorensen  ;;
946821601eaSJes Sorensen  --enable-vnc) vnc="yes"
947821601eaSJes Sorensen  ;;
9482f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
9492f6a1ab0Sblueswir1  ;;
9500c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9510c58ac1cSmalc  ;;
95289138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
953b64ec4e4SFam Zheng  ;;
95489138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
955eb852011SMarkus Armbruster  ;;
956f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
957f8393946Saurel32  ;;
958f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
959f8393946Saurel32  ;;
960f3d08ee6SPaul Brook  --enable-debug)
961f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
962f3d08ee6SPaul Brook      debug_tcg="yes"
963f3d08ee6SPaul Brook      debug="yes"
964f3d08ee6SPaul Brook      strip_opt="no"
965b553a042SJohn Snow      fortify_source="no"
966f3d08ee6SPaul Brook  ;;
96703b4fe7dSaliguori  --enable-sparse) sparse="yes"
96803b4fe7dSaliguori  ;;
96903b4fe7dSaliguori  --disable-sparse) sparse="no"
97003b4fe7dSaliguori  ;;
9711625af87Saliguori  --disable-strip) strip_opt="no"
9721625af87Saliguori  ;;
9732f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
9742f9606b3Saliguori  ;;
975ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
976ea784e3bSJuan Quintela  ;;
9772f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
9782f6f5c7aSCorentin Chary  ;;
9792f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
9802f6f5c7aSCorentin Chary  ;;
981efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
982efe556adSCorentin Chary  ;;
983efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
984efe556adSCorentin Chary  ;;
985443f1376Sbellard  --disable-slirp) slirp="no"
986c20709aaSbellard  ;;
987e0e6c8c0Saliguori  --disable-vde) vde="no"
9888a16d273Sths  ;;
989dfb278bdSJuan Quintela  --enable-vde) vde="yes"
990dfb278bdSJuan Quintela  ;;
99158952137SVincenzo Maffione  --disable-netmap) netmap="no"
99258952137SVincenzo Maffione  ;;
99358952137SVincenzo Maffione  --enable-netmap) netmap="yes"
99458952137SVincenzo Maffione  ;;
995e37630caSaliguori  --disable-xen) xen="no"
996e37630caSaliguori  ;;
997fc321b4bSJuan Quintela  --enable-xen) xen="yes"
998fc321b4bSJuan Quintela  ;;
999eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1000eb6fda0fSAnthony PERARD  ;;
1001eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1002eb6fda0fSAnthony PERARD  ;;
100364a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
100464a7ad6fSIan Campbell  ;;
100564a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
100664a7ad6fSIan Campbell  ;;
10072e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10082e4d9fb1Saurel32  ;;
10094ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10104ffcedb6SJuan Quintela  ;;
1011fb599c9aSbalrog  --disable-bluez) bluez="no"
1012fb599c9aSbalrog  ;;
1013a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1014a20a6f46SJuan Quintela  ;;
10157ba1e619Saliguori  --disable-kvm) kvm="no"
10167ba1e619Saliguori  ;;
1017b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1018b31a0277SJuan Quintela  ;;
1019b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1020180fb750Szhanghailiang  ;;
1021b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1022180fb750Szhanghailiang  ;;
10239195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
10249195b2c2SStefan Weil  ;;
10259195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
10269195b2c2SStefan Weil  ;;
102747e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
102847e98658SCorey Bryant  ;;
102947e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
103047e98658SCorey Bryant  ;;
1031b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1032b3f6ea7eSPaolo Bonzini  ;;
1033b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1034b3f6ea7eSPaolo Bonzini  ;;
1035cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1036cd4ec0b4SGerd Hoffmann  ;;
1037cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1038cd4ec0b4SGerd Hoffmann  ;;
1039c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1040c589b249SRonnie Sahlberg  ;;
1041c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1042c589b249SRonnie Sahlberg  ;;
10436542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
10446542aa9cSPeter Lieven  ;;
10456542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
10466542aa9cSPeter Lieven  ;;
104705c2a3e7Sbellard  --enable-profiler) profiler="yes"
104805c2a3e7Sbellard  ;;
104914821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
105014821030SPavel Borzenkov  ;;
1051c2de5c91Smalc  --enable-cocoa)
1052c2de5c91Smalc      cocoa="yes" ;
105389138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
10545b0753e0Sbellard  ;;
1055cad25d69Spbrook  --disable-system) softmmu="no"
10560a8e90f4Spbrook  ;;
1057cad25d69Spbrook  --enable-system) softmmu="yes"
10580a8e90f4Spbrook  ;;
10590953a80fSZachary Amsden  --disable-user)
10600953a80fSZachary Amsden      linux_user="no" ;
10610953a80fSZachary Amsden      bsd_user="no" ;
10620953a80fSZachary Amsden  ;;
10630953a80fSZachary Amsden  --enable-user) ;;
1064831b7825Sths  --disable-linux-user) linux_user="no"
10650a8e90f4Spbrook  ;;
1066831b7825Sths  --enable-linux-user) linux_user="yes"
1067831b7825Sths  ;;
106884778508Sblueswir1  --disable-bsd-user) bsd_user="no"
106984778508Sblueswir1  ;;
107084778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
107184778508Sblueswir1  ;;
107240d6444eSAvi Kivity  --enable-pie) pie="yes"
107334005a00SKirill A. Shutemov  ;;
107440d6444eSAvi Kivity  --disable-pie) pie="no"
107534005a00SKirill A. Shutemov  ;;
107685aa5189Sbellard  --enable-werror) werror="yes"
107785aa5189Sbellard  ;;
107885aa5189Sbellard  --disable-werror) werror="no"
107985aa5189Sbellard  ;;
108063678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
108163678e17SSteven Noonan  ;;
108263678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
108363678e17SSteven Noonan  ;;
10844d3b6f6eSbalrog  --disable-curses) curses="no"
10854d3b6f6eSbalrog  ;;
1086c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1087c584a6d0SJuan Quintela  ;;
1088769ce76dSAlexander Graf  --disable-curl) curl="no"
1089769ce76dSAlexander Graf  ;;
1090788c8196SJuan Quintela  --enable-curl) curl="yes"
1091788c8196SJuan Quintela  ;;
10922df87df7SJuan Quintela  --disable-fdt) fdt="no"
10932df87df7SJuan Quintela  ;;
10942df87df7SJuan Quintela  --enable-fdt) fdt="yes"
10952df87df7SJuan Quintela  ;;
10965c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
10975c6c3a6cSChristoph Hellwig  ;;
10985c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
10995c6c3a6cSChristoph Hellwig  ;;
1100758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1101758e8e38SVenkateswararao Jujjuri (JV)  ;;
1102758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1103758e8e38SVenkateswararao Jujjuri (JV)  ;;
110477755340Sths  --disable-blobs) blobs="no"
110577755340Sths  ;;
11064a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
11074a19f1ecSpbrook  ;;
1108519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1109519175a2SAlex Barcelo  ;;
111070c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
111170c60c08SStefan Hajnoczi  ;;
111270c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
111370c60c08SStefan Hajnoczi  ;;
11147d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
11157d992e4dSPeter Lieven  ;;
1116f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1117f0d92b56SLongpeng(Mike)  ;;
1118f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1119f0d92b56SLongpeng(Mike)  ;;
1120a25dba17SJuan Quintela  --disable-docs) docs="no"
112170ec5dc0SAnthony Liguori  ;;
1122a25dba17SJuan Quintela  --enable-docs) docs="yes"
112383a3ab8bSJuan Quintela  ;;
1124d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1125d5970055SMichael S. Tsirkin  ;;
1126d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1127d5970055SMichael S. Tsirkin  ;;
11285e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
11295e9be92dSNicholas Bellinger  ;;
11305e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
11315e9be92dSNicholas Bellinger  ;;
1132fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1133fc0b9b0eSStefan Hajnoczi  ;;
1134fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1135fc0b9b0eSStefan Hajnoczi  ;;
1136da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
113720ff075bSMichael Walle  ;;
1138da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
113920ff075bSMichael Walle  ;;
1140f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1141f27aaf4bSChristian Brunner  ;;
1142f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1143f27aaf4bSChristian Brunner  ;;
11448c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
11458c84cf11SSergei Trofimovich  ;;
11468c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
11478c84cf11SSergei Trofimovich  ;;
11487b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1149111a38b0SRobert Relyea  ;;
11507b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1151111a38b0SRobert Relyea  ;;
11522b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
11532b2325ffSGerd Hoffmann  ;;
11542b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
11552b2325ffSGerd Hoffmann  ;;
115669354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
115769354a83SHans de Goede  ;;
115869354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
115969354a83SHans de Goede  ;;
11601ece9905SAlon Levy  --disable-zlib-test) zlib="no"
11611ece9905SAlon Levy  ;;
1162b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1163b25c9dffSStefan Weil  ;;
1164607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1165607dacd0Sqiaonuohan  ;;
1166b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1167b25c9dffSStefan Weil  ;;
1168607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1169607dacd0Sqiaonuohan  ;;
11706b383c08SPeter Wu  --disable-bzip2) bzip2="no"
11716b383c08SPeter Wu  ;;
11726b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
11736b383c08SPeter Wu  ;;
1174d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1175d138cee9SMichael Roth  ;;
1176d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1177d138cee9SMichael Roth  ;;
11789dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
11799dacf32dSYossi Hindin  ;;
11809dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
11819dacf32dSYossi Hindin  ;;
1182d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1183d9840e25STomoki Sekiyama  ;;
1184d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1185d9840e25STomoki Sekiyama  ;;
1186d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1187d9840e25STomoki Sekiyama  ;;
1188d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1189d9840e25STomoki Sekiyama  ;;
1190d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1191d9840e25STomoki Sekiyama  ;;
1192d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1193d9840e25STomoki Sekiyama  ;;
11944b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
11954b1c11fdSDaniel P. Berrange  ;;
11964b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
11974b1c11fdSDaniel P. Berrange  ;;
1198f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1199f794573eSEduardo Otubo  ;;
1200f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1201f794573eSEduardo Otubo  ;;
1202eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1203eb100396SBharata B Rao  ;;
1204eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1205eb100396SBharata B Rao  ;;
120652b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
120752b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1208583f6e7bSStefan Hajnoczi  ;;
1209cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1210cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1211cb6414dfSFam Zheng  ;;
1212315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1213315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1214315d3184SFam Zheng  ;;
1215a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1216a4ccabcfSAnthony Liguori  ;;
1217a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1218a4ccabcfSAnthony Liguori  ;;
1219a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1220a1c5e949SDaniel P. Berrange  ;;
1221ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1222ddbb0d09SDaniel P. Berrange  ;;
1223ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1224ddbb0d09SDaniel P. Berrange  ;;
122591bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
122691bfcdb0SDaniel P. Berrange  ;;
122791bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
122891bfcdb0SDaniel P. Berrange  ;;
122991bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
123091bfcdb0SDaniel P. Berrange  ;;
123191bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
123291bfcdb0SDaniel P. Berrange  ;;
12332da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
12342da776dbSMichael R. Hines  ;;
12352da776dbSMichael R. Hines  --disable-rdma) rdma="no"
12362da776dbSMichael R. Hines  ;;
1237528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1238528de90aSDaniel P. Berrange  ;;
1239bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1240bbbf9bfbSStefan Weil  ;;
1241bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1242bbbf9bfbSStefan Weil  ;;
12439d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
12449d9e1521SGerd Hoffmann  ;;
12459d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
12469d9e1521SGerd Hoffmann  ;;
1247e91c793cSCole Robinson  --disable-tpm) tpm="no"
1248e91c793cSCole Robinson  ;;
1249ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1250ab214c29SStefan Berger  ;;
12510a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
12520a12ec87SRichard W.M. Jones  ;;
12530a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
12540a12ec87SRichard W.M. Jones  ;;
1255ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1256ed1701c6SDr. David Alan Gilbert  ;;
1257ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1258ed1701c6SDr. David Alan Gilbert  ;;
1259a99d57bbSWanlong Gao  --disable-numa) numa="no"
1260a99d57bbSWanlong Gao  ;;
1261a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1262a99d57bbSWanlong Gao  ;;
12632847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
12642847b469SFam Zheng  ;;
12652847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
12662847b469SFam Zheng  ;;
12677b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
12687b01cb97SAlexandre Derumier  ;;
12697b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
12707b01cb97SAlexandre Derumier  ;;
1271a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1272a6b1d4c0SChanglong Xie  ;;
1273a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1274a6b1d4c0SChanglong Xie  ;;
1275da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1276da92c3ffSAshish Mittal  ;;
1277da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1278da92c3ffSAshish Mittal  ;;
1279e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1280e6a74868SMarc-André Lureau  ;;
1281e6a74868SMarc-André Lureau  --enable-vhost-user)
1282e6a74868SMarc-André Lureau      vhost_user="yes"
1283e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1284e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1285e6a74868SMarc-André Lureau      fi
1286e6a74868SMarc-André Lureau  ;;
12872d2ad6d0SFam Zheng  *)
12882d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
12892d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
12902d2ad6d0SFam Zheng      exit 1
12917f1559c6Sbalrog  ;;
12927d13299dSbellard  esac
12937d13299dSbellarddone
12947d13299dSbellard
1295e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1296e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1297e6a74868SMarc-André Lureau        vhost_user="no"
1298e6a74868SMarc-André Lureau    else
1299e6a74868SMarc-André Lureau        vhost_user="yes"
1300e6a74868SMarc-André Lureau    fi
1301e6a74868SMarc-André Lureaufi
1302e6a74868SMarc-André Lureau
130340293e58Sbellardcase "$cpu" in
1304e3608d66SRichard Henderson    ppc)
1305e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1306e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1307e3608d66SRichard Henderson           ;;
1308e3608d66SRichard Henderson    ppc64)
1309e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1310e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1311e3608d66SRichard Henderson           ;;
13129b9c37c3SRichard Henderson    sparc)
1313f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1314f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
13153142255cSblueswir1           ;;
1316ed968ff1SJuan Quintela    sparc64)
131779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1318f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
13193142255cSblueswir1           ;;
132076d83bdeSths    s390)
1321061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
132228d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
132328d7cc49SRichard Henderson           ;;
132428d7cc49SRichard Henderson    s390x)
1325061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
132628d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
132776d83bdeSths           ;;
132840293e58Sbellard    i386)
132979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
13300c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
13312b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
133240293e58Sbellard           ;;
133340293e58Sbellard    x86_64)
13347ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
13357ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
13367ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
13377ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
13380c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
13392b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1340379f6698SPaul Brook           ;;
1341c72b26ecSRichard Henderson    x32)
1342c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1343c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1344c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1345c72b26ecSRichard Henderson           ;;
134630163d89SPeter Maydell    # No special flags required for other host CPUs
13473142255cSblueswir1esac
13483142255cSblueswir1
134979f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
135079f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
135179f3b12fSPeter Crosthwaite
1352affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1353affc88ccSPeter Maydell# support, even if we're using TCI.
1354affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1355affc88ccSPeter Maydell  bsd_user="no"
1356affc88ccSPeter Maydell  linux_user="no"
1357affc88ccSPeter Maydellfi
1358affc88ccSPeter Maydell
135960e0df25SPeter Maydelldefault_target_list=""
136060e0df25SPeter Maydell
13616e92f823SPeter Maydellmak_wilds=""
13626e92f823SPeter Maydell
136360e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
13646e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
136560e0df25SPeter Maydellfi
136660e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
13676e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
136860e0df25SPeter Maydellfi
136960e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
13706e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
137160e0df25SPeter Maydellfi
137260e0df25SPeter Maydell
13736e92f823SPeter Maydellfor config in $mak_wilds; do
13746e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
13756e92f823SPeter Maydelldone
13766e92f823SPeter Maydell
1377c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
137864a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1379c53eeaf7SStefan Hajnoczi
1380af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1381af5db58eSpbrookcat << EOF
1382af5db58eSpbrook
1383af5db58eSpbrookUsage: configure [options]
1384af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1385af5db58eSpbrook
138608fb77edSStefan WeilStandard options:
138708fb77edSStefan Weil  --help                   print this message
138808fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
138908fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
139008fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
139108fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
139208fb77edSStefan Weil$(echo Available targets: $default_target_list | \
139308fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
139408fb77edSStefan Weil
139508fb77edSStefan WeilAdvanced options (experts only):
139608fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
139708fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
139808fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
139908fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
140008fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
140108fb77edSStefan Weil                           build time
140208fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
140308fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
140408fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
140511cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
140608fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
140708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
140808fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
140908fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
141008fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
141108fb77edSStefan Weil  --static                 enable static build [$static]
141208fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
141308fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
141408fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
141508fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
141608fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
141708fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
141808fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1419e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
142008fb77edSStefan Weil  --enable-debug           enable common debug build options
142108fb77edSStefan Weil  --disable-strip          disable stripping binaries
142208fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
142363678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
142408fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
142508fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
142608fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
142708fb77edSStefan Weil  --block-drv-rw-whitelist=L
142808fb77edSStefan Weil                           set block driver read-write whitelist
142908fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
143008fb77edSStefan Weil  --block-drv-ro-whitelist=L
143108fb77edSStefan Weil                           set block driver read-only whitelist
143208fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
14335b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1434c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
143508fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
143608fb77edSStefan Weil                           Default:trace-<pid>
1437c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1438c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1439c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1440c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
144108fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
144233c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
144308fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
144408fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1445c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1446c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1447c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1448a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1449c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1450c12d66aaSLin Ma  --enable-profiler        profiler support
1451c12d66aaSLin Ma  --enable-xen-pv-domain-build
1452c12d66aaSLin Ma                           xen pv domain builder
1453c12d66aaSLin Ma  --enable-debug-stack-usage
1454c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1455c23f23b9SMichael Tokarev
1456c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1457c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1458c23f23b9SMichael Tokarev
1459c23f23b9SMichael Tokarev  system          all system emulation targets
1460c23f23b9SMichael Tokarev  user            supported user emulation targets
1461c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1462c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1463c23f23b9SMichael Tokarev  docs            build documentation
1464c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1465c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1466c23f23b9SMichael Tokarev  pie             Position Independent Executables
1467c23f23b9SMichael Tokarev  modules         modules support
1468c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1469c23f23b9SMichael Tokarev  debug-info      debugging information
1470c23f23b9SMichael Tokarev  sparse          sparse checker
1471c23f23b9SMichael Tokarev
1472ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
147391bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
147491bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1475c23f23b9SMichael Tokarev  sdl             SDL UI
1476c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1477c23f23b9SMichael Tokarev  gtk             gtk UI
1478c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1479c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1480c23f23b9SMichael Tokarev  curses          curses UI
1481c23f23b9SMichael Tokarev  vnc             VNC UI support
1482c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1483c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1484c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1485c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1486c23f23b9SMichael Tokarev  virtfs          VirtFS
1487c23f23b9SMichael Tokarev  xen             xen backend driver support
1488c23f23b9SMichael Tokarev  xen-pci-passthrough
1489c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1490c23f23b9SMichael Tokarev  curl            curl connectivity
1491c23f23b9SMichael Tokarev  fdt             fdt device tree
1492c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1493c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1494b0cb0a66SVincent Palatin  hax             HAX acceleration support
1495c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1496c23f23b9SMichael Tokarev  vde             support for vde network
1497c23f23b9SMichael Tokarev  netmap          support for netmap network
1498c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1499c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1500c23f23b9SMichael Tokarev  attr            attr and xattr support
1501c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1502c23f23b9SMichael Tokarev  spice           spice
1503c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1504c23f23b9SMichael Tokarev  libiscsi        iscsi support
1505c23f23b9SMichael Tokarev  libnfs          nfs support
15067b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1507c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1508ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1509c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1510c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1511c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1512c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1513c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1514c23f23b9SMichael Tokarev  seccomp         seccomp support
1515c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1516c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1517c23f23b9SMichael Tokarev  tpm             TPM support
1518c23f23b9SMichael Tokarev  libssh2         ssh block device support
1519c23f23b9SMichael Tokarev  numa            libnuma support
1520c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
15217b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1522a6b1d4c0SChanglong Xie  replication     replication support
1523c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1524c12d66aaSLin Ma  opengl          opengl support
1525c12d66aaSLin Ma  virglrenderer   virgl rendering support
1526c12d66aaSLin Ma  xfsctl          xfsctl support
1527c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1528c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1529da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1530f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1531e6a74868SMarc-André Lureau  vhost-user      vhost-user support
153208fb77edSStefan Weil
153308fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1534af5db58eSpbrookEOF
15352d2ad6d0SFam Zhengexit 0
1536af5db58eSpbrookfi
1537af5db58eSpbrook
1538c53eeaf7SStefan Hajnocziif ! has $python; then
1539c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1540c53eeaf7SStefan Hajnoczifi
1541c53eeaf7SStefan Hajnoczi
1542c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1543c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1544c53eeaf7SStefan Hajnocziif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1545c53eeaf7SStefan Hajnoczi  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1546c53eeaf7SStefan Hajnoczi      "Note that Python 3 or later is not yet supported." \
1547c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1548c53eeaf7SStefan Hajnoczifi
1549c53eeaf7SStefan Hajnoczi
1550c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1551c53eeaf7SStefan Hajnoczipython="$python -B"
1552c53eeaf7SStefan Hajnoczi
1553359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1554359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1555359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1556359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1557359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1558359bc95dSPeter Maydell    else
155976ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1560359bc95dSPeter Maydell    fi
1561359bc95dSPeter Maydellfi
1562359bc95dSPeter Maydell
15639c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
15649c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
15659c83ffd8SPeter Maydellif test -z "$werror" ; then
15669c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1567e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
15689c83ffd8SPeter Maydell        werror="yes"
15699c83ffd8SPeter Maydell    else
15709c83ffd8SPeter Maydell        werror="no"
15719c83ffd8SPeter Maydell    fi
15729c83ffd8SPeter Maydellfi
15739c83ffd8SPeter Maydell
15748d05095cSPaolo Bonzini# check that the C compiler works.
157593b25869SJohn Snowwrite_c_skeleton;
15768d05095cSPaolo Bonziniif compile_object ; then
15778d05095cSPaolo Bonzini  : C compiler works ok
15788d05095cSPaolo Bonzinielse
157976ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
15808d05095cSPaolo Bonzinifi
15810ef74c74SPeter Maydellif ! compile_prog ; then
15820ef74c74SPeter Maydell    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
15830ef74c74SPeter Maydellfi
15848d05095cSPaolo Bonzini
1585fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1586fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1587fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1588fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1589fb59dabdSPeter Maydell    # host OS we should stop now.
1590951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1591fb59dabdSPeter Maydellfi
1592fb59dabdSPeter Maydell
15938d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
15948d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1595ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1596435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1597b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
159871429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
15996ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
16006ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
16016ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
16026ca026cbSPeter Maydell# so it's too error prone.
160393b25869SJohn Snow
160493b25869SJohn Snowcc_has_warning_flag() {
160593b25869SJohn Snow    write_c_skeleton;
160693b25869SJohn Snow
1607a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1608a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1609a1d29d6cSPeter Maydell    # warning options).
161093b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
161193b25869SJohn Snow    compile_prog "-Werror $optflag" ""
161293b25869SJohn Snow}
161393b25869SJohn Snow
161493b25869SJohn Snowfor flag in $gcc_flags; do
161593b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16168d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16178d05095cSPaolo Bonzini    fi
16188d05095cSPaolo Bonzinidone
16198d05095cSPaolo Bonzini
162063678e17SSteven Noonanif test "$stack_protector" != "no"; then
1621fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1622fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1623fccd35a0SRodrigo Rebello{
1624fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1625fccd35a0SRodrigo Rebello    while (*c) {
1626fccd35a0SRodrigo Rebello        *p++ = *c++;
1627fccd35a0SRodrigo Rebello    }
1628fccd35a0SRodrigo Rebello    return 0;
1629fccd35a0SRodrigo Rebello}
1630fccd35a0SRodrigo RebelloEOF
163163678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16323b463a3fSMiroslav Rezanina  sp_on=0
163363678e17SSteven Noonan  for flag in $gcc_flags; do
1634590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1635590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1636590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1637590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
163863678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16393b463a3fSMiroslav Rezanina      sp_on=1
164063678e17SSteven Noonan      break
164163678e17SSteven Noonan    fi
164263678e17SSteven Noonan  done
16433b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
16443b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
16453b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
16463b463a3fSMiroslav Rezanina    fi
16473b463a3fSMiroslav Rezanina  fi
164837746c5eSMarc-André Lureaufi
164937746c5eSMarc-André Lureau
1650cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1651cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1652cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1653cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1654cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1655cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1656cbdd1999SPaolo Bonziniint main(void) { return 0; }
1657cbdd1999SPaolo Bonzini#else
1658cbdd1999SPaolo Bonzini#error No bug in this compiler.
1659cbdd1999SPaolo Bonzini#endif
1660cbdd1999SPaolo BonziniEOF
1661cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1662cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1663cbdd1999SPaolo Bonzinifi
1664cbdd1999SPaolo Bonzini
166540d6444eSAvi Kivityif test "$static" = "yes" ; then
1666aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1667aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1668aa0d1f44SPaolo Bonzini  fi
166940d6444eSAvi Kivity  if test "$pie" = "yes" ; then
167076ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
167140d6444eSAvi Kivity  else
167240d6444eSAvi Kivity    pie="no"
167340d6444eSAvi Kivity  fi
167440d6444eSAvi Kivityfi
167540d6444eSAvi Kivity
1676768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1677768b7855SEmilio G. Cota  cat > $TMPC << EOF
1678768b7855SEmilio G. Cotastatic __thread int tls_var;
1679768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1680768b7855SEmilio G. CotaEOF
1681768b7855SEmilio G. Cota
1682768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1683768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1684768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1685768b7855SEmilio G. Cotafi
1686768b7855SEmilio G. Cota
168740d6444eSAvi Kivityif test "$pie" = ""; then
168840d6444eSAvi Kivity  case "$cpu-$targetos" in
1689c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
169040d6444eSAvi Kivity      ;;
169140d6444eSAvi Kivity    *)
169240d6444eSAvi Kivity      pie="no"
169340d6444eSAvi Kivity      ;;
169440d6444eSAvi Kivity  esac
169540d6444eSAvi Kivityfi
169640d6444eSAvi Kivity
169740d6444eSAvi Kivityif test "$pie" != "no" ; then
169840d6444eSAvi Kivity  cat > $TMPC << EOF
169921d4a791SAvi Kivity
170021d4a791SAvi Kivity#ifdef __linux__
170121d4a791SAvi Kivity#  define THREAD __thread
170221d4a791SAvi Kivity#else
170321d4a791SAvi Kivity#  define THREAD
170421d4a791SAvi Kivity#endif
170521d4a791SAvi Kivity
170621d4a791SAvi Kivitystatic THREAD int tls_var;
170721d4a791SAvi Kivity
170821d4a791SAvi Kivityint main(void) { return tls_var; }
170921d4a791SAvi Kivity
171040d6444eSAvi KivityEOF
171140d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
171240d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
171340d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
171440d6444eSAvi Kivity    pie="yes"
171540d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
171640d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
171740d6444eSAvi Kivity    fi
171840d6444eSAvi Kivity  else
171940d6444eSAvi Kivity    if test "$pie" = "yes"; then
172076ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
172140d6444eSAvi Kivity    else
172240d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
172340d6444eSAvi Kivity      pie="no"
172440d6444eSAvi Kivity    fi
172540d6444eSAvi Kivity  fi
172646eef33bSBrad
1727e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
172846eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
172946eef33bSBrad    LDFLAGS_NOPIE="-nopie"
173046eef33bSBrad  fi
173140d6444eSAvi Kivityfi
173240d6444eSAvi Kivity
173309dada40SPaolo Bonzini##########################################
173409dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
173509dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
173609dada40SPaolo Bonzini# specification is necessary
173709dada40SPaolo Bonzini
173809dada40SPaolo Bonziniif test "$cpu" = "i386"; then
173909dada40SPaolo Bonzini  cat > $TMPC << EOF
174009dada40SPaolo Bonzinistatic int sfaa(int *ptr)
174109dada40SPaolo Bonzini{
174209dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
174309dada40SPaolo Bonzini}
174409dada40SPaolo Bonzini
174509dada40SPaolo Bonziniint main(void)
174609dada40SPaolo Bonzini{
174709dada40SPaolo Bonzini  int val = 42;
17481405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
174909dada40SPaolo Bonzini  sfaa(&val);
175009dada40SPaolo Bonzini  return val;
175109dada40SPaolo Bonzini}
175209dada40SPaolo BonziniEOF
175309dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
175409dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
175509dada40SPaolo Bonzini  fi
175609dada40SPaolo Bonzinifi
175709dada40SPaolo Bonzini
175809dada40SPaolo Bonzini#########################################
1759ec530c81Sbellard# Solaris specific configure tool chain decisions
176009dada40SPaolo Bonzini
1761ec530c81Sbellardif test "$solaris" = "yes" ; then
17626792aa11SLoïc Minier  if has $install; then
17636792aa11SLoïc Minier    :
17646792aa11SLoïc Minier  else
176576ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
176676ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
176776ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1768ec530c81Sbellard  fi
176989138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
177076ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
177176ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
177276ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1773ec530c81Sbellard  fi
17746792aa11SLoïc Minier  if has ar; then
17756792aa11SLoïc Minier    :
17766792aa11SLoïc Minier  else
1777ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
177876ad07a4SPeter Maydell      error_exit "No path includes ar" \
177976ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1780ec530c81Sbellard    fi
178176ad07a4SPeter Maydell    error_exit "No path includes ar"
1782ec530c81Sbellard  fi
1783ec530c81Sbellardfi
1784ec530c81Sbellard
1785afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1786d880a3baSPaolo Bonzini    for target in $default_target_list; do
1787d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1788d880a3baSPaolo Bonzini            target_list="$target_list $target"
1789d880a3baSPaolo Bonzini    done
1790d880a3baSPaolo Bonzini    target_list="${target_list# }"
1791121afa9eSAnthony Liguorielse
179289138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1793d880a3baSPaolo Bonzini    for target in $target_list; do
179425b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
179525b48338SPeter Maydell        # friendly error message than if we let it fall through.
179625b48338SPeter Maydell        case " $default_target_list " in
179725b48338SPeter Maydell            *" $target "*)
179825b48338SPeter Maydell                ;;
179925b48338SPeter Maydell            *)
180025b48338SPeter Maydell                error_exit "Unknown target name '$target'"
180125b48338SPeter Maydell                ;;
180225b48338SPeter Maydell        esac
1803d880a3baSPaolo Bonzini        supported_target $target || exit 1
180425b48338SPeter Maydell    done
1805d880a3baSPaolo Bonzinifi
180625b48338SPeter Maydell
1807f55fe278SPaolo Bonzini# see if system emulation was really requested
1808f55fe278SPaolo Bonzinicase " $target_list " in
1809f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1810f55fe278SPaolo Bonzini  ;;
1811f55fe278SPaolo Bonzini  *) softmmu=no
1812f55fe278SPaolo Bonzini  ;;
1813f55fe278SPaolo Bonziniesac
18145327cf48Sbellard
1815249247c9SJuan Quintelafeature_not_found() {
1816249247c9SJuan Quintela  feature=$1
181721684af0SStewart Smith  remedy=$2
1818249247c9SJuan Quintela
181976ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
182021684af0SStewart Smith      "configure was not able to find it." \
182121684af0SStewart Smith      "$remedy"
1822249247c9SJuan Quintela}
1823249247c9SJuan Quintela
18247d13299dSbellard# ---
18257d13299dSbellard# big/little endian test
18267d13299dSbellardcat > $TMPC << EOF
182761cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
182861cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
182961cc919fSMike Frysingerextern int foo(short *, short *);
183061cc919fSMike Frysingerint main(int argc, char *argv[]) {
183161cc919fSMike Frysinger    return foo(big_endian, little_endian);
18327d13299dSbellard}
18337d13299dSbellardEOF
18347d13299dSbellard
183561cc919fSMike Frysingerif compile_object ; then
183661cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
183761cc919fSMike Frysinger        bigendian="yes"
183861cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
183961cc919fSMike Frysinger        bigendian="no"
18407d13299dSbellard    else
18417d13299dSbellard        echo big/little test failed
18427d13299dSbellard    fi
18437d13299dSbellardelse
184461cc919fSMike Frysinger    echo big/little test failed
18457d13299dSbellardfi
18467d13299dSbellard
1847b0a47e79SJuan Quintela##########################################
1848a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1849a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1850a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1851a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1852a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1853a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1854a30878e7SPeter Maydell    fi
1855a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1856a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1857a30878e7SPeter Maydell    fi
1858a30878e7SPeter Maydell    gtk=no
1859a30878e7SPeter Maydell    sdl=no
1860a30878e7SPeter Maydellfi
1861a30878e7SPeter Maydell
18626b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
18636b39b063SEric Blakecat > $TMPC << EOF
18646b39b063SEric Blake#include <stdint.h>
18656b39b063SEric Blake#include <stdio.h>
18666b39b063SEric Blakeint main(int argc, char *argv[]) {
18676b39b063SEric Blake    return printf("%zu", SIZE_MAX);
18686b39b063SEric Blake}
18696b39b063SEric BlakeEOF
18706b39b063SEric Blakehave_broken_size_max=no
18716b39b063SEric Blakeif ! compile_object -Werror ; then
18726b39b063SEric Blake    have_broken_size_max=yes
18736b39b063SEric Blakefi
18746b39b063SEric Blake
1875a30878e7SPeter Maydell##########################################
1876015a33bdSGonglei# L2TPV3 probe
1877015a33bdSGonglei
1878015a33bdSGongleicat > $TMPC <<EOF
1879015a33bdSGonglei#include <sys/socket.h>
1880bff6cb72SMichael Tokarev#include <linux/ip.h>
1881015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1882015a33bdSGongleiEOF
1883015a33bdSGongleiif compile_prog "" "" ; then
1884015a33bdSGonglei  l2tpv3=yes
1885015a33bdSGongleielse
1886015a33bdSGonglei  l2tpv3=no
1887015a33bdSGongleifi
1888015a33bdSGonglei
1889015a33bdSGonglei##########################################
18904d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
18914d9310f4SDaniel P. Berrange
18924d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
18934d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
18944d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
18954d9310f4SDaniel P. Berrange    #
18964d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
18974d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
18984d9310f4SDaniel P. Berrange    #
18994d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
19004d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
19014d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
19024d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
19034d9310f4SDaniel P. Berrange    # that for you.
19044d9310f4SDaniel P. Berrange    #
19054d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
19064d9310f4SDaniel P. Berrange    # are not in fact redundant.
19074d9310f4SDaniel P. Berrangecat > $TMPC << EOF
19084d9310f4SDaniel P. Berrange#include <unistd.h>
19094d9310f4SDaniel P. Berrange#include <time.h>
19104d9310f4SDaniel P. Berrange#undef localtime_r
19114d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
19124d9310f4SDaniel P. BerrangeEOF
19134d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
19144d9310f4SDaniel P. Berrange        localtime_r="yes"
19154d9310f4SDaniel P. Berrange    else
19164d9310f4SDaniel P. Berrange        localtime_r="no"
19174d9310f4SDaniel P. Berrange    fi
19184d9310f4SDaniel P. Berrangefi
19194d9310f4SDaniel P. Berrange
19204d9310f4SDaniel P. Berrange##########################################
1921779ab5e3SStefan Weil# pkg-config probe
1922779ab5e3SStefan Weil
1923779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
192476ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1925779ab5e3SStefan Weilfi
1926779ab5e3SStefan Weil
1927779ab5e3SStefan Weil##########################################
1928b0a47e79SJuan Quintela# NPTL probe
1929b0a47e79SJuan Quintela
193024cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1931bd0c5661Spbrook  cat > $TMPC <<EOF
1932bd0c5661Spbrook#include <sched.h>
193330813ceaSpbrook#include <linux/futex.h>
1934182eacc0SStefan Weilint main(void) {
1935bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1936bd0c5661Spbrook#error bork
1937bd0c5661Spbrook#endif
1938182eacc0SStefan Weil  return 0;
1939bd0c5661Spbrook}
1940bd0c5661SpbrookEOF
194124cb36a6SPeter Maydell  if ! compile_object ; then
194221684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1943b0a47e79SJuan Quintela  fi
1944bd0c5661Spbrookfi
1945bd0c5661Spbrook
194699f2dbd3SLiang Li#########################################
1947ac62922eSbalrog# zlib check
1948ac62922eSbalrog
19491ece9905SAlon Levyif test "$zlib" != "no" ; then
1950ac62922eSbalrog    cat > $TMPC << EOF
1951ac62922eSbalrog#include <zlib.h>
1952ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1953ac62922eSbalrogEOF
195452166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1955ac62922eSbalrog        :
1956ac62922eSbalrog    else
195776ad07a4SPeter Maydell        error_exit "zlib check failed" \
195876ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1959ac62922eSbalrog    fi
19601ece9905SAlon Levyfi
1961eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1962ac62922eSbalrog
1963ac62922eSbalrog##########################################
1964607dacd0Sqiaonuohan# lzo check
1965607dacd0Sqiaonuohan
1966607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1967607dacd0Sqiaonuohan    cat > $TMPC << EOF
1968607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1969607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1970607dacd0SqiaonuohanEOF
1971607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1972607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
1973b25c9dffSStefan Weil        lzo="yes"
1974b25c9dffSStefan Weil    else
1975b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
1976b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
1977b25c9dffSStefan Weil        fi
1978b25c9dffSStefan Weil        lzo="no"
1979b25c9dffSStefan Weil    fi
1980607dacd0Sqiaonuohanfi
1981607dacd0Sqiaonuohan
1982607dacd0Sqiaonuohan##########################################
1983607dacd0Sqiaonuohan# snappy check
1984607dacd0Sqiaonuohan
1985607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1986607dacd0Sqiaonuohan    cat > $TMPC << EOF
1987607dacd0Sqiaonuohan#include <snappy-c.h>
1988607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1989607dacd0SqiaonuohanEOF
1990607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1991607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
1992b25c9dffSStefan Weil        snappy="yes"
1993b25c9dffSStefan Weil    else
1994b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
1995b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
1996b25c9dffSStefan Weil        fi
1997b25c9dffSStefan Weil        snappy="no"
1998b25c9dffSStefan Weil    fi
1999607dacd0Sqiaonuohanfi
2000607dacd0Sqiaonuohan
2001607dacd0Sqiaonuohan##########################################
20026b383c08SPeter Wu# bzip2 check
20036b383c08SPeter Wu
20046b383c08SPeter Wuif test "$bzip2" != "no" ; then
20056b383c08SPeter Wu    cat > $TMPC << EOF
20066b383c08SPeter Wu#include <bzlib.h>
20076b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
20086b383c08SPeter WuEOF
20096b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
20106b383c08SPeter Wu        bzip2="yes"
20116b383c08SPeter Wu    else
20126b383c08SPeter Wu        if test "$bzip2" = "yes"; then
20136b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
20146b383c08SPeter Wu        fi
20156b383c08SPeter Wu        bzip2="no"
20166b383c08SPeter Wu    fi
20176b383c08SPeter Wufi
20186b383c08SPeter Wu
20196b383c08SPeter Wu##########################################
2020f794573eSEduardo Otubo# libseccomp check
2021f794573eSEduardo Otubo
2022f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2023693e5910SAndrew Jones    case "$cpu" in
2024693e5910SAndrew Jones    i386|x86_64)
2025ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2026693e5910SAndrew Jones        ;;
20275ce43972SJames Hogan    mips)
20285ce43972SJames Hogan        libseccomp_minver="2.2.0"
20295ce43972SJames Hogan        ;;
2030693e5910SAndrew Jones    arm|aarch64)
2031693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2032693e5910SAndrew Jones        ;;
20333e684455SMichael Strosaker    ppc|ppc64)
20343e684455SMichael Strosaker        libseccomp_minver="2.3.0"
20353e684455SMichael Strosaker        ;;
2036693e5910SAndrew Jones    *)
2037693e5910SAndrew Jones        libseccomp_minver=""
2038693e5910SAndrew Jones        ;;
2039693e5910SAndrew Jones    esac
2040693e5910SAndrew Jones
2041693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2042693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
204389138857SStefan Weil        libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
204489138857SStefan Weil        QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
2045f794573eSEduardo Otubo        seccomp="yes"
2046f794573eSEduardo Otubo    else
2047f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2048693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2049693e5910SAndrew Jones                feature_not_found "libseccomp" \
2050693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2051693e5910SAndrew Jones            else
2052693e5910SAndrew Jones                feature_not_found "libseccomp" \
2053693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2054693e5910SAndrew Jones            fi
2055896848f0SEduardo Otubo        fi
2056e84d5956SYann E. MORIN        seccomp="no"
2057f794573eSEduardo Otubo    fi
2058f794573eSEduardo Otubofi
2059f794573eSEduardo Otubo##########################################
2060e37630caSaliguori# xen probe
2061e37630caSaliguori
2062fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2063c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2064c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2065c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2066c1cdd9d5SJuergen Gross
2067c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2068c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2069c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2070c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2071c1cdd9d5SJuergen Gross    xen=yes
2072c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2073c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
2074c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2075c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2076c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2077c1cdd9d5SJuergen Gross  else
2078c1cdd9d5SJuergen Gross
2079b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2080d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2081d5b93ddfSAnthony PERARD
208250ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
208350ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
208450ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
208550ced5b3SStefan Weil
208650ced5b3SStefan Weil    # Xen (any)
208750ced5b3SStefan Weil    cat > $TMPC <<EOF
208850ced5b3SStefan Weil#include <xenctrl.h>
208950ced5b3SStefan Weilint main(void) {
209050ced5b3SStefan Weil  return 0;
209150ced5b3SStefan Weil}
209250ced5b3SStefan WeilEOF
209350ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
209450ced5b3SStefan Weil      # Xen not found
209550ced5b3SStefan Weil      if test "$xen" = "yes" ; then
209621684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
209750ced5b3SStefan Weil      fi
209850ced5b3SStefan Weil      xen=no
209950ced5b3SStefan Weil
2100d5b93ddfSAnthony PERARD    # Xen unstable
210169deef08SPeter Maydell    elif
210269deef08SPeter Maydell        cat > $TMPC <<EOF &&
21035ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21045ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
21055ba3d756SIgor Druzhininint main(void) {
21065ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
21075ba3d756SIgor Druzhinin
21085ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
21095ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
21105ba3d756SIgor Druzhinin
21115ba3d756SIgor Druzhinin  return 0;
21125ba3d756SIgor Druzhinin}
21135ba3d756SIgor DruzhininEOF
21145ba3d756SIgor Druzhinin        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
21155ba3d756SIgor Druzhinin      then
21165ba3d756SIgor Druzhinin      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
21175ba3d756SIgor Druzhinin      xen_ctrl_version=41000
21185ba3d756SIgor Druzhinin      xen=yes
21195ba3d756SIgor Druzhinin    elif
21205ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2121da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2122da8090ccSPaul Durrant#define __XEN_TOOLS__
2123da8090ccSPaul Durrant#include <xendevicemodel.h>
2124da8090ccSPaul Durrantint main(void) {
2125da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2126da8090ccSPaul Durrant
2127da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2128da8090ccSPaul Durrant  xendevicemodel_close(xd);
2129da8090ccSPaul Durrant
2130da8090ccSPaul Durrant  return 0;
2131da8090ccSPaul Durrant}
2132da8090ccSPaul DurrantEOF
2133da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2134da8090ccSPaul Durrant      then
2135da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2136f1167ee6SJuergen Gross      xen_ctrl_version=40900
2137da8090ccSPaul Durrant      xen=yes
2138da8090ccSPaul Durrant    elif
2139da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
21405eeb39c2SIan Campbell/*
21415eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
21425eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2143b6eb9b45SPaulina Szubarczyk *
2144b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2145b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2146b6eb9b45SPaulina Szubarczyk */
2147b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2148b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2149b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2150b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2151b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2152b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2153b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2154b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2155b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2156b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2157b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2158b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2159b6eb9b45SPaulina Szubarczyk#endif
2160b6eb9b45SPaulina Szubarczykint main(void) {
2161b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2162b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2163b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2164b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2165b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2166b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2167b6eb9b45SPaulina Szubarczyk
2168b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2169b6eb9b45SPaulina Szubarczyk
2170b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2171b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2172b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2173b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2174b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2175b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2176b6eb9b45SPaulina Szubarczyk
2177b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2178b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2179b6eb9b45SPaulina Szubarczyk
2180b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2181b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2182b6eb9b45SPaulina Szubarczyk
2183b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2184b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2185b6eb9b45SPaulina Szubarczyk
2186b6eb9b45SPaulina Szubarczyk  return 0;
2187b6eb9b45SPaulina Szubarczyk}
2188b6eb9b45SPaulina SzubarczykEOF
2189b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2190b6eb9b45SPaulina Szubarczyk      then
2191f1167ee6SJuergen Gross      xen_ctrl_version=40800
2192b6eb9b45SPaulina Szubarczyk      xen=yes
2193b6eb9b45SPaulina Szubarczyk    elif
2194b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2195b6eb9b45SPaulina Szubarczyk/*
2196b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2197b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
21985eeb39c2SIan Campbell */
21995eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
22005eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
22015eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
22025eeb39c2SIan Campbell#include <xenctrl.h>
22035eeb39c2SIan Campbell#include <xenstore.h>
22045eeb39c2SIan Campbell#include <xenevtchn.h>
22055eeb39c2SIan Campbell#include <xengnttab.h>
22065eeb39c2SIan Campbell#include <xenforeignmemory.h>
22075eeb39c2SIan Campbell#include <stdint.h>
22085eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
22095eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
22105eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
22115eeb39c2SIan Campbell#endif
22125eeb39c2SIan Campbellint main(void) {
22135eeb39c2SIan Campbell  xc_interface *xc = NULL;
22145eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
22155eeb39c2SIan Campbell  xenevtchn_handle *xe;
22165eeb39c2SIan Campbell  xengnttab_handle *xg;
22175eeb39c2SIan Campbell  xen_domain_handle_t handle;
22185eeb39c2SIan Campbell
22195eeb39c2SIan Campbell  xs_daemon_open();
22205eeb39c2SIan Campbell
22215eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
22225eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
22235eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22245eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22255eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
22265eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
22275eeb39c2SIan Campbell
22285eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
22295eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
22305eeb39c2SIan Campbell
22315eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
22325eeb39c2SIan Campbell  xenevtchn_fd(xe);
22335eeb39c2SIan Campbell
22345eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
22355eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
22365eeb39c2SIan Campbell
22375eeb39c2SIan Campbell  return 0;
22385eeb39c2SIan Campbell}
22395eeb39c2SIan CampbellEOF
22405eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
22415eeb39c2SIan Campbell      then
2242f1167ee6SJuergen Gross      xen_ctrl_version=40701
22435eeb39c2SIan Campbell      xen=yes
22445eeb39c2SIan Campbell    elif
22455eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2246e37630caSaliguori#include <xenctrl.h>
2247cdadde39SRoger Pau Monne#include <stdint.h>
2248cdadde39SRoger Pau Monneint main(void) {
2249cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2250cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2251cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2252cdadde39SRoger Pau Monne  return 0;
2253cdadde39SRoger Pau Monne}
2254cdadde39SRoger Pau MonneEOF
2255cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2256cdadde39SRoger Pau Monne      then
2257f1167ee6SJuergen Gross      xen_ctrl_version=40700
2258cdadde39SRoger Pau Monne      xen=yes
2259cdadde39SRoger Pau Monne
2260cdadde39SRoger Pau Monne    # Xen 4.6
2261cdadde39SRoger Pau Monne    elif
2262cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2263cdadde39SRoger Pau Monne#include <xenctrl.h>
2264e108a3c1SAnthony PERARD#include <xenstore.h>
2265d5b93ddfSAnthony PERARD#include <stdint.h>
2266d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2267d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2268d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2269d5b93ddfSAnthony PERARD#endif
2270d5b93ddfSAnthony PERARDint main(void) {
2271d5b93ddfSAnthony PERARD  xc_interface *xc;
2272d5b93ddfSAnthony PERARD  xs_daemon_open();
2273d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2274d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2275d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2276b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22778688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2278d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
227920a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2280d8b441a3SJan Beulich  return 0;
2281d8b441a3SJan Beulich}
2282d8b441a3SJan BeulichEOF
2283d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2284d8b441a3SJan Beulich      then
2285f1167ee6SJuergen Gross      xen_ctrl_version=40600
2286d8b441a3SJan Beulich      xen=yes
2287d8b441a3SJan Beulich
2288d8b441a3SJan Beulich    # Xen 4.5
2289d8b441a3SJan Beulich    elif
2290d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2291d8b441a3SJan Beulich#include <xenctrl.h>
2292d8b441a3SJan Beulich#include <xenstore.h>
2293d8b441a3SJan Beulich#include <stdint.h>
2294d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2295d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2296d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2297d8b441a3SJan Beulich#endif
2298d8b441a3SJan Beulichint main(void) {
2299d8b441a3SJan Beulich  xc_interface *xc;
2300d8b441a3SJan Beulich  xs_daemon_open();
2301d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2302d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2303d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2304d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2305d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23063996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
23073996e85cSPaul Durrant  return 0;
23083996e85cSPaul Durrant}
23093996e85cSPaul DurrantEOF
23103996e85cSPaul Durrant        compile_prog "" "$xen_libs"
23113996e85cSPaul Durrant      then
2312f1167ee6SJuergen Gross      xen_ctrl_version=40500
23133996e85cSPaul Durrant      xen=yes
23143996e85cSPaul Durrant
23153996e85cSPaul Durrant    elif
23163996e85cSPaul Durrant        cat > $TMPC <<EOF &&
23173996e85cSPaul Durrant#include <xenctrl.h>
23183996e85cSPaul Durrant#include <xenstore.h>
23193996e85cSPaul Durrant#include <stdint.h>
23203996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
23213996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
23223996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
23233996e85cSPaul Durrant#endif
23243996e85cSPaul Durrantint main(void) {
23253996e85cSPaul Durrant  xc_interface *xc;
23263996e85cSPaul Durrant  xs_daemon_open();
23273996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
23283996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
23293996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
23303996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23313996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23328688e065SStefano Stabellini  return 0;
23338688e065SStefano Stabellini}
23348688e065SStefano StabelliniEOF
23358688e065SStefano Stabellini        compile_prog "" "$xen_libs"
233669deef08SPeter Maydell      then
2337f1167ee6SJuergen Gross      xen_ctrl_version=40200
23388688e065SStefano Stabellini      xen=yes
23398688e065SStefano Stabellini
2340e37630caSaliguori    else
2341fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2342edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2343edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2344fc321b4bSJuan Quintela      fi
2345fc321b4bSJuan Quintela      xen=no
2346e37630caSaliguori    fi
2347d5b93ddfSAnthony PERARD
2348d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2349f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
23505eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
23515eeb39c2SIan Campbell      fi
2352d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2353d5b93ddfSAnthony PERARD    fi
2354e37630caSaliguori  fi
2355c1cdd9d5SJuergen Grossfi
2356e37630caSaliguori
2357eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2358edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2359eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2360eb6fda0fSAnthony PERARD  else
2361eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
236276ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
236376ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2364eb6fda0fSAnthony PERARD    fi
2365eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2366eb6fda0fSAnthony PERARD  fi
2367eb6fda0fSAnthony PERARDfi
2368eb6fda0fSAnthony PERARD
236964a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
237064a7ad6fSIan Campbell   test "$xen" != "yes"; then
237164a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
237264a7ad6fSIan Campbell	       "which requires Xen support."
237364a7ad6fSIan Campbellfi
237464a7ad6fSIan Campbell
2375e37630caSaliguori##########################################
2376dfffc653SJuan Quintela# Sparse probe
2377dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
23780dba6195SLoïc Minier  if has cgcc; then
2379dfffc653SJuan Quintela    sparse=yes
2380dfffc653SJuan Quintela  else
2381dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
238221684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2383dfffc653SJuan Quintela    fi
2384dfffc653SJuan Quintela    sparse=no
2385dfffc653SJuan Quintela  fi
2386dfffc653SJuan Quintelafi
2387dfffc653SJuan Quintela
2388dfffc653SJuan Quintela##########################################
2389f676c67eSJeremy White# X11 probe
2390f676c67eSJeremy Whitex11_cflags=
2391f676c67eSJeremy Whitex11_libs=-lX11
2392f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
239389138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
239489138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2395f676c67eSJeremy Whitefi
2396f676c67eSJeremy White
2397f676c67eSJeremy White##########################################
2398a4ccabcfSAnthony Liguori# GTK probe
2399a4ccabcfSAnthony Liguori
24009e04c683SStefan Weilif test "$gtkabi" = ""; then
24015fe309ffSGerd Hoffmann    # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
24025fe309ffSGerd Hoffmann    # Use 2.0 as a fallback if that is available.
24035fe309ffSGerd Hoffmann    if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
24049e04c683SStefan Weil        gtkabi=3.0
24055fe309ffSGerd Hoffmann    elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
24069e04c683SStefan Weil        gtkabi=2.0
24075fe309ffSGerd Hoffmann    else
24085fe309ffSGerd Hoffmann        gtkabi=3.0
24099e04c683SStefan Weil    fi
24109e04c683SStefan Weilfi
24119e04c683SStefan Weil
2412a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2413528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
24140a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2415528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2416528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2417bbbf9bfbSStefan Weil    else
2418bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2419bbbf9bfbSStefan Weil    fi
2420bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
242189138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
242289138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
242389138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
24240a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2425f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2426f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
24270a337ed0SGerd Hoffmann        fi
2428bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2429bbbf9bfbSStefan Weil        gtk="yes"
2430bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
24315fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2432bbbf9bfbSStefan Weil    else
2433bbbf9bfbSStefan Weil        gtk="no"
2434bbbf9bfbSStefan Weil    fi
2435bbbf9bfbSStefan Weilfi
2436bbbf9bfbSStefan Weil
2437ddbb0d09SDaniel P. Berrange
2438ddbb0d09SDaniel P. Berrange##########################################
2439ddbb0d09SDaniel P. Berrange# GNUTLS probe
2440ddbb0d09SDaniel P. Berrange
244137371299SPeter Maydellgnutls_works() {
244237371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
244337371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
244437371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
244537371299SPeter Maydell    # builds doesn't work:
244637371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
244737371299SPeter Maydell    #
244837371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
244937371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
245037371299SPeter Maydell        return 1
245137371299SPeter Maydell    fi
245237371299SPeter Maydell
245337371299SPeter Maydell    write_c_skeleton
245437371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
245537371299SPeter Maydell}
245637371299SPeter Maydell
245762893b67SDaniel P. Berrangegnutls_gcrypt=no
2458ed754746SDaniel P. Berrangegnutls_nettle=no
2459ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
246037371299SPeter Maydell    if gnutls_works; then
246189138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
246289138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2463ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2464ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2465ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2466ddbb0d09SDaniel P. Berrange        gnutls="yes"
2467ddbb0d09SDaniel P. Berrange
2468b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2469b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2470b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2471b917da4cSDaniel P. Berrange	else
2472b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2473b917da4cSDaniel P. Berrange	fi
2474b917da4cSDaniel P. Berrange
247562893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
247662893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2477ed754746SDaniel P. Berrange	    gnutls_nettle=yes
247862893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
247989138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2480ed754746SDaniel P. Berrange		*gcrypt*)
2481ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2482ed754746SDaniel P. Berrange		    gnutls_nettle=no
2483ed754746SDaniel P. Berrange		    ;;
2484ed754746SDaniel P. Berrange		*nettle*)
2485ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2486ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2487ed754746SDaniel P. Berrange		    ;;
2488ed754746SDaniel P. Berrange		*)
2489ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2490ed754746SDaniel P. Berrange		    gnutls_nettle=no
2491ed754746SDaniel P. Berrange		    ;;
249262893b67SDaniel P. Berrange	    esac
249362893b67SDaniel P. Berrange	else
249462893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2495ed754746SDaniel P. Berrange	    gnutls_nettle=no
249662893b67SDaniel P. Berrange	fi
2497ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2498ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2499ddbb0d09SDaniel P. Berrange    else
2500ddbb0d09SDaniel P. Berrange        gnutls="no"
2501b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2502ddbb0d09SDaniel P. Berrange    fi
2503ddbb0d09SDaniel P. Berrangeelse
2504b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2505ddbb0d09SDaniel P. Berrangefi
2506ddbb0d09SDaniel P. Berrange
250791bfcdb0SDaniel P. Berrange
250891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
250991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
251091bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
251191bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
251291bfcdb0SDaniel P. Berrangethen
251391bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
251491bfcdb0SDaniel P. Berrange    then
251591bfcdb0SDaniel P. Berrange        gcrypt="no"
251691bfcdb0SDaniel P. Berrange    fi
251791bfcdb0SDaniel P. Berrangefi
251891bfcdb0SDaniel P. Berrange
251991bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
252091bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
252191bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
252291bfcdb0SDaniel P. Berrangeif test -z "$nettle"
252391bfcdb0SDaniel P. Berrangethen
252491bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
252591bfcdb0SDaniel P. Berrange    then
252691bfcdb0SDaniel P. Berrange        nettle="no"
252791bfcdb0SDaniel P. Berrange    fi
252891bfcdb0SDaniel P. Berrangefi
252991bfcdb0SDaniel P. Berrange
253091bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
253191bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
253291bfcdb0SDaniel P. Berrange    then
253391bfcdb0SDaniel P. Berrange	return 1
253491bfcdb0SDaniel P. Berrange    fi
253591bfcdb0SDaniel P. Berrange
253691bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
253791bfcdb0SDaniel P. Berrange    then
253889138857SStefan Weil	host=$(libgcrypt-config --host)
253991bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
254091bfcdb0SDaniel P. Berrange	then
254191bfcdb0SDaniel P. Berrange	    return 1
254291bfcdb0SDaniel P. Berrange	fi
254391bfcdb0SDaniel P. Berrange    fi
254491bfcdb0SDaniel P. Berrange
254591bfcdb0SDaniel P. Berrange    return 0
254691bfcdb0SDaniel P. Berrange}
254791bfcdb0SDaniel P. Berrange
254891bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
254991bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
255089138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
255189138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
255291bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
255391bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
255491bfcdb0SDaniel P. Berrange        # turn breaks static builds...
255591bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
255691bfcdb0SDaniel P. Berrange        then
255791bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
255891bfcdb0SDaniel P. Berrange        fi
255962893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
256062893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
256162893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
256291bfcdb0SDaniel P. Berrange        gcrypt="yes"
256391bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
256491bfcdb0SDaniel P. Berrange           nettle="no"
256591bfcdb0SDaniel P. Berrange        fi
256637788f25SDaniel P. Berrange
256737788f25SDaniel P. Berrange        cat > $TMPC << EOF
256837788f25SDaniel P. Berrange#include <gcrypt.h>
256937788f25SDaniel P. Berrangeint main(void) {
257037788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
257137788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
257237788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
257337788f25SDaniel P. Berrange return 0;
257437788f25SDaniel P. Berrange}
257537788f25SDaniel P. BerrangeEOF
257637788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
257737788f25SDaniel P. Berrange            gcrypt_kdf=yes
257837788f25SDaniel P. Berrange        fi
25791f923c70SLongpeng(Mike)
25801f923c70SLongpeng(Mike)        cat > $TMPC << EOF
25811f923c70SLongpeng(Mike)#include <gcrypt.h>
25821f923c70SLongpeng(Mike)int main(void) {
25831f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
25841f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
25851f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
25861f923c70SLongpeng(Mike)  return 0;
25871f923c70SLongpeng(Mike)}
25881f923c70SLongpeng(Mike)EOF
25891f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
25901f923c70SLongpeng(Mike)            gcrypt_hmac=yes
25911f923c70SLongpeng(Mike)        fi
259262893b67SDaniel P. Berrange    else
259391bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
259462893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
259591bfcdb0SDaniel P. Berrange        else
259691bfcdb0SDaniel P. Berrange            gcrypt="no"
259791bfcdb0SDaniel P. Berrange        fi
259862893b67SDaniel P. Berrange    fi
259962893b67SDaniel P. Berrangefi
260062893b67SDaniel P. Berrange
2601ddbb0d09SDaniel P. Berrange
260291bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2603ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
260489138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
260589138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
260689138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2607ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2608ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2609ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
261091bfcdb0SDaniel P. Berrange        nettle="yes"
2611fff2f982SDaniel P. Berrange
2612fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
26139e87a691SSteven Luo#include <stddef.h>
2614fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2615fff2f982SDaniel P. Berrangeint main(void) {
2616fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2617fff2f982SDaniel P. Berrange     return 0;
2618fff2f982SDaniel P. Berrange}
2619fff2f982SDaniel P. BerrangeEOF
2620fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2621fff2f982SDaniel P. Berrange            nettle_kdf=yes
2622fff2f982SDaniel P. Berrange        fi
2623ed754746SDaniel P. Berrange    else
262491bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2625ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
262691bfcdb0SDaniel P. Berrange        else
262791bfcdb0SDaniel P. Berrange            nettle="no"
2628ed754746SDaniel P. Berrange        fi
2629ed754746SDaniel P. Berrange    fi
263091bfcdb0SDaniel P. Berrangefi
263191bfcdb0SDaniel P. Berrange
263291bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
263391bfcdb0SDaniel P. Berrangethen
263491bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
263591bfcdb0SDaniel P. Berrangefi
2636ed754746SDaniel P. Berrange
26379a2fd434SDaniel P. Berrange##########################################
26389a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
26399a2fd434SDaniel P. Berrange
26409a2fd434SDaniel P. Berrangetasn1=yes
264190246037SDaniel P. Berrangetasn1_cflags=""
264290246037SDaniel P. Berrangetasn1_libs=""
26439a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
264489138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
264589138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
26469a2fd434SDaniel P. Berrangeelse
26479a2fd434SDaniel P. Berrange    tasn1=no
26489a2fd434SDaniel P. Berrangefi
26499a2fd434SDaniel P. Berrange
2650ed754746SDaniel P. Berrange
2651bbbf9bfbSStefan Weil##########################################
2652559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2653559607eaSDaniel P. Berrange
2654559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2655559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2656559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2657559607eaSDaniel P. Berrangefi
2658559607eaSDaniel P. Berrange
2659559607eaSDaniel P. Berrange##########################################
2660bbbf9bfbSStefan Weil# VTE probe
2661bbbf9bfbSStefan Weil
2662bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2663bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2664c6feff9eSCole Robinson      vteminversion="0.32.0"
2665c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2666c6feff9eSCole Robinson        vtepackage="vte-2.91"
2667c6feff9eSCole Robinson      else
2668528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2669c6feff9eSCole Robinson      fi
2670528de90aSDaniel P. Berrange    else
2671528de90aSDaniel P. Berrange      vtepackage="vte"
2672c6feff9eSCole Robinson      vteminversion="0.24.0"
2673528de90aSDaniel P. Berrange    fi
2674c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
267589138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
267689138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
267789138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2678bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2679bbbf9bfbSStefan Weil        vte="yes"
2680bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
26819e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2682c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
26839e04c683SStefan Weil        else
26849e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
26859e04c683SStefan Weil        fi
2686bbbf9bfbSStefan Weil    else
2687bbbf9bfbSStefan Weil        vte="no"
2688a4ccabcfSAnthony Liguori    fi
2689a4ccabcfSAnthony Liguorifi
2690a4ccabcfSAnthony Liguori
2691a4ccabcfSAnthony Liguori##########################################
269211d9f695Sbellard# SDL probe
269311d9f695Sbellard
26943ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
26953ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
269647c03744SDave Airlie
2697ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
26988f4ea9cdSGerd Hoffmann    if $pkg_config --exists "sdl2"; then
2699ee8466d0SCole Robinson        sdlabi=2.0
27008f4ea9cdSGerd Hoffmann    elif $pkg_config --exists "sdl"; then
2701ee8466d0SCole Robinson        sdlabi=1.2
27028f4ea9cdSGerd Hoffmann    else
27038f4ea9cdSGerd Hoffmann        sdlabi=2.0
2704ee8466d0SCole Robinson    fi
2705ee8466d0SCole Robinsonfi
2706ee8466d0SCole Robinson
270747c03744SDave Airlieif test $sdlabi = "2.0"; then
270847c03744SDave Airlie    sdl_config=$sdl2_config
270947c03744SDave Airlie    sdlname=sdl2
271047c03744SDave Airlie    sdlconfigname=sdl2_config
2711e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
271247c03744SDave Airlie    sdlname=sdl
271347c03744SDave Airlie    sdlconfigname=sdl_config
2714e07047cfSCole Robinsonelse
2715e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
27163ec87ffeSPaolo Bonzinifi
27173ec87ffeSPaolo Bonzini
271889138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
271947c03744SDave Airlie  sdl_config=$sdlconfigname
272047c03744SDave Airliefi
272147c03744SDave Airlie
272247c03744SDave Airlieif $pkg_config $sdlname --exists; then
272347c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
272489138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
27253ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
27263ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
272789138857SStefan Weil  sdlversion=$($sdlconfig --version)
2728a0dfd8a4SLoïc Minierelse
2729a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
27308f4ea9cdSGerd Hoffmann    feature_not_found "sdl" "Install SDL2-devel"
2731a0dfd8a4SLoïc Minier  fi
2732a0dfd8a4SLoïc Minier  sdl=no
27339316f803SPaolo Bonzinifi
273429e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
27353ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
27363ec87ffeSPaolo Bonzinifi
273711d9f695Sbellard
27389316f803SPaolo Bonzinisdl_too_old=no
2739c4198157SJuan Quintelaif test "$sdl" != "no" ; then
274011d9f695Sbellard  cat > $TMPC << EOF
274111d9f695Sbellard#include <SDL.h>
274211d9f695Sbellard#undef main /* We don't want SDL to override our main() */
274311d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
274411d9f695SbellardEOF
274589138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
274674f42e18STeLeMan  if test "$static" = "yes" ; then
27475f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
27485f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
27495f37e6d4SThomas Huth    else
275089138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
27515f37e6d4SThomas Huth    fi
275274f42e18STeLeMan  else
275389138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
275474f42e18STeLeMan  fi
275552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
275689138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
275711d9f695Sbellard      sdl_too_old=yes
275811d9f695Sbellard    else
275911d9f695Sbellard      sdl=yes
276011d9f695Sbellard    fi
27617c1f25b4Sbellard
276267c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
27631ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
276467c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
276589138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
276689138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
276711d9f695Sbellard      fi
276852166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
27691ac88f28SJuan Quintela	:
27701ac88f28SJuan Quintela      else
27711ac88f28SJuan Quintela        sdl=no
27727c1f25b4Sbellard      fi
27737c1f25b4Sbellard    fi # static link
2774c4198157SJuan Quintela  else # sdl not found
2775c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
277621684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2777c4198157SJuan Quintela    fi
2778c4198157SJuan Quintela    sdl=no
27797c1f25b4Sbellard  fi # sdl compile test
2780fd677642Sthsfi
278111d9f695Sbellard
27825368a422Saliguoriif test "$sdl" = "yes" ; then
27835368a422Saliguori  cat > $TMPC <<EOF
27845368a422Saliguori#include <SDL.h>
27855368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
27865368a422Saliguori#include <X11/XKBlib.h>
27875368a422Saliguori#else
27885368a422Saliguori#error No x11 support
27895368a422Saliguori#endif
27905368a422Saliguoriint main(void) { return 0; }
27915368a422SaliguoriEOF
2792f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2793f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2794f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
27955368a422Saliguori  fi
27960705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
27975368a422Saliguorifi
27985368a422Saliguori
27998f28f3fbSths##########################################
28002da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28012da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28022da776dbSMichael R. Hines  cat > $TMPC <<EOF
28032da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28042da776dbSMichael R. Hinesint main(void) { return 0; }
28052da776dbSMichael R. HinesEOF
28062da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
28072da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28082da776dbSMichael R. Hines    rdma="yes"
28092da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
28102da776dbSMichael R. Hines  else
28112da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28122da776dbSMichael R. Hines        error_exit \
28132da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28142da776dbSMichael R. Hines            " Your options:" \
28152da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28162da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28172da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28182da776dbSMichael R. Hines    fi
28192da776dbSMichael R. Hines    rdma="no"
28202da776dbSMichael R. Hines  fi
28212da776dbSMichael R. Hinesfi
28222da776dbSMichael R. Hines
282395c6bff3SBenoît Canet
282495c6bff3SBenoît Canet##########################################
28252f9606b3Saliguori# VNC SASL detection
2826821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
28272f9606b3Saliguori  cat > $TMPC <<EOF
28282f9606b3Saliguori#include <sasl/sasl.h>
28292f9606b3Saliguori#include <stdio.h>
28302f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
28312f9606b3SaliguoriEOF
28322f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
28332f9606b3Saliguori  vnc_sasl_cflags=""
28342f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
283552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2836ea784e3bSJuan Quintela    vnc_sasl=yes
2837fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2838ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
28392f9606b3Saliguori  else
2840ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
284121684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2842ea784e3bSJuan Quintela    fi
2843ea784e3bSJuan Quintela    vnc_sasl=no
28442f9606b3Saliguori  fi
28452f9606b3Saliguorifi
28462f9606b3Saliguori
28472f9606b3Saliguori##########################################
28482f6f5c7aSCorentin Chary# VNC JPEG detection
2849821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
28502f6f5c7aSCorentin Charycat > $TMPC <<EOF
28512f6f5c7aSCorentin Chary#include <stdio.h>
28522f6f5c7aSCorentin Chary#include <jpeglib.h>
28532f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
28542f6f5c7aSCorentin CharyEOF
28552f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
28562f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
28572f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
28582f6f5c7aSCorentin Chary    vnc_jpeg=yes
28592f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2860ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
28612f6f5c7aSCorentin Chary  else
28622f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
286321684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
28642f6f5c7aSCorentin Chary    fi
28652f6f5c7aSCorentin Chary    vnc_jpeg=no
28662f6f5c7aSCorentin Chary  fi
28672f6f5c7aSCorentin Charyfi
28682f6f5c7aSCorentin Chary
28692f6f5c7aSCorentin Chary##########################################
2870efe556adSCorentin Chary# VNC PNG detection
2871821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2872efe556adSCorentin Charycat > $TMPC <<EOF
2873efe556adSCorentin Chary//#include <stdio.h>
2874efe556adSCorentin Chary#include <png.h>
2875832ce9c2SScott Wood#include <stddef.h>
2876efe556adSCorentin Charyint main(void) {
2877efe556adSCorentin Chary    png_structp png_ptr;
2878efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
28797edc3fedSPeter Maydell    return png_ptr != 0;
2880efe556adSCorentin Chary}
2881efe556adSCorentin CharyEOF
288265d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
288389138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
288489138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
28859af8025eSBrad  else
2886efe556adSCorentin Chary    vnc_png_cflags=""
2887efe556adSCorentin Chary    vnc_png_libs="-lpng"
28889af8025eSBrad  fi
2889efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2890efe556adSCorentin Chary    vnc_png=yes
2891efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
28929af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2893efe556adSCorentin Chary  else
2894efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
289521684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2896efe556adSCorentin Chary    fi
2897efe556adSCorentin Chary    vnc_png=no
2898efe556adSCorentin Chary  fi
2899efe556adSCorentin Charyfi
2900efe556adSCorentin Chary
2901efe556adSCorentin Chary##########################################
290276655d6dSaliguori# fnmatch() probe, used for ACL routines
290376655d6dSaliguorifnmatch="no"
290476655d6dSaliguoricat > $TMPC << EOF
290576655d6dSaliguori#include <fnmatch.h>
290676655d6dSaliguoriint main(void)
290776655d6dSaliguori{
290876655d6dSaliguori    fnmatch("foo", "foo", 0);
290976655d6dSaliguori    return 0;
291076655d6dSaliguori}
291176655d6dSaliguoriEOF
291252166aa0SJuan Quintelaif compile_prog "" "" ; then
291376655d6dSaliguori   fnmatch="yes"
291476655d6dSaliguorifi
291576655d6dSaliguori
291676655d6dSaliguori##########################################
2917c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2918dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2919dce512deSChristoph Hellwig  cat > $TMPC << EOF
2920ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2921dce512deSChristoph Hellwig#include <xfs/xfs.h>
2922dce512deSChristoph Hellwigint main(void)
2923dce512deSChristoph Hellwig{
2924dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2925dce512deSChristoph Hellwig    return 0;
2926dce512deSChristoph Hellwig}
2927dce512deSChristoph HellwigEOF
2928dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2929dce512deSChristoph Hellwig    xfs="yes"
2930dce512deSChristoph Hellwig  else
2931dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
293221684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2933dce512deSChristoph Hellwig    fi
2934dce512deSChristoph Hellwig    xfs=no
2935dce512deSChristoph Hellwig  fi
2936dce512deSChristoph Hellwigfi
2937dce512deSChristoph Hellwig
2938dce512deSChristoph Hellwig##########################################
29398a16d273Sths# vde libraries probe
2940dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29414baae0acSJuan Quintela  vde_libs="-lvdeplug"
29428a16d273Sths  cat > $TMPC << EOF
29438a16d273Sths#include <libvdeplug.h>
29444a7f0e06Spbrookint main(void)
29454a7f0e06Spbrook{
29464a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2947fea08e08SPeter Maydell    char s[] = "";
2948fea08e08SPeter Maydell    vde_open(s, s, &a);
29494a7f0e06Spbrook    return 0;
29504a7f0e06Spbrook}
29518a16d273SthsEOF
295252166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29534baae0acSJuan Quintela    vde=yes
29548e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
29558e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2956dfb278bdSJuan Quintela  else
2957dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
295821684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2959dfb278bdSJuan Quintela    fi
2960dfb278bdSJuan Quintela    vde=no
29618a16d273Sths  fi
29628a16d273Sthsfi
29638a16d273Sths
29648a16d273Sths##########################################
29650a985b37SVincenzo Maffione# netmap support probe
29660a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29670a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29680a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29690a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29700a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
297158952137SVincenzo Maffioneif test "$netmap" != "no" ; then
297258952137SVincenzo Maffione  cat > $TMPC << EOF
297358952137SVincenzo Maffione#include <inttypes.h>
297458952137SVincenzo Maffione#include <net/if.h>
297558952137SVincenzo Maffione#include <net/netmap.h>
297658952137SVincenzo Maffione#include <net/netmap_user.h>
29770a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29780a985b37SVincenzo Maffione#error
29790a985b37SVincenzo Maffione#endif
298058952137SVincenzo Maffioneint main(void) { return 0; }
298158952137SVincenzo MaffioneEOF
298258952137SVincenzo Maffione  if compile_prog "" "" ; then
298358952137SVincenzo Maffione    netmap=yes
298458952137SVincenzo Maffione  else
298558952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
298658952137SVincenzo Maffione      feature_not_found "netmap"
298758952137SVincenzo Maffione    fi
298858952137SVincenzo Maffione    netmap=no
298958952137SVincenzo Maffione  fi
299058952137SVincenzo Maffionefi
299158952137SVincenzo Maffione
299258952137SVincenzo Maffione##########################################
299347e98658SCorey Bryant# libcap-ng library probe
299447e98658SCorey Bryantif test "$cap_ng" != "no" ; then
299547e98658SCorey Bryant  cap_libs="-lcap-ng"
299647e98658SCorey Bryant  cat > $TMPC << EOF
299747e98658SCorey Bryant#include <cap-ng.h>
299847e98658SCorey Bryantint main(void)
299947e98658SCorey Bryant{
300047e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
300147e98658SCorey Bryant    return 0;
300247e98658SCorey Bryant}
300347e98658SCorey BryantEOF
300447e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
300547e98658SCorey Bryant    cap_ng=yes
300647e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
300747e98658SCorey Bryant  else
300847e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
300921684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
301047e98658SCorey Bryant    fi
301147e98658SCorey Bryant    cap_ng=no
301247e98658SCorey Bryant  fi
301347e98658SCorey Bryantfi
301447e98658SCorey Bryant
301547e98658SCorey Bryant##########################################
3016c2de5c91Smalc# Sound support libraries probe
30178f28f3fbSths
3018c2de5c91Smalcaudio_drv_probe()
3019c2de5c91Smalc{
3020c2de5c91Smalc    drv=$1
3021c2de5c91Smalc    hdr=$2
3022c2de5c91Smalc    lib=$3
3023c2de5c91Smalc    exp=$4
3024c2de5c91Smalc    cfl=$5
30258f28f3fbSths        cat > $TMPC << EOF
3026c2de5c91Smalc#include <$hdr>
3027c2de5c91Smalcint main(void) { $exp }
30288f28f3fbSthsEOF
302952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
30308f28f3fbSths        :
30318f28f3fbSths    else
303276ad07a4SPeter Maydell        error_exit "$drv check failed" \
303376ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
30348f28f3fbSths    fi
3035c2de5c91Smalc}
3036c2de5c91Smalc
303789138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3038c2de5c91Smalcfor drv in $audio_drv_list; do
3039c2de5c91Smalc    case $drv in
3040c2de5c91Smalc    alsa)
3041c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3042e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3043a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
3044c2de5c91Smalc    ;;
3045c2de5c91Smalc
3046b8e59f18Smalc    pa)
3047e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3048e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3049a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
305067f86e8eSJuan Quintela    audio_pt_int="yes"
3051b8e59f18Smalc    ;;
3052b8e59f18Smalc
3053373967b2SGerd Hoffmann    sdl)
3054373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3055373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3056373967b2SGerd Hoffmann    fi
3057373967b2SGerd Hoffmann    ;;
3058373967b2SGerd Hoffmann
3059997e690aSJuan Quintela    coreaudio)
3060997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
3061997e690aSJuan Quintela    ;;
3062997e690aSJuan Quintela
3063a4bf6780SJuan Quintela    dsound)
3064a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
3065d5631638Smalc      audio_win_int="yes"
3066a4bf6780SJuan Quintela    ;;
3067a4bf6780SJuan Quintela
3068a4bf6780SJuan Quintela    oss)
3069a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
3070a4bf6780SJuan Quintela    ;;
3071a4bf6780SJuan Quintela
3072373967b2SGerd Hoffmann    wav)
3073373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
30742f6a1ab0Sblueswir1    ;;
30752f6a1ab0Sblueswir1
3076e4c63a6aSmalc    *)
30771c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
307876ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
307976ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3080e4c63a6aSmalc    }
3081e4c63a6aSmalc    ;;
3082c2de5c91Smalc    esac
3083c2de5c91Smalcdone
30848f28f3fbSths
30854d3b6f6eSbalrog##########################################
30862e4d9fb1Saurel32# BrlAPI probe
30872e4d9fb1Saurel32
30884ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3089eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
30902e4d9fb1Saurel32  cat > $TMPC << EOF
30912e4d9fb1Saurel32#include <brlapi.h>
3092832ce9c2SScott Wood#include <stddef.h>
30932e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
30942e4d9fb1Saurel32EOF
309552166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
30962e4d9fb1Saurel32    brlapi=yes
3097264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
30984ffcedb6SJuan Quintela  else
30994ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
310021684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
31014ffcedb6SJuan Quintela    fi
31024ffcedb6SJuan Quintela    brlapi=no
3103eb82284fSJuan Quintela  fi
3104eb82284fSJuan Quintelafi
31052e4d9fb1Saurel32
31062e4d9fb1Saurel32##########################################
31074d3b6f6eSbalrog# curses probe
3108a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3109e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
31108ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
31118ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3112e095e2f3SStefan Weil  else
31137c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
31148ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3115e095e2f3SStefan Weil  fi
3116c584a6d0SJuan Quintela  curses_found=no
31174d3b6f6eSbalrog  cat > $TMPC << EOF
31188ddc5bf9SSamuel Thibault#include <locale.h>
31194d3b6f6eSbalrog#include <curses.h>
31208ddc5bf9SSamuel Thibault#include <wchar.h>
3121ef9a2524SStefan Weilint main(void) {
31228ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
31238ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3124ef9a2524SStefan Weil  resize_term(0, 0);
31258ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
31268ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
31277c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3128271f37abSKamil Rytarowski  return 0;
3129ef9a2524SStefan Weil}
31304d3b6f6eSbalrogEOF
3131ecbe251fSVadim Evard  IFS=:
31328ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3133b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3134b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
31357c703002SSamuel Thibault    IFS=:
31368ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3137ecbe251fSVadim Evard      unset IFS
31388ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3139c584a6d0SJuan Quintela        curses_found=yes
31408ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
31414f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
31424f78ef9aSJuan Quintela        break
31434d3b6f6eSbalrog      fi
31444f78ef9aSJuan Quintela    done
31457c703002SSamuel Thibault    if test "$curses_found" = yes ; then
31467c703002SSamuel Thibault      break
31477c703002SSamuel Thibault    fi
31488ddc5bf9SSamuel Thibault  done
3149ecbe251fSVadim Evard  unset IFS
3150c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3151c584a6d0SJuan Quintela    curses=yes
3152c584a6d0SJuan Quintela  else
3153c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
315421684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3155c584a6d0SJuan Quintela    fi
3156c584a6d0SJuan Quintela    curses=no
3157c584a6d0SJuan Quintela  fi
31584f78ef9aSJuan Quintelafi
31594d3b6f6eSbalrog
3160414f0dabSblueswir1##########################################
3161769ce76dSAlexander Graf# curl probe
3162a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
316365d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3164a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
31654e2b0658SPaolo Bonzini  else
31664e2b0658SPaolo Bonzini    curlconfig=curl-config
31674e2b0658SPaolo Bonzini  fi
3168769ce76dSAlexander Graf  cat > $TMPC << EOF
3169769ce76dSAlexander Graf#include <curl/curl.h>
31700b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3171769ce76dSAlexander GrafEOF
317289138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
317389138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3174b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3175769ce76dSAlexander Graf    curl=yes
3176788c8196SJuan Quintela  else
3177788c8196SJuan Quintela    if test "$curl" = "yes" ; then
317821684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3179788c8196SJuan Quintela    fi
3180788c8196SJuan Quintela    curl=no
3181769ce76dSAlexander Graf  fi
3182769ce76dSAlexander Graffi # test "$curl"
3183769ce76dSAlexander Graf
3184769ce76dSAlexander Graf##########################################
3185fb599c9aSbalrog# bluez support probe
3186a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3187e820e3f4Sbalrog  cat > $TMPC << EOF
3188e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3189e820e3f4Sbalrogint main(void) { return bt_error(0); }
3190e820e3f4SbalrogEOF
319189138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
319289138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
319352166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3194a20a6f46SJuan Quintela    bluez=yes
3195e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3196e820e3f4Sbalrog  else
3197a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
319821684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3199a20a6f46SJuan Quintela    fi
3200e820e3f4Sbalrog    bluez="no"
3201e820e3f4Sbalrog  fi
3202fb599c9aSbalrogfi
3203fb599c9aSbalrog
3204fb599c9aSbalrog##########################################
3205e18df141SAnthony Liguori# glib support probe
3206a52d28afSPaolo Bonzini
3207ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3208ad04d8cbSPeter Maydell    glib_req_ver=2.30
3209ad04d8cbSPeter Maydellelse
3210f40685c6SJohn Snow    glib_req_ver=2.22
3211ad04d8cbSPeter Maydellfi
3212aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3213aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3214aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3215aa0d1f44SPaolo Bonzinifi
3216e26110cfSFam Zheng
32174eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
32184eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
32194eaf7202SSameeh Jubran
32204eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
32214eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
32224eaf7202SSameeh Jubranfi
32234eaf7202SSameeh Jubran
3224aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3225e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
322689138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
322789138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
32284a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
322914015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3230957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3231e18df141SAnthony Liguori    else
3232e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3233e26110cfSFam Zheng    fi
3234e26110cfSFam Zhengdone
3235e26110cfSFam Zheng
3236977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3237977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3238977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3239977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3240977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3241977a82abSDaniel P. Berrange#include <glib.h>
3242977a82abSDaniel P. Berrange#include <unistd.h>
3243977a82abSDaniel P. Berrange
3244977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3245977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3246977a82abSDaniel P. Berrange
3247977a82abSDaniel P. Berrangeint main(void) {
3248977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3249977a82abSDaniel P. Berrange   return 0;
3250977a82abSDaniel P. Berrange}
3251977a82abSDaniel P. BerrangeEOF
3252977a82abSDaniel P. Berrange
32535919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3254977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3255977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3256977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3257977a82abSDaniel P. Berrange	       "build target"
3258977a82abSDaniel P. Berrangefi
3259977a82abSDaniel P. Berrange
32609d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
32619d41401bSMichael S. Tsirkinglib_subprocess=yes
3262a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
32639d41401bSMichael S. Tsirkin    glib_subprocess=no
32649d41401bSMichael S. Tsirkinfi
32659d41401bSMichael S. Tsirkin
3266bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3267bbbf2e04SJohn Snowcat > $TMPC << EOF
3268bbbf2e04SJohn Snow#include <glib.h>
3269bbbf2e04SJohn Snowint main(void) { return 0; }
3270bbbf2e04SJohn SnowEOF
3271bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3272bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3273bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3274bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3275bbbf2e04SJohn Snow    fi
3276bbbf2e04SJohn Snowfi
3277bbbf2e04SJohn Snow
3278e26110cfSFam Zheng##########################################
3279e26110cfSFam Zheng# SHA command probe for modules
3280e26110cfSFam Zhengif test "$modules" = yes; then
3281e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3282e26110cfSFam Zheng    for c in $shacmd_probe; do
32838ccefb91SFam Zheng        if has $c; then
3284e26110cfSFam Zheng            shacmd="$c"
3285e26110cfSFam Zheng            break
3286e26110cfSFam Zheng        fi
3287e26110cfSFam Zheng    done
3288e26110cfSFam Zheng    if test "$shacmd" = ""; then
3289e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3290e26110cfSFam Zheng    fi
3291e18df141SAnthony Liguorifi
3292e18df141SAnthony Liguori
3293e18df141SAnthony Liguori##########################################
3294e2134eb9SGerd Hoffmann# pixman support probe
3295e2134eb9SGerd Hoffmann
3296e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
329774880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
329874880fe2SRobert Schiele    pixman="none"
3299236f282cSHu Tao  elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3300e2134eb9SGerd Hoffmann    pixman="system"
3301e2134eb9SGerd Hoffmann  fi
3302e2134eb9SGerd Hoffmannfi
330374880fe2SRobert Schieleif test "$pixman" = "none"; then
330474880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
330576ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
330676ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
330776ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
330876ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
330974880fe2SRobert Schiele  fi
331074880fe2SRobert Schiele  pixman_cflags=
331174880fe2SRobert Schiele  pixman_libs=
331274880fe2SRobert Schieleelif test "$pixman" = "system"; then
3313236f282cSHu Tao  # pixman version has been checked above
331489138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
331589138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3316e2134eb9SGerd Hoffmannelse
3317*c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3318*c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3319e2134eb9SGerd Hoffmannfi
3320e2134eb9SGerd Hoffmann
3321e2134eb9SGerd Hoffmann##########################################
332217bff52bSM. Mohan Kumar# libcap probe
332317bff52bSM. Mohan Kumar
332417bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
332517bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
332617bff52bSM. Mohan Kumar#include <stdio.h>
332717bff52bSM. Mohan Kumar#include <sys/capability.h>
3328cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
332917bff52bSM. Mohan KumarEOF
333017bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
333117bff52bSM. Mohan Kumar    cap=yes
333217bff52bSM. Mohan Kumar  else
333317bff52bSM. Mohan Kumar    cap=no
333417bff52bSM. Mohan Kumar  fi
333517bff52bSM. Mohan Kumarfi
333617bff52bSM. Mohan Kumar
333717bff52bSM. Mohan Kumar##########################################
3338e5d355d1Saliguori# pthread probe
33394b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
33403c529d93Saliguori
3341e5d355d1Saliguoripthread=no
3342414f0dabSblueswir1cat > $TMPC << EOF
33433c529d93Saliguori#include <pthread.h>
33447a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
33457a42bbe4SStefan Weilint main(void) {
33467a42bbe4SStefan Weil  pthread_t thread;
33477a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
33487a42bbe4SStefan Weil  return 0;
33497a42bbe4SStefan Weil}
3350414f0dabSblueswir1EOF
3351bd00d539SAndreas Färberif compile_prog "" "" ; then
3352bd00d539SAndreas Färber  pthread=yes
3353bd00d539SAndreas Färberelse
3354de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
335552166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3356e5d355d1Saliguori      pthread=yes
3357e3c56761SPeter Portante      found=no
3358e3c56761SPeter Portante      for lib_entry in $LIBS; do
3359e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3360e3c56761SPeter Portante          found=yes
3361e3c56761SPeter Portante          break
3362e3c56761SPeter Portante        fi
3363e3c56761SPeter Portante      done
3364e3c56761SPeter Portante      if test "$found" = "no"; then
33655572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3366e3c56761SPeter Portante      fi
3367409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3368de65fe0fSSebastian Herbszt      break
3369414f0dabSblueswir1    fi
3370de65fe0fSSebastian Herbszt  done
3371bd00d539SAndreas Färberfi
3372414f0dabSblueswir1
33734617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
337476ad07a4SPeter Maydell  error_exit "pthread check failed" \
337576ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3376e5d355d1Saliguorifi
3377e5d355d1Saliguori
33785c312079SDr. David Alan Gilbert# check for pthread_setname_np
33795c312079SDr. David Alan Gilbertpthread_setname_np=no
33805c312079SDr. David Alan Gilbertcat > $TMPC << EOF
33815c312079SDr. David Alan Gilbert#include <pthread.h>
33825c312079SDr. David Alan Gilbert
33835c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
33845c312079SDr. David Alan Gilbertint main(void)
33855c312079SDr. David Alan Gilbert{
33865c312079SDr. David Alan Gilbert    pthread_t thread;
33875c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
33885c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
33895c312079SDr. David Alan Gilbert    return 0;
33905c312079SDr. David Alan Gilbert}
33915c312079SDr. David Alan GilbertEOF
33925c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
33935c312079SDr. David Alan Gilbert  pthread_setname_np=yes
33945c312079SDr. David Alan Gilbertfi
33955c312079SDr. David Alan Gilbert
3396bf9298b9Saliguori##########################################
3397f27aaf4bSChristian Brunner# rbd probe
3398f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3399f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3400f27aaf4bSChristian Brunner#include <stdio.h>
3401ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3402f27aaf4bSChristian Brunnerint main(void) {
3403ad32e9c0SJosh Durgin    rados_t cluster;
3404ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3405f27aaf4bSChristian Brunner    return 0;
3406f27aaf4bSChristian Brunner}
3407f27aaf4bSChristian BrunnerEOF
3408ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3409f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3410f27aaf4bSChristian Brunner    rbd=yes
3411f27aaf4bSChristian Brunner  else
3412f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
341321684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3414f27aaf4bSChristian Brunner    fi
3415f27aaf4bSChristian Brunner    rbd=no
3416f27aaf4bSChristian Brunner  fi
3417f27aaf4bSChristian Brunnerfi
3418f27aaf4bSChristian Brunner
3419f27aaf4bSChristian Brunner##########################################
34200a12ec87SRichard W.M. Jones# libssh2 probe
34214fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
34220a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
342365d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
342489138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
342589138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
34260a12ec87SRichard W.M. Jones    libssh2=yes
34270a12ec87SRichard W.M. Jones  else
34280a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
34294fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
34300a12ec87SRichard W.M. Jones    fi
34310a12ec87SRichard W.M. Jones    libssh2=no
34320a12ec87SRichard W.M. Jones  fi
34330a12ec87SRichard W.M. Jonesfi
34340a12ec87SRichard W.M. Jones
34350a12ec87SRichard W.M. Jones##########################################
34369a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
34379a2d462eSRichard W.M. Jones
34389a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
34399a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
34409a2d462eSRichard W.M. Jones#include <stdio.h>
34419a2d462eSRichard W.M. Jones#include <libssh2.h>
34429a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
34439a2d462eSRichard W.M. Jonesint main(void) {
34449a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
34459a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
34469a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
34479a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
34489a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
34499a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
34509a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
34519a2d462eSRichard W.M. Jones    return 0;
34529a2d462eSRichard W.M. Jones}
34539a2d462eSRichard W.M. JonesEOF
34549a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
34559a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
34569a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
34579a2d462eSRichard W.M. Jones  fi
34589a2d462eSRichard W.M. Jonesfi
34599a2d462eSRichard W.M. Jones
34609a2d462eSRichard W.M. Jones##########################################
34615c6c3a6cSChristoph Hellwig# linux-aio probe
34625c6c3a6cSChristoph Hellwig
34635c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
34645c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
34655c6c3a6cSChristoph Hellwig#include <libaio.h>
34665c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3467832ce9c2SScott Wood#include <stddef.h>
34685c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
34695c6c3a6cSChristoph HellwigEOF
34705c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
34715c6c3a6cSChristoph Hellwig    linux_aio=yes
34725c6c3a6cSChristoph Hellwig  else
34735c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
347421684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
34755c6c3a6cSChristoph Hellwig    fi
34763cfcae3cSLuiz Capitulino    linux_aio=no
34775c6c3a6cSChristoph Hellwig  fi
34785c6c3a6cSChristoph Hellwigfi
34795c6c3a6cSChristoph Hellwig
34805c6c3a6cSChristoph Hellwig##########################################
34813b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
34823b8acc11SPaolo Bonzini
34833b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
34843b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
34853b8acc11SPaolo Bonzinielse
34863b8acc11SPaolo Bonzini  tpm_passthrough=no
34873b8acc11SPaolo Bonzinifi
34883b8acc11SPaolo Bonzini
34893b8acc11SPaolo Bonzini##########################################
3490758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3491758e8e38SVenkateswararao Jujjuri (JV)
3492758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3493758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3494758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3495758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3496f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3497f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3498f2338fb4SPavel Borzenkov#else
34994f26f2b6SAvi Kivity#include <sys/xattr.h>
3500f2338fb4SPavel Borzenkov#endif
3501758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3502758e8e38SVenkateswararao Jujjuri (JV)EOF
35034f26f2b6SAvi Kivity  if compile_prog "" "" ; then
35044f26f2b6SAvi Kivity    attr=yes
35054f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3506f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3507758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3508758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
35094f26f2b6SAvi Kivity    libattr=yes
3510758e8e38SVenkateswararao Jujjuri (JV)  else
3511758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
351221684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3513758e8e38SVenkateswararao Jujjuri (JV)    fi
3514758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3515758e8e38SVenkateswararao Jujjuri (JV)  fi
3516758e8e38SVenkateswararao Jujjuri (JV)fi
3517758e8e38SVenkateswararao Jujjuri (JV)
3518758e8e38SVenkateswararao Jujjuri (JV)##########################################
3519bf9298b9Saliguori# iovec probe
3520bf9298b9Saliguoricat > $TMPC <<EOF
3521db34f0b3Sblueswir1#include <sys/types.h>
3522bf9298b9Saliguori#include <sys/uio.h>
3523db34f0b3Sblueswir1#include <unistd.h>
3524f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3525bf9298b9SaliguoriEOF
3526bf9298b9Saliguoriiovec=no
352752166aa0SJuan Quintelaif compile_prog "" "" ; then
3528bf9298b9Saliguori  iovec=yes
3529bf9298b9Saliguorifi
3530bf9298b9Saliguori
3531f652e6afSaurel32##########################################
3532ceb42de8Saliguori# preadv probe
3533ceb42de8Saliguoricat > $TMPC <<EOF
3534ceb42de8Saliguori#include <sys/types.h>
3535ceb42de8Saliguori#include <sys/uio.h>
3536ceb42de8Saliguori#include <unistd.h>
3537c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3538ceb42de8SaliguoriEOF
3539ceb42de8Saliguoripreadv=no
354052166aa0SJuan Quintelaif compile_prog "" "" ; then
3541ceb42de8Saliguori  preadv=yes
3542ceb42de8Saliguorifi
3543ceb42de8Saliguori
3544ceb42de8Saliguori##########################################
3545f652e6afSaurel32# fdt probe
3546e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3547e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3548e169e1e1SPeter Maydellfdt_required=no
3549e169e1e1SPeter Maydellfor target in $target_list; do
3550e169e1e1SPeter Maydell  case $target in
3551df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3552e169e1e1SPeter Maydell      fdt_required=yes
3553e169e1e1SPeter Maydell    ;;
3554e169e1e1SPeter Maydell  esac
3555e169e1e1SPeter Maydelldone
3556e169e1e1SPeter Maydell
3557e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3558e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3559e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3560e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3561e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3562e169e1e1SPeter Maydell  fi
3563e169e1e1SPeter Maydell  fdt=yes
3564e169e1e1SPeter Maydellfi
3565e169e1e1SPeter Maydell
35662df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3567b41af4baSJuan Quintela  fdt_libs="-lfdt"
356896ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
35696e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3570f652e6afSaurel32  cat > $TMPC << EOF
357131ce0adbSThomas Huth#include <libfdt.h>
357296ce6545SPeter Crosthwaite#include <libfdt_env.h>
35736e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3574f652e6afSaurel32EOF
357552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3576a540f158SPeter Crosthwaite    # system DTC is good - use it
3577f652e6afSaurel32    fdt=yes
3578a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
3579a540f158SPeter Crosthwaite    # have submodule DTC - use it
3580a540f158SPeter Crosthwaite    fdt=yes
3581a540f158SPeter Crosthwaite    dtc_internal="yes"
3582a540f158SPeter Crosthwaite    mkdir -p dtc
3583cab00a5aSMichael S. Tsirkin    if [ "$pwd_is_source_path" != "y" ] ; then
3584a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3585a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
35862df87df7SJuan Quintela    fi
3587a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3588a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3589a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
3590a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
35916e85fce0SPaul Burton    error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
35923f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
3593a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
3594a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
3595a540f158SPeter Crosthwaite  else
3596a540f158SPeter Crosthwaite    # don't have and don't want
3597de3a354aSMichael Walle    fdt_libs=
35982df87df7SJuan Quintela    fdt=no
3599f652e6afSaurel32  fi
3600f652e6afSaurel32fi
3601f652e6afSaurel32
3602a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3603a540f158SPeter Crosthwaite
360420ff075bSMichael Walle##########################################
3605fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3606b1546f32SGerd Hoffmann
3607da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3608014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3609fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3610f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3611f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3612da076ffeSGerd Hoffmann    opengl=yes
3613925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3614925a0400SGerd Hoffmann        gtk_gl="yes"
3615925a0400SGerd Hoffmann    fi
3616cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
361720ff075bSMichael Walle  else
3618da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3619dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
362020ff075bSMichael Walle    fi
3621f676c67eSJeremy White    opengl_cflags=""
3622da076ffeSGerd Hoffmann    opengl_libs=""
3623da076ffeSGerd Hoffmann    opengl=no
362420ff075bSMichael Walle  fi
362520ff075bSMichael Wallefi
362620ff075bSMichael Walle
3627014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3628014cb152SGerd Hoffmann  cat > $TMPC << EOF
3629014cb152SGerd Hoffmann#include <epoxy/egl.h>
3630014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3631014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3632014cb152SGerd Hoffmann#endif
3633014cb152SGerd Hoffmannint main(void) { return 0; }
3634014cb152SGerd HoffmannEOF
3635014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3636014cb152SGerd Hoffmann    opengl_dmabuf=yes
3637014cb152SGerd Hoffmann  fi
3638014cb152SGerd Hoffmannfi
3639c9a12e75SChrysostomos Nanakos
3640c9a12e75SChrysostomos Nanakos
3641eb100396SBharata B Rao##########################################
3642eb100396SBharata B Rao# glusterfs probe
3643eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
364465d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3645e01bee08SBharata B Rao    glusterfs="yes"
364689138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
364789138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3648d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3649d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3650d85fa9ebSJeff Cody    fi
365165d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
36520c14fb47SBharata B Rao      glusterfs_discard="yes"
36530c14fb47SBharata B Rao    fi
36547c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3655df3a429aSNiels de Vos      glusterfs_fallocate="yes"
36567c815372SBharata B Rao      glusterfs_zerofill="yes"
36577c815372SBharata B Rao    fi
3658eb100396SBharata B Rao  else
3659eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
36608efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
36618efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3662eb100396SBharata B Rao    fi
3663e01bee08SBharata B Rao    glusterfs="no"
3664eb100396SBharata B Rao  fi
3665eb100396SBharata B Raofi
3666eb100396SBharata B Rao
366739386ac7Saurel32# Check for inotify functions when we are building linux-user
36683b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36693b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36703b3f24adSaurel32# don't provide them even if kernel supports them.
36713b3f24adSaurel32#
36723b3f24adSaurel32inotify=no
36733b3f24adSaurel32cat > $TMPC << EOF
36743b3f24adSaurel32#include <sys/inotify.h>
36753b3f24adSaurel32
36763b3f24adSaurel32int
36773b3f24adSaurel32main(void)
36783b3f24adSaurel32{
36793b3f24adSaurel32	/* try to start inotify */
36808690e420Saurel32	return inotify_init();
36813b3f24adSaurel32}
36823b3f24adSaurel32EOF
368352166aa0SJuan Quintelaif compile_prog "" "" ; then
36843b3f24adSaurel32  inotify=yes
36853b3f24adSaurel32fi
36863b3f24adSaurel32
3687c05c7a73SRiku Voipioinotify1=no
3688c05c7a73SRiku Voipiocat > $TMPC << EOF
3689c05c7a73SRiku Voipio#include <sys/inotify.h>
3690c05c7a73SRiku Voipio
3691c05c7a73SRiku Voipioint
3692c05c7a73SRiku Voipiomain(void)
3693c05c7a73SRiku Voipio{
3694c05c7a73SRiku Voipio    /* try to start inotify */
3695c05c7a73SRiku Voipio    return inotify_init1(0);
3696c05c7a73SRiku Voipio}
3697c05c7a73SRiku VoipioEOF
3698c05c7a73SRiku Voipioif compile_prog "" "" ; then
3699c05c7a73SRiku Voipio  inotify1=yes
3700c05c7a73SRiku Voipiofi
3701c05c7a73SRiku Voipio
3702099d6b0fSRiku Voipio# check if pipe2 is there
3703099d6b0fSRiku Voipiopipe2=no
3704099d6b0fSRiku Voipiocat > $TMPC << EOF
3705099d6b0fSRiku Voipio#include <unistd.h>
3706099d6b0fSRiku Voipio#include <fcntl.h>
3707099d6b0fSRiku Voipio
3708099d6b0fSRiku Voipioint main(void)
3709099d6b0fSRiku Voipio{
3710099d6b0fSRiku Voipio    int pipefd[2];
37119bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3712099d6b0fSRiku Voipio}
3713099d6b0fSRiku VoipioEOF
371452166aa0SJuan Quintelaif compile_prog "" "" ; then
3715099d6b0fSRiku Voipio  pipe2=yes
3716099d6b0fSRiku Voipiofi
3717099d6b0fSRiku Voipio
371840ff6d7eSKevin Wolf# check if accept4 is there
371940ff6d7eSKevin Wolfaccept4=no
372040ff6d7eSKevin Wolfcat > $TMPC << EOF
372140ff6d7eSKevin Wolf#include <sys/socket.h>
372240ff6d7eSKevin Wolf#include <stddef.h>
372340ff6d7eSKevin Wolf
372440ff6d7eSKevin Wolfint main(void)
372540ff6d7eSKevin Wolf{
372640ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
372740ff6d7eSKevin Wolf    return 0;
372840ff6d7eSKevin Wolf}
372940ff6d7eSKevin WolfEOF
373040ff6d7eSKevin Wolfif compile_prog "" "" ; then
373140ff6d7eSKevin Wolf  accept4=yes
373240ff6d7eSKevin Wolffi
373340ff6d7eSKevin Wolf
37343ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
37353ce34dfbSvibisreenivasansplice=no
37363ce34dfbSvibisreenivasancat > $TMPC << EOF
37373ce34dfbSvibisreenivasan#include <unistd.h>
37383ce34dfbSvibisreenivasan#include <fcntl.h>
37393ce34dfbSvibisreenivasan#include <limits.h>
37403ce34dfbSvibisreenivasan
37413ce34dfbSvibisreenivasanint main(void)
37423ce34dfbSvibisreenivasan{
374366ea0f22SStefan Weil    int len, fd = 0;
37443ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
37453ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
37463ce34dfbSvibisreenivasan    return 0;
37473ce34dfbSvibisreenivasan}
37483ce34dfbSvibisreenivasanEOF
374952166aa0SJuan Quintelaif compile_prog "" "" ; then
37503ce34dfbSvibisreenivasan  splice=yes
37513ce34dfbSvibisreenivasanfi
37523ce34dfbSvibisreenivasan
3753dcc38d1cSMarcelo Tosatti##########################################
3754a99d57bbSWanlong Gao# libnuma probe
3755a99d57bbSWanlong Gao
3756a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3757a99d57bbSWanlong Gao  cat > $TMPC << EOF
3758a99d57bbSWanlong Gao#include <numa.h>
3759a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3760a99d57bbSWanlong GaoEOF
3761a99d57bbSWanlong Gao
3762a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3763a99d57bbSWanlong Gao    numa=yes
3764a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3765a99d57bbSWanlong Gao  else
3766a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3767a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3768a99d57bbSWanlong Gao    fi
3769a99d57bbSWanlong Gao    numa=no
3770a99d57bbSWanlong Gao  fi
3771a99d57bbSWanlong Gaofi
3772a99d57bbSWanlong Gao
37737b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37747b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37757b01cb97SAlexandre Derumier    exit 1
37767b01cb97SAlexandre Derumierfi
37777b01cb97SAlexandre Derumier
3778a99d57bbSWanlong Gao##########################################
37792847b469SFam Zheng# tcmalloc probe
37802847b469SFam Zheng
37812847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
37822847b469SFam Zheng  cat > $TMPC << EOF
37832847b469SFam Zheng#include <stdlib.h>
37842847b469SFam Zhengint main(void) { malloc(1); return 0; }
37852847b469SFam ZhengEOF
37862847b469SFam Zheng
37872847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
37882847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
37892847b469SFam Zheng  else
37902847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
37912847b469SFam Zheng  fi
37922847b469SFam Zhengfi
37932847b469SFam Zheng
37942847b469SFam Zheng##########################################
37957b01cb97SAlexandre Derumier# jemalloc probe
37967b01cb97SAlexandre Derumier
37977b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
37987b01cb97SAlexandre Derumier  cat > $TMPC << EOF
37997b01cb97SAlexandre Derumier#include <stdlib.h>
38007b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
38017b01cb97SAlexandre DerumierEOF
38027b01cb97SAlexandre Derumier
38037b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
38047b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
38057b01cb97SAlexandre Derumier  else
38067b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
38077b01cb97SAlexandre Derumier  fi
38087b01cb97SAlexandre Derumierfi
38097b01cb97SAlexandre Derumier
38107b01cb97SAlexandre Derumier##########################################
3811dcc38d1cSMarcelo Tosatti# signalfd probe
3812dcc38d1cSMarcelo Tosattisignalfd="no"
3813dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3814dcc38d1cSMarcelo Tosatti#include <unistd.h>
3815dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3816dcc38d1cSMarcelo Tosatti#include <signal.h>
3817dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3818dcc38d1cSMarcelo TosattiEOF
3819dcc38d1cSMarcelo Tosatti
3820dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3821dcc38d1cSMarcelo Tosatti  signalfd=yes
3822dcc38d1cSMarcelo Tosattifi
3823dcc38d1cSMarcelo Tosatti
3824c2882b96SRiku Voipio# check if eventfd is supported
3825c2882b96SRiku Voipioeventfd=no
3826c2882b96SRiku Voipiocat > $TMPC << EOF
3827c2882b96SRiku Voipio#include <sys/eventfd.h>
3828c2882b96SRiku Voipio
3829c2882b96SRiku Voipioint main(void)
3830c2882b96SRiku Voipio{
383155cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3832c2882b96SRiku Voipio}
3833c2882b96SRiku VoipioEOF
3834c2882b96SRiku Voipioif compile_prog "" "" ; then
3835c2882b96SRiku Voipio  eventfd=yes
3836c2882b96SRiku Voipiofi
3837c2882b96SRiku Voipio
3838751bcc39SMarc-André Lureau# check if memfd is supported
3839751bcc39SMarc-André Lureaumemfd=no
3840751bcc39SMarc-André Lureaucat > $TMPC << EOF
3841751bcc39SMarc-André Lureau#include <sys/memfd.h>
3842751bcc39SMarc-André Lureau
3843751bcc39SMarc-André Lureauint main(void)
3844751bcc39SMarc-André Lureau{
3845751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3846751bcc39SMarc-André Lureau}
3847751bcc39SMarc-André LureauEOF
3848751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3849751bcc39SMarc-André Lureau  memfd=yes
3850751bcc39SMarc-André Lureaufi
3851751bcc39SMarc-André Lureau
3852751bcc39SMarc-André Lureau
3853751bcc39SMarc-André Lureau
3854d0927938SUlrich Hecht# check for fallocate
3855d0927938SUlrich Hechtfallocate=no
3856d0927938SUlrich Hechtcat > $TMPC << EOF
3857d0927938SUlrich Hecht#include <fcntl.h>
3858d0927938SUlrich Hecht
3859d0927938SUlrich Hechtint main(void)
3860d0927938SUlrich Hecht{
3861d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3862d0927938SUlrich Hecht    return 0;
3863d0927938SUlrich Hecht}
3864d0927938SUlrich HechtEOF
38658fb03151SPeter Maydellif compile_prog "" "" ; then
3866d0927938SUlrich Hecht  fallocate=yes
3867d0927938SUlrich Hechtfi
3868d0927938SUlrich Hecht
38693d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38703d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38713d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38723d4fa43eSKusanagi Kouichi#include <fcntl.h>
38733d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38743d4fa43eSKusanagi Kouichi
38753d4fa43eSKusanagi Kouichiint main(void)
38763d4fa43eSKusanagi Kouichi{
38773d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38783d4fa43eSKusanagi Kouichi    return 0;
38793d4fa43eSKusanagi Kouichi}
38803d4fa43eSKusanagi KouichiEOF
38813d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38823d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38833d4fa43eSKusanagi Kouichifi
38843d4fa43eSKusanagi Kouichi
3885b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3886b953f075SDenis V. Lunevfallocate_zero_range=no
3887b953f075SDenis V. Lunevcat > $TMPC << EOF
3888b953f075SDenis V. Lunev#include <fcntl.h>
3889b953f075SDenis V. Lunev#include <linux/falloc.h>
3890b953f075SDenis V. Lunev
3891b953f075SDenis V. Lunevint main(void)
3892b953f075SDenis V. Lunev{
3893b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3894b953f075SDenis V. Lunev    return 0;
3895b953f075SDenis V. Lunev}
3896b953f075SDenis V. LunevEOF
3897b953f075SDenis V. Lunevif compile_prog "" "" ; then
3898b953f075SDenis V. Lunev  fallocate_zero_range=yes
3899b953f075SDenis V. Lunevfi
3900b953f075SDenis V. Lunev
3901ed911435SKevin Wolf# check for posix_fallocate
3902ed911435SKevin Wolfposix_fallocate=no
3903ed911435SKevin Wolfcat > $TMPC << EOF
3904ed911435SKevin Wolf#include <fcntl.h>
3905ed911435SKevin Wolf
3906ed911435SKevin Wolfint main(void)
3907ed911435SKevin Wolf{
3908ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3909ed911435SKevin Wolf    return 0;
3910ed911435SKevin Wolf}
3911ed911435SKevin WolfEOF
3912ed911435SKevin Wolfif compile_prog "" "" ; then
3913ed911435SKevin Wolf    posix_fallocate=yes
3914ed911435SKevin Wolffi
3915ed911435SKevin Wolf
3916c727f47dSPeter Maydell# check for sync_file_range
3917c727f47dSPeter Maydellsync_file_range=no
3918c727f47dSPeter Maydellcat > $TMPC << EOF
3919c727f47dSPeter Maydell#include <fcntl.h>
3920c727f47dSPeter Maydell
3921c727f47dSPeter Maydellint main(void)
3922c727f47dSPeter Maydell{
3923c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3924c727f47dSPeter Maydell    return 0;
3925c727f47dSPeter Maydell}
3926c727f47dSPeter MaydellEOF
39278fb03151SPeter Maydellif compile_prog "" "" ; then
3928c727f47dSPeter Maydell  sync_file_range=yes
3929c727f47dSPeter Maydellfi
3930c727f47dSPeter Maydell
3931dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3932dace20dcSPeter Maydellfiemap=no
3933dace20dcSPeter Maydellcat > $TMPC << EOF
3934dace20dcSPeter Maydell#include <sys/ioctl.h>
3935dace20dcSPeter Maydell#include <linux/fs.h>
3936dace20dcSPeter Maydell#include <linux/fiemap.h>
3937dace20dcSPeter Maydell
3938dace20dcSPeter Maydellint main(void)
3939dace20dcSPeter Maydell{
3940dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3941dace20dcSPeter Maydell    return 0;
3942dace20dcSPeter Maydell}
3943dace20dcSPeter MaydellEOF
39448fb03151SPeter Maydellif compile_prog "" "" ; then
3945dace20dcSPeter Maydell  fiemap=yes
3946dace20dcSPeter Maydellfi
3947dace20dcSPeter Maydell
3948d0927938SUlrich Hecht# check for dup3
3949d0927938SUlrich Hechtdup3=no
3950d0927938SUlrich Hechtcat > $TMPC << EOF
3951d0927938SUlrich Hecht#include <unistd.h>
3952d0927938SUlrich Hecht
3953d0927938SUlrich Hechtint main(void)
3954d0927938SUlrich Hecht{
3955d0927938SUlrich Hecht    dup3(0, 0, 0);
3956d0927938SUlrich Hecht    return 0;
3957d0927938SUlrich Hecht}
3958d0927938SUlrich HechtEOF
395978f5d726SJan Kiszkaif compile_prog "" "" ; then
3960d0927938SUlrich Hecht  dup3=yes
3961d0927938SUlrich Hechtfi
3962d0927938SUlrich Hecht
39634e0c6529SAlex Bligh# check for ppoll support
39644e0c6529SAlex Blighppoll=no
39654e0c6529SAlex Blighcat > $TMPC << EOF
39664e0c6529SAlex Bligh#include <poll.h>
39674e0c6529SAlex Bligh
39684e0c6529SAlex Blighint main(void)
39694e0c6529SAlex Bligh{
39704e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39714e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39724e0c6529SAlex Bligh    return 0;
39734e0c6529SAlex Bligh}
39744e0c6529SAlex BlighEOF
39754e0c6529SAlex Blighif compile_prog "" "" ; then
39764e0c6529SAlex Bligh  ppoll=yes
39774e0c6529SAlex Blighfi
39784e0c6529SAlex Bligh
3979cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3980cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3981cd758dd0SAlex Blighcat > $TMPC << EOF
3982cd758dd0SAlex Bligh#include <sys/prctl.h>
3983cd758dd0SAlex Bligh
3984cd758dd0SAlex Blighint main(void)
3985cd758dd0SAlex Bligh{
3986cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3987cd758dd0SAlex Bligh    return 0;
3988cd758dd0SAlex Bligh}
3989cd758dd0SAlex BlighEOF
3990cd758dd0SAlex Blighif compile_prog "" "" ; then
3991cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3992cd758dd0SAlex Blighfi
3993cd758dd0SAlex Bligh
39943b6edd16SPeter Maydell# check for epoll support
39953b6edd16SPeter Maydellepoll=no
39963b6edd16SPeter Maydellcat > $TMPC << EOF
39973b6edd16SPeter Maydell#include <sys/epoll.h>
39983b6edd16SPeter Maydell
39993b6edd16SPeter Maydellint main(void)
40003b6edd16SPeter Maydell{
40013b6edd16SPeter Maydell    epoll_create(0);
40023b6edd16SPeter Maydell    return 0;
40033b6edd16SPeter Maydell}
40043b6edd16SPeter MaydellEOF
40058fb03151SPeter Maydellif compile_prog "" "" ; then
40063b6edd16SPeter Maydell  epoll=yes
40073b6edd16SPeter Maydellfi
40083b6edd16SPeter Maydell
4009227f0214SPeter Maydell# epoll_create1 is a later addition
4010227f0214SPeter Maydell# so we must check separately for its presence
40113b6edd16SPeter Maydellepoll_create1=no
40123b6edd16SPeter Maydellcat > $TMPC << EOF
40133b6edd16SPeter Maydell#include <sys/epoll.h>
40143b6edd16SPeter Maydell
40153b6edd16SPeter Maydellint main(void)
40163b6edd16SPeter Maydell{
401719e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
401819e83f6bSPeter Maydell     * a function being called. This is necessary so that on
401919e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
402019e83f6bSPeter Maydell     * the library but not declared in the header file we will
402119e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
402219e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
402319e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
402419e83f6bSPeter Maydell     */
4025c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
40263b6edd16SPeter Maydell}
40273b6edd16SPeter MaydellEOF
40288fb03151SPeter Maydellif compile_prog "" "" ; then
40293b6edd16SPeter Maydell  epoll_create1=yes
40303b6edd16SPeter Maydellfi
40313b6edd16SPeter Maydell
4032a8fd1abaSPeter Maydell# check for sendfile support
4033a8fd1abaSPeter Maydellsendfile=no
4034a8fd1abaSPeter Maydellcat > $TMPC << EOF
4035a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4036a8fd1abaSPeter Maydell
4037a8fd1abaSPeter Maydellint main(void)
4038a8fd1abaSPeter Maydell{
4039a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4040a8fd1abaSPeter Maydell}
4041a8fd1abaSPeter MaydellEOF
4042a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4043a8fd1abaSPeter Maydell  sendfile=yes
4044a8fd1abaSPeter Maydellfi
4045a8fd1abaSPeter Maydell
404651834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
404751834341SRiku Voipiotimerfd=no
404851834341SRiku Voipiocat > $TMPC << EOF
404951834341SRiku Voipio#include <sys/timerfd.h>
405051834341SRiku Voipio
405151834341SRiku Voipioint main(void)
405251834341SRiku Voipio{
405351834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
405451834341SRiku Voipio}
405551834341SRiku VoipioEOF
405651834341SRiku Voipioif compile_prog "" "" ; then
405751834341SRiku Voipio  timerfd=yes
405851834341SRiku Voipiofi
405951834341SRiku Voipio
40609af5c906SRiku Voipio# check for setns and unshare support
40619af5c906SRiku Voipiosetns=no
40629af5c906SRiku Voipiocat > $TMPC << EOF
40639af5c906SRiku Voipio#include <sched.h>
40649af5c906SRiku Voipio
40659af5c906SRiku Voipioint main(void)
40669af5c906SRiku Voipio{
40679af5c906SRiku Voipio    int ret;
40689af5c906SRiku Voipio    ret = setns(0, 0);
40699af5c906SRiku Voipio    ret = unshare(0);
40709af5c906SRiku Voipio    return ret;
40719af5c906SRiku Voipio}
40729af5c906SRiku VoipioEOF
40739af5c906SRiku Voipioif compile_prog "" "" ; then
40749af5c906SRiku Voipio  setns=yes
40759af5c906SRiku Voipiofi
40769af5c906SRiku Voipio
407738860a03SAleksandar Markovic# clock_adjtime probe
407838860a03SAleksandar Markovicclock_adjtime=no
407938860a03SAleksandar Markoviccat > $TMPC <<EOF
408038860a03SAleksandar Markovic#include <time.h>
408138860a03SAleksandar Markovic
408238860a03SAleksandar Markovicint main(void)
408338860a03SAleksandar Markovic{
408438860a03SAleksandar Markovic    return clock_adjtime(0, 0);
408538860a03SAleksandar Markovic}
408638860a03SAleksandar MarkovicEOF
408738860a03SAleksandar Markovicclock_adjtime=no
408838860a03SAleksandar Markovicif compile_prog "" "" ; then
408938860a03SAleksandar Markovic  clock_adjtime=yes
409038860a03SAleksandar Markovicfi
409138860a03SAleksandar Markovic
40925a03cd00SAleksandar Markovic# syncfs probe
40935a03cd00SAleksandar Markovicsyncfs=no
40945a03cd00SAleksandar Markoviccat > $TMPC <<EOF
40955a03cd00SAleksandar Markovic#include <unistd.h>
40965a03cd00SAleksandar Markovic
40975a03cd00SAleksandar Markovicint main(void)
40985a03cd00SAleksandar Markovic{
40995a03cd00SAleksandar Markovic    return syncfs(0);
41005a03cd00SAleksandar Markovic}
41015a03cd00SAleksandar MarkovicEOF
41025a03cd00SAleksandar Markovicsyncfs=no
41035a03cd00SAleksandar Markovicif compile_prog "" "" ; then
41045a03cd00SAleksandar Markovic  syncfs=yes
41055a03cd00SAleksandar Markovicfi
41065a03cd00SAleksandar Markovic
4107cc8ae6deSpbrook# Check if tools are available to build documentation.
4108a25dba17SJuan Quintelaif test "$docs" != "no" ; then
410901668d98SStefan Weil  if has makeinfo && has pod2man; then
4110a25dba17SJuan Quintela    docs=yes
411183a3ab8bSJuan Quintela  else
4112a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
411321684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
411483a3ab8bSJuan Quintela    fi
4115a25dba17SJuan Quintela    docs=no
411683a3ab8bSJuan Quintela  fi
4117cc8ae6deSpbrookfi
4118cc8ae6deSpbrook
4119f514f41cSStefan Weil# Search for bswap_32 function
41206ae9a1f4SJuan Quintelabyteswap_h=no
41216ae9a1f4SJuan Quintelacat > $TMPC << EOF
41226ae9a1f4SJuan Quintela#include <byteswap.h>
41236ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
41246ae9a1f4SJuan QuintelaEOF
412552166aa0SJuan Quintelaif compile_prog "" "" ; then
41266ae9a1f4SJuan Quintela  byteswap_h=yes
41276ae9a1f4SJuan Quintelafi
41286ae9a1f4SJuan Quintela
412975f13596SStefan Weil# Search for bswap32 function
41306ae9a1f4SJuan Quintelabswap_h=no
41316ae9a1f4SJuan Quintelacat > $TMPC << EOF
41326ae9a1f4SJuan Quintela#include <sys/endian.h>
41336ae9a1f4SJuan Quintela#include <sys/types.h>
41346ae9a1f4SJuan Quintela#include <machine/bswap.h>
41356ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
41366ae9a1f4SJuan QuintelaEOF
413752166aa0SJuan Quintelaif compile_prog "" "" ; then
41386ae9a1f4SJuan Quintela  bswap_h=yes
41396ae9a1f4SJuan Quintelafi
41406ae9a1f4SJuan Quintela
4141da93a1fdSaliguori##########################################
4142e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4143c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4144e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
41453c33ea96SPaolo Bonzini    libiscsi="yes"
4146ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4147ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4148c589b249SRonnie Sahlberg  else
4149c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4150e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4151c589b249SRonnie Sahlberg    fi
4152c589b249SRonnie Sahlberg    libiscsi="no"
4153c589b249SRonnie Sahlberg  fi
4154c589b249SRonnie Sahlbergfi
4155c589b249SRonnie Sahlberg
4156c589b249SRonnie Sahlberg##########################################
41578bacde8dSNatanael Copa# Do we need libm
41588bacde8dSNatanael Copacat > $TMPC << EOF
41598bacde8dSNatanael Copa#include <math.h>
4160f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
41618bacde8dSNatanael CopaEOF
41628bacde8dSNatanael Copaif compile_prog "" "" ; then
41638bacde8dSNatanael Copa  :
41648bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
41658bacde8dSNatanael Copa  LIBS="-lm $LIBS"
41668bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
41678bacde8dSNatanael Copaelse
416876ad07a4SPeter Maydell  error_exit "libm check failed"
41698bacde8dSNatanael Copafi
41708bacde8dSNatanael Copa
41718bacde8dSNatanael Copa##########################################
4172da93a1fdSaliguori# Do we need librt
41738bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
41748bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
41758bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
41768bacde8dSNatanael Copa# function in addition.
4177da93a1fdSaliguoricat > $TMPC <<EOF
4178da93a1fdSaliguori#include <signal.h>
4179da93a1fdSaliguori#include <time.h>
41808bacde8dSNatanael Copaint main(void) {
41818bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
41828bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
41838bacde8dSNatanael Copa}
4184da93a1fdSaliguoriEOF
4185da93a1fdSaliguori
418652166aa0SJuan Quintelaif compile_prog "" "" ; then
418707ffa4bdSJuan Quintela  :
41888bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
418918e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
419018e588b1SRick Liu  LIBS="$LIBS -lrt"
419118e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4192da93a1fdSaliguorifi
4193da93a1fdSaliguori
419431ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
419578723752SPeter Maydell        "$haiku" != "yes" ; then
41966362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
41976362a53fSJuan Quintelafi
41986362a53fSJuan Quintela
4199de5071c5SBlue Swirl##########################################
4200cd4ec0b4SGerd Hoffmann# spice probe
4201cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4202cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4203cd4ec0b4SGerd Hoffmann#include <spice.h>
4204cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4205cd4ec0b4SGerd HoffmannEOF
4206710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4207710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
420865d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
420965d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4210cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4211cd4ec0b4SGerd Hoffmann    spice="yes"
4212cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4213cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
42142e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
42152e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4216cd4ec0b4SGerd Hoffmann  else
4217cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
42188efc9363SHu Tao      feature_not_found "spice" \
42198efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4220cd4ec0b4SGerd Hoffmann    fi
4221cd4ec0b4SGerd Hoffmann    spice="no"
4222cd4ec0b4SGerd Hoffmann  fi
4223cd4ec0b4SGerd Hoffmannfi
4224cd4ec0b4SGerd Hoffmann
42257b02f544SMarc-André Lureau# check for smartcard support
4226111a38b0SRobert Relyeasmartcard_cflags=""
42277b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
42287b02f544SMarc-André Lureau    if $pkg_config libcacard; then
42297b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
42307b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
42317b02f544SMarc-André Lureau        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
42327b02f544SMarc-André Lureau        libs_softmmu="$libs_softmmu $libcacard_libs"
42337b02f544SMarc-André Lureau        smartcard="yes"
4234111a38b0SRobert Relyea    else
42357b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
42367b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4237111a38b0SRobert Relyea        fi
42387b02f544SMarc-André Lureau        smartcard="no"
4239111a38b0SRobert Relyea    fi
4240111a38b0SRobert Relyeafi
4241111a38b0SRobert Relyea
42422b2325ffSGerd Hoffmann# check for libusb
42432b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
424465d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
42452b2325ffSGerd Hoffmann        libusb="yes"
4246ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4247ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
42482b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
42492b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
42502b2325ffSGerd Hoffmann    else
42512b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
42528efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
42532b2325ffSGerd Hoffmann        fi
42542b2325ffSGerd Hoffmann        libusb="no"
42552b2325ffSGerd Hoffmann    fi
42562b2325ffSGerd Hoffmannfi
42572b2325ffSGerd Hoffmann
425869354a83SHans de Goede# check for usbredirparser for usb network redirection support
425969354a83SHans de Goedeif test "$usb_redir" != "no" ; then
426065d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
426169354a83SHans de Goede        usb_redir="yes"
4262ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4263ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
426469354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
426556ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
426669354a83SHans de Goede    else
426769354a83SHans de Goede        if test "$usb_redir" = "yes"; then
426821684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
426969354a83SHans de Goede        fi
427069354a83SHans de Goede        usb_redir="no"
427169354a83SHans de Goede    fi
427269354a83SHans de Goedefi
427369354a83SHans de Goede
4274cd4ec0b4SGerd Hoffmann##########################################
4275d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4276d9840e25STomoki Sekiyama
4277d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4278d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4279690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4280d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4281d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4282690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4283d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4284d9840e25STomoki Sekiyama	  ;;
4285690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4286d9840e25STomoki Sekiyama  esac
4287d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4288d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4289d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4290d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4291d9840e25STomoki SekiyamaEOF
4292d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4293d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4294d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4295315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4296f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4297d9840e25STomoki Sekiyama  else
4298d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4299d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4300d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4301d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4302d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4303d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4304d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4305d9840e25STomoki Sekiyama    fi
4306d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4307d9840e25STomoki Sekiyama  fi
4308d9840e25STomoki Sekiyamafi
4309d9840e25STomoki Sekiyama
4310d9840e25STomoki Sekiyama##########################################
4311d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4312d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4313d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4314d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4315d9840e25STomoki Sekiyama
4316d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4317d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4318d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4319d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4320d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4321d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4322d9840e25STomoki Sekiyama    else
4323d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4324d9840e25STomoki Sekiyama    fi
4325d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4326d9840e25STomoki Sekiyama    win_sdk=""
4327d9840e25STomoki Sekiyama  fi
4328d9840e25STomoki Sekiyamafi
4329d9840e25STomoki Sekiyama
4330d9840e25STomoki Sekiyama##########################################
433150cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
433250cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
433350cbebb9SMichael Roth  cat > $TMPC << EOF
433450cbebb9SMichael Roth#include <windows.h>
433550cbebb9SMichael Roth#include <ntddscsi.h>
433650cbebb9SMichael Rothint main(void) {
433750cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
433850cbebb9SMichael Roth#error Missing required ioctl definitions
433950cbebb9SMichael Roth#endif
434050cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
434150cbebb9SMichael Roth  return addr.Lun;
434250cbebb9SMichael Roth}
434350cbebb9SMichael RothEOF
434450cbebb9SMichael Roth  if compile_prog "" "" ; then
434550cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4346c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
434750cbebb9SMichael Roth  fi
434850cbebb9SMichael Rothfi
434950cbebb9SMichael Roth
435050cbebb9SMichael Roth##########################################
43519d9e1521SGerd Hoffmann# virgl renderer probe
43529d9e1521SGerd Hoffmann
43539d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
43549d9e1521SGerd Hoffmann  cat > $TMPC << EOF
43559d9e1521SGerd Hoffmann#include <virglrenderer.h>
43569d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
43579d9e1521SGerd HoffmannEOF
43589d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
43599d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
43609d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
43619d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
43629d9e1521SGerd Hoffmann    virglrenderer="yes"
43639d9e1521SGerd Hoffmann  else
43649d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
43659d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
43669d9e1521SGerd Hoffmann    fi
43679d9e1521SGerd Hoffmann    virglrenderer="no"
43689d9e1521SGerd Hoffmann  fi
43699d9e1521SGerd Hoffmannfi
43709d9e1521SGerd Hoffmann
43719d9e1521SGerd Hoffmann##########################################
43725f6b9e8fSBlue Swirl# check if we have fdatasync
43735f6b9e8fSBlue Swirl
43745f6b9e8fSBlue Swirlfdatasync=no
43755f6b9e8fSBlue Swirlcat > $TMPC << EOF
43765f6b9e8fSBlue Swirl#include <unistd.h>
4377d1722a27SAlexandre Raymondint main(void) {
4378d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4379d1722a27SAlexandre Raymondreturn fdatasync(0);
4380d1722a27SAlexandre Raymond#else
4381e172fe11SStefan Weil#error Not supported
4382d1722a27SAlexandre Raymond#endif
4383d1722a27SAlexandre Raymond}
43845f6b9e8fSBlue SwirlEOF
43855f6b9e8fSBlue Swirlif compile_prog "" "" ; then
43865f6b9e8fSBlue Swirl    fdatasync=yes
43875f6b9e8fSBlue Swirlfi
43885f6b9e8fSBlue Swirl
438994a420b1SStefan Hajnoczi##########################################
4390e78815a5SAndreas Färber# check if we have madvise
4391e78815a5SAndreas Färber
4392e78815a5SAndreas Färbermadvise=no
4393e78815a5SAndreas Färbercat > $TMPC << EOF
4394e78815a5SAndreas Färber#include <sys/types.h>
4395e78815a5SAndreas Färber#include <sys/mman.h>
4396832ce9c2SScott Wood#include <stddef.h>
4397e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4398e78815a5SAndreas FärberEOF
4399e78815a5SAndreas Färberif compile_prog "" "" ; then
4400e78815a5SAndreas Färber    madvise=yes
4401e78815a5SAndreas Färberfi
4402e78815a5SAndreas Färber
4403e78815a5SAndreas Färber##########################################
4404e78815a5SAndreas Färber# check if we have posix_madvise
4405e78815a5SAndreas Färber
4406e78815a5SAndreas Färberposix_madvise=no
4407e78815a5SAndreas Färbercat > $TMPC << EOF
4408e78815a5SAndreas Färber#include <sys/mman.h>
4409832ce9c2SScott Wood#include <stddef.h>
4410e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4411e78815a5SAndreas FärberEOF
4412e78815a5SAndreas Färberif compile_prog "" "" ; then
4413e78815a5SAndreas Färber    posix_madvise=yes
4414e78815a5SAndreas Färberfi
4415e78815a5SAndreas Färber
4416e78815a5SAndreas Färber##########################################
44170a852417SPaul Durrant# check if we have posix_syslog
44180a852417SPaul Durrant
44190a852417SPaul Durrantposix_syslog=no
44200a852417SPaul Durrantcat > $TMPC << EOF
44210a852417SPaul Durrant#include <syslog.h>
44220a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
44230a852417SPaul DurrantEOF
44240a852417SPaul Durrantif compile_prog "" "" ; then
44250a852417SPaul Durrant    posix_syslog=yes
44260a852417SPaul Durrantfi
44270a852417SPaul Durrant
44280a852417SPaul Durrant##########################################
442994a420b1SStefan Hajnoczi# check if trace backend exists
443094a420b1SStefan Hajnoczi
44315b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
443294a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
44335b808275SLluís Vilanova  error_exit "invalid trace backends" \
44345b808275SLluís Vilanova      "Please choose supported trace backends."
443594a420b1SStefan Hajnoczifi
443694a420b1SStefan Hajnoczi
44377e24e92aSStefan Hajnoczi##########################################
44387e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
44395b808275SLluís Vilanovaif have_backend "ust"; then
44407e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4441bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
44427e24e92aSStefan Hajnocziint main(void) { return 0; }
44437e24e92aSStefan HajnocziEOF
4444c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4445bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
444689138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
44477e24e92aSStefan Hajnoczi    else
4448c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4449bf15f63cSMohamad Gebai    fi
4450bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
445189138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4452bf15f63cSMohamad Gebai    else
4453bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4454bf15f63cSMohamad Gebai    fi
4455bf15f63cSMohamad Gebai
4456bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4457bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4458bf15f63cSMohamad Gebai  else
4459bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44607e24e92aSStefan Hajnoczi  fi
44617e24e92aSStefan Hajnoczifi
4462b3d08c02SDaniel P. Berrange
4463b3d08c02SDaniel P. Berrange##########################################
4464b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44655b808275SLluís Vilanovaif have_backend "dtrace"; then
4466b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
446776ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4468b3d08c02SDaniel P. Berrange  fi
4469c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4470c276b17dSDaniel P. Berrange  if has 'stap' ; then
4471c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4472c276b17dSDaniel P. Berrange  fi
4473b3d08c02SDaniel P. Berrangefi
4474b3d08c02SDaniel P. Berrange
44757e24e92aSStefan Hajnoczi##########################################
4476519175a2SAlex Barcelo# check and set a backend for coroutine
4477d0e2fce5SAneesh Kumar K.V
44787c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
447933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
448033c53c54SDaniel P. Berrange# specific one.
44817c2acc70SPeter Maydell
44827c2acc70SPeter Maydellucontext_works=no
4483d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4484d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4485d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4486cdf84806SPeter Maydell#ifdef __stub_makecontext
4487cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4488cdf84806SPeter Maydell#endif
448975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4490d0e2fce5SAneesh Kumar K.VEOF
4491d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
44927c2acc70SPeter Maydell    ucontext_works=yes
4493d0e2fce5SAneesh Kumar K.V  fi
4494519175a2SAlex Barcelofi
44957c2acc70SPeter Maydell
44967c2acc70SPeter Maydellif test "$coroutine" = ""; then
44977c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
44987c2acc70SPeter Maydell    coroutine=win32
44997c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
45007c2acc70SPeter Maydell    coroutine=ucontext
4501519175a2SAlex Barcelo  else
45027c2acc70SPeter Maydell    coroutine=sigaltstack
45037c2acc70SPeter Maydell  fi
45047c2acc70SPeter Maydellelse
45057c2acc70SPeter Maydell  case $coroutine in
45067c2acc70SPeter Maydell  windows)
45077c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
45087c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
45097c2acc70SPeter Maydell    fi
45107c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
45117c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
45127c2acc70SPeter Maydell    coroutine=win32
45137c2acc70SPeter Maydell    ;;
45147c2acc70SPeter Maydell  ucontext)
45157c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
45167c2acc70SPeter Maydell      feature_not_found "ucontext"
45177c2acc70SPeter Maydell    fi
45187c2acc70SPeter Maydell    ;;
451933c53c54SDaniel P. Berrange  sigaltstack)
45207c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
45217c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
45227c2acc70SPeter Maydell    fi
45237c2acc70SPeter Maydell    ;;
45247c2acc70SPeter Maydell  *)
452576ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
45267c2acc70SPeter Maydell    ;;
45277c2acc70SPeter Maydell  esac
4528d0e2fce5SAneesh Kumar K.Vfi
4529d0e2fce5SAneesh Kumar K.V
453070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
453170c60c08SStefan Hajnoczi  coroutine_pool=yes
453270c60c08SStefan Hajnoczifi
453370c60c08SStefan Hajnoczi
45347d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
45357d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
45367d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
45377d992e4dSPeter Lieven  fi
45387d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
45397d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
45407d992e4dSPeter Lieven    coroutine_pool=no
45417d992e4dSPeter Lieven  fi
45427d992e4dSPeter Lievenfi
45437d992e4dSPeter Lieven
45447d992e4dSPeter Lieven
4545d0e2fce5SAneesh Kumar K.V##########################################
4546d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4547d2042378SAneesh Kumar K.V
45484e1797f9SStefan Weilopen_by_handle_at=no
4549d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4550d2042378SAneesh Kumar K.V#include <fcntl.h>
4551acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4552acc55ba8SStefan Weil# error missing definition
4553acc55ba8SStefan Weil#else
455475cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4555acc55ba8SStefan Weil#endif
4556d2042378SAneesh Kumar K.VEOF
4557d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4558d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4559d2042378SAneesh Kumar K.Vfi
4560d2042378SAneesh Kumar K.V
4561e06a765eSHarsh Prateek Bora########################################
4562e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4563e06a765eSHarsh Prateek Bora
4564e06a765eSHarsh Prateek Boralinux_magic_h=no
4565e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4566e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4567e06a765eSHarsh Prateek Boraint main(void) {
456875cafad7SStefan Weil  return 0;
4569e06a765eSHarsh Prateek Bora}
4570e06a765eSHarsh Prateek BoraEOF
4571e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4572e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4573e06a765eSHarsh Prateek Borafi
4574e06a765eSHarsh Prateek Bora
45758ab1bf12SLuiz Capitulino########################################
4576c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4577c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4578c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4579c95e3080SKevin Wolf# only a warning.
4580c95e3080SKevin Wolf#
4581c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4582c95e3080SKevin Wolf# the build doesn't fail anyway.
4583c95e3080SKevin Wolf
458406d71fa1SPeter Maydellpragma_disable_unused_but_set=no
458506d71fa1SPeter Maydellcat > $TMPC << EOF
4586e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
458706d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4588c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4589e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4590c95e3080SKevin Wolf
459106d71fa1SPeter Maydellint main(void) {
459206d71fa1SPeter Maydell    return 0;
459306d71fa1SPeter Maydell}
459406d71fa1SPeter MaydellEOF
459506d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4596cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4597c95e3080SKevin Wolfelse
4598c95e3080SKevin Wolf    werror=no
459906d71fa1SPeter Maydellfi
460006d71fa1SPeter Maydell
460106d71fa1SPeter Maydell########################################
4602541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
46033f4349dcSKevin Wolf
46043f4349dcSKevin Wolfvalgrind_h=no
46053f4349dcSKevin Wolfcat > $TMPC << EOF
46063f4349dcSKevin Wolf#include <valgrind/valgrind.h>
46073f4349dcSKevin Wolfint main(void) {
46083f4349dcSKevin Wolf  return 0;
46093f4349dcSKevin Wolf}
46103f4349dcSKevin WolfEOF
46113f4349dcSKevin Wolfif compile_prog "" "" ; then
46123f4349dcSKevin Wolf    valgrind_h=yes
46133f4349dcSKevin Wolffi
46143f4349dcSKevin Wolf
46153f4349dcSKevin Wolf########################################
46168ab1bf12SLuiz Capitulino# check if environ is declared
46178ab1bf12SLuiz Capitulino
46188ab1bf12SLuiz Capitulinohas_environ=no
46198ab1bf12SLuiz Capitulinocat > $TMPC << EOF
46208ab1bf12SLuiz Capitulino#include <unistd.h>
46218ab1bf12SLuiz Capitulinoint main(void) {
4622c075a723SBlue Swirl    environ = 0;
46238ab1bf12SLuiz Capitulino    return 0;
46248ab1bf12SLuiz Capitulino}
46258ab1bf12SLuiz CapitulinoEOF
46268ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
46278ab1bf12SLuiz Capitulino    has_environ=yes
46288ab1bf12SLuiz Capitulinofi
46298ab1bf12SLuiz Capitulino
463076a347e1SRichard Henderson########################################
463176a347e1SRichard Henderson# check if cpuid.h is usable.
463276a347e1SRichard Henderson
463376a347e1SRichard Hendersoncat > $TMPC << EOF
463476a347e1SRichard Henderson#include <cpuid.h>
463576a347e1SRichard Hendersonint main(void) {
4636774d566cSPeter Maydell    unsigned a, b, c, d;
4637774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4638774d566cSPeter Maydell
4639774d566cSPeter Maydell    if (max >= 1) {
4640774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4641774d566cSPeter Maydell    }
4642774d566cSPeter Maydell
4643774d566cSPeter Maydell    if (max >= 7) {
4644774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4645774d566cSPeter Maydell    }
4646774d566cSPeter Maydell
464776a347e1SRichard Henderson    return 0;
464876a347e1SRichard Henderson}
464976a347e1SRichard HendersonEOF
465076a347e1SRichard Hendersonif compile_prog "" "" ; then
465176a347e1SRichard Henderson    cpuid_h=yes
465276a347e1SRichard Hendersonfi
465376a347e1SRichard Henderson
46545dd89908SRichard Henderson##########################################
46555dd89908SRichard Henderson# avx2 optimization requirement check
46565dd89908SRichard Henderson#
46575dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
46585dd89908SRichard Henderson# since we won't be able to select the new routines.
46595dd89908SRichard Henderson
46605dd89908SRichard Hendersonif test $cpuid_h = yes; then
46615dd89908SRichard Henderson  cat > $TMPC << EOF
46625dd89908SRichard Henderson#pragma GCC push_options
46635dd89908SRichard Henderson#pragma GCC target("avx2")
46645dd89908SRichard Henderson#include <cpuid.h>
46655dd89908SRichard Henderson#include <immintrin.h>
46665dd89908SRichard Hendersonstatic int bar(void *a) {
46675dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
46685dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
46695dd89908SRichard Henderson}
46705dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
46715dd89908SRichard HendersonEOF
46725dd89908SRichard Henderson  if compile_object "" ; then
46735dd89908SRichard Henderson    avx2_opt="yes"
46745dd89908SRichard Henderson  fi
46755dd89908SRichard Hendersonfi
46765dd89908SRichard Henderson
4677f540166bSRichard Henderson########################################
4678f540166bSRichard Henderson# check if __[u]int128_t is usable.
4679f540166bSRichard Henderson
4680f540166bSRichard Hendersonint128=no
4681f540166bSRichard Hendersoncat > $TMPC << EOF
4682a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4683a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4684a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4685a00f66abSStefan Weil# endif
4686a00f66abSStefan Weil#endif
4687f540166bSRichard Henderson__int128_t a;
4688f540166bSRichard Henderson__uint128_t b;
4689f540166bSRichard Hendersonint main (void) {
4690f540166bSRichard Henderson  a = a + b;
4691f540166bSRichard Henderson  b = a * b;
4692464e3671SPeter Maydell  a = a * a;
4693f540166bSRichard Henderson  return 0;
4694f540166bSRichard Henderson}
4695f540166bSRichard HendersonEOF
4696f540166bSRichard Hendersonif compile_prog "" "" ; then
4697f540166bSRichard Henderson    int128=yes
4698f540166bSRichard Hendersonfi
469976a347e1SRichard Henderson
47007ebee43eSRichard Henderson#########################################
47017ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
47027ebee43eSRichard Henderson
47037ebee43eSRichard Hendersonatomic128=no
47047ebee43eSRichard Hendersonif test "$int128" = "yes"; then
47057ebee43eSRichard Henderson  cat > $TMPC << EOF
47067ebee43eSRichard Hendersonint main(void)
47077ebee43eSRichard Henderson{
47087ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
47097ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
47107ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
47117ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
47127ebee43eSRichard Henderson  return 0;
47137ebee43eSRichard Henderson}
47147ebee43eSRichard HendersonEOF
47157ebee43eSRichard Henderson  if compile_prog "" "" ; then
47167ebee43eSRichard Henderson    atomic128=yes
47177ebee43eSRichard Henderson  fi
47187ebee43eSRichard Hendersonfi
47197ebee43eSRichard Henderson
4720df79b996SRichard Henderson#########################################
4721df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4722df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4723df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4724df79b996SRichard Henderson
4725df79b996SRichard Hendersoncat > $TMPC << EOF
4726df79b996SRichard Henderson#include <stdint.h>
4727df79b996SRichard Hendersonint main(void)
4728df79b996SRichard Henderson{
4729df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4730df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4731df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4732df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4733df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4734df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4735df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4736df79b996SRichard Henderson#else
4737df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4738df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4739df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4740df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4741df79b996SRichard Henderson#endif
4742df79b996SRichard Henderson  return 0;
4743df79b996SRichard Henderson}
4744df79b996SRichard HendersonEOF
4745df79b996SRichard Hendersonif compile_prog "" "" ; then
4746df79b996SRichard Henderson  atomic64=yes
4747df79b996SRichard Hendersonfi
4748df79b996SRichard Henderson
47491e6e9acaSRichard Henderson########################################
47501e6e9acaSRichard Henderson# check if getauxval is available.
47511e6e9acaSRichard Henderson
47521e6e9acaSRichard Hendersongetauxval=no
47531e6e9acaSRichard Hendersoncat > $TMPC << EOF
47541e6e9acaSRichard Henderson#include <sys/auxv.h>
47551e6e9acaSRichard Hendersonint main(void) {
47561e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
47571e6e9acaSRichard Henderson}
47581e6e9acaSRichard HendersonEOF
47591e6e9acaSRichard Hendersonif compile_prog "" "" ; then
47601e6e9acaSRichard Henderson    getauxval=yes
47611e6e9acaSRichard Hendersonfi
47621e6e9acaSRichard Henderson
4763fd0e6053SJohn Snow########################################
4764fd0e6053SJohn Snow# check if ccache is interfering with
4765fd0e6053SJohn Snow# semantic analysis of macros
4766fd0e6053SJohn Snow
47675e4dfd3dSJohn Snowunset CCACHE_CPP2
4768fd0e6053SJohn Snowccache_cpp2=no
4769fd0e6053SJohn Snowcat > $TMPC << EOF
4770fd0e6053SJohn Snowstatic const int Z = 1;
4771fd0e6053SJohn Snow#define fn() ({ Z; })
4772fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4773fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4774fd0e6053SJohn Snow#define ID(X) (X)
4775fd0e6053SJohn Snowint main(int argc, char *argv[])
4776fd0e6053SJohn Snow{
4777fd0e6053SJohn Snow    int x = 0, y = 0;
4778fd0e6053SJohn Snow    x = ID(x);
4779fd0e6053SJohn Snow    x = fn();
4780fd0e6053SJohn Snow    fn();
4781fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4782fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4783fd0e6053SJohn Snow    return 0;
4784fd0e6053SJohn Snow}
4785fd0e6053SJohn SnowEOF
4786fd0e6053SJohn Snow
4787fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4788fd0e6053SJohn Snow    ccache_cpp2=yes
4789fd0e6053SJohn Snowfi
4790fd0e6053SJohn Snow
4791b553a042SJohn Snow#################################################
4792b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4793b553a042SJohn Snow
4794b553a042SJohn Snowif test "$fortify_source" != "no"; then
4795b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4796b553a042SJohn Snow    fortify_source="no";
4797e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4798cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4799b553a042SJohn Snow    fortify_source="no";
4800b553a042SJohn Snow  else
4801b553a042SJohn Snow    fortify_source="yes"
4802b553a042SJohn Snow  fi
4803b553a042SJohn Snowfi
4804b553a042SJohn Snow
4805d2042378SAneesh Kumar K.V##########################################
4806277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4807277abf15SJan Vesely
4808277abf15SJan Veselyhave_fsxattr=no
4809277abf15SJan Veselycat > $TMPC << EOF
4810277abf15SJan Vesely#include <linux/fs.h>
4811277abf15SJan Veselystruct fsxattr foo;
4812277abf15SJan Veselyint main(void) {
4813277abf15SJan Vesely  return 0;
4814277abf15SJan Vesely}
4815277abf15SJan VeselyEOF
4816277abf15SJan Veselyif compile_prog "" "" ; then
4817277abf15SJan Vesely    have_fsxattr=yes
4818277abf15SJan Veselyfi
4819277abf15SJan Vesely
4820b66e10e4SPeter Maydell##########################################
4821b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4822575b22b1SLaurent Vivierhave_rtnetlink=no
4823575b22b1SLaurent Viviercat > $TMPC << EOF
4824575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4825575b22b1SLaurent Vivierint main(void) {
4826575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4827575b22b1SLaurent Vivier}
4828575b22b1SLaurent VivierEOF
4829575b22b1SLaurent Vivierif compile_prog "" "" ; then
4830575b22b1SLaurent Vivier    have_rtnetlink=yes
4831575b22b1SLaurent Vivierfi
4832575b22b1SLaurent Vivier
48336a02c806SStefan Hajnoczi##########################################
48346a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
48356a02c806SStefan Hajnoczihave_af_vsock=no
48366a02c806SStefan Hajnoczicat > $TMPC << EOF
48376a02c806SStefan Hajnoczi#include <errno.h>
48386a02c806SStefan Hajnoczi#include <sys/types.h>
48396a02c806SStefan Hajnoczi#include <sys/socket.h>
48406a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
48416a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
48426a02c806SStefan Hajnoczi#endif
48436a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
48446a02c806SStefan Hajnocziint main(void) {
48456a02c806SStefan Hajnoczi    int sock, ret;
48466a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
48476a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
48486a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
48496a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
48506a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
48516a02c806SStefan Hajnoczi        return 0;
48526a02c806SStefan Hajnoczi    }
48536a02c806SStefan Hajnoczi    return -1;
48546a02c806SStefan Hajnoczi}
48556a02c806SStefan HajnocziEOF
48566a02c806SStefan Hajnocziif compile_prog "" "" ; then
48576a02c806SStefan Hajnoczi    have_af_vsock=yes
48586a02c806SStefan Hajnoczifi
48596a02c806SStefan Hajnoczi
4860f0d92b56SLongpeng(Mike)##########################################
4861f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
4862f0d92b56SLongpeng(Mike)hava_afalg=no
4863f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
4864f0d92b56SLongpeng(Mike)#include <errno.h>
4865f0d92b56SLongpeng(Mike)#include <sys/types.h>
4866f0d92b56SLongpeng(Mike)#include <sys/socket.h>
4867f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
4868f0d92b56SLongpeng(Mike)int main(void) {
4869f0d92b56SLongpeng(Mike)    int sock;
4870f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
4871f0d92b56SLongpeng(Mike)    return sock;
4872f0d92b56SLongpeng(Mike)}
4873f0d92b56SLongpeng(Mike)EOF
4874f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4875f0d92b56SLongpeng(Mike)    have_afalg=yes
4876f0d92b56SLongpeng(Mike)fi
4877f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4878f0d92b56SLongpeng(Mike)then
4879f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4880f0d92b56SLongpeng(Mike)    then
4881f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4882f0d92b56SLongpeng(Mike)    fi
4883f0d92b56SLongpeng(Mike)fi
4884f0d92b56SLongpeng(Mike)
4885f0d92b56SLongpeng(Mike)
48866969ec6cSJames Clarke#################################################
48876969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
48886969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
48896969ec6cSJames Clarke# given. It does no harm to give it on other
48906969ec6cSJames Clarke# platforms too.
48916969ec6cSJames Clarke
48926969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
48936969ec6cSJames Clarke#       contains -Wmissing-prototypes
48946969ec6cSJames Clarkecat > $TMPC << EOF
48956969ec6cSJames Clarkeextern int foo(void);
48966969ec6cSJames Clarkeint foo(void) { return 0; }
48976969ec6cSJames ClarkeEOF
48986969ec6cSJames Clarkeif ! compile_object ""; then
48996969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
49006969ec6cSJames Clarkefi
49017ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
49027ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
49037ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
49047ecf44a5SPaolo Bonzini    break
49057ecf44a5SPaolo Bonzini  fi
49067ecf44a5SPaolo Bonzinidone
49077ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
49087ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
49096969ec6cSJames Clarkefi
49106969ec6cSJames Clarke
4911277abf15SJan Vesely##########################################
49124d04351fSChristopher Covington# check for sysmacros.h
49134d04351fSChristopher Covington
49144d04351fSChristopher Covingtonhave_sysmacros=no
49154d04351fSChristopher Covingtoncat > $TMPC << EOF
49164d04351fSChristopher Covington#include <sys/sysmacros.h>
49174d04351fSChristopher Covingtonint main(void) {
49184d04351fSChristopher Covington    return makedev(0, 0);
49194d04351fSChristopher Covington}
49204d04351fSChristopher CovingtonEOF
49214d04351fSChristopher Covingtonif compile_prog "" "" ; then
49224d04351fSChristopher Covington    have_sysmacros=yes
49234d04351fSChristopher Covingtonfi
49244d04351fSChristopher Covington
49254d04351fSChristopher Covington##########################################
4926da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
4927da92c3ffSAshish Mittal# Check if libvxhs is installed
4928da92c3ffSAshish Mittal
4929da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
4930da92c3ffSAshish Mittal  cat > $TMPC <<EOF
4931da92c3ffSAshish Mittal#include <stdint.h>
4932da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
4933da92c3ffSAshish Mittal
4934da92c3ffSAshish Mittalvoid *vxhs_callback;
4935da92c3ffSAshish Mittal
4936da92c3ffSAshish Mittalint main(void) {
4937da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
4938da92c3ffSAshish Mittal    return 0;
4939da92c3ffSAshish Mittal}
4940da92c3ffSAshish MittalEOF
4941da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
4942da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
4943da92c3ffSAshish Mittal    vxhs=yes
4944da92c3ffSAshish Mittal  else
4945da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
4946da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
4947da92c3ffSAshish Mittal    fi
4948da92c3ffSAshish Mittal    vxhs=no
4949da92c3ffSAshish Mittal  fi
4950da92c3ffSAshish Mittalfi
4951da92c3ffSAshish Mittal
4952da92c3ffSAshish Mittal##########################################
495349e00a18SAndreas Grapentin# check for _Static_assert()
495449e00a18SAndreas Grapentin
495549e00a18SAndreas Grapentinhave_static_assert=no
495649e00a18SAndreas Grapentincat > $TMPC << EOF
495749e00a18SAndreas Grapentin_Static_assert(1, "success");
495849e00a18SAndreas Grapentinint main(void) {
495949e00a18SAndreas Grapentin    return 0;
496049e00a18SAndreas Grapentin}
496149e00a18SAndreas GrapentinEOF
496249e00a18SAndreas Grapentinif compile_prog "" "" ; then
496349e00a18SAndreas Grapentin    have_static_assert=yes
496449e00a18SAndreas Grapentinfi
496549e00a18SAndreas Grapentin
496649e00a18SAndreas Grapentin##########################################
4967e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
4968e674605fSTomáš Golembiovský
4969e674605fSTomáš Golembiovskýhave_utmpx=no
4970e674605fSTomáš Golembiovskýcat > $TMPC << EOF
4971e674605fSTomáš Golembiovský#include <utmpx.h>
4972e674605fSTomáš Golembiovskýstruct utmpx user_info;
4973e674605fSTomáš Golembiovskýint main(void) {
4974e674605fSTomáš Golembiovský    return 0;
4975e674605fSTomáš Golembiovský}
4976e674605fSTomáš GolembiovskýEOF
4977e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
4978e674605fSTomáš Golembiovský    have_utmpx=yes
4979e674605fSTomáš Golembiovskýfi
4980e674605fSTomáš Golembiovský
4981e674605fSTomáš Golembiovský##########################################
4982e86ecd4bSJuan Quintela# End of CC checks
4983e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4984e86ecd4bSJuan Quintela
49851d728c39SBlue Swirlif test "$gcov" = "yes" ; then
49861d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
49871d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4988b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4989e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4990ce278618SPeter Maydellelif test "$debug" = "no"; then
4991ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
4992e86ecd4bSJuan Quintelafi
4993a316e378SJuan Quintela
49946542aa9cSPeter Lieven##########################################
49956542aa9cSPeter Lieven# Do we have libnfs
49966542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
4997b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
49986542aa9cSPeter Lieven    libnfs="yes"
49996542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
50006542aa9cSPeter Lieven  else
50016542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
50028efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
50036542aa9cSPeter Lieven    fi
50046542aa9cSPeter Lieven    libnfs="no"
50056542aa9cSPeter Lieven  fi
50066542aa9cSPeter Lievenfi
50071d728c39SBlue Swirl
50086ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
50096ca026cbSPeter Maydellif test "$werror" = "yes"; then
50106ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
50116ca026cbSPeter Maydellfi
50126ca026cbSPeter Maydell
5013e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5014e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
50151156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5016e86ecd4bSJuan Quintela    fi
5017e86ecd4bSJuan Quintelafi
5018e86ecd4bSJuan Quintela
501994dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
502094dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
502194dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
502294dd53c5SGerd Hoffmannelse
502394dd53c5SGerd Hoffmann    POD2MAN="pod2man"
502494dd53c5SGerd Hoffmannfi
502594dd53c5SGerd Hoffmann
5026952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5027952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5028952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5029e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5030952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5031952afb71SBlue Swirl        fi
5032952afb71SBlue Swirl    done
5033952afb71SBlue Swirlfi
5034952afb71SBlue Swirl
503510ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5036e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5037528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5038834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
50395a67135aSbellard
5040e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5041e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5042e0580342SKamil Rytarowski  ivshmem=yes
5043e0580342SKamil Rytarowskifi
5044e0580342SKamil Rytarowski
50454b1c11fdSDaniel P. Berrangetools=""
50464b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5047ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
50484b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
50494b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5050b1449edbSKamil Rytarowski  fi
5051b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5052a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
50534b1c11fdSDaniel P. Berrange  fi
50544b1c11fdSDaniel P. Berrangefi
50554b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5056983eef5aSMeador Inge  if test "$virtfs" != no ; then
5057be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
5058983eef5aSMeador Inge      virtfs=yes
505917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5060983eef5aSMeador Inge    else
5061983eef5aSMeador Inge      if test "$virtfs" = yes; then
50623f3b5388SStefan Weil        error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
5063983eef5aSMeador Inge      fi
506417500370SAndreas Färber      virtfs=no
5065983eef5aSMeador Inge    fi
506617bff52bSM. Mohan Kumar  fi
5067d138cee9SMichael Rothfi
50689d6bc27bSMichael Roth
50699d6bc27bSMichael Roth# Probe for guest agent support/options
50709d6bc27bSMichael Roth
5071e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5072b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5073fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5074e8ef31a3SMichael Tokarev      guest_agent=yes
5075e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5076e8ef31a3SMichael Tokarev      guest_agent=no
5077e8ef31a3SMichael Tokarev  else
5078e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5079ca35f780SPaolo Bonzini  fi
50804b1c11fdSDaniel P. Berrangefi
5081ca35f780SPaolo Bonzini
50829d6bc27bSMichael Roth# Guest agent Window MSI  package
50839d6bc27bSMichael Roth
50849d6bc27bSMichael Rothif test "$guest_agent" != yes; then
50859d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
50869d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
50879d6bc27bSMichael Roth  fi
50889d6bc27bSMichael Roth  guest_agent_msi=no
50899d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
50909d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50919d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
50929d6bc27bSMichael Roth  fi
50939d6bc27bSMichael Roth  guest_agent_msi=no
50949d6bc27bSMichael Rothelif ! has wixl; then
50959d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50969d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
50979d6bc27bSMichael Roth  fi
50989d6bc27bSMichael Roth  guest_agent_msi=no
50991a34904eSMichael Rothelse
51001a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
51011a34904eSMichael Roth  # disabled explicitly
51021a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
51031a34904eSMichael Roth    guest_agent_msi=yes
51041a34904eSMichael Roth  fi
51059d6bc27bSMichael Rothfi
51069d6bc27bSMichael Roth
51071a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
51089d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
51099d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
51109d6bc27bSMichael Roth  fi
51119d6bc27bSMichael Roth
51129d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
51139d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
51149d6bc27bSMichael Roth  fi
51159d6bc27bSMichael Roth
51169d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
51179d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
51189d6bc27bSMichael Roth  fi
51199d6bc27bSMichael Roth
51209d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
512189138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
51229d6bc27bSMichael Roth  fi
51239d6bc27bSMichael Roth
512489138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
51259d6bc27bSMichael Roth
51269d6bc27bSMichael Roth  case "$cpu" in
51279d6bc27bSMichael Roth  x86_64)
51289d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
51299d6bc27bSMichael Roth    ;;
51309d6bc27bSMichael Roth  i386)
51319d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
51329d6bc27bSMichael Roth    ;;
51339d6bc27bSMichael Roth  *)
51349d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
51359d6bc27bSMichael Roth    ;;
51369d6bc27bSMichael Roth  esac
51379d6bc27bSMichael Rothfi
51389d6bc27bSMichael Roth
5139ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5140ca35f780SPaolo Bonziniroms=
5141ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5142ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5143ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5144e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5145e57218b6SPeter Maydell    # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5146e57218b6SPeter Maydell    # variant; and Windows uses i386pe.
5147e57218b6SPeter Maydell    for emu in elf_i386 elf_i386_fbsd i386pe; do
5148e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5149e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5150ca35f780SPaolo Bonzini            roms="optionrom"
5151e57218b6SPeter Maydell            break
5152e57218b6SPeter Maydell        fi
5153e57218b6SPeter Maydell    done
5154ca35f780SPaolo Bonzinifi
5155d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
515639ac8455SDavid Gibson  roms="$roms spapr-rtas"
515739ac8455SDavid Gibsonfi
5158ca35f780SPaolo Bonzini
51599933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
51609933c305SChristian Borntraeger  roms="$roms s390-ccw"
51619933c305SChristian Borntraegerfi
51629933c305SChristian Borntraeger
5163964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
516492fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5165964c6fa1SRichard Henderson  textseg_addr=
5166964c6fa1SRichard Henderson  case "$cpu" in
5167479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5168479eb121SRichard Henderson      # ??? Rationale for choosing this address
5169964c6fa1SRichard Henderson      textseg_addr=0x60000000
5170964c6fa1SRichard Henderson      ;;
5171964c6fa1SRichard Henderson    mips)
5172479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5173479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5174479eb121SRichard Henderson      textseg_addr=0x60000000
5175964c6fa1SRichard Henderson      ;;
5176964c6fa1SRichard Henderson  esac
5177964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5178964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5179964c6fa1SRichard Henderson    int main(void) { return 0; }
5180964c6fa1SRichard HendersonEOF
5181964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5182964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5183964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5184964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5185964c6fa1SRichard Henderson      # at least.
518692fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
518792fe2ba8SPeter Maydell        error_exit \
518892fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
518992fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
519092fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
519192fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
519292fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
519392fe2ba8SPeter Maydell            "--disable-user option to configure."
519492fe2ba8SPeter Maydell      fi
519592fe2ba8SPeter Maydell
5196964c6fa1SRichard Henderson      $ld --verbose | sed \
5197964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5198964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5199964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5200964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5201964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5202964c6fa1SRichard Henderson    fi
5203964c6fa1SRichard Henderson  fi
5204964c6fa1SRichard Hendersonfi
5205964c6fa1SRichard Henderson
520611cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
520711cde1c8SBruno 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.
520811cde1c8SBruno Dominguezif has $cxx; then
520911cde1c8SBruno Dominguez    cat > $TMPC <<EOF
521011cde1c8SBruno Dominguezint c_function(void);
521111cde1c8SBruno Dominguezint main(void) { return c_function(); }
521211cde1c8SBruno DominguezEOF
521311cde1c8SBruno Dominguez
521411cde1c8SBruno Dominguez    compile_object
521511cde1c8SBruno Dominguez
521611cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
521711cde1c8SBruno Dominguezextern "C" {
521811cde1c8SBruno Dominguez   int c_function(void);
521911cde1c8SBruno Dominguez}
522011cde1c8SBruno Dominguezint c_function(void) { return 42; }
522111cde1c8SBruno DominguezEOF
522211cde1c8SBruno Dominguez
522311cde1c8SBruno Dominguez    update_cxxflags
522411cde1c8SBruno Dominguez
522511cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
522611cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
522711cde1c8SBruno Dominguez        :
522811cde1c8SBruno Dominguez    else
522911cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
523011cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
523111cde1c8SBruno Dominguez        cxx=
523211cde1c8SBruno Dominguez    fi
523311cde1c8SBruno Dominguezelse
523411cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
523511cde1c8SBruno Dominguez    cxx=
523611cde1c8SBruno Dominguezfi
523711cde1c8SBruno Dominguez
523802d34f62SCole Robinsonecho_version() {
523902d34f62SCole Robinson    if test "$1" = "yes" ; then
524002d34f62SCole Robinson        echo "($2)"
524102d34f62SCole Robinson    fi
524202d34f62SCole Robinson}
524302d34f62SCole Robinson
524450e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
524550e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
524650e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
52475ca9388aSGerd Hoffmann
52487d13299dSbellardecho "Install prefix    $prefix"
524989138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
525089138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
525189138857SStefan Weilecho "library directory $(eval echo $libdir)"
525289138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
525389138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
525489138857SStefan Weilecho "include directory $(eval echo $includedir)"
525589138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
525611d9f695Sbellardif test "$mingw32" = "no" ; then
525789138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
525889138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
525943ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
52605a699bbbSLaszlo Ersekelse
52615a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5262d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
526311d9f695Sbellardfi
52645a67135aSbellardecho "Source path       $source_path"
52657d13299dSbellardecho "C compiler        $cc"
526683469015Sbellardecho "Host C compiler   $host_cc"
526783f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
52683c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
526945d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
52700c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5271a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
52720c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
52737d13299dSbellardecho "make              $make"
52746a882643Spbrookecho "install           $install"
5275c886edfbSBlue Swirlecho "python            $python"
5276e2d8830eSBradif test "$slirp" = "yes" ; then
5277e2d8830eSBrad    echo "smbd              $smbd"
5278e2d8830eSBradfi
527917969268SFam Zhengecho "module support    $modules"
5280a98fd896Sbellardecho "host CPU          $cpu"
5281de83cd02Sbellardecho "host big endian   $bigendian"
528297a847bcSbellardecho "target list       $target_list"
52837d13299dSbellardecho "gprof enabled     $gprof"
528403b4fe7dSaliguoriecho "sparse enabled    $sparse"
52851625af87Saliguoriecho "strip binaries    $strip_opt"
528605c2a3e7Sbellardecho "profiler          $profiler"
528743ce4dfeSbellardecho "static build      $static"
52885b0753e0Sbellardif test "$darwin" = "yes" ; then
52895b0753e0Sbellard    echo "Cocoa support     $cocoa"
52905b0753e0Sbellardfi
5291e2134eb9SGerd Hoffmannecho "pixman            $pixman"
529289138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
529389138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5294925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
529589138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5296a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5297ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5298b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
529991bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
530037788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
530189138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5302fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
53039a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
53044d3b6f6eSbalrogecho "curses support    $curses"
53059d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5306769ce76dSAlexander Grafecho "curl support      $curl"
530767b915a5Sbellardecho "mingw32 support   $mingw32"
53080c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5309b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5310b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5311983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5312821601eaSJes Sorensenecho "VNC support       $vnc"
5313821601eaSJes Sorensenif test "$vnc" = "yes" ; then
53142f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
53152f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5316efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5317821601eaSJes Sorensenfi
53183142255cSblueswir1if test -n "$sparc_cpu"; then
53193142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
53203142255cSblueswir1fi
5321e37630caSaliguoriecho "xen support       $xen"
53223996e85cSPaul Durrantif test "$xen" = "yes" ; then
53233996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
532464a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
53253996e85cSPaul Durrantfi
53262e4d9fb1Saurel32echo "brlapi support    $brlapi"
5327a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5328a25dba17SJuan Quintelaecho "Documentation     $docs"
532940d6444eSAvi Kivityecho "PIE               $pie"
53308a16d273Sthsecho "vde support       $vde"
533158952137SVincenzo Maffioneecho "netmap support    $netmap"
53325c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5333758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
533477755340Sthsecho "Install blobs     $blobs"
5335b31a0277SJuan Quintelaecho "KVM support       $kvm"
5336b0cb0a66SVincent Palatinecho "HAX support       $hax"
5337b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5338b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5339b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
53409195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5341b3f6ea7eSPaolo Bonzinifi
5342b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5343f652e6afSaurel32echo "fdt support       $fdt"
5344ceb42de8Saliguoriecho "preadv support    $preadv"
53455f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5346e78815a5SAndreas Färberecho "madvise           $madvise"
5347e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
534847e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5349d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
53505e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5351fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5352e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
53535b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5354713572a7SMarc-André Lureauif have_backend "simple"; then
53559410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5356e00e36fbSStefan Weilfi
535789138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5358f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5359dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
53607b02f544SMarc-André Lureauecho "smartcard support $smartcard"
53612b2325ffSGerd Hoffmannecho "libusb            $libusb"
536269354a83SHans de Goedeecho "usb net redir     $usb_redir"
5363da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5364014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5365c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
53666542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5367d138cee9SMichael Rothecho "build guest agent $guest_agent"
5368d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
536950cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
53704c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5371f794573eSEduardo Otuboecho "seccomp support   $seccomp"
53727c2acc70SPeter Maydellecho "coroutine backend $coroutine"
537370c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
53747d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5375f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5376eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
53771d728c39SBlue Swirlecho "gcov              $gcov_tool"
53781d728c39SBlue Swirlecho "gcov enabled      $gcov"
5379ab214c29SStefan Bergerecho "TPM support       $tpm"
53800a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
53813b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
53823556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5383ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5384607dacd0Sqiaonuohanecho "lzo support       $lzo"
5385607dacd0Sqiaonuohanecho "snappy support    $snappy"
53866b383c08SPeter Wuecho "bzip2 support     $bzip2"
5387a99d57bbSWanlong Gaoecho "NUMA host support $numa"
53882847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
53897b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
539099f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5391a6b1d4c0SChanglong Xieecho "replication support $replication"
5392da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
539367b915a5Sbellard
53941ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
539524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5396e8cd23deSbellardfi
539797a847bcSbellard
5398898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5399898be3e0SPeter Maydell    echo
5400898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5401898be3e0SPeter Maydell    echo
5402898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5403898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5404898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5405898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5406898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5407898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5408898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5409898be3e0SPeter Maydellfi
5410898be3e0SPeter Maydell
5411898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5412898be3e0SPeter Maydell    echo
5413898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5414898be3e0SPeter Maydell    echo
5415c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5416c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5417898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5418898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5419898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5420898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5421898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5422898be3e0SPeter Maydellfi
5423898be3e0SPeter Maydell
542498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
542597a847bcSbellard
5426dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5427dbd99ae3SStefan Weil
542898ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
542998ec69acSJuan Quintelaecho >> $config_host_mak
543098ec69acSJuan Quintela
5431e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
543299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
543399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
54343aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
54358bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
54360f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
543799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
543899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
543922d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
54409afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
54419afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5442e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
54435a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5444785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
54455a699bbbSLaszlo Ersekfi
5446f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5447f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
544811cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5449f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5450834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5451f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5452804edf29SJuan Quintela
545398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5454727e5283SPaolo Bonzini
5455f8393946Saurel32if test "$debug_tcg" = "yes" ; then
54562358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5457f8393946Saurel32fi
54581625af87Saliguoriif test "$strip_opt" = "yes" ; then
545952ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
54601625af87Saliguorifi
54617d13299dSbellardif test "$bigendian" = "yes" ; then
5462e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
546397a847bcSbellardfi
546467b915a5Sbellardif test "$mingw32" = "yes" ; then
546598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
546689138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
54679fe6de94SBlue Swirl  version_major=${rc_version%%.*}
54689fe6de94SBlue Swirl  rc_version=${rc_version#*.}
54699fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
54709fe6de94SBlue Swirl  rc_version=${rc_version#*.}
54719fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
54729fe6de94SBlue Swirl  version_micro=0
54739fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
54749fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5475d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5476d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5477f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5478d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5479d9840e25STomoki Sekiyama  fi
548050cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
548150cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
548250cbebb9SMichael Roth  fi
54831a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
54849dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
54859dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
54869dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
54879dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
54889dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
54899dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
54909dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
54919dacf32dSYossi Hindin  fi
5492210fa556Spbrookelse
549335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5494210fa556Spbrookfi
5495128ab2ffSblueswir1
5496dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5497dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5498dffcb71cSMark McLoughlinfi
5499dffcb71cSMark McLoughlin
550083fb7adfSbellardif test "$darwin" = "yes" ; then
550198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
550283fb7adfSbellardfi
5503b29fe3edSmalc
5504ec530c81Sbellardif test "$solaris" = "yes" ; then
550598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5506ec530c81Sbellardfi
5507179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5508179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5509179cf400SAndreas Färberfi
551097a847bcSbellardif test "$static" = "yes" ; then
551198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
551297a847bcSbellardfi
55131ba16968SStefan Weilif test "$profiler" = "yes" ; then
55142358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
551505c2a3e7Sbellardfi
5516c20709aaSbellardif test "$slirp" = "yes" ; then
551798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5518e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5519c20709aaSbellardfi
55208a16d273Sthsif test "$vde" = "yes" ; then
552198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
55228a16d273Sthsfi
552358952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
552458952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
552558952137SVincenzo Maffionefi
5526015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5527015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5528015a33bdSGongleifi
552947e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
553047e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
553147e98658SCorey Bryantfi
55322358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
55330c58ac1cSmalcfor drv in $audio_drv_list; do
553489138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
553598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
55360c58ac1cSmalcdone
553767f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
553867f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
553967f86e8eSJuan Quintelafi
5540d5631638Smalcif test "$audio_win_int" = "yes" ; then
5541d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5542d5631638Smalcfi
5543b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5544b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5545821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5546821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5547821601eaSJes Sorensenfi
55482f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
554998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
55502f9606b3Saliguorifi
5551821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
55522f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
55532f6f5c7aSCorentin Charyfi
5554821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5555efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5556efe556adSCorentin Charyfi
555776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
55582358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
555976655d6dSaliguorifi
5560dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5561dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5562dce512deSChristoph Hellwigfi
556389138857SStefan Weilqemu_version=$(head $source_path/VERSION)
556498ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
55652358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
556698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
556798ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5568a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
556998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5570cc8ae6deSpbrookfi
557117969268SFam Zhengif test "$modules" = "yes"; then
5572e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5573e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
557489138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
557517969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
557617969268SFam Zhengfi
55771ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
557898ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5579a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
55808ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
558149ecc3faSbellardfi
558249ecc3faSbellardif test "$cocoa" = "yes" ; then
558398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
558449ecc3faSbellardfi
55854d3b6f6eSbalrogif test "$curses" = "yes" ; then
558698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5587ab4e5602SJan Kiszkafi
5588099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
55892358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5590099d6b0fSRiku Voipiofi
559140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
559240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
559340ff6d7eSKevin Wolffi
55943ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
55952358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
55963ce34dfbSvibisreenivasanfi
5597c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5598c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5599c2882b96SRiku Voipiofi
5600751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5601751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5602751bcc39SMarc-André Lureaufi
5603d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5604d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5605d0927938SUlrich Hechtfi
56063d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
56073d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
56083d4fa43eSKusanagi Kouichifi
5609b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5610b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5611b953f075SDenis V. Lunevfi
5612ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5613ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5614ed911435SKevin Wolffi
5615c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5616c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5617c727f47dSPeter Maydellfi
5618dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5619dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5620dace20dcSPeter Maydellfi
5621d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5622d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5623d0927938SUlrich Hechtfi
56244e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
56254e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
56264e0c6529SAlex Blighfi
5627cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5628cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5629cd758dd0SAlex Blighfi
56303b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
56313b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
56323b6edd16SPeter Maydellfi
56333b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
56343b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
56353b6edd16SPeter Maydellfi
5636a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5637a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5638a8fd1abaSPeter Maydellfi
563951834341SRiku Voipioif test "$timerfd" = "yes" ; then
564051834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
564151834341SRiku Voipiofi
56429af5c906SRiku Voipioif test "$setns" = "yes" ; then
56439af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
56449af5c906SRiku Voipiofi
564538860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
564638860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
564738860a03SAleksandar Markovicfi
56485a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
56495a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
56505a03cd00SAleksandar Markovicfi
56513b3f24adSaurel32if test "$inotify" = "yes" ; then
56522358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
56533b3f24adSaurel32fi
5654c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5655c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5656c05c7a73SRiku Voipiofi
56576ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
56586ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
56596ae9a1f4SJuan Quintelafi
56606ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
56616ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
56626ae9a1f4SJuan Quintelafi
5663769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5664d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5665b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
56666ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5667769ce76dSAlexander Graffi
56682e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
566998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
56702e4d9fb1Saurel32fi
5671fb599c9aSbalrogif test "$bluez" = "yes" ; then
567298ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5673ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5674fb599c9aSbalrogfi
5675d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
56769d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
56779d41401bSMichael S. Tsirkinfi
5678a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5679a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5680a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5681a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5682014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5683925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5684925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5685925a0400SGerd Hoffmann  fi
5686bbbf9bfbSStefan Weilfi
5687a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5688ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5689ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5690ddbb0d09SDaniel P. Berrangefi
5691b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5692b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5693b917da4cSDaniel P. Berrangefi
569491bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
569591bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
56961f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
56971f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
56981f923c70SLongpeng(Mike)  fi
569937788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
570037788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
570137788f25SDaniel P. Berrange  fi
570262893b67SDaniel P. Berrangefi
570391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
570491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5705becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5706fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5707fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5708fff2f982SDaniel P. Berrange  fi
5709ed754746SDaniel P. Berrangefi
57109a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
57119a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
57129a2fd434SDaniel P. Berrangefi
5713559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5714559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5715559607eaSDaniel P. Berrangefi
57166b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
57176b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
57186b39b063SEric Blakefi
5719277abf15SJan Vesely
5720277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5721277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5722277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5723277abf15SJan Vesely# if this macro is set.
5724277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5725277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5726277abf15SJan Veselyfi
5727bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5728bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5729a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5730a4ccabcfSAnthony Liguorifi
57319d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
57329d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
57339d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
57349d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
57359d9e1521SGerd Hoffmannfi
5736e37630caSaliguoriif test "$xen" = "yes" ; then
57376dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5738d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
573964a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
574064a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
574164a7ad6fSIan Campbell  fi
5742e37630caSaliguorifi
57435c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
57445c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
57455c6c3a6cSChristoph Hellwigfi
5746758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5747758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5748758e8e38SVenkateswararao Jujjuri (JV)fi
57494f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
57504f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
57514f26f2b6SAvi Kivityfi
5752983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5753758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5754758e8e38SVenkateswararao Jujjuri (JV)fi
57555e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
57565e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
57575e9be92dSNicholas Bellingerfi
5758e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
575903ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
576003ce5744SNikolay Nikolaevfi
5761fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5762fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5763fc0b9b0eSStefan Hajnoczifi
5764e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5765e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5766e6a74868SMarc-André Lureaufi
576777755340Sthsif test "$blobs" = "yes" ; then
576898ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
576977755340Sthsfi
5770bf9298b9Saliguoriif test "$iovec" = "yes" ; then
57712358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5772bf9298b9Saliguorifi
5773ceb42de8Saliguoriif test "$preadv" = "yes" ; then
57742358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5775ceb42de8Saliguorifi
5776f652e6afSaurel32if test "$fdt" = "yes" ; then
57773f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5778f652e6afSaurel32fi
5779dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5780dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5781dcc38d1cSMarcelo Tosattifi
5782b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
5783b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
57849195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
57859195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
57869195b2c2SStefan Weil  fi
5787b3f6ea7eSPaolo Bonzinifi
57885f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
57895f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
57905f6b9e8fSBlue Swirlfi
5791e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5792e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5793e78815a5SAndreas Färberfi
5794e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5795e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5796e78815a5SAndreas Färberfi
579797a847bcSbellard
5798cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5799cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5800cd4ec0b4SGerd Hoffmannfi
5801cd4ec0b4SGerd Hoffmann
58027b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
58037b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5804111a38b0SRobert Relyeafi
5805111a38b0SRobert Relyea
58062b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
58072b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
58082b2325ffSGerd Hoffmannfi
58092b2325ffSGerd Hoffmann
581069354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
581169354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
581269354a83SHans de Goedefi
581369354a83SHans de Goede
5814da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5815da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5816da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5817014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5818014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5819014cb152SGerd Hoffmann  fi
582020ff075bSMichael Wallefi
582120ff075bSMichael Walle
582299f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
582399f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
582499f2dbd3SLiang Lifi
582599f2dbd3SLiang Li
5826607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5827607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5828607dacd0Sqiaonuohanfi
5829607dacd0Sqiaonuohan
5830607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5831607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5832607dacd0Sqiaonuohanfi
5833607dacd0Sqiaonuohan
58346b383c08SPeter Wuif test "$bzip2" = "yes" ; then
58356b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
58366b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
58376b383c08SPeter Wufi
58386b383c08SPeter Wu
5839c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5840d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
58416ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
58426ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5843c589b249SRonnie Sahlbergfi
5844c589b249SRonnie Sahlberg
58456542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
58464be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
58474be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
58486542aa9cSPeter Lievenfi
58496542aa9cSPeter Lieven
5850f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5851f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5852f794573eSEduardo Otubofi
5853f794573eSEduardo Otubo
585483fb7adfSbellard# XXX: suppress that
58557d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
58562358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
58577d3505c5Sbellardfi
58587d3505c5Sbellard
58594d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
58604d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
58614d9310f4SDaniel P. Berrangefi
58623556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
58633556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
58643556c233SPaolo Bonzinifi
5865f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5866d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
58676ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
58686ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5869f27aaf4bSChristian Brunnerfi
587020ff6c80SAnthony Liguori
58717c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
587270c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
587370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
587470c60c08SStefan Hajnoczielse
587570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
587670c60c08SStefan Hajnoczifi
5877d0e2fce5SAneesh Kumar K.V
58787d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
58797d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
58807d992e4dSPeter Lievenfi
58817d992e4dSPeter Lieven
5882f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5883f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5884f0d92b56SLongpeng(Mike)fi
5885f0d92b56SLongpeng(Mike)
5886d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5887d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5888d2042378SAneesh Kumar K.Vfi
5889d2042378SAneesh Kumar K.V
5890e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5891e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5892e06a765eSHarsh Prateek Borafi
5893e06a765eSHarsh Prateek Bora
5894cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5895cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
589606d71fa1SPeter Maydellfi
589706d71fa1SPeter Maydell
58983f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
58993f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
59003f4349dcSKevin Wolffi
59013f4349dcSKevin Wolf
59028ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
59038ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
59048ab1bf12SLuiz Capitulinofi
59058ab1bf12SLuiz Capitulino
590676a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
590776a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
590876a347e1SRichard Hendersonfi
590976a347e1SRichard Henderson
5910f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5911f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5912f540166bSRichard Hendersonfi
5913f540166bSRichard Henderson
59147ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
59157ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
59167ebee43eSRichard Hendersonfi
59177ebee43eSRichard Henderson
5918df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5919df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5920df79b996SRichard Hendersonfi
5921df79b996SRichard Henderson
59221e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
59231e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
59241e6e9acaSRichard Hendersonfi
59251e6e9acaSRichard Henderson
5926eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5927d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
59286ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
59296ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5930eb100396SBharata B Raofi
5931eb100396SBharata B Rao
5932d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5933d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5934d85fa9ebSJeff Codyfi
5935d85fa9ebSJeff Cody
59360c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
59370c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
59380c14fb47SBharata B Raofi
59390c14fb47SBharata B Rao
5940df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
5941df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
5942df3a429aSNiels de Vosfi
5943df3a429aSNiels de Vos
59447c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
59457c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
59467c815372SBharata B Raofi
59477c815372SBharata B Rao
59480a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
5949d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
59506ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
59516ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
59520a12ec87SRichard W.M. Jonesfi
59530a12ec87SRichard W.M. Jones
5954ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5955ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5956ed1701c6SDr. David Alan Gilbertfi
5957ed1701c6SDr. David Alan Gilbert
595868063649Sblueswir1# USB host support
5959b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
59602b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
5961b5613fdcSGerd Hoffmannelse
596298ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
5963b5613fdcSGerd Hoffmannfi
596468063649Sblueswir1
59653b8acc11SPaolo Bonzini# TPM passthrough support?
59663b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
59673b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
59683b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
59693b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
59703b8acc11SPaolo Bonzini  fi
59713b8acc11SPaolo Bonzinifi
59723b8acc11SPaolo Bonzini
59735b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
59745b808275SLluís Vilanovaif have_backend "nop"; then
59756d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
597622890ab5SPrerna Saxenafi
59775b808275SLluís Vilanovaif have_backend "simple"; then
59786d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
59796d8a764eSLluís  # Set the appropriate trace file.
5980953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
59819410b56cSPrerna Saxenafi
5982ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5983ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
59846d8a764eSLluísfi
59855b808275SLluís Vilanovaif have_backend "ust"; then
59866d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
59876d8a764eSLluísfi
59885b808275SLluís Vilanovaif have_backend "dtrace"; then
59896d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
59906d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
59916d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
59926d8a764eSLluís  fi
5993c276b17dSDaniel P. Berrangefi
59945b808275SLluís Vilanovaif have_backend "ftrace"; then
5995781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5996781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5997781e9545SEiichi Tsukata  else
599821684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5999781e9545SEiichi Tsukata  fi
6000781e9545SEiichi Tsukatafi
60010a852417SPaul Durrantif have_backend "syslog"; then
60020a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
60030a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
60040a852417SPaul Durrant  else
60050a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
60060a852417SPaul Durrant  fi
60070a852417SPaul Durrantfi
60089410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
60099410b56cSPrerna Saxena
60102da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
60112da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
60122da776dbSMichael R. Hinesfi
60132da776dbSMichael R. Hines
6014575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6015575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6016575b22b1SLaurent Vivierfi
6017575b22b1SLaurent Vivier
6018a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6019a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6020a6b1d4c0SChanglong Xiefi
6021a6b1d4c0SChanglong Xie
60226a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
60236a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
60246a02c806SStefan Hajnoczifi
60256a02c806SStefan Hajnoczi
60264d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
60274d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
60284d04351fSChristopher Covingtonfi
60294d04351fSChristopher Covington
603049e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
603149e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
603249e00a18SAndreas Grapentinfi
603349e00a18SAndreas Grapentin
6034e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6035e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6036e674605fSTomáš Golembiovskýfi
6037e674605fSTomáš Golembiovský
6038e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6039e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6040e0580342SKamil Rytarowskifi
6041e0580342SKamil Rytarowski
60425c312079SDr. David Alan Gilbert# Hold two types of flag:
60435c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
60445c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
60455c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
60465c312079SDr. David Alan Gilbert#                                     platform
60475c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
60485c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
60495c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
60505c312079SDr. David Alan Gilbertfi
60515c312079SDr. David Alan Gilbert
6052da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6053da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6054da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6055da92c3ffSAshish Mittalfi
6056da92c3ffSAshish Mittal
60575b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
60585b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
60595b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
60605b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
60615b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
60625b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6063c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
60645b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
606540d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
606640d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
60675b5e3037SPaolo Bonzinielse
60685b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
60695b5e3037SPaolo Bonzinifi
60705b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
60715b5e3037SPaolo Bonzini
607298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
607398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6074804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6075804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
60761901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
60771901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
60781901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
607921655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6080c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6081804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6082a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6083a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6084a31a8642SMichael S. Tsirkinfi
60852b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6086804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
608783f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
60883c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6089804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
609045d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6091cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
60925f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
60933dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6094804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6095804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
60964852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
60979fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6098e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
609946eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6100a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
610111cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6102f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6103e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6104e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
610580fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
61062944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6107e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6108e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6109e39f0062SPaolo Bonzinifi
611042da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
611142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
611242da6041SGerd Hoffmannelse
611342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
611442da6041SGerd Hoffmannfi
6115e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
611646eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
61176969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6118e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
611973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
61203e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6121409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6122804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
612317969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
612417969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6125957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
612690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
612790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
612894dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6129cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
61301d728c39SBlue Swirlif test "$gcov" = "yes" ; then
61311d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
61321d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
61331d728c39SBlue Swirlfi
6134804edf29SJuan Quintela
61356efd7517SPeter Maydell# use included Linux headers
61366efd7517SPeter Maydellif test "$linux" = "yes" ; then
6137a307beb6SAndreas Färber  mkdir -p linux-headers
61386efd7517SPeter Maydell  case "$cpu" in
6139c72b26ecSRichard Henderson  i386|x86_64|x32)
614008312a63SPeter Maydell    linux_arch=x86
61416efd7517SPeter Maydell    ;;
61426efd7517SPeter Maydell  ppcemb|ppc|ppc64)
614308312a63SPeter Maydell    linux_arch=powerpc
61446efd7517SPeter Maydell    ;;
61456efd7517SPeter Maydell  s390x)
614608312a63SPeter Maydell    linux_arch=s390
614708312a63SPeter Maydell    ;;
61481f080313SClaudio Fontana  aarch64)
61491f080313SClaudio Fontana    linux_arch=arm64
61501f080313SClaudio Fontana    ;;
6151222e7d11SSanjay Lal  mips64)
6152222e7d11SSanjay Lal    linux_arch=mips
6153222e7d11SSanjay Lal    ;;
615408312a63SPeter Maydell  *)
615508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
615608312a63SPeter Maydell    linux_arch="$cpu"
61576efd7517SPeter Maydell    ;;
61586efd7517SPeter Maydell  esac
615908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
616008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
616108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
616208312a63SPeter Maydell    fi
61636efd7517SPeter Maydellfi
61646efd7517SPeter Maydell
616597a847bcSbellardfor target in $target_list; do
616697a847bcSbellardtarget_dir="$target"
616725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
616889138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
616997a847bcSbellardtarget_bigendian="no"
61701f3d3c8fSJuan Quintela
6171c1799a84SPaolo Bonzinicase "$target_name" in
61724a09d0bbSRichard Henderson  armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6173ea2d6a39SJuan Quintela  target_bigendian=yes
6174ea2d6a39SJuan Quintela  ;;
6175ea2d6a39SJuan Quintelaesac
617697a847bcSbellardtarget_softmmu="no"
6177997344f3Sbellardtarget_user_only="no"
6178831b7825Sthstarget_linux_user="no"
617984778508Sblueswir1target_bsd_user="no"
61809e407a85Spbrookcase "$target" in
6181c1799a84SPaolo Bonzini  ${target_name}-softmmu)
61829e407a85Spbrook    target_softmmu="yes"
61839e407a85Spbrook    ;;
6184c1799a84SPaolo Bonzini  ${target_name}-linux-user)
61859e407a85Spbrook    target_user_only="yes"
61869e407a85Spbrook    target_linux_user="yes"
61879e407a85Spbrook    ;;
6188c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
618984778508Sblueswir1    target_user_only="yes"
619084778508Sblueswir1    target_bsd_user="yes"
619184778508Sblueswir1    ;;
61929e407a85Spbrook  *)
619376ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
61949e407a85Spbrook    exit 1
61959e407a85Spbrook    ;;
61969e407a85Spbrookesac
6197831b7825Sths
619897a847bcSbellardmkdir -p $target_dir
619925be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
620097a847bcSbellard
6201e5fe0c52Spbrookbflt="no"
6202ca759f9eSAlex Bennéemttcg="no"
620389138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
620456aebc89Spbrookgdb_xml_files=""
62057ba1e619Saliguori
6206c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
62076acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6208e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6209e73aae67SJuan Quintela
6210c1799a84SPaolo Bonzinicase "$target_name" in
62112408a527Saurel32  i386)
6212b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
62132408a527Saurel32  ;;
62142408a527Saurel32  x86_64)
62156acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6216b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
62172408a527Saurel32  ;;
62182408a527Saurel32  alpha)
62195ee4f3c2SRichard Henderson    mttcg="yes"
62202408a527Saurel32  ;;
62212408a527Saurel32  arm|armeb)
6222b498c8a0SJuan Quintela    TARGET_ARCH=arm
6223e5fe0c52Spbrook    bflt="yes"
6224ca759f9eSAlex Bennée    mttcg="yes"
622556aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62262408a527Saurel32  ;;
62276a49fa95SAlexander Graf  aarch64)
62286a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
62296a49fa95SAlexander Graf    bflt="yes"
6230ca759f9eSAlex Bennée    mttcg="yes"
62318f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62326a49fa95SAlexander Graf  ;;
62332408a527Saurel32  cris)
62342408a527Saurel32  ;;
623561766fe9SRichard Henderson  hppa)
623661766fe9SRichard Henderson  ;;
6237613a22c9SMichael Walle  lm32)
6238613a22c9SMichael Walle  ;;
62392408a527Saurel32  m68k)
62400938cda5Saurel32    bflt="yes"
62415a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
62422408a527Saurel32  ;;
6243877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6244877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
624572b675caSEdgar E. Iglesias    bflt="yes"
624672b675caSEdgar E. Iglesias  ;;
62472408a527Saurel32  mips|mipsel)
6248b498c8a0SJuan Quintela    TARGET_ARCH=mips
624925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
62502408a527Saurel32  ;;
62512408a527Saurel32  mipsn32|mipsn32el)
6252597e2cecSRichard Henderson    TARGET_ARCH=mips64
62536acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
625425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6255597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
62562408a527Saurel32  ;;
62572408a527Saurel32  mips64|mips64el)
6258b498c8a0SJuan Quintela    TARGET_ARCH=mips64
62596acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
626025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
62612408a527Saurel32  ;;
6262d15a9c23SAnthony Green  moxie)
6263d15a9c23SAnthony Green  ;;
6264e671711cSMarek Vasut  nios2)
6265e671711cSMarek Vasut  ;;
62664a09d0bbSRichard Henderson  or1k)
6267e67db06eSJia Liu    TARGET_ARCH=openrisc
6268e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6269e67db06eSJia Liu  ;;
62702408a527Saurel32  ppc)
6271c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
62722408a527Saurel32  ;;
62732408a527Saurel32  ppcemb)
62746acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6275e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6276c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
62772408a527Saurel32  ;;
62782408a527Saurel32  ppc64)
62796acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6280e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6281f0b0685dSNikunj A Dadhania    mttcg=yes
62821438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62832408a527Saurel32  ;;
62849c35126cSDoug Kwan  ppc64le)
62859c35126cSDoug Kwan    TARGET_ARCH=ppc64
62869c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
62879c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6288f0b0685dSNikunj A Dadhania    mttcg=yes
62891438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62909c35126cSDoug Kwan  ;;
62912408a527Saurel32  ppc64abi32)
6292b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
62936acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6294e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
629525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62961438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62972408a527Saurel32  ;;
62982408a527Saurel32  sh4|sh4eb)
6299b498c8a0SJuan Quintela    TARGET_ARCH=sh4
63004dbed897Spbrook    bflt="yes"
63012408a527Saurel32  ;;
63022408a527Saurel32  sparc)
63032408a527Saurel32  ;;
63042408a527Saurel32  sparc64)
63056acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
63062408a527Saurel32  ;;
63072408a527Saurel32  sparc32plus)
6308b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
63096acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6310e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
631125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
63122408a527Saurel32  ;;
631324e804ecSAlexander Graf  s390x)
631486158a2aSChristian 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"
631524e804ecSAlexander Graf  ;;
6316444e06b1SChen Gang  tilegx)
6317444e06b1SChen Gang  ;;
63185ecaa4edSPeter Crosthwaite  tricore)
63195ecaa4edSPeter Crosthwaite  ;;
6320d2fbca94SGuan Xuetao  unicore32)
6321d2fbca94SGuan Xuetao  ;;
6322cfa550c6SMax Filippov  xtensa|xtensaeb)
6323cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6324cfa550c6SMax Filippov  ;;
63252408a527Saurel32  *)
632676ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
63272408a527Saurel32  ;;
63282408a527Saurel32esac
63295e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
63305e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
63315e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
63325e8861a0SPaolo Bonzinifi
63335e8861a0SPaolo Bonzini
63345e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
63355e8861a0SPaolo Bonzini
633699afc91dSDaniel P. Berrangeupper() {
633799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
633899afc91dSDaniel P. Berrange}
633999afc91dSDaniel P. Berrange
634089138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
634125be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6342c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
634325be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6344e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6345e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6346e6e91b9cSJuan Quintelafi
634725be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6348adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6349adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6350adfc3e91SStacey Sonfi
63513b6b7550SPaolo Bonzini
63523b6b7550SPaolo Bonziniif supported_xen_target $target; then
635325be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6354eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6355eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6356eb6fda0fSAnthony PERARD    fi
6357432d268cSJun Nakajimafi
63583b6b7550SPaolo Bonziniif supported_kvm_target $target; then
635925be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
63601ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6361d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6362e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
6363e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6364e6a74868SMarc-André Lureau        fi
6365d5970055SMichael S. Tsirkin    fi
6366c59249f9SJuan Quintelafi
63673b6b7550SPaolo Bonziniif supported_hax_target $target; then
6368b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6369b0cb0a66SVincent Palatinfi
6370de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
637125be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
637297a847bcSbellardfi
637397a847bcSbellardif test "$target_softmmu" = "yes" ; then
637425be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6375ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6376ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6377ca759f9eSAlex Bennée  fi
6378de83cd02Sbellardfi
6379997344f3Sbellardif test "$target_user_only" = "yes" ; then
638025be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6381a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6382997344f3Sbellardfi
6383831b7825Sthsif test "$target_linux_user" = "yes" ; then
638425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6385831b7825Sthsfi
638656aebc89Spbrooklist=""
638756aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
638856aebc89Spbrook  for x in $gdb_xml_files; do
638956aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
639056aebc89Spbrook  done
639125be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
63923d0f1517SJuan Quintelafi
6393de83cd02Sbellard
6394e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
639525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6396e5fe0c52Spbrookfi
639784778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
639825be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
639984778508Sblueswir1fi
64005b0753e0Sbellard
64014afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6402fa282484SJuan Quintela
64034afddb55SJuan Quintelacflags=""
6404fa282484SJuan Quintelaldflags=""
64059b8e111fSJuan Quintela
6406c765fcacSPeter Crosthwaitedisas_config() {
6407c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6408c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6409c765fcacSPeter Crosthwaite}
6410c765fcacSPeter Crosthwaite
641164656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
641264656024SJuan Quintela  case "$i" in
641364656024SJuan Quintela  alpha)
6414c765fcacSPeter Crosthwaite    disas_config "ALPHA"
641564656024SJuan Quintela  ;;
641682295d8aSRichard Henderson  aarch64)
641782295d8aSRichard Henderson    if test -n "${cxx}"; then
6418c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
641982295d8aSRichard Henderson    fi
642082295d8aSRichard Henderson  ;;
642164656024SJuan Quintela  arm)
6422c765fcacSPeter Crosthwaite    disas_config "ARM"
6423999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6424c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6425999b53ecSClaudio Fontana    fi
642664656024SJuan Quintela  ;;
642764656024SJuan Quintela  cris)
6428c765fcacSPeter Crosthwaite    disas_config "CRIS"
642964656024SJuan Quintela  ;;
6430429b31a2SRichard Henderson  hppa)
6431429b31a2SRichard Henderson    disas_config "HPPA"
6432429b31a2SRichard Henderson  ;;
6433c72b26ecSRichard Henderson  i386|x86_64|x32)
6434c765fcacSPeter Crosthwaite    disas_config "I386"
643564656024SJuan Quintela  ;;
643679368f49SMichael Walle  lm32)
6437c765fcacSPeter Crosthwaite    disas_config "LM32"
643879368f49SMichael Walle  ;;
643964656024SJuan Quintela  m68k)
6440c765fcacSPeter Crosthwaite    disas_config "M68K"
644164656024SJuan Quintela  ;;
6442877fdc12SEdgar E. Iglesias  microblaze*)
6443c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
644464656024SJuan Quintela  ;;
644564656024SJuan Quintela  mips*)
6446c765fcacSPeter Crosthwaite    disas_config "MIPS"
644764656024SJuan Quintela  ;;
6448d15a9c23SAnthony Green  moxie*)
6449c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6450d15a9c23SAnthony Green  ;;
6451e671711cSMarek Vasut  nios2)
6452e671711cSMarek Vasut    disas_config "NIOS2"
6453e671711cSMarek Vasut  ;;
64544a09d0bbSRichard Henderson  or1k)
6455c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6456e67db06eSJia Liu  ;;
645764656024SJuan Quintela  ppc*)
6458c765fcacSPeter Crosthwaite    disas_config "PPC"
645964656024SJuan Quintela  ;;
646024e804ecSAlexander Graf  s390*)
6461c765fcacSPeter Crosthwaite    disas_config "S390"
646264656024SJuan Quintela  ;;
646364656024SJuan Quintela  sh4)
6464c765fcacSPeter Crosthwaite    disas_config "SH4"
646564656024SJuan Quintela  ;;
646664656024SJuan Quintela  sparc*)
6467c765fcacSPeter Crosthwaite    disas_config "SPARC"
646864656024SJuan Quintela  ;;
6469cfa550c6SMax Filippov  xtensa*)
6470c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6471cfa550c6SMax Filippov  ;;
647264656024SJuan Quintela  esac
647364656024SJuan Quinteladone
64749195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6475c765fcacSPeter Crosthwaite  disas_config "TCI"
64769195b2c2SStefan Weilfi
647764656024SJuan Quintela
64786ee7126fSJuan Quintelacase "$ARCH" in
64796ee7126fSJuan Quintelaalpha)
64806ee7126fSJuan Quintela  # Ensure there's only a single GP
64816ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
64826ee7126fSJuan Quintela;;
64836ee7126fSJuan Quintelaesac
64846ee7126fSJuan Quintela
6485d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
648625be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6487d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6488d02c1db3SJuan Quintela    cflags="-p $cflags"
6489d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6490d02c1db3SJuan Quintela  fi
6491d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6492d02c1db3SJuan Quintela    ldflags="-p $ldflags"
649325be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6494d02c1db3SJuan Quintela  fi
6495d02c1db3SJuan Quintelafi
6496d02c1db3SJuan Quintela
64979b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6498964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6499fa282484SJuan Quintelafi
6500fa282484SJuan Quintela
6501e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
6502e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
6503e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
6504e9a3591fSChristian Borntraeger# header if
6505e9a3591fSChristian Borntraeger#  - we build on s390x
6506e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
6507e9a3591fSChristian Borntraeger#  - KVM is enabled
6508e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
6509e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6510e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
6511e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
6512e9a3591fSChristian Borntraeger    fi
6513e9a3591fSChristian Borntraegerfi
6514e9a3591fSChristian Borntraeger
651525be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
651625be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6517fa282484SJuan Quintela
651897a847bcSbellarddone # for target in $targets
65197d13299dSbellard
6520a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6521a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6522a540f158SPeter Crosthwaitefi
6523a540f158SPeter Crosthwaite
6524a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6525a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6526a99d57bbSWanlong Gaofi
6527a99d57bbSWanlong Gao
6528fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6529fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6530fd0e6053SJohn Snowfi
6531fd0e6053SJohn Snow
6532d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6533f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6534d59157eaSPaolo BonziniDIRS="$DIRS docs docs/interop fsdev"
65359933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
65362d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
65372dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6538c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6539c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6540aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6541ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6542446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
65439933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
65442d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
65454652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
65463a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6547753d11f2SRichard Hendersonfor bios_file in \
6548753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6549225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
65505acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6551753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6552753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6553e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6554753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
65554e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6556753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6557753d11f2SRichard Hendersondo
655889138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
65597ea78b74SJan Kiszkadone
656089138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6561c2304b52SMarcel Apfelbaumdo
656289138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6563c2304b52SMarcel Apfelbaumdone
6564d1807a4fSPaolo Bonzinimkdir -p $DIRS
65657d13299dSbellardfor f in $FILES ; do
6566cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6567f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6568f9245e10SPeter Maydell    fi
65697d13299dSbellarddone
65701ad2134fSPaul Brook
6571c34ebfdcSAnthony Liguori# temporary config to build submodules
65722d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6573c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
657437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6575c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6576cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
65775f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6578c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6579c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
65803dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6581c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6582a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6583c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
6584c34ebfdcSAnthony Liguoridone
6585c34ebfdcSAnthony Liguori
6586fe31017fSMarc-André Lureau# set up tests data directory
6587fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6588fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6589fe31017fSMarc-André Lureaufi
6590fe31017fSMarc-André Lureau
659176c7560aSMax Reitz# set up qemu-iotests in this build directory
659276c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
659376c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
659476c7560aSMax Reitz
659576c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
659676c7560aSMax Reitzecho >> "$iotests_common_env"
659776c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
659876c7560aSMax Reitz
659976c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
660076c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
660176c7560aSMax Reitzfi
660276c7560aSMax Reitz
6603dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6604dc655404SMichael S. Tsirkincat <<EOD >config.status
6605dc655404SMichael S. Tsirkin#!/bin/sh
6606dc655404SMichael S. Tsirkin# Generated by configure.
6607dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6608dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6609dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6610dc655404SMichael S. TsirkinEOD
6611dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6612dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6613cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6614dc655404SMichael S. Tsirkinchmod +x config.status
6615dc655404SMichael S. Tsirkin
66168cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6617