xref: /openbmc/qemu/configure (revision aef45d51)
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=""
267*aef45d51SDaniel P. Berrangegit_submodules=""
268ac0df51dSaliguori
269afb63ebdSStefan Weil# Don't accept a target_list environment variable.
270afb63ebdSStefan Weilunset target_list
271377529c0SPaolo Bonzini
272377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
273377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
274377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
275377529c0SPaolo Bonzini#              unless --disable-foo is given
276377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
277377529c0SPaolo Bonzini#              feature will searched for,
278377529c0SPaolo Bonzini#              if not found, configure exits with error
279377529c0SPaolo Bonzini#
280377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
281377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
282377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
283377529c0SPaolo Bonzini
284377529c0SPaolo Bonzinibluez=""
285377529c0SPaolo Bonzinibrlapi=""
286377529c0SPaolo Bonzinicurl=""
287377529c0SPaolo Bonzinicurses=""
288377529c0SPaolo Bonzinidocs=""
289377529c0SPaolo Bonzinifdt=""
29058952137SVincenzo Maffionenetmap="no"
291377529c0SPaolo Bonzinisdl=""
292ee8466d0SCole Robinsonsdlabi=""
293983eef5aSMeador Ingevirtfs=""
294fe8fc5aeSPaolo Bonzinimpath=""
295821601eaSJes Sorensenvnc="yes"
296377529c0SPaolo Bonzinisparse="no"
297377529c0SPaolo Bonzinivde=""
298377529c0SPaolo Bonzinivnc_sasl=""
299377529c0SPaolo Bonzinivnc_jpeg=""
300377529c0SPaolo Bonzinivnc_png=""
301377529c0SPaolo Bonzinixen=""
302d5b93ddfSAnthony PERARDxen_ctrl_version=""
30364a7ad6fSIan Campbellxen_pv_domain_build="no"
304eb6fda0fSAnthony PERARDxen_pci_passthrough=""
305377529c0SPaolo Bonzinilinux_aio=""
30647e98658SCorey Bryantcap_ng=""
307377529c0SPaolo Bonziniattr=""
3084f26f2b6SAvi Kivitylibattr=""
309377529c0SPaolo Bonzinixfs=""
310b3f6ea7eSPaolo Bonzinitcg="yes"
311377529c0SPaolo Bonzini
312d41a75a2SBradvhost_net="no"
3135e9be92dSNicholas Bellingervhost_scsi="no"
314fc0b9b0eSStefan Hajnoczivhost_vsock="no"
315e6a74868SMarc-André Lureauvhost_user=""
316d41a75a2SBradkvm="no"
317b0cb0a66SVincent Palatinhax="no"
3182da776dbSMichael R. Hinesrdma=""
319377529c0SPaolo Bonzinigprof="no"
320377529c0SPaolo Bonzinidebug_tcg="no"
321377529c0SPaolo Bonzinidebug="no"
322b553a042SJohn Snowfortify_source=""
323377529c0SPaolo Bonzinistrip_opt="yes"
3249195b2c2SStefan Weiltcg_interpreter="no"
325377529c0SPaolo Bonzinibigendian="no"
326377529c0SPaolo Bonzinimingw32="no"
3271d728c39SBlue Swirlgcov="no"
3281d728c39SBlue Swirlgcov_tool="gcov"
329377529c0SPaolo BonziniEXESUF=""
33017969268SFam ZhengDSOSUF=".so"
33117969268SFam ZhengLDFLAGS_SHARED="-shared"
33217969268SFam Zhengmodules="no"
333377529c0SPaolo Bonziniprefix="/usr/local"
334377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
335528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
3363d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
337850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
338377529c0SPaolo Bonzinibindir="\${prefix}/bin"
3393aa5d2beSAlon Levylibdir="\${prefix}/lib"
3408bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
3410f94d6daSAlon Levyincludedir="\${prefix}/include"
342377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
343785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
344377529c0SPaolo Bonziniconfsuffix="/qemu"
345377529c0SPaolo Bonzinislirp="yes"
346377529c0SPaolo Bonzinioss_lib=""
347377529c0SPaolo Bonzinibsd="no"
348377529c0SPaolo Bonzinilinux="no"
349377529c0SPaolo Bonzinisolaris="no"
350377529c0SPaolo Bonziniprofiler="no"
351377529c0SPaolo Bonzinicocoa="no"
352377529c0SPaolo Bonzinisoftmmu="yes"
353377529c0SPaolo Bonzinilinux_user="no"
354377529c0SPaolo Bonzinibsd_user="no"
355377529c0SPaolo Bonziniblobs="yes"
356377529c0SPaolo Bonzinipkgversion=""
35740d6444eSAvi Kivitypie=""
3583556c233SPaolo Bonziniqom_cast_debug="yes"
359baf86d6bSPaolo Bonzinitrace_backends="log"
360377529c0SPaolo Bonzinitrace_file="trace"
361377529c0SPaolo Bonzinispice=""
362377529c0SPaolo Bonzinirbd=""
3637b02f544SMarc-André Lureausmartcard=""
3642b2325ffSGerd Hoffmannlibusb=""
36569354a83SHans de Goedeusb_redir=""
366da076ffeSGerd Hoffmannopengl=""
367014cb152SGerd Hoffmannopengl_dmabuf="no"
3685dd89908SRichard Hendersoncpuid_h="no"
36999f2dbd3SLiang Liavx2_opt="no"
3701ece9905SAlon Levyzlib="yes"
371b25c9dffSStefan Weillzo=""
372b25c9dffSStefan Weilsnappy=""
3736b383c08SPeter Wubzip2=""
374e8ef31a3SMichael Tokarevguest_agent=""
375d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
37650cbebb9SMichael Rothguest_agent_ntddscsi="no"
3779dacf32dSYossi Hindinguest_agent_msi=""
378d9840e25STomoki Sekiyamavss_win32_sdk=""
379d9840e25STomoki Sekiyamawin_sdk="no"
3804b1c11fdSDaniel P. Berrangewant_tools="yes"
381c589b249SRonnie Sahlberglibiscsi=""
3826542aa9cSPeter Lievenlibnfs=""
383519175a2SAlex Barcelocoroutine=""
38470c60c08SStefan Hajnoczicoroutine_pool=""
3857d992e4dSPeter Lievendebug_stack_usage="no"
386f0d92b56SLongpeng(Mike)crypto_afalg="no"
387f794573eSEduardo Otuboseccomp=""
388eb100396SBharata B Raoglusterfs=""
389d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
3900c14fb47SBharata B Raoglusterfs_discard="no"
391df3a429aSNiels de Vosglusterfs_fallocate="no"
3927c815372SBharata B Raoglusterfs_zerofill="no"
393a4ccabcfSAnthony Liguorigtk=""
3949e04c683SStefan Weilgtkabi=""
395925a0400SGerd Hoffmanngtk_gl="no"
396a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
397ddbb0d09SDaniel P. Berrangegnutls=""
398b917da4cSDaniel P. Berrangegnutls_rnd=""
39991bfcdb0SDaniel P. Berrangenettle=""
400fff2f982SDaniel P. Berrangenettle_kdf="no"
40191bfcdb0SDaniel P. Berrangegcrypt=""
4021f923c70SLongpeng(Mike)gcrypt_hmac="no"
40337788f25SDaniel P. Berrangegcrypt_kdf="no"
404bbbf9bfbSStefan Weilvte=""
4059d9e1521SGerd Hoffmannvirglrenderer=""
406e91c793cSCole Robinsontpm="yes"
4070a12ec87SRichard W.M. Joneslibssh2=""
408ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
409a99d57bbSWanlong Gaonuma=""
4102847b469SFam Zhengtcmalloc="no"
4117b01cb97SAlexandre Derumierjemalloc="no"
412a6b1d4c0SChanglong Xiereplication="yes"
413da92c3ffSAshish Mittalvxhs=""
414377529c0SPaolo Bonzini
415898be3e0SPeter Maydellsupported_cpu="no"
416898be3e0SPeter Maydellsupported_os="no"
417fb59dabdSPeter Maydellbogus_os="no"
418898be3e0SPeter Maydell
419ac0df51dSaliguori# parse CC options first
420ac0df51dSaliguorifor opt do
42189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
422ac0df51dSaliguori  case "$opt" in
423ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
424ac0df51dSaliguori  ;;
4253d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
426ac0df51dSaliguori  ;;
42783f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
42883f73fceSTomoki Sekiyama  ;;
429ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
430ca4deeb1SPaolo Bonzini  ;;
4312ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4322ff6b91eSJuan Quintela  ;;
433de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
434f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
435e2a2ed06SJuan Quintela  ;;
43611cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
43711cde1c8SBruno Dominguez                      EXTRA_CXXFLAGS="$optarg"
43811cde1c8SBruno Dominguez  ;;
439a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
440f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
441e2a2ed06SJuan Quintela  ;;
4425bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4435bc62e01SGerd Hoffmann  ;;
4445bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4455bc62e01SGerd Hoffmann  ;;
446ac0df51dSaliguori  esac
447ac0df51dSaliguoridone
448ac0df51dSaliguori# OS specific
449ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
45093148aa5SStefan Weil# we can eliminate its usage altogether.
451ac0df51dSaliguori
452e49d021eSPeter Maydell# Preferred compiler:
453e49d021eSPeter Maydell#  ${CC} (if set)
454e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
455e49d021eSPeter Maydell#  system compiler
456e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
457e49d021eSPeter Maydell  cc="$host_cc"
458e49d021eSPeter Maydellelse
459b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
460e49d021eSPeter Maydellfi
461e49d021eSPeter Maydell
46283f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
46383f73fceSTomoki Sekiyama  cxx="c++"
46483f73fceSTomoki Sekiyamaelse
46583f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
46683f73fceSTomoki Sekiyamafi
46783f73fceSTomoki Sekiyama
468b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
469cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4705f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4713dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
472b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
473b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
4744852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
475b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
476b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
47717884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
47817884d7bSSergei Trofimovichquery_pkg_config() {
47917884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
48017884d7bSSergei Trofimovich}
48117884d7bSSergei Trofimovichpkg_config=query_pkg_config
482b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
48347c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
484ac0df51dSaliguori
48545d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
48645d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
48745d285abSPeter Maydell
488be17dc90SMichael S. Tsirkin# default flags for all hosts
4892d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
4902d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
4912d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
4922d31515bSPeter Maydell# provides these semantics.)
4932d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
494f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
495c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
496be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
497244f1441SYang ZhongQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
4985bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
4995bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
500be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
5015bc62e01SGerd Hoffmannfi
502be17dc90SMichael S. Tsirkin
503ca4deeb1SPaolo Bonzini# make source path absolute
50489138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
505ca4deeb1SPaolo Bonzini
506cab00a5aSMichael S. Tsirkin# running configure in the source tree?
507cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
508cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
509cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
510cab00a5aSMichael S. Tsirkinelse
511cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
512cab00a5aSMichael S. Tsirkinfi
513cab00a5aSMichael S. Tsirkin
514ac0df51dSaliguoricheck_define() {
515ac0df51dSaliguoricat > $TMPC <<EOF
516ac0df51dSaliguori#if !defined($1)
517fd786e1aSPeter Maydell#error $1 not defined
518ac0df51dSaliguori#endif
519ac0df51dSaliguoriint main(void) { return 0; }
520ac0df51dSaliguoriEOF
52152166aa0SJuan Quintela  compile_object
522ac0df51dSaliguori}
523ac0df51dSaliguori
524307119e7SGerd Hoffmanncheck_include() {
525307119e7SGerd Hoffmanncat > $TMPC <<EOF
526307119e7SGerd Hoffmann#include <$1>
527307119e7SGerd Hoffmannint main(void) { return 0; }
528307119e7SGerd HoffmannEOF
529307119e7SGerd Hoffmann  compile_object
530307119e7SGerd Hoffmann}
531307119e7SGerd Hoffmann
53293b25869SJohn Snowwrite_c_skeleton() {
53393b25869SJohn Snow    cat > $TMPC <<EOF
53493b25869SJohn Snowint main(void) { return 0; }
53593b25869SJohn SnowEOF
53693b25869SJohn Snow}
53793b25869SJohn Snow
538bbea4050SPeter Maydellif check_define __linux__ ; then
539bbea4050SPeter Maydell  targetos="Linux"
540bbea4050SPeter Maydellelif check_define _WIN32 ; then
541bbea4050SPeter Maydell  targetos='MINGW32'
542bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
543bbea4050SPeter Maydell  targetos='OpenBSD'
544bbea4050SPeter Maydellelif check_define __sun__ ; then
545bbea4050SPeter Maydell  targetos='SunOS'
546bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
547bbea4050SPeter Maydell  targetos='Haiku'
548951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
549951fedfcSPeter Maydell  targetos='FreeBSD'
550951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
551951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
552951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
553951fedfcSPeter Maydell  targetos='DragonFly'
554951fedfcSPeter Maydellelif check_define __NetBSD__; then
555951fedfcSPeter Maydell  targetos='NetBSD'
556951fedfcSPeter Maydellelif check_define __APPLE__; then
557951fedfcSPeter Maydell  targetos='Darwin'
558bbea4050SPeter Maydellelse
559951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
560951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
561951fedfcSPeter Maydell  # be the result of a missing compiler.
562951fedfcSPeter Maydell  targetos='bogus'
563951fedfcSPeter Maydell  bogus_os='yes'
564bbea4050SPeter Maydellfi
565bbea4050SPeter Maydell
566bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
567bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
568bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
569bbea4050SPeter Maydell# the correct CPU with the --cpu option.
570bbea4050SPeter Maydellcase $targetos in
571bbea4050SPeter MaydellDarwin)
572bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
573bbea4050SPeter Maydell  # run 64-bit userspace code.
574bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
575bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
576bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
577bbea4050SPeter Maydell    cpu="x86_64"
578bbea4050SPeter Maydell  fi
579bbea4050SPeter Maydell  ;;
580bbea4050SPeter MaydellSunOS)
58189138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
582bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
583bbea4050SPeter Maydell    cpu="x86_64"
584bbea4050SPeter Maydell  fi
585bbea4050SPeter Maydellesac
586bbea4050SPeter Maydell
5872ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
5882ff6b91eSJuan Quintela  # command line argument
5892ff6b91eSJuan Quintela  :
5902ff6b91eSJuan Quintelaelif check_define __i386__ ; then
591ac0df51dSaliguori  cpu="i386"
592ac0df51dSaliguorielif check_define __x86_64__ ; then
593c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
594c72b26ecSRichard Henderson    cpu="x32"
595c72b26ecSRichard Henderson  else
596ac0df51dSaliguori    cpu="x86_64"
597c72b26ecSRichard Henderson  fi
5983aa9bd6cSblueswir1elif check_define __sparc__ ; then
5993aa9bd6cSblueswir1  if check_define __arch64__ ; then
6003aa9bd6cSblueswir1    cpu="sparc64"
6013aa9bd6cSblueswir1  else
6023aa9bd6cSblueswir1    cpu="sparc"
6033aa9bd6cSblueswir1  fi
604fdf7ed96Smalcelif check_define _ARCH_PPC ; then
605fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
606fdf7ed96Smalc    cpu="ppc64"
607ac0df51dSaliguori  else
608fdf7ed96Smalc    cpu="ppc"
609fdf7ed96Smalc  fi
610afa05235SAurelien Jarnoelif check_define __mips__ ; then
611afa05235SAurelien Jarno  cpu="mips"
612477ba620SAurelien Jarnoelif check_define __ia64__ ; then
613477ba620SAurelien Jarno  cpu="ia64"
614d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
615d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
616d66ed0eaSAurelien Jarno    cpu="s390x"
617d66ed0eaSAurelien Jarno  else
618d66ed0eaSAurelien Jarno    cpu="s390"
619d66ed0eaSAurelien Jarno  fi
62021d89f84SPeter Maydellelif check_define __arm__ ; then
62121d89f84SPeter Maydell  cpu="arm"
6221f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6231f080313SClaudio Fontana  cpu="aarch64"
624fdf7ed96Smalcelse
62589138857SStefan Weil  cpu=$(uname -m)
626ac0df51dSaliguorifi
627ac0df51dSaliguori
628359bc95dSPeter MaydellARCH=
629359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
630359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6317d13299dSbellardcase "$cpu" in
6326499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
633898be3e0SPeter Maydell    cpu="$cpu"
634898be3e0SPeter Maydell    supported_cpu="yes"
635898be3e0SPeter Maydell  ;;
6367d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
63797a847bcSbellard    cpu="i386"
638898be3e0SPeter Maydell    supported_cpu="yes"
6397d13299dSbellard  ;;
640aaa5fa14Saurel32  x86_64|amd64)
641aaa5fa14Saurel32    cpu="x86_64"
642898be3e0SPeter Maydell    supported_cpu="yes"
643aaa5fa14Saurel32  ;;
64421d89f84SPeter Maydell  armv*b|armv*l|arm)
64521d89f84SPeter Maydell    cpu="arm"
646898be3e0SPeter Maydell    supported_cpu="yes"
6477d13299dSbellard  ;;
6481f080313SClaudio Fontana  aarch64)
6491f080313SClaudio Fontana    cpu="aarch64"
650898be3e0SPeter Maydell    supported_cpu="yes"
6511f080313SClaudio Fontana  ;;
652afa05235SAurelien Jarno  mips*)
653afa05235SAurelien Jarno    cpu="mips"
654898be3e0SPeter Maydell    supported_cpu="yes"
655afa05235SAurelien Jarno  ;;
6563142255cSblueswir1  sparc|sun4[cdmuv])
657ae228531Sbellard    cpu="sparc"
6586499fd15SPeter Maydell    supported_cpu="yes"
659ae228531Sbellard  ;;
6607d13299dSbellard  *)
661359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
662359bc95dSPeter Maydell    ARCH=unknown
6637d13299dSbellard  ;;
6647d13299dSbellardesac
665359bc95dSPeter Maydellif test -z "$ARCH"; then
666359bc95dSPeter Maydell  ARCH="$cpu"
667359bc95dSPeter Maydellfi
668e2d52ad3SJuan Quintela
6697d13299dSbellard# OS specific
6700dbfc675SJuan Quintela
671adfc3e91SStacey Son# host *BSD for user mode
672adfc3e91SStacey SonHOST_VARIANT_DIR=""
673adfc3e91SStacey Son
6747d13299dSbellardcase $targetos in
67567b915a5SbellardMINGW32*)
67667b915a5Sbellard  mingw32="yes"
677b0cb0a66SVincent Palatin  hax="yes"
6783cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
679307119e7SGerd Hoffmann  if check_include dsound.h; then
6803cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
681307119e7SGerd Hoffmann  else
682307119e7SGerd Hoffmann    audio_drv_list=""
683307119e7SGerd Hoffmann  fi
684898be3e0SPeter Maydell  supported_os="yes"
68567b915a5Sbellard;;
6865c40d2bdSthsGNU/kFreeBSD)
687a167ba50SAurelien Jarno  bsd="yes"
6880c58ac1cSmalc  audio_drv_list="oss"
6890bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
6905c40d2bdSths;;
6917d3505c5SbellardFreeBSD)
6927d3505c5Sbellard  bsd="yes"
6930db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6940c58ac1cSmalc  audio_drv_list="oss"
6950bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
696f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
697f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
698a7764f15SEd Maste  # needed for kinfo_getproc
699a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
70058952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
701adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
702898be3e0SPeter Maydell  supported_os="yes"
7037d3505c5Sbellard;;
704c5e97233Sblueswir1DragonFly)
705c5e97233Sblueswir1  bsd="yes"
7060db4a067SPaolo Bonzini  make="${MAKE-gmake}"
707c5e97233Sblueswir1  audio_drv_list="oss"
7080bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
709adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
710c5e97233Sblueswir1;;
7117d3505c5SbellardNetBSD)
7127d3505c5Sbellard  bsd="yes"
7130db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7140c58ac1cSmalc  audio_drv_list="oss"
7150bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7168ef92a88Sblueswir1  oss_lib="-lossaudio"
717adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
7183c2bdbc1SKamil Rytarowski  supported_os="yes"
7197d3505c5Sbellard;;
7207d3505c5SbellardOpenBSD)
7217d3505c5Sbellard  bsd="yes"
7220db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7234f6ab397SBrad Smith  audio_drv_list="sdl"
7240bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
725adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7267d3505c5Sbellard;;
72783fb7adfSbellardDarwin)
72883fb7adfSbellard  bsd="yes"
72983fb7adfSbellard  darwin="yes"
730b0cb0a66SVincent Palatin  hax="yes"
73117969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7321b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
733a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7340c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
7351b0f9cc2Saliguori  fi
736fd677642Sths  cocoa="yes"
7370c58ac1cSmalc  audio_drv_list="coreaudio"
73814382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
7390c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7407973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
741a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
742a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
743a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
744adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
745898be3e0SPeter Maydell  supported_os="yes"
74683fb7adfSbellard;;
747ec530c81SbellardSunOS)
748ec530c81Sbellard  solaris="yes"
7490db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7500db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
751e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7526b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7530c58ac1cSmalc    audio_drv_list="oss"
7546b4d2ba1Sths  fi
755c2de5c91Smalc  audio_possible_drivers="oss sdl"
756d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
757d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
758d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
759d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
760a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
761560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
762560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
763560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
764ec530c81Sbellard;;
765179cf400SAndreas FärberHaiku)
766179cf400SAndreas Färber  haiku="yes"
767179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
768179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
769179cf400SAndreas Färber;;
770898be3e0SPeter MaydellLinux)
7710c58ac1cSmalc  audio_drv_list="oss"
7720bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7735327cf48Sbellard  linux="yes"
774831b7825Sths  linux_user="yes"
775af2be207SJan Kiszka  kvm="yes"
776af2be207SJan Kiszka  vhost_net="yes"
7775e9be92dSNicholas Bellinger  vhost_scsi="yes"
778fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
779a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
780898be3e0SPeter Maydell  supported_os="yes"
781898be3e0SPeter Maydell;;
7827d13299dSbellardesac
7837d13299dSbellard
7847d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
785b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
78684778508Sblueswir1    bsd_user="yes"
7877d3505c5Sbellard  fi
78808de3949SAndreas Färberfi
7897d3505c5Sbellard
7900db4a067SPaolo Bonzini: ${make=${MAKE-make}}
7910db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
79252510f8bSStefan Weil: ${python=${PYTHON-python}}
793e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
7940db4a067SPaolo Bonzini
7953c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7963c4a4d0dSPeter Maydellif has clang; then
7973c4a4d0dSPeter Maydell  objcc=clang
7983c4a4d0dSPeter Maydellelse
7993c4a4d0dSPeter Maydell  objcc="$cc"
8003c4a4d0dSPeter Maydellfi
8013c4a4d0dSPeter Maydell
8023457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8033457a3f8SJuan Quintela  EXESUF=".exe"
80417969268SFam Zheng  DSOSUF=".dll"
805a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
806e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
807e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
80878e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
80978e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
810f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
81193b25869SJohn Snow  write_c_skeleton;
812f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
813f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
814f7cf5d5bSStefan Weil  fi
815c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
816683035deSPaolo Bonzini  mandir="\${prefix}"
817528ae5b8SEduardo Habkost  datadir="\${prefix}"
818850da188SEduardo Habkost  qemu_docdir="\${prefix}"
819683035deSPaolo Bonzini  bindir="\${prefix}"
820683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8215a699bbbSLaszlo Ersek  local_statedir=
822683035deSPaolo Bonzini  confsuffix=""
823161a56a9SVinzenz Feenstra  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -liphlpapi -lnetapi32 $libs_qga"
8243457a3f8SJuan Quintelafi
8253457a3f8SJuan Quintela
826487fefdbSAnthony Liguoriwerror=""
82785aa5189Sbellard
8287d13299dSbellardfor opt do
82989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8307d13299dSbellard  case "$opt" in
8312efc3265Sbellard  --help|-h) show_help=yes
8322efc3265Sbellard  ;;
83399123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
83499123e13SMike Frysinger  ;;
835b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8367d13299dSbellard  ;;
837b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
83832ce6337Sbellard  ;;
839ca4deeb1SPaolo Bonzini  --source-path=*)
8407d13299dSbellard  ;;
841ac0df51dSaliguori  --cross-prefix=*)
8427d13299dSbellard  ;;
843ac0df51dSaliguori  --cc=*)
8447d13299dSbellard  ;;
845b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
84683469015Sbellard  ;;
84783f73fceSTomoki Sekiyama  --cxx=*)
84883f73fceSTomoki Sekiyama  ;;
849e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
850e007dbecSMichael S. Tsirkin  ;;
8513c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8523c4a4d0dSPeter Maydell  ;;
853b1a550a0Spbrook  --make=*) make="$optarg"
8547d13299dSbellard  ;;
8556a882643Spbrook  --install=*) install="$optarg"
8566a882643Spbrook  ;;
857c886edfbSBlue Swirl  --python=*) python="$optarg"
858c886edfbSBlue Swirl  ;;
8591d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
8601d728c39SBlue Swirl  ;;
861e2d8830eSBrad  --smbd=*) smbd="$optarg"
862e2d8830eSBrad  ;;
863e2a2ed06SJuan Quintela  --extra-cflags=*)
8647d13299dSbellard  ;;
86511cde1c8SBruno Dominguez  --extra-cxxflags=*)
86611cde1c8SBruno Dominguez  ;;
867e2a2ed06SJuan Quintela  --extra-ldflags=*)
8687d13299dSbellard  ;;
8695bc62e01SGerd Hoffmann  --enable-debug-info)
8705bc62e01SGerd Hoffmann  ;;
8715bc62e01SGerd Hoffmann  --disable-debug-info)
8725bc62e01SGerd Hoffmann  ;;
87317969268SFam Zheng  --enable-modules)
87417969268SFam Zheng      modules="yes"
87517969268SFam Zheng  ;;
8763aa88b31SStefan Hajnoczi  --disable-modules)
8773aa88b31SStefan Hajnoczi      modules="no"
8783aa88b31SStefan Hajnoczi  ;;
8792ff6b91eSJuan Quintela  --cpu=*)
8807d13299dSbellard  ;;
881b1a550a0Spbrook  --target-list=*) target_list="$optarg"
882de83cd02Sbellard  ;;
8835b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8845b808275SLluís Vilanova  ;;
8855b808275SLluís Vilanova  # XXX: backwards compatibility
8865b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
88794a420b1SStefan Hajnoczi  ;;
88874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8899410b56cSPrerna Saxena  ;;
8907d13299dSbellard  --enable-gprof) gprof="yes"
8917d13299dSbellard  ;;
8921d728c39SBlue Swirl  --enable-gcov) gcov="yes"
8931d728c39SBlue Swirl  ;;
89479427693SLoïc Minier  --static)
89579427693SLoïc Minier    static="yes"
89679427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
89717884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
89843ce4dfeSbellard  ;;
8990b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9000b24e75fSPaolo Bonzini  ;;
9010b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9020b24e75fSPaolo Bonzini  ;;
9033aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9043aa5d2beSAlon Levy  ;;
9058bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9068bf188aaSMichael Tokarev  ;;
9070f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9080f94d6daSAlon Levy  ;;
909528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9100b24e75fSPaolo Bonzini  ;;
911023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
912023d3d67SEduardo Habkost  ;;
913850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9140b24e75fSPaolo Bonzini  ;;
915ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
91607381cc1SAnthony Liguori  ;;
917785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
918785c23aeSLuiz Capitulino  ;;
9193d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9203d5eecabSGerd Hoffmann  ;;
921785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
922023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
923023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
924023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
925023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
926023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
927023ddd74SMax Filippov    # lots of directory switches by default.
928023ddd74SMax Filippov  ;;
92997a847bcSbellard  --disable-sdl) sdl="no"
93097a847bcSbellard  ;;
931c4198157SJuan Quintela  --enable-sdl) sdl="yes"
932c4198157SJuan Quintela  ;;
93347c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
93447c03744SDave Airlie  ;;
9353556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9363556c233SPaolo Bonzini  ;;
9373556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9383556c233SPaolo Bonzini  ;;
939983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
940983eef5aSMeador Inge  ;;
941983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
942983eef5aSMeador Inge  ;;
943fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
944fe8fc5aeSPaolo Bonzini  ;;
945fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
946fe8fc5aeSPaolo Bonzini  ;;
947821601eaSJes Sorensen  --disable-vnc) vnc="no"
948821601eaSJes Sorensen  ;;
949821601eaSJes Sorensen  --enable-vnc) vnc="yes"
950821601eaSJes Sorensen  ;;
9512f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
9522f6a1ab0Sblueswir1  ;;
9530c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9540c58ac1cSmalc  ;;
95589138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
956b64ec4e4SFam Zheng  ;;
95789138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
958eb852011SMarkus Armbruster  ;;
959f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
960f8393946Saurel32  ;;
961f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
962f8393946Saurel32  ;;
963f3d08ee6SPaul Brook  --enable-debug)
964f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
965f3d08ee6SPaul Brook      debug_tcg="yes"
966f3d08ee6SPaul Brook      debug="yes"
967f3d08ee6SPaul Brook      strip_opt="no"
968b553a042SJohn Snow      fortify_source="no"
969f3d08ee6SPaul Brook  ;;
97003b4fe7dSaliguori  --enable-sparse) sparse="yes"
97103b4fe7dSaliguori  ;;
97203b4fe7dSaliguori  --disable-sparse) sparse="no"
97303b4fe7dSaliguori  ;;
9741625af87Saliguori  --disable-strip) strip_opt="no"
9751625af87Saliguori  ;;
9762f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
9772f9606b3Saliguori  ;;
978ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
979ea784e3bSJuan Quintela  ;;
9802f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
9812f6f5c7aSCorentin Chary  ;;
9822f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
9832f6f5c7aSCorentin Chary  ;;
984efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
985efe556adSCorentin Chary  ;;
986efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
987efe556adSCorentin Chary  ;;
988443f1376Sbellard  --disable-slirp) slirp="no"
989c20709aaSbellard  ;;
990e0e6c8c0Saliguori  --disable-vde) vde="no"
9918a16d273Sths  ;;
992dfb278bdSJuan Quintela  --enable-vde) vde="yes"
993dfb278bdSJuan Quintela  ;;
99458952137SVincenzo Maffione  --disable-netmap) netmap="no"
99558952137SVincenzo Maffione  ;;
99658952137SVincenzo Maffione  --enable-netmap) netmap="yes"
99758952137SVincenzo Maffione  ;;
998e37630caSaliguori  --disable-xen) xen="no"
999e37630caSaliguori  ;;
1000fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1001fc321b4bSJuan Quintela  ;;
1002eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1003eb6fda0fSAnthony PERARD  ;;
1004eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1005eb6fda0fSAnthony PERARD  ;;
100664a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
100764a7ad6fSIan Campbell  ;;
100864a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
100964a7ad6fSIan Campbell  ;;
10102e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10112e4d9fb1Saurel32  ;;
10124ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10134ffcedb6SJuan Quintela  ;;
1014fb599c9aSbalrog  --disable-bluez) bluez="no"
1015fb599c9aSbalrog  ;;
1016a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1017a20a6f46SJuan Quintela  ;;
10187ba1e619Saliguori  --disable-kvm) kvm="no"
10197ba1e619Saliguori  ;;
1020b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1021b31a0277SJuan Quintela  ;;
1022b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1023180fb750Szhanghailiang  ;;
1024b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1025180fb750Szhanghailiang  ;;
10269195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
10279195b2c2SStefan Weil  ;;
10289195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
10299195b2c2SStefan Weil  ;;
103047e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
103147e98658SCorey Bryant  ;;
103247e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
103347e98658SCorey Bryant  ;;
1034b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1035b3f6ea7eSPaolo Bonzini  ;;
1036b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1037b3f6ea7eSPaolo Bonzini  ;;
1038cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1039cd4ec0b4SGerd Hoffmann  ;;
1040cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1041cd4ec0b4SGerd Hoffmann  ;;
1042c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1043c589b249SRonnie Sahlberg  ;;
1044c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1045c589b249SRonnie Sahlberg  ;;
10466542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
10476542aa9cSPeter Lieven  ;;
10486542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
10496542aa9cSPeter Lieven  ;;
105005c2a3e7Sbellard  --enable-profiler) profiler="yes"
105105c2a3e7Sbellard  ;;
105214821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
105314821030SPavel Borzenkov  ;;
1054c2de5c91Smalc  --enable-cocoa)
1055c2de5c91Smalc      cocoa="yes" ;
105689138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
10575b0753e0Sbellard  ;;
1058cad25d69Spbrook  --disable-system) softmmu="no"
10590a8e90f4Spbrook  ;;
1060cad25d69Spbrook  --enable-system) softmmu="yes"
10610a8e90f4Spbrook  ;;
10620953a80fSZachary Amsden  --disable-user)
10630953a80fSZachary Amsden      linux_user="no" ;
10640953a80fSZachary Amsden      bsd_user="no" ;
10650953a80fSZachary Amsden  ;;
10660953a80fSZachary Amsden  --enable-user) ;;
1067831b7825Sths  --disable-linux-user) linux_user="no"
10680a8e90f4Spbrook  ;;
1069831b7825Sths  --enable-linux-user) linux_user="yes"
1070831b7825Sths  ;;
107184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
107284778508Sblueswir1  ;;
107384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
107484778508Sblueswir1  ;;
107540d6444eSAvi Kivity  --enable-pie) pie="yes"
107634005a00SKirill A. Shutemov  ;;
107740d6444eSAvi Kivity  --disable-pie) pie="no"
107834005a00SKirill A. Shutemov  ;;
107985aa5189Sbellard  --enable-werror) werror="yes"
108085aa5189Sbellard  ;;
108185aa5189Sbellard  --disable-werror) werror="no"
108285aa5189Sbellard  ;;
108363678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
108463678e17SSteven Noonan  ;;
108563678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
108663678e17SSteven Noonan  ;;
10874d3b6f6eSbalrog  --disable-curses) curses="no"
10884d3b6f6eSbalrog  ;;
1089c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1090c584a6d0SJuan Quintela  ;;
1091769ce76dSAlexander Graf  --disable-curl) curl="no"
1092769ce76dSAlexander Graf  ;;
1093788c8196SJuan Quintela  --enable-curl) curl="yes"
1094788c8196SJuan Quintela  ;;
10952df87df7SJuan Quintela  --disable-fdt) fdt="no"
10962df87df7SJuan Quintela  ;;
10972df87df7SJuan Quintela  --enable-fdt) fdt="yes"
10982df87df7SJuan Quintela  ;;
10995c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
11005c6c3a6cSChristoph Hellwig  ;;
11015c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
11025c6c3a6cSChristoph Hellwig  ;;
1103758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1104758e8e38SVenkateswararao Jujjuri (JV)  ;;
1105758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1106758e8e38SVenkateswararao Jujjuri (JV)  ;;
110777755340Sths  --disable-blobs) blobs="no"
110877755340Sths  ;;
11094a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
11104a19f1ecSpbrook  ;;
1111519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1112519175a2SAlex Barcelo  ;;
111370c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
111470c60c08SStefan Hajnoczi  ;;
111570c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
111670c60c08SStefan Hajnoczi  ;;
11177d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
11187d992e4dSPeter Lieven  ;;
1119f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1120f0d92b56SLongpeng(Mike)  ;;
1121f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1122f0d92b56SLongpeng(Mike)  ;;
1123a25dba17SJuan Quintela  --disable-docs) docs="no"
112470ec5dc0SAnthony Liguori  ;;
1125a25dba17SJuan Quintela  --enable-docs) docs="yes"
112683a3ab8bSJuan Quintela  ;;
1127d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1128d5970055SMichael S. Tsirkin  ;;
1129d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1130d5970055SMichael S. Tsirkin  ;;
11315e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
11325e9be92dSNicholas Bellinger  ;;
11335e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
11345e9be92dSNicholas Bellinger  ;;
1135fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1136fc0b9b0eSStefan Hajnoczi  ;;
1137fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1138fc0b9b0eSStefan Hajnoczi  ;;
1139da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
114020ff075bSMichael Walle  ;;
1141da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
114220ff075bSMichael Walle  ;;
1143f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1144f27aaf4bSChristian Brunner  ;;
1145f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1146f27aaf4bSChristian Brunner  ;;
11478c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
11488c84cf11SSergei Trofimovich  ;;
11498c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
11508c84cf11SSergei Trofimovich  ;;
11517b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1152111a38b0SRobert Relyea  ;;
11537b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1154111a38b0SRobert Relyea  ;;
11552b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
11562b2325ffSGerd Hoffmann  ;;
11572b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
11582b2325ffSGerd Hoffmann  ;;
115969354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
116069354a83SHans de Goede  ;;
116169354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
116269354a83SHans de Goede  ;;
11631ece9905SAlon Levy  --disable-zlib-test) zlib="no"
11641ece9905SAlon Levy  ;;
1165b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1166b25c9dffSStefan Weil  ;;
1167607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1168607dacd0Sqiaonuohan  ;;
1169b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1170b25c9dffSStefan Weil  ;;
1171607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1172607dacd0Sqiaonuohan  ;;
11736b383c08SPeter Wu  --disable-bzip2) bzip2="no"
11746b383c08SPeter Wu  ;;
11756b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
11766b383c08SPeter Wu  ;;
1177d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1178d138cee9SMichael Roth  ;;
1179d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1180d138cee9SMichael Roth  ;;
11819dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
11829dacf32dSYossi Hindin  ;;
11839dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
11849dacf32dSYossi Hindin  ;;
1185d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1186d9840e25STomoki Sekiyama  ;;
1187d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1188d9840e25STomoki Sekiyama  ;;
1189d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1190d9840e25STomoki Sekiyama  ;;
1191d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1192d9840e25STomoki Sekiyama  ;;
1193d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1194d9840e25STomoki Sekiyama  ;;
1195d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1196d9840e25STomoki Sekiyama  ;;
11974b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
11984b1c11fdSDaniel P. Berrange  ;;
11994b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
12004b1c11fdSDaniel P. Berrange  ;;
1201f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1202f794573eSEduardo Otubo  ;;
1203f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1204f794573eSEduardo Otubo  ;;
1205eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1206eb100396SBharata B Rao  ;;
1207eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1208eb100396SBharata B Rao  ;;
120952b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
121052b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1211583f6e7bSStefan Hajnoczi  ;;
1212cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1213cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1214cb6414dfSFam Zheng  ;;
1215315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1216315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1217315d3184SFam Zheng  ;;
1218a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1219a4ccabcfSAnthony Liguori  ;;
1220a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1221a4ccabcfSAnthony Liguori  ;;
1222a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1223a1c5e949SDaniel P. Berrange  ;;
1224ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1225ddbb0d09SDaniel P. Berrange  ;;
1226ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1227ddbb0d09SDaniel P. Berrange  ;;
122891bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
122991bfcdb0SDaniel P. Berrange  ;;
123091bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
123191bfcdb0SDaniel P. Berrange  ;;
123291bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
123391bfcdb0SDaniel P. Berrange  ;;
123491bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
123591bfcdb0SDaniel P. Berrange  ;;
12362da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
12372da776dbSMichael R. Hines  ;;
12382da776dbSMichael R. Hines  --disable-rdma) rdma="no"
12392da776dbSMichael R. Hines  ;;
1240528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1241528de90aSDaniel P. Berrange  ;;
1242bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1243bbbf9bfbSStefan Weil  ;;
1244bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1245bbbf9bfbSStefan Weil  ;;
12469d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
12479d9e1521SGerd Hoffmann  ;;
12489d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
12499d9e1521SGerd Hoffmann  ;;
1250e91c793cSCole Robinson  --disable-tpm) tpm="no"
1251e91c793cSCole Robinson  ;;
1252ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1253ab214c29SStefan Berger  ;;
12540a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
12550a12ec87SRichard W.M. Jones  ;;
12560a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
12570a12ec87SRichard W.M. Jones  ;;
1258ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1259ed1701c6SDr. David Alan Gilbert  ;;
1260ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1261ed1701c6SDr. David Alan Gilbert  ;;
1262a99d57bbSWanlong Gao  --disable-numa) numa="no"
1263a99d57bbSWanlong Gao  ;;
1264a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1265a99d57bbSWanlong Gao  ;;
12662847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
12672847b469SFam Zheng  ;;
12682847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
12692847b469SFam Zheng  ;;
12707b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
12717b01cb97SAlexandre Derumier  ;;
12727b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
12737b01cb97SAlexandre Derumier  ;;
1274a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1275a6b1d4c0SChanglong Xie  ;;
1276a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1277a6b1d4c0SChanglong Xie  ;;
1278da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1279da92c3ffSAshish Mittal  ;;
1280da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1281da92c3ffSAshish Mittal  ;;
1282e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1283e6a74868SMarc-André Lureau  ;;
1284e6a74868SMarc-André Lureau  --enable-vhost-user)
1285e6a74868SMarc-André Lureau      vhost_user="yes"
1286e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1287e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1288e6a74868SMarc-André Lureau      fi
1289e6a74868SMarc-André Lureau  ;;
12902d2ad6d0SFam Zheng  *)
12912d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
12922d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
12932d2ad6d0SFam Zheng      exit 1
12947f1559c6Sbalrog  ;;
12957d13299dSbellard  esac
12967d13299dSbellarddone
12977d13299dSbellard
1298e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1299e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1300e6a74868SMarc-André Lureau        vhost_user="no"
1301e6a74868SMarc-André Lureau    else
1302e6a74868SMarc-André Lureau        vhost_user="yes"
1303e6a74868SMarc-André Lureau    fi
1304e6a74868SMarc-André Lureaufi
1305e6a74868SMarc-André Lureau
130640293e58Sbellardcase "$cpu" in
1307e3608d66SRichard Henderson    ppc)
1308e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1309e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1310e3608d66SRichard Henderson           ;;
1311e3608d66SRichard Henderson    ppc64)
1312e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1313e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1314e3608d66SRichard Henderson           ;;
13159b9c37c3SRichard Henderson    sparc)
1316f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1317f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
13183142255cSblueswir1           ;;
1319ed968ff1SJuan Quintela    sparc64)
132079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1321f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
13223142255cSblueswir1           ;;
132376d83bdeSths    s390)
1324061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
132528d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
132628d7cc49SRichard Henderson           ;;
132728d7cc49SRichard Henderson    s390x)
1328061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
132928d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
133076d83bdeSths           ;;
133140293e58Sbellard    i386)
133279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
13330c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
13342b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
133540293e58Sbellard           ;;
133640293e58Sbellard    x86_64)
13377ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
13387ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
13397ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
13407ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
13410c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
13422b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1343379f6698SPaul Brook           ;;
1344c72b26ecSRichard Henderson    x32)
1345c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1346c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1347c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1348c72b26ecSRichard Henderson           ;;
134930163d89SPeter Maydell    # No special flags required for other host CPUs
13503142255cSblueswir1esac
13513142255cSblueswir1
135279f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
135379f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
135479f3b12fSPeter Crosthwaite
1355affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1356affc88ccSPeter Maydell# support, even if we're using TCI.
1357affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1358affc88ccSPeter Maydell  bsd_user="no"
1359affc88ccSPeter Maydell  linux_user="no"
1360affc88ccSPeter Maydellfi
1361affc88ccSPeter Maydell
136260e0df25SPeter Maydelldefault_target_list=""
136360e0df25SPeter Maydell
13646e92f823SPeter Maydellmak_wilds=""
13656e92f823SPeter Maydell
136660e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
13676e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
136860e0df25SPeter Maydellfi
136960e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
13706e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
137160e0df25SPeter Maydellfi
137260e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
13736e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
137460e0df25SPeter Maydellfi
137560e0df25SPeter Maydell
13766e92f823SPeter Maydellfor config in $mak_wilds; do
13776e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
13786e92f823SPeter Maydelldone
13796e92f823SPeter Maydell
1380c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
138164a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1382c53eeaf7SStefan Hajnoczi
1383af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1384af5db58eSpbrookcat << EOF
1385af5db58eSpbrook
1386af5db58eSpbrookUsage: configure [options]
1387af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1388af5db58eSpbrook
138908fb77edSStefan WeilStandard options:
139008fb77edSStefan Weil  --help                   print this message
139108fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
139208fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
139308fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
139408fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
139508fb77edSStefan Weil$(echo Available targets: $default_target_list | \
139608fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
139708fb77edSStefan Weil
139808fb77edSStefan WeilAdvanced options (experts only):
139908fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
140008fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
140108fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
140208fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
140308fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
140408fb77edSStefan Weil                           build time
140508fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
140608fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
140708fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
140811cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
140908fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
141008fb77edSStefan Weil  --make=MAKE              use specified make [$make]
141108fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
141208fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
141308fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
141408fb77edSStefan Weil  --static                 enable static build [$static]
141508fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
141608fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
141708fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
141808fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
141908fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
142008fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
142108fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
14223d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
1423e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
142408fb77edSStefan Weil  --enable-debug           enable common debug build options
142508fb77edSStefan Weil  --disable-strip          disable stripping binaries
142608fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
142763678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
142808fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
142908fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
143008fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
143108fb77edSStefan Weil  --block-drv-rw-whitelist=L
143208fb77edSStefan Weil                           set block driver read-write whitelist
143308fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
143408fb77edSStefan Weil  --block-drv-ro-whitelist=L
143508fb77edSStefan Weil                           set block driver read-only whitelist
143608fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
14375b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1438c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
143908fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
144008fb77edSStefan Weil                           Default:trace-<pid>
1441c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1442c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1443c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1444c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
144508fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
144633c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
144708fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
144808fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1449c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1450c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1451c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1452a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1453c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1454c12d66aaSLin Ma  --enable-profiler        profiler support
1455c12d66aaSLin Ma  --enable-xen-pv-domain-build
1456c12d66aaSLin Ma                           xen pv domain builder
1457c12d66aaSLin Ma  --enable-debug-stack-usage
1458c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1459c23f23b9SMichael Tokarev
1460c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1461c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1462c23f23b9SMichael Tokarev
1463c23f23b9SMichael Tokarev  system          all system emulation targets
1464c23f23b9SMichael Tokarev  user            supported user emulation targets
1465c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1466c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1467c23f23b9SMichael Tokarev  docs            build documentation
1468c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1469c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1470c23f23b9SMichael Tokarev  pie             Position Independent Executables
1471c23f23b9SMichael Tokarev  modules         modules support
1472c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1473c23f23b9SMichael Tokarev  debug-info      debugging information
1474c23f23b9SMichael Tokarev  sparse          sparse checker
1475c23f23b9SMichael Tokarev
1476ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
147791bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
147891bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1479c23f23b9SMichael Tokarev  sdl             SDL UI
1480c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1481c23f23b9SMichael Tokarev  gtk             gtk UI
1482c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1483c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1484c23f23b9SMichael Tokarev  curses          curses UI
1485c23f23b9SMichael Tokarev  vnc             VNC UI support
1486c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1487c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1488c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1489c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1490c23f23b9SMichael Tokarev  virtfs          VirtFS
1491fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1492c23f23b9SMichael Tokarev  xen             xen backend driver support
1493c23f23b9SMichael Tokarev  xen-pci-passthrough
1494c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1495c23f23b9SMichael Tokarev  curl            curl connectivity
1496c23f23b9SMichael Tokarev  fdt             fdt device tree
1497c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1498c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1499b0cb0a66SVincent Palatin  hax             HAX acceleration support
1500c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1501c23f23b9SMichael Tokarev  vde             support for vde network
1502c23f23b9SMichael Tokarev  netmap          support for netmap network
1503c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1504c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1505c23f23b9SMichael Tokarev  attr            attr and xattr support
1506c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1507c23f23b9SMichael Tokarev  spice           spice
1508c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1509c23f23b9SMichael Tokarev  libiscsi        iscsi support
1510c23f23b9SMichael Tokarev  libnfs          nfs support
15117b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1512c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1513ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1514c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1515c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1516c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1517c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1518c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1519c23f23b9SMichael Tokarev  seccomp         seccomp support
1520c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1521c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1522c23f23b9SMichael Tokarev  tpm             TPM support
1523c23f23b9SMichael Tokarev  libssh2         ssh block device support
1524c23f23b9SMichael Tokarev  numa            libnuma support
1525c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
15267b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1527a6b1d4c0SChanglong Xie  replication     replication support
1528c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1529c12d66aaSLin Ma  opengl          opengl support
1530c12d66aaSLin Ma  virglrenderer   virgl rendering support
1531c12d66aaSLin Ma  xfsctl          xfsctl support
1532c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1533c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1534da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1535f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1536e6a74868SMarc-André Lureau  vhost-user      vhost-user support
153708fb77edSStefan Weil
153808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1539af5db58eSpbrookEOF
15402d2ad6d0SFam Zhengexit 0
1541af5db58eSpbrookfi
1542af5db58eSpbrook
1543c53eeaf7SStefan Hajnocziif ! has $python; then
1544c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1545c53eeaf7SStefan Hajnoczifi
1546c53eeaf7SStefan Hajnoczi
1547c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1548c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1549c53eeaf7SStefan Hajnocziif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1550c53eeaf7SStefan Hajnoczi  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1551c53eeaf7SStefan Hajnoczi      "Note that Python 3 or later is not yet supported." \
1552c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1553c53eeaf7SStefan Hajnoczifi
1554c53eeaf7SStefan Hajnoczi
1555c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1556c53eeaf7SStefan Hajnoczipython="$python -B"
1557c53eeaf7SStefan Hajnoczi
1558359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1559359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1560359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1561359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1562359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1563359bc95dSPeter Maydell    else
156476ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1565359bc95dSPeter Maydell    fi
1566359bc95dSPeter Maydellfi
1567359bc95dSPeter Maydell
15689c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
15699c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
15709c83ffd8SPeter Maydellif test -z "$werror" ; then
15719c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1572e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
15739c83ffd8SPeter Maydell        werror="yes"
15749c83ffd8SPeter Maydell    else
15759c83ffd8SPeter Maydell        werror="no"
15769c83ffd8SPeter Maydell    fi
15779c83ffd8SPeter Maydellfi
15789c83ffd8SPeter Maydell
15798d05095cSPaolo Bonzini# check that the C compiler works.
158093b25869SJohn Snowwrite_c_skeleton;
15818d05095cSPaolo Bonziniif compile_object ; then
15828d05095cSPaolo Bonzini  : C compiler works ok
15838d05095cSPaolo Bonzinielse
158476ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
15858d05095cSPaolo Bonzinifi
15860ef74c74SPeter Maydellif ! compile_prog ; then
15870ef74c74SPeter Maydell    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
15880ef74c74SPeter Maydellfi
15898d05095cSPaolo Bonzini
1590fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1591fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1592fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1593fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1594fb59dabdSPeter Maydell    # host OS we should stop now.
1595951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1596fb59dabdSPeter Maydellfi
1597fb59dabdSPeter Maydell
15988d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
15998d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1600ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1601435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1602b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
160371429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
16046ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
16056ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
16066ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
16076ca026cbSPeter Maydell# so it's too error prone.
160893b25869SJohn Snow
160993b25869SJohn Snowcc_has_warning_flag() {
161093b25869SJohn Snow    write_c_skeleton;
161193b25869SJohn Snow
1612a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1613a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1614a1d29d6cSPeter Maydell    # warning options).
161593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
161693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
161793b25869SJohn Snow}
161893b25869SJohn Snow
161993b25869SJohn Snowfor flag in $gcc_flags; do
162093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16218d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16228d05095cSPaolo Bonzini    fi
16238d05095cSPaolo Bonzinidone
16248d05095cSPaolo Bonzini
162563678e17SSteven Noonanif test "$stack_protector" != "no"; then
1626fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1627fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1628fccd35a0SRodrigo Rebello{
1629fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1630fccd35a0SRodrigo Rebello    while (*c) {
1631fccd35a0SRodrigo Rebello        *p++ = *c++;
1632fccd35a0SRodrigo Rebello    }
1633fccd35a0SRodrigo Rebello    return 0;
1634fccd35a0SRodrigo Rebello}
1635fccd35a0SRodrigo RebelloEOF
163663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16373b463a3fSMiroslav Rezanina  sp_on=0
163863678e17SSteven Noonan  for flag in $gcc_flags; do
1639590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1640590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1641590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1642590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
164363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16443b463a3fSMiroslav Rezanina      sp_on=1
164563678e17SSteven Noonan      break
164663678e17SSteven Noonan    fi
164763678e17SSteven Noonan  done
16483b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
16493b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
16503b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
16513b463a3fSMiroslav Rezanina    fi
16523b463a3fSMiroslav Rezanina  fi
165337746c5eSMarc-André Lureaufi
165437746c5eSMarc-André Lureau
1655cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1656cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1657cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1658cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1659cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1660cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1661cbdd1999SPaolo Bonziniint main(void) { return 0; }
1662cbdd1999SPaolo Bonzini#else
1663cbdd1999SPaolo Bonzini#error No bug in this compiler.
1664cbdd1999SPaolo Bonzini#endif
1665cbdd1999SPaolo BonziniEOF
1666cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1667cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1668cbdd1999SPaolo Bonzinifi
1669cbdd1999SPaolo Bonzini
167040d6444eSAvi Kivityif test "$static" = "yes" ; then
1671aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1672aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1673aa0d1f44SPaolo Bonzini  fi
167440d6444eSAvi Kivity  if test "$pie" = "yes" ; then
167576ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
167640d6444eSAvi Kivity  else
167740d6444eSAvi Kivity    pie="no"
167840d6444eSAvi Kivity  fi
167940d6444eSAvi Kivityfi
168040d6444eSAvi Kivity
1681768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1682768b7855SEmilio G. Cota  cat > $TMPC << EOF
1683768b7855SEmilio G. Cotastatic __thread int tls_var;
1684768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1685768b7855SEmilio G. CotaEOF
1686768b7855SEmilio G. Cota
1687768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1688768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1689768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1690768b7855SEmilio G. Cotafi
1691768b7855SEmilio G. Cota
169240d6444eSAvi Kivityif test "$pie" = ""; then
169340d6444eSAvi Kivity  case "$cpu-$targetos" in
1694c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
169540d6444eSAvi Kivity      ;;
169640d6444eSAvi Kivity    *)
169740d6444eSAvi Kivity      pie="no"
169840d6444eSAvi Kivity      ;;
169940d6444eSAvi Kivity  esac
170040d6444eSAvi Kivityfi
170140d6444eSAvi Kivity
170240d6444eSAvi Kivityif test "$pie" != "no" ; then
170340d6444eSAvi Kivity  cat > $TMPC << EOF
170421d4a791SAvi Kivity
170521d4a791SAvi Kivity#ifdef __linux__
170621d4a791SAvi Kivity#  define THREAD __thread
170721d4a791SAvi Kivity#else
170821d4a791SAvi Kivity#  define THREAD
170921d4a791SAvi Kivity#endif
171021d4a791SAvi Kivity
171121d4a791SAvi Kivitystatic THREAD int tls_var;
171221d4a791SAvi Kivity
171321d4a791SAvi Kivityint main(void) { return tls_var; }
171421d4a791SAvi Kivity
171540d6444eSAvi KivityEOF
171640d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
171740d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
171840d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
171940d6444eSAvi Kivity    pie="yes"
172040d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
172140d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
172240d6444eSAvi Kivity    fi
172340d6444eSAvi Kivity  else
172440d6444eSAvi Kivity    if test "$pie" = "yes"; then
172576ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
172640d6444eSAvi Kivity    else
172740d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
172840d6444eSAvi Kivity      pie="no"
172940d6444eSAvi Kivity    fi
173040d6444eSAvi Kivity  fi
173146eef33bSBrad
1732e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
173346eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
173446eef33bSBrad    LDFLAGS_NOPIE="-nopie"
173546eef33bSBrad  fi
173640d6444eSAvi Kivityfi
173740d6444eSAvi Kivity
173809dada40SPaolo Bonzini##########################################
173909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
174009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
174109dada40SPaolo Bonzini# specification is necessary
174209dada40SPaolo Bonzini
174309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
174409dada40SPaolo Bonzini  cat > $TMPC << EOF
174509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
174609dada40SPaolo Bonzini{
174709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
174809dada40SPaolo Bonzini}
174909dada40SPaolo Bonzini
175009dada40SPaolo Bonziniint main(void)
175109dada40SPaolo Bonzini{
175209dada40SPaolo Bonzini  int val = 42;
17531405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
175409dada40SPaolo Bonzini  sfaa(&val);
175509dada40SPaolo Bonzini  return val;
175609dada40SPaolo Bonzini}
175709dada40SPaolo BonziniEOF
175809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
175909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
176009dada40SPaolo Bonzini  fi
176109dada40SPaolo Bonzinifi
176209dada40SPaolo Bonzini
176309dada40SPaolo Bonzini#########################################
1764ec530c81Sbellard# Solaris specific configure tool chain decisions
176509dada40SPaolo Bonzini
1766ec530c81Sbellardif test "$solaris" = "yes" ; then
17676792aa11SLoïc Minier  if has $install; then
17686792aa11SLoïc Minier    :
17696792aa11SLoïc Minier  else
177076ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
177176ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
177276ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1773ec530c81Sbellard  fi
177489138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
177576ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
177676ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
177776ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1778ec530c81Sbellard  fi
17796792aa11SLoïc Minier  if has ar; then
17806792aa11SLoïc Minier    :
17816792aa11SLoïc Minier  else
1782ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
178376ad07a4SPeter Maydell      error_exit "No path includes ar" \
178476ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1785ec530c81Sbellard    fi
178676ad07a4SPeter Maydell    error_exit "No path includes ar"
1787ec530c81Sbellard  fi
1788ec530c81Sbellardfi
1789ec530c81Sbellard
1790afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1791d880a3baSPaolo Bonzini    for target in $default_target_list; do
1792d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1793d880a3baSPaolo Bonzini            target_list="$target_list $target"
1794d880a3baSPaolo Bonzini    done
1795d880a3baSPaolo Bonzini    target_list="${target_list# }"
1796121afa9eSAnthony Liguorielse
179789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1798d880a3baSPaolo Bonzini    for target in $target_list; do
179925b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
180025b48338SPeter Maydell        # friendly error message than if we let it fall through.
180125b48338SPeter Maydell        case " $default_target_list " in
180225b48338SPeter Maydell            *" $target "*)
180325b48338SPeter Maydell                ;;
180425b48338SPeter Maydell            *)
180525b48338SPeter Maydell                error_exit "Unknown target name '$target'"
180625b48338SPeter Maydell                ;;
180725b48338SPeter Maydell        esac
1808d880a3baSPaolo Bonzini        supported_target $target || exit 1
180925b48338SPeter Maydell    done
1810d880a3baSPaolo Bonzinifi
181125b48338SPeter Maydell
1812f55fe278SPaolo Bonzini# see if system emulation was really requested
1813f55fe278SPaolo Bonzinicase " $target_list " in
1814f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1815f55fe278SPaolo Bonzini  ;;
1816f55fe278SPaolo Bonzini  *) softmmu=no
1817f55fe278SPaolo Bonzini  ;;
1818f55fe278SPaolo Bonziniesac
18195327cf48Sbellard
1820249247c9SJuan Quintelafeature_not_found() {
1821249247c9SJuan Quintela  feature=$1
182221684af0SStewart Smith  remedy=$2
1823249247c9SJuan Quintela
182476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
182521684af0SStewart Smith      "configure was not able to find it." \
182621684af0SStewart Smith      "$remedy"
1827249247c9SJuan Quintela}
1828249247c9SJuan Quintela
18297d13299dSbellard# ---
18307d13299dSbellard# big/little endian test
18317d13299dSbellardcat > $TMPC << EOF
183261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
183361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
183461cc919fSMike Frysingerextern int foo(short *, short *);
183561cc919fSMike Frysingerint main(int argc, char *argv[]) {
183661cc919fSMike Frysinger    return foo(big_endian, little_endian);
18377d13299dSbellard}
18387d13299dSbellardEOF
18397d13299dSbellard
184061cc919fSMike Frysingerif compile_object ; then
184161cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
184261cc919fSMike Frysinger        bigendian="yes"
184361cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
184461cc919fSMike Frysinger        bigendian="no"
18457d13299dSbellard    else
18467d13299dSbellard        echo big/little test failed
18477d13299dSbellard    fi
18487d13299dSbellardelse
184961cc919fSMike Frysinger    echo big/little test failed
18507d13299dSbellardfi
18517d13299dSbellard
1852b0a47e79SJuan Quintela##########################################
1853a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1854a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1855a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1856a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1857a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1858a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1859a30878e7SPeter Maydell    fi
1860a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1861a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1862a30878e7SPeter Maydell    fi
1863a30878e7SPeter Maydell    gtk=no
1864a30878e7SPeter Maydell    sdl=no
1865a30878e7SPeter Maydellfi
1866a30878e7SPeter Maydell
18676b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
18686b39b063SEric Blakecat > $TMPC << EOF
18696b39b063SEric Blake#include <stdint.h>
18706b39b063SEric Blake#include <stdio.h>
18716b39b063SEric Blakeint main(int argc, char *argv[]) {
18726b39b063SEric Blake    return printf("%zu", SIZE_MAX);
18736b39b063SEric Blake}
18746b39b063SEric BlakeEOF
18756b39b063SEric Blakehave_broken_size_max=no
18766b39b063SEric Blakeif ! compile_object -Werror ; then
18776b39b063SEric Blake    have_broken_size_max=yes
18786b39b063SEric Blakefi
18796b39b063SEric Blake
1880a30878e7SPeter Maydell##########################################
1881015a33bdSGonglei# L2TPV3 probe
1882015a33bdSGonglei
1883015a33bdSGongleicat > $TMPC <<EOF
1884015a33bdSGonglei#include <sys/socket.h>
1885bff6cb72SMichael Tokarev#include <linux/ip.h>
1886015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1887015a33bdSGongleiEOF
1888015a33bdSGongleiif compile_prog "" "" ; then
1889015a33bdSGonglei  l2tpv3=yes
1890015a33bdSGongleielse
1891015a33bdSGonglei  l2tpv3=no
1892015a33bdSGongleifi
1893015a33bdSGonglei
1894015a33bdSGonglei##########################################
18954d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
18964d9310f4SDaniel P. Berrange
18974d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
18984d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
18994d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
19004d9310f4SDaniel P. Berrange    #
19014d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
19024d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
19034d9310f4SDaniel P. Berrange    #
19044d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
19054d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
19064d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
19074d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
19084d9310f4SDaniel P. Berrange    # that for you.
19094d9310f4SDaniel P. Berrange    #
19104d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
19114d9310f4SDaniel P. Berrange    # are not in fact redundant.
19124d9310f4SDaniel P. Berrangecat > $TMPC << EOF
19134d9310f4SDaniel P. Berrange#include <unistd.h>
19144d9310f4SDaniel P. Berrange#include <time.h>
19154d9310f4SDaniel P. Berrange#undef localtime_r
19164d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
19174d9310f4SDaniel P. BerrangeEOF
19184d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
19194d9310f4SDaniel P. Berrange        localtime_r="yes"
19204d9310f4SDaniel P. Berrange    else
19214d9310f4SDaniel P. Berrange        localtime_r="no"
19224d9310f4SDaniel P. Berrange    fi
19234d9310f4SDaniel P. Berrangefi
19244d9310f4SDaniel P. Berrange
19254d9310f4SDaniel P. Berrange##########################################
1926779ab5e3SStefan Weil# pkg-config probe
1927779ab5e3SStefan Weil
1928779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
192976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1930779ab5e3SStefan Weilfi
1931779ab5e3SStefan Weil
1932779ab5e3SStefan Weil##########################################
1933b0a47e79SJuan Quintela# NPTL probe
1934b0a47e79SJuan Quintela
193524cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1936bd0c5661Spbrook  cat > $TMPC <<EOF
1937bd0c5661Spbrook#include <sched.h>
193830813ceaSpbrook#include <linux/futex.h>
1939182eacc0SStefan Weilint main(void) {
1940bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1941bd0c5661Spbrook#error bork
1942bd0c5661Spbrook#endif
1943182eacc0SStefan Weil  return 0;
1944bd0c5661Spbrook}
1945bd0c5661SpbrookEOF
194624cb36a6SPeter Maydell  if ! compile_object ; then
194721684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1948b0a47e79SJuan Quintela  fi
1949bd0c5661Spbrookfi
1950bd0c5661Spbrook
195199f2dbd3SLiang Li#########################################
1952ac62922eSbalrog# zlib check
1953ac62922eSbalrog
19541ece9905SAlon Levyif test "$zlib" != "no" ; then
1955ac62922eSbalrog    cat > $TMPC << EOF
1956ac62922eSbalrog#include <zlib.h>
1957ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1958ac62922eSbalrogEOF
195952166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1960ac62922eSbalrog        :
1961ac62922eSbalrog    else
196276ad07a4SPeter Maydell        error_exit "zlib check failed" \
196376ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1964ac62922eSbalrog    fi
19651ece9905SAlon Levyfi
1966eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1967ac62922eSbalrog
1968ac62922eSbalrog##########################################
1969607dacd0Sqiaonuohan# lzo check
1970607dacd0Sqiaonuohan
1971607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1972607dacd0Sqiaonuohan    cat > $TMPC << EOF
1973607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1974607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1975607dacd0SqiaonuohanEOF
1976607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1977607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
1978b25c9dffSStefan Weil        lzo="yes"
1979b25c9dffSStefan Weil    else
1980b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
1981b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
1982b25c9dffSStefan Weil        fi
1983b25c9dffSStefan Weil        lzo="no"
1984b25c9dffSStefan Weil    fi
1985607dacd0Sqiaonuohanfi
1986607dacd0Sqiaonuohan
1987607dacd0Sqiaonuohan##########################################
1988607dacd0Sqiaonuohan# snappy check
1989607dacd0Sqiaonuohan
1990607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1991607dacd0Sqiaonuohan    cat > $TMPC << EOF
1992607dacd0Sqiaonuohan#include <snappy-c.h>
1993607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1994607dacd0SqiaonuohanEOF
1995607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1996607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
1997b25c9dffSStefan Weil        snappy="yes"
1998b25c9dffSStefan Weil    else
1999b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2000b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2001b25c9dffSStefan Weil        fi
2002b25c9dffSStefan Weil        snappy="no"
2003b25c9dffSStefan Weil    fi
2004607dacd0Sqiaonuohanfi
2005607dacd0Sqiaonuohan
2006607dacd0Sqiaonuohan##########################################
20076b383c08SPeter Wu# bzip2 check
20086b383c08SPeter Wu
20096b383c08SPeter Wuif test "$bzip2" != "no" ; then
20106b383c08SPeter Wu    cat > $TMPC << EOF
20116b383c08SPeter Wu#include <bzlib.h>
20126b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
20136b383c08SPeter WuEOF
20146b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
20156b383c08SPeter Wu        bzip2="yes"
20166b383c08SPeter Wu    else
20176b383c08SPeter Wu        if test "$bzip2" = "yes"; then
20186b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
20196b383c08SPeter Wu        fi
20206b383c08SPeter Wu        bzip2="no"
20216b383c08SPeter Wu    fi
20226b383c08SPeter Wufi
20236b383c08SPeter Wu
20246b383c08SPeter Wu##########################################
2025f794573eSEduardo Otubo# libseccomp check
2026f794573eSEduardo Otubo
2027f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2028693e5910SAndrew Jones    case "$cpu" in
2029693e5910SAndrew Jones    i386|x86_64)
2030ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2031693e5910SAndrew Jones        ;;
20325ce43972SJames Hogan    mips)
20335ce43972SJames Hogan        libseccomp_minver="2.2.0"
20345ce43972SJames Hogan        ;;
2035693e5910SAndrew Jones    arm|aarch64)
2036693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2037693e5910SAndrew Jones        ;;
20383aa35fcfSThomas Huth    ppc|ppc64|s390x)
20393e684455SMichael Strosaker        libseccomp_minver="2.3.0"
20403e684455SMichael Strosaker        ;;
2041693e5910SAndrew Jones    *)
2042693e5910SAndrew Jones        libseccomp_minver=""
2043693e5910SAndrew Jones        ;;
2044693e5910SAndrew Jones    esac
2045693e5910SAndrew Jones
2046693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2047693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2048c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2049c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2050f794573eSEduardo Otubo        seccomp="yes"
2051f794573eSEduardo Otubo    else
2052f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2053693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2054693e5910SAndrew Jones                feature_not_found "libseccomp" \
2055693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2056693e5910SAndrew Jones            else
2057693e5910SAndrew Jones                feature_not_found "libseccomp" \
2058693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2059693e5910SAndrew Jones            fi
2060896848f0SEduardo Otubo        fi
2061e84d5956SYann E. MORIN        seccomp="no"
2062f794573eSEduardo Otubo    fi
2063f794573eSEduardo Otubofi
2064f794573eSEduardo Otubo##########################################
2065e37630caSaliguori# xen probe
2066e37630caSaliguori
2067fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2068c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2069c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2070c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2071c1cdd9d5SJuergen Gross
2072c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2073c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2074c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2075c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2076c1cdd9d5SJuergen Gross    xen=yes
2077c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2078c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
2079c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2080c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2081c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2082c1cdd9d5SJuergen Gross  else
2083c1cdd9d5SJuergen Gross
2084b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2085d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2086d5b93ddfSAnthony PERARD
208750ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
208850ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
208950ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
209050ced5b3SStefan Weil
209150ced5b3SStefan Weil    # Xen (any)
209250ced5b3SStefan Weil    cat > $TMPC <<EOF
209350ced5b3SStefan Weil#include <xenctrl.h>
209450ced5b3SStefan Weilint main(void) {
209550ced5b3SStefan Weil  return 0;
209650ced5b3SStefan Weil}
209750ced5b3SStefan WeilEOF
209850ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
209950ced5b3SStefan Weil      # Xen not found
210050ced5b3SStefan Weil      if test "$xen" = "yes" ; then
210121684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
210250ced5b3SStefan Weil      fi
210350ced5b3SStefan Weil      xen=no
210450ced5b3SStefan Weil
2105d5b93ddfSAnthony PERARD    # Xen unstable
210669deef08SPeter Maydell    elif
210769deef08SPeter Maydell        cat > $TMPC <<EOF &&
21085ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21095ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
21105ba3d756SIgor Druzhininint main(void) {
21115ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
21125ba3d756SIgor Druzhinin
21135ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
21145ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
21155ba3d756SIgor Druzhinin
21165ba3d756SIgor Druzhinin  return 0;
21175ba3d756SIgor Druzhinin}
21185ba3d756SIgor DruzhininEOF
21195ba3d756SIgor Druzhinin        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
21205ba3d756SIgor Druzhinin      then
21215ba3d756SIgor Druzhinin      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
21225ba3d756SIgor Druzhinin      xen_ctrl_version=41000
21235ba3d756SIgor Druzhinin      xen=yes
21245ba3d756SIgor Druzhinin    elif
21255ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2126da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2127da8090ccSPaul Durrant#define __XEN_TOOLS__
2128da8090ccSPaul Durrant#include <xendevicemodel.h>
2129da8090ccSPaul Durrantint main(void) {
2130da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2131da8090ccSPaul Durrant
2132da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2133da8090ccSPaul Durrant  xendevicemodel_close(xd);
2134da8090ccSPaul Durrant
2135da8090ccSPaul Durrant  return 0;
2136da8090ccSPaul Durrant}
2137da8090ccSPaul DurrantEOF
2138da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2139da8090ccSPaul Durrant      then
2140da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2141f1167ee6SJuergen Gross      xen_ctrl_version=40900
2142da8090ccSPaul Durrant      xen=yes
2143da8090ccSPaul Durrant    elif
2144da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
21455eeb39c2SIan Campbell/*
21465eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
21475eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2148b6eb9b45SPaulina Szubarczyk *
2149b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2150b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2151b6eb9b45SPaulina Szubarczyk */
2152b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2153b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2154b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2155b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2156b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2157b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2158b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2159b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2160b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2161b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2162b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2163b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2164b6eb9b45SPaulina Szubarczyk#endif
2165b6eb9b45SPaulina Szubarczykint main(void) {
2166b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2167b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2168b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2169b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2170b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2171b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2172b6eb9b45SPaulina Szubarczyk
2173b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2174b6eb9b45SPaulina Szubarczyk
2175b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2176b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2177b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2178b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2179b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2180b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2181b6eb9b45SPaulina Szubarczyk
2182b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2183b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2184b6eb9b45SPaulina Szubarczyk
2185b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2186b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2187b6eb9b45SPaulina Szubarczyk
2188b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2189b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2190b6eb9b45SPaulina Szubarczyk
2191b6eb9b45SPaulina Szubarczyk  return 0;
2192b6eb9b45SPaulina Szubarczyk}
2193b6eb9b45SPaulina SzubarczykEOF
2194b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2195b6eb9b45SPaulina Szubarczyk      then
2196f1167ee6SJuergen Gross      xen_ctrl_version=40800
2197b6eb9b45SPaulina Szubarczyk      xen=yes
2198b6eb9b45SPaulina Szubarczyk    elif
2199b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2200b6eb9b45SPaulina Szubarczyk/*
2201b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2202b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
22035eeb39c2SIan Campbell */
22045eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
22055eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
22065eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
22075eeb39c2SIan Campbell#include <xenctrl.h>
22085eeb39c2SIan Campbell#include <xenstore.h>
22095eeb39c2SIan Campbell#include <xenevtchn.h>
22105eeb39c2SIan Campbell#include <xengnttab.h>
22115eeb39c2SIan Campbell#include <xenforeignmemory.h>
22125eeb39c2SIan Campbell#include <stdint.h>
22135eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
22145eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
22155eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
22165eeb39c2SIan Campbell#endif
22175eeb39c2SIan Campbellint main(void) {
22185eeb39c2SIan Campbell  xc_interface *xc = NULL;
22195eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
22205eeb39c2SIan Campbell  xenevtchn_handle *xe;
22215eeb39c2SIan Campbell  xengnttab_handle *xg;
22225eeb39c2SIan Campbell  xen_domain_handle_t handle;
22235eeb39c2SIan Campbell
22245eeb39c2SIan Campbell  xs_daemon_open();
22255eeb39c2SIan Campbell
22265eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
22275eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
22285eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22295eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22305eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
22315eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
22325eeb39c2SIan Campbell
22335eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
22345eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
22355eeb39c2SIan Campbell
22365eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
22375eeb39c2SIan Campbell  xenevtchn_fd(xe);
22385eeb39c2SIan Campbell
22395eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
22405eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
22415eeb39c2SIan Campbell
22425eeb39c2SIan Campbell  return 0;
22435eeb39c2SIan Campbell}
22445eeb39c2SIan CampbellEOF
22455eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
22465eeb39c2SIan Campbell      then
2247f1167ee6SJuergen Gross      xen_ctrl_version=40701
22485eeb39c2SIan Campbell      xen=yes
22495eeb39c2SIan Campbell    elif
22505eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2251e37630caSaliguori#include <xenctrl.h>
2252cdadde39SRoger Pau Monne#include <stdint.h>
2253cdadde39SRoger Pau Monneint main(void) {
2254cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2255cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2256cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2257cdadde39SRoger Pau Monne  return 0;
2258cdadde39SRoger Pau Monne}
2259cdadde39SRoger Pau MonneEOF
2260cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2261cdadde39SRoger Pau Monne      then
2262f1167ee6SJuergen Gross      xen_ctrl_version=40700
2263cdadde39SRoger Pau Monne      xen=yes
2264cdadde39SRoger Pau Monne
2265cdadde39SRoger Pau Monne    # Xen 4.6
2266cdadde39SRoger Pau Monne    elif
2267cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2268cdadde39SRoger Pau Monne#include <xenctrl.h>
2269e108a3c1SAnthony PERARD#include <xenstore.h>
2270d5b93ddfSAnthony PERARD#include <stdint.h>
2271d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2272d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2273d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2274d5b93ddfSAnthony PERARD#endif
2275d5b93ddfSAnthony PERARDint main(void) {
2276d5b93ddfSAnthony PERARD  xc_interface *xc;
2277d5b93ddfSAnthony PERARD  xs_daemon_open();
2278d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2279d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2280d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2281b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22828688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2283d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
228420a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2285d8b441a3SJan Beulich  return 0;
2286d8b441a3SJan Beulich}
2287d8b441a3SJan BeulichEOF
2288d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2289d8b441a3SJan Beulich      then
2290f1167ee6SJuergen Gross      xen_ctrl_version=40600
2291d8b441a3SJan Beulich      xen=yes
2292d8b441a3SJan Beulich
2293d8b441a3SJan Beulich    # Xen 4.5
2294d8b441a3SJan Beulich    elif
2295d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2296d8b441a3SJan Beulich#include <xenctrl.h>
2297d8b441a3SJan Beulich#include <xenstore.h>
2298d8b441a3SJan Beulich#include <stdint.h>
2299d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2300d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2301d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2302d8b441a3SJan Beulich#endif
2303d8b441a3SJan Beulichint main(void) {
2304d8b441a3SJan Beulich  xc_interface *xc;
2305d8b441a3SJan Beulich  xs_daemon_open();
2306d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2307d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2308d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2309d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2310d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23113996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
23123996e85cSPaul Durrant  return 0;
23133996e85cSPaul Durrant}
23143996e85cSPaul DurrantEOF
23153996e85cSPaul Durrant        compile_prog "" "$xen_libs"
23163996e85cSPaul Durrant      then
2317f1167ee6SJuergen Gross      xen_ctrl_version=40500
23183996e85cSPaul Durrant      xen=yes
23193996e85cSPaul Durrant
23203996e85cSPaul Durrant    elif
23213996e85cSPaul Durrant        cat > $TMPC <<EOF &&
23223996e85cSPaul Durrant#include <xenctrl.h>
23233996e85cSPaul Durrant#include <xenstore.h>
23243996e85cSPaul Durrant#include <stdint.h>
23253996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
23263996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
23273996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
23283996e85cSPaul Durrant#endif
23293996e85cSPaul Durrantint main(void) {
23303996e85cSPaul Durrant  xc_interface *xc;
23313996e85cSPaul Durrant  xs_daemon_open();
23323996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
23333996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
23343996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
23353996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23363996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23378688e065SStefano Stabellini  return 0;
23388688e065SStefano Stabellini}
23398688e065SStefano StabelliniEOF
23408688e065SStefano Stabellini        compile_prog "" "$xen_libs"
234169deef08SPeter Maydell      then
2342f1167ee6SJuergen Gross      xen_ctrl_version=40200
23438688e065SStefano Stabellini      xen=yes
23448688e065SStefano Stabellini
2345e37630caSaliguori    else
2346fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2347edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2348edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2349fc321b4bSJuan Quintela      fi
2350fc321b4bSJuan Quintela      xen=no
2351e37630caSaliguori    fi
2352d5b93ddfSAnthony PERARD
2353d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2354f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
23555eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
23565eeb39c2SIan Campbell      fi
2357d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2358d5b93ddfSAnthony PERARD    fi
2359e37630caSaliguori  fi
2360c1cdd9d5SJuergen Grossfi
2361e37630caSaliguori
2362eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2363edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2364eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2365eb6fda0fSAnthony PERARD  else
2366eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
236776ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
236876ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2369eb6fda0fSAnthony PERARD    fi
2370eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2371eb6fda0fSAnthony PERARD  fi
2372eb6fda0fSAnthony PERARDfi
2373eb6fda0fSAnthony PERARD
237464a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
237564a7ad6fSIan Campbell   test "$xen" != "yes"; then
237664a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
237764a7ad6fSIan Campbell	       "which requires Xen support."
237864a7ad6fSIan Campbellfi
237964a7ad6fSIan Campbell
2380e37630caSaliguori##########################################
2381dfffc653SJuan Quintela# Sparse probe
2382dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
23830dba6195SLoïc Minier  if has cgcc; then
2384dfffc653SJuan Quintela    sparse=yes
2385dfffc653SJuan Quintela  else
2386dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
238721684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2388dfffc653SJuan Quintela    fi
2389dfffc653SJuan Quintela    sparse=no
2390dfffc653SJuan Quintela  fi
2391dfffc653SJuan Quintelafi
2392dfffc653SJuan Quintela
2393dfffc653SJuan Quintela##########################################
2394f676c67eSJeremy White# X11 probe
2395f676c67eSJeremy Whitex11_cflags=
2396f676c67eSJeremy Whitex11_libs=-lX11
2397f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
239889138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
239989138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2400f676c67eSJeremy Whitefi
2401f676c67eSJeremy White
2402f676c67eSJeremy White##########################################
2403a4ccabcfSAnthony Liguori# GTK probe
2404a4ccabcfSAnthony Liguori
24059e04c683SStefan Weilif test "$gtkabi" = ""; then
24065fe309ffSGerd Hoffmann    # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
24075fe309ffSGerd Hoffmann    # Use 2.0 as a fallback if that is available.
24085fe309ffSGerd Hoffmann    if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
24099e04c683SStefan Weil        gtkabi=3.0
24105fe309ffSGerd Hoffmann    elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
24119e04c683SStefan Weil        gtkabi=2.0
24125fe309ffSGerd Hoffmann    else
24135fe309ffSGerd Hoffmann        gtkabi=3.0
24149e04c683SStefan Weil    fi
24159e04c683SStefan Weilfi
24169e04c683SStefan Weil
2417a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2418528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
24190a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2420528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2421528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2422bbbf9bfbSStefan Weil    else
2423bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2424bbbf9bfbSStefan Weil    fi
2425bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
242689138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
242789138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
242889138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
24290a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2430f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2431f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
24320a337ed0SGerd Hoffmann        fi
2433bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2434bbbf9bfbSStefan Weil        gtk="yes"
2435bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
24365fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2437bbbf9bfbSStefan Weil    else
2438bbbf9bfbSStefan Weil        gtk="no"
2439bbbf9bfbSStefan Weil    fi
2440bbbf9bfbSStefan Weilfi
2441bbbf9bfbSStefan Weil
2442ddbb0d09SDaniel P. Berrange
2443ddbb0d09SDaniel P. Berrange##########################################
2444ddbb0d09SDaniel P. Berrange# GNUTLS probe
2445ddbb0d09SDaniel P. Berrange
244637371299SPeter Maydellgnutls_works() {
244737371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
244837371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
244937371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
245037371299SPeter Maydell    # builds doesn't work:
245137371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
245237371299SPeter Maydell    #
245337371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
245437371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
245537371299SPeter Maydell        return 1
245637371299SPeter Maydell    fi
245737371299SPeter Maydell
245837371299SPeter Maydell    write_c_skeleton
245937371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
246037371299SPeter Maydell}
246137371299SPeter Maydell
246262893b67SDaniel P. Berrangegnutls_gcrypt=no
2463ed754746SDaniel P. Berrangegnutls_nettle=no
2464ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
246537371299SPeter Maydell    if gnutls_works; then
246689138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
246789138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2468ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2469ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2470ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2471ddbb0d09SDaniel P. Berrange        gnutls="yes"
2472ddbb0d09SDaniel P. Berrange
2473b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2474b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2475b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2476b917da4cSDaniel P. Berrange	else
2477b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2478b917da4cSDaniel P. Berrange	fi
2479b917da4cSDaniel P. Berrange
248062893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
248162893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2482ed754746SDaniel P. Berrange	    gnutls_nettle=yes
248362893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
248489138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2485ed754746SDaniel P. Berrange		*gcrypt*)
2486ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2487ed754746SDaniel P. Berrange		    gnutls_nettle=no
2488ed754746SDaniel P. Berrange		    ;;
2489ed754746SDaniel P. Berrange		*nettle*)
2490ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2491ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2492ed754746SDaniel P. Berrange		    ;;
2493ed754746SDaniel P. Berrange		*)
2494ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2495ed754746SDaniel P. Berrange		    gnutls_nettle=no
2496ed754746SDaniel P. Berrange		    ;;
249762893b67SDaniel P. Berrange	    esac
249862893b67SDaniel P. Berrange	else
249962893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2500ed754746SDaniel P. Berrange	    gnutls_nettle=no
250162893b67SDaniel P. Berrange	fi
2502ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2503ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2504ddbb0d09SDaniel P. Berrange    else
2505ddbb0d09SDaniel P. Berrange        gnutls="no"
2506b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2507ddbb0d09SDaniel P. Berrange    fi
2508ddbb0d09SDaniel P. Berrangeelse
2509b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2510ddbb0d09SDaniel P. Berrangefi
2511ddbb0d09SDaniel P. Berrange
251291bfcdb0SDaniel P. Berrange
251391bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
251491bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
251591bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
251691bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
251791bfcdb0SDaniel P. Berrangethen
251891bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
251991bfcdb0SDaniel P. Berrange    then
252091bfcdb0SDaniel P. Berrange        gcrypt="no"
252191bfcdb0SDaniel P. Berrange    fi
252291bfcdb0SDaniel P. Berrangefi
252391bfcdb0SDaniel P. Berrange
252491bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
252591bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
252691bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
252791bfcdb0SDaniel P. Berrangeif test -z "$nettle"
252891bfcdb0SDaniel P. Berrangethen
252991bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
253091bfcdb0SDaniel P. Berrange    then
253191bfcdb0SDaniel P. Berrange        nettle="no"
253291bfcdb0SDaniel P. Berrange    fi
253391bfcdb0SDaniel P. Berrangefi
253491bfcdb0SDaniel P. Berrange
253591bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
253691bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
253791bfcdb0SDaniel P. Berrange    then
253891bfcdb0SDaniel P. Berrange	return 1
253991bfcdb0SDaniel P. Berrange    fi
254091bfcdb0SDaniel P. Berrange
254191bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
254291bfcdb0SDaniel P. Berrange    then
254389138857SStefan Weil	host=$(libgcrypt-config --host)
254491bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
254591bfcdb0SDaniel P. Berrange	then
254691bfcdb0SDaniel P. Berrange	    return 1
254791bfcdb0SDaniel P. Berrange	fi
254891bfcdb0SDaniel P. Berrange    fi
254991bfcdb0SDaniel P. Berrange
255091bfcdb0SDaniel P. Berrange    return 0
255191bfcdb0SDaniel P. Berrange}
255291bfcdb0SDaniel P. Berrange
255391bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
255491bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
255589138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
255689138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
255791bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
255891bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
255991bfcdb0SDaniel P. Berrange        # turn breaks static builds...
256091bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
256191bfcdb0SDaniel P. Berrange        then
256291bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
256391bfcdb0SDaniel P. Berrange        fi
256462893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
256562893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
256662893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
256791bfcdb0SDaniel P. Berrange        gcrypt="yes"
256891bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
256991bfcdb0SDaniel P. Berrange           nettle="no"
257091bfcdb0SDaniel P. Berrange        fi
257137788f25SDaniel P. Berrange
257237788f25SDaniel P. Berrange        cat > $TMPC << EOF
257337788f25SDaniel P. Berrange#include <gcrypt.h>
257437788f25SDaniel P. Berrangeint main(void) {
257537788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
257637788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
257737788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
257837788f25SDaniel P. Berrange return 0;
257937788f25SDaniel P. Berrange}
258037788f25SDaniel P. BerrangeEOF
258137788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
258237788f25SDaniel P. Berrange            gcrypt_kdf=yes
258337788f25SDaniel P. Berrange        fi
25841f923c70SLongpeng(Mike)
25851f923c70SLongpeng(Mike)        cat > $TMPC << EOF
25861f923c70SLongpeng(Mike)#include <gcrypt.h>
25871f923c70SLongpeng(Mike)int main(void) {
25881f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
25891f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
25901f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
25911f923c70SLongpeng(Mike)  return 0;
25921f923c70SLongpeng(Mike)}
25931f923c70SLongpeng(Mike)EOF
25941f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
25951f923c70SLongpeng(Mike)            gcrypt_hmac=yes
25961f923c70SLongpeng(Mike)        fi
259762893b67SDaniel P. Berrange    else
259891bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
259962893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
260091bfcdb0SDaniel P. Berrange        else
260191bfcdb0SDaniel P. Berrange            gcrypt="no"
260291bfcdb0SDaniel P. Berrange        fi
260362893b67SDaniel P. Berrange    fi
260462893b67SDaniel P. Berrangefi
260562893b67SDaniel P. Berrange
2606ddbb0d09SDaniel P. Berrange
260791bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2608ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
260989138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
261089138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
261189138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2612ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2613ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2614ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
261591bfcdb0SDaniel P. Berrange        nettle="yes"
2616fff2f982SDaniel P. Berrange
2617fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
26189e87a691SSteven Luo#include <stddef.h>
2619fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2620fff2f982SDaniel P. Berrangeint main(void) {
2621fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2622fff2f982SDaniel P. Berrange     return 0;
2623fff2f982SDaniel P. Berrange}
2624fff2f982SDaniel P. BerrangeEOF
2625fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2626fff2f982SDaniel P. Berrange            nettle_kdf=yes
2627fff2f982SDaniel P. Berrange        fi
2628ed754746SDaniel P. Berrange    else
262991bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2630ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
263191bfcdb0SDaniel P. Berrange        else
263291bfcdb0SDaniel P. Berrange            nettle="no"
2633ed754746SDaniel P. Berrange        fi
2634ed754746SDaniel P. Berrange    fi
263591bfcdb0SDaniel P. Berrangefi
263691bfcdb0SDaniel P. Berrange
263791bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
263891bfcdb0SDaniel P. Berrangethen
263991bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
264091bfcdb0SDaniel P. Berrangefi
2641ed754746SDaniel P. Berrange
26429a2fd434SDaniel P. Berrange##########################################
26439a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
26449a2fd434SDaniel P. Berrange
26459a2fd434SDaniel P. Berrangetasn1=yes
264690246037SDaniel P. Berrangetasn1_cflags=""
264790246037SDaniel P. Berrangetasn1_libs=""
26489a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
264989138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
265089138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
26519a2fd434SDaniel P. Berrangeelse
26529a2fd434SDaniel P. Berrange    tasn1=no
26539a2fd434SDaniel P. Berrangefi
26549a2fd434SDaniel P. Berrange
2655ed754746SDaniel P. Berrange
2656bbbf9bfbSStefan Weil##########################################
2657559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2658559607eaSDaniel P. Berrange
2659559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2660559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2661559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2662559607eaSDaniel P. Berrangefi
2663559607eaSDaniel P. Berrange
2664559607eaSDaniel P. Berrange##########################################
2665bbbf9bfbSStefan Weil# VTE probe
2666bbbf9bfbSStefan Weil
2667bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2668bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2669c6feff9eSCole Robinson      vteminversion="0.32.0"
2670c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2671c6feff9eSCole Robinson        vtepackage="vte-2.91"
2672c6feff9eSCole Robinson      else
2673528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2674c6feff9eSCole Robinson      fi
2675528de90aSDaniel P. Berrange    else
2676528de90aSDaniel P. Berrange      vtepackage="vte"
2677c6feff9eSCole Robinson      vteminversion="0.24.0"
2678528de90aSDaniel P. Berrange    fi
2679c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
268089138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
268189138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
268289138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2683bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2684bbbf9bfbSStefan Weil        vte="yes"
2685bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
26869e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2687c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
26889e04c683SStefan Weil        else
26899e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
26909e04c683SStefan Weil        fi
2691bbbf9bfbSStefan Weil    else
2692bbbf9bfbSStefan Weil        vte="no"
2693a4ccabcfSAnthony Liguori    fi
2694a4ccabcfSAnthony Liguorifi
2695a4ccabcfSAnthony Liguori
2696a4ccabcfSAnthony Liguori##########################################
269711d9f695Sbellard# SDL probe
269811d9f695Sbellard
26993ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
27003ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
270147c03744SDave Airlie
2702ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
27038f4ea9cdSGerd Hoffmann    if $pkg_config --exists "sdl2"; then
2704ee8466d0SCole Robinson        sdlabi=2.0
27058f4ea9cdSGerd Hoffmann    elif $pkg_config --exists "sdl"; then
2706ee8466d0SCole Robinson        sdlabi=1.2
27078f4ea9cdSGerd Hoffmann    else
27088f4ea9cdSGerd Hoffmann        sdlabi=2.0
2709ee8466d0SCole Robinson    fi
2710ee8466d0SCole Robinsonfi
2711ee8466d0SCole Robinson
271247c03744SDave Airlieif test $sdlabi = "2.0"; then
271347c03744SDave Airlie    sdl_config=$sdl2_config
271447c03744SDave Airlie    sdlname=sdl2
271547c03744SDave Airlie    sdlconfigname=sdl2_config
2716e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
271747c03744SDave Airlie    sdlname=sdl
271847c03744SDave Airlie    sdlconfigname=sdl_config
2719e07047cfSCole Robinsonelse
2720e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
27213ec87ffeSPaolo Bonzinifi
27223ec87ffeSPaolo Bonzini
272389138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
272447c03744SDave Airlie  sdl_config=$sdlconfigname
272547c03744SDave Airliefi
272647c03744SDave Airlie
272747c03744SDave Airlieif $pkg_config $sdlname --exists; then
272847c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
272989138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
27303ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
27313ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
273289138857SStefan Weil  sdlversion=$($sdlconfig --version)
2733a0dfd8a4SLoïc Minierelse
2734a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
27358f4ea9cdSGerd Hoffmann    feature_not_found "sdl" "Install SDL2-devel"
2736a0dfd8a4SLoïc Minier  fi
2737a0dfd8a4SLoïc Minier  sdl=no
27389316f803SPaolo Bonzinifi
273929e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
27403ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
27413ec87ffeSPaolo Bonzinifi
274211d9f695Sbellard
27439316f803SPaolo Bonzinisdl_too_old=no
2744c4198157SJuan Quintelaif test "$sdl" != "no" ; then
274511d9f695Sbellard  cat > $TMPC << EOF
274611d9f695Sbellard#include <SDL.h>
274711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
274811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
274911d9f695SbellardEOF
275089138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
275174f42e18STeLeMan  if test "$static" = "yes" ; then
27525f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
27535f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
27545f37e6d4SThomas Huth    else
275589138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
27565f37e6d4SThomas Huth    fi
275774f42e18STeLeMan  else
275889138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
275974f42e18STeLeMan  fi
276052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
276189138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
276211d9f695Sbellard      sdl_too_old=yes
276311d9f695Sbellard    else
276411d9f695Sbellard      sdl=yes
276511d9f695Sbellard    fi
27667c1f25b4Sbellard
276767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
27681ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
276967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
277089138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
277189138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
277211d9f695Sbellard      fi
277352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
27741ac88f28SJuan Quintela	:
27751ac88f28SJuan Quintela      else
27761ac88f28SJuan Quintela        sdl=no
27777c1f25b4Sbellard      fi
27787c1f25b4Sbellard    fi # static link
2779c4198157SJuan Quintela  else # sdl not found
2780c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
278121684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2782c4198157SJuan Quintela    fi
2783c4198157SJuan Quintela    sdl=no
27847c1f25b4Sbellard  fi # sdl compile test
2785fd677642Sthsfi
278611d9f695Sbellard
27875368a422Saliguoriif test "$sdl" = "yes" ; then
27885368a422Saliguori  cat > $TMPC <<EOF
27895368a422Saliguori#include <SDL.h>
27905368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
27915368a422Saliguori#include <X11/XKBlib.h>
27925368a422Saliguori#else
27935368a422Saliguori#error No x11 support
27945368a422Saliguori#endif
27955368a422Saliguoriint main(void) { return 0; }
27965368a422SaliguoriEOF
2797f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2798f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2799f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
28005368a422Saliguori  fi
28015368a422Saliguorifi
28025368a422Saliguori
28038f28f3fbSths##########################################
28042da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28052da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28062da776dbSMichael R. Hines  cat > $TMPC <<EOF
28072da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28082da776dbSMichael R. Hinesint main(void) { return 0; }
28092da776dbSMichael R. HinesEOF
28102da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
28112da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28122da776dbSMichael R. Hines    rdma="yes"
28132da776dbSMichael R. Hines  else
28142da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28152da776dbSMichael R. Hines        error_exit \
28162da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28172da776dbSMichael R. Hines            " Your options:" \
28182da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28192da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28202da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28212da776dbSMichael R. Hines    fi
28222da776dbSMichael R. Hines    rdma="no"
28232da776dbSMichael R. Hines  fi
28242da776dbSMichael R. Hinesfi
28252da776dbSMichael R. Hines
282695c6bff3SBenoît Canet
282795c6bff3SBenoît Canet##########################################
28282f9606b3Saliguori# VNC SASL detection
2829821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
28302f9606b3Saliguori  cat > $TMPC <<EOF
28312f9606b3Saliguori#include <sasl/sasl.h>
28322f9606b3Saliguori#include <stdio.h>
28332f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
28342f9606b3SaliguoriEOF
28352f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
28362f9606b3Saliguori  vnc_sasl_cflags=""
28372f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
283852166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2839ea784e3bSJuan Quintela    vnc_sasl=yes
2840fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2841ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
28422f9606b3Saliguori  else
2843ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
284421684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2845ea784e3bSJuan Quintela    fi
2846ea784e3bSJuan Quintela    vnc_sasl=no
28472f9606b3Saliguori  fi
28482f9606b3Saliguorifi
28492f9606b3Saliguori
28502f9606b3Saliguori##########################################
28512f6f5c7aSCorentin Chary# VNC JPEG detection
2852821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
28532f6f5c7aSCorentin Charycat > $TMPC <<EOF
28542f6f5c7aSCorentin Chary#include <stdio.h>
28552f6f5c7aSCorentin Chary#include <jpeglib.h>
28562f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
28572f6f5c7aSCorentin CharyEOF
28582f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
28592f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
28602f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
28612f6f5c7aSCorentin Chary    vnc_jpeg=yes
28622f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2863ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
28642f6f5c7aSCorentin Chary  else
28652f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
286621684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
28672f6f5c7aSCorentin Chary    fi
28682f6f5c7aSCorentin Chary    vnc_jpeg=no
28692f6f5c7aSCorentin Chary  fi
28702f6f5c7aSCorentin Charyfi
28712f6f5c7aSCorentin Chary
28722f6f5c7aSCorentin Chary##########################################
2873efe556adSCorentin Chary# VNC PNG detection
2874821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2875efe556adSCorentin Charycat > $TMPC <<EOF
2876efe556adSCorentin Chary//#include <stdio.h>
2877efe556adSCorentin Chary#include <png.h>
2878832ce9c2SScott Wood#include <stddef.h>
2879efe556adSCorentin Charyint main(void) {
2880efe556adSCorentin Chary    png_structp png_ptr;
2881efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
28827edc3fedSPeter Maydell    return png_ptr != 0;
2883efe556adSCorentin Chary}
2884efe556adSCorentin CharyEOF
288565d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
288689138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
288789138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
28889af8025eSBrad  else
2889efe556adSCorentin Chary    vnc_png_cflags=""
2890efe556adSCorentin Chary    vnc_png_libs="-lpng"
28919af8025eSBrad  fi
2892efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2893efe556adSCorentin Chary    vnc_png=yes
2894efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
28959af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2896efe556adSCorentin Chary  else
2897efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
289821684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2899efe556adSCorentin Chary    fi
2900efe556adSCorentin Chary    vnc_png=no
2901efe556adSCorentin Chary  fi
2902efe556adSCorentin Charyfi
2903efe556adSCorentin Chary
2904efe556adSCorentin Chary##########################################
290576655d6dSaliguori# fnmatch() probe, used for ACL routines
290676655d6dSaliguorifnmatch="no"
290776655d6dSaliguoricat > $TMPC << EOF
290876655d6dSaliguori#include <fnmatch.h>
290976655d6dSaliguoriint main(void)
291076655d6dSaliguori{
291176655d6dSaliguori    fnmatch("foo", "foo", 0);
291276655d6dSaliguori    return 0;
291376655d6dSaliguori}
291476655d6dSaliguoriEOF
291552166aa0SJuan Quintelaif compile_prog "" "" ; then
291676655d6dSaliguori   fnmatch="yes"
291776655d6dSaliguorifi
291876655d6dSaliguori
291976655d6dSaliguori##########################################
2920c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2921dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2922dce512deSChristoph Hellwig  cat > $TMPC << EOF
2923ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2924dce512deSChristoph Hellwig#include <xfs/xfs.h>
2925dce512deSChristoph Hellwigint main(void)
2926dce512deSChristoph Hellwig{
2927dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2928dce512deSChristoph Hellwig    return 0;
2929dce512deSChristoph Hellwig}
2930dce512deSChristoph HellwigEOF
2931dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2932dce512deSChristoph Hellwig    xfs="yes"
2933dce512deSChristoph Hellwig  else
2934dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
293521684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2936dce512deSChristoph Hellwig    fi
2937dce512deSChristoph Hellwig    xfs=no
2938dce512deSChristoph Hellwig  fi
2939dce512deSChristoph Hellwigfi
2940dce512deSChristoph Hellwig
2941dce512deSChristoph Hellwig##########################################
29428a16d273Sths# vde libraries probe
2943dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29444baae0acSJuan Quintela  vde_libs="-lvdeplug"
29458a16d273Sths  cat > $TMPC << EOF
29468a16d273Sths#include <libvdeplug.h>
29474a7f0e06Spbrookint main(void)
29484a7f0e06Spbrook{
29494a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2950fea08e08SPeter Maydell    char s[] = "";
2951fea08e08SPeter Maydell    vde_open(s, s, &a);
29524a7f0e06Spbrook    return 0;
29534a7f0e06Spbrook}
29548a16d273SthsEOF
295552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29564baae0acSJuan Quintela    vde=yes
2957dfb278bdSJuan Quintela  else
2958dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
295921684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2960dfb278bdSJuan Quintela    fi
2961dfb278bdSJuan Quintela    vde=no
29628a16d273Sths  fi
29638a16d273Sthsfi
29648a16d273Sths
29658a16d273Sths##########################################
29660a985b37SVincenzo Maffione# netmap support probe
29670a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29680a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29690a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29700a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29710a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
297258952137SVincenzo Maffioneif test "$netmap" != "no" ; then
297358952137SVincenzo Maffione  cat > $TMPC << EOF
297458952137SVincenzo Maffione#include <inttypes.h>
297558952137SVincenzo Maffione#include <net/if.h>
297658952137SVincenzo Maffione#include <net/netmap.h>
297758952137SVincenzo Maffione#include <net/netmap_user.h>
29780a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29790a985b37SVincenzo Maffione#error
29800a985b37SVincenzo Maffione#endif
298158952137SVincenzo Maffioneint main(void) { return 0; }
298258952137SVincenzo MaffioneEOF
298358952137SVincenzo Maffione  if compile_prog "" "" ; then
298458952137SVincenzo Maffione    netmap=yes
298558952137SVincenzo Maffione  else
298658952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
298758952137SVincenzo Maffione      feature_not_found "netmap"
298858952137SVincenzo Maffione    fi
298958952137SVincenzo Maffione    netmap=no
299058952137SVincenzo Maffione  fi
299158952137SVincenzo Maffionefi
299258952137SVincenzo Maffione
299358952137SVincenzo Maffione##########################################
299447e98658SCorey Bryant# libcap-ng library probe
299547e98658SCorey Bryantif test "$cap_ng" != "no" ; then
299647e98658SCorey Bryant  cap_libs="-lcap-ng"
299747e98658SCorey Bryant  cat > $TMPC << EOF
299847e98658SCorey Bryant#include <cap-ng.h>
299947e98658SCorey Bryantint main(void)
300047e98658SCorey Bryant{
300147e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
300247e98658SCorey Bryant    return 0;
300347e98658SCorey Bryant}
300447e98658SCorey BryantEOF
300547e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
300647e98658SCorey Bryant    cap_ng=yes
300747e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
300847e98658SCorey Bryant  else
300947e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
301021684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
301147e98658SCorey Bryant    fi
301247e98658SCorey Bryant    cap_ng=no
301347e98658SCorey Bryant  fi
301447e98658SCorey Bryantfi
301547e98658SCorey Bryant
301647e98658SCorey Bryant##########################################
3017c2de5c91Smalc# Sound support libraries probe
30188f28f3fbSths
3019c2de5c91Smalcaudio_drv_probe()
3020c2de5c91Smalc{
3021c2de5c91Smalc    drv=$1
3022c2de5c91Smalc    hdr=$2
3023c2de5c91Smalc    lib=$3
3024c2de5c91Smalc    exp=$4
3025c2de5c91Smalc    cfl=$5
30268f28f3fbSths        cat > $TMPC << EOF
3027c2de5c91Smalc#include <$hdr>
3028c2de5c91Smalcint main(void) { $exp }
30298f28f3fbSthsEOF
303052166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
30318f28f3fbSths        :
30328f28f3fbSths    else
303376ad07a4SPeter Maydell        error_exit "$drv check failed" \
303476ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
30358f28f3fbSths    fi
3036c2de5c91Smalc}
3037c2de5c91Smalc
303889138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3039c2de5c91Smalcfor drv in $audio_drv_list; do
3040c2de5c91Smalc    case $drv in
3041c2de5c91Smalc    alsa)
3042c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3043e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3044b1149911SFam Zheng    alsa_libs="-lasound"
3045c2de5c91Smalc    ;;
3046c2de5c91Smalc
3047b8e59f18Smalc    pa)
3048e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3049e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3050b1149911SFam Zheng    pulse_libs="-lpulse"
305167f86e8eSJuan Quintela    audio_pt_int="yes"
3052b8e59f18Smalc    ;;
3053b8e59f18Smalc
3054373967b2SGerd Hoffmann    sdl)
3055373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3056373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3057373967b2SGerd Hoffmann    fi
3058373967b2SGerd Hoffmann    ;;
3059373967b2SGerd Hoffmann
3060997e690aSJuan Quintela    coreaudio)
3061b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3062997e690aSJuan Quintela    ;;
3063997e690aSJuan Quintela
3064a4bf6780SJuan Quintela    dsound)
3065b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3066d5631638Smalc      audio_win_int="yes"
3067a4bf6780SJuan Quintela    ;;
3068a4bf6780SJuan Quintela
3069a4bf6780SJuan Quintela    oss)
3070b1149911SFam Zheng      oss_libs="$oss_lib"
3071a4bf6780SJuan Quintela    ;;
3072a4bf6780SJuan Quintela
3073373967b2SGerd Hoffmann    wav)
3074373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
30752f6a1ab0Sblueswir1    ;;
30762f6a1ab0Sblueswir1
3077e4c63a6aSmalc    *)
30781c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
307976ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
308076ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3081e4c63a6aSmalc    }
3082e4c63a6aSmalc    ;;
3083c2de5c91Smalc    esac
3084c2de5c91Smalcdone
30858f28f3fbSths
30864d3b6f6eSbalrog##########################################
30872e4d9fb1Saurel32# BrlAPI probe
30882e4d9fb1Saurel32
30894ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3090eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
30912e4d9fb1Saurel32  cat > $TMPC << EOF
30922e4d9fb1Saurel32#include <brlapi.h>
3093832ce9c2SScott Wood#include <stddef.h>
30942e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
30952e4d9fb1Saurel32EOF
309652166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
30972e4d9fb1Saurel32    brlapi=yes
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
329674880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
329774880fe2SRobert Schiele  pixman_cflags=
329874880fe2SRobert Schiele  pixman_libs=
329935c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
330089138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
330189138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3302e2134eb9SGerd Hoffmannelse
3303c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3304c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3305e2134eb9SGerd Hoffmannfi
3306e2134eb9SGerd Hoffmann
3307e2134eb9SGerd Hoffmann##########################################
3308fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3309fe8fc5aeSPaolo Bonzini
3310fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
3311fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3312fe8fc5aeSPaolo Bonzini#include <libudev.h>
3313fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3314fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3315fe8fc5aeSPaolo Bonziniint logsink;
3316fe8fc5aeSPaolo Bonziniint main(void) {
3317fe8fc5aeSPaolo Bonzini    struct udev *udev = udev_new();
3318fe8fc5aeSPaolo Bonzini    mpath_lib_init(udev);
3319fe8fc5aeSPaolo Bonzini    return 0;
3320fe8fc5aeSPaolo Bonzini}
3321fe8fc5aeSPaolo BonziniEOF
3322fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3323fe8fc5aeSPaolo Bonzini    mpathpersist=yes
3324fe8fc5aeSPaolo Bonzini  else
3325fe8fc5aeSPaolo Bonzini    mpathpersist=no
3326fe8fc5aeSPaolo Bonzini  fi
3327fe8fc5aeSPaolo Bonzinielse
3328fe8fc5aeSPaolo Bonzini  mpathpersist=no
3329fe8fc5aeSPaolo Bonzinifi
3330fe8fc5aeSPaolo Bonzini
3331fe8fc5aeSPaolo Bonzini##########################################
333217bff52bSM. Mohan Kumar# libcap probe
333317bff52bSM. Mohan Kumar
333417bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
333517bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
333617bff52bSM. Mohan Kumar#include <stdio.h>
333717bff52bSM. Mohan Kumar#include <sys/capability.h>
3338cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
333917bff52bSM. Mohan KumarEOF
334017bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
334117bff52bSM. Mohan Kumar    cap=yes
334217bff52bSM. Mohan Kumar  else
334317bff52bSM. Mohan Kumar    cap=no
334417bff52bSM. Mohan Kumar  fi
334517bff52bSM. Mohan Kumarfi
334617bff52bSM. Mohan Kumar
334717bff52bSM. Mohan Kumar##########################################
3348e5d355d1Saliguori# pthread probe
33494b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
33503c529d93Saliguori
3351e5d355d1Saliguoripthread=no
3352414f0dabSblueswir1cat > $TMPC << EOF
33533c529d93Saliguori#include <pthread.h>
33547a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
33557a42bbe4SStefan Weilint main(void) {
33567a42bbe4SStefan Weil  pthread_t thread;
33577a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
33587a42bbe4SStefan Weil  return 0;
33597a42bbe4SStefan Weil}
3360414f0dabSblueswir1EOF
3361bd00d539SAndreas Färberif compile_prog "" "" ; then
3362bd00d539SAndreas Färber  pthread=yes
3363bd00d539SAndreas Färberelse
3364de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
336552166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3366e5d355d1Saliguori      pthread=yes
3367e3c56761SPeter Portante      found=no
3368e3c56761SPeter Portante      for lib_entry in $LIBS; do
3369e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3370e3c56761SPeter Portante          found=yes
3371e3c56761SPeter Portante          break
3372e3c56761SPeter Portante        fi
3373e3c56761SPeter Portante      done
3374e3c56761SPeter Portante      if test "$found" = "no"; then
33755572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3376e3c56761SPeter Portante      fi
3377409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3378de65fe0fSSebastian Herbszt      break
3379414f0dabSblueswir1    fi
3380de65fe0fSSebastian Herbszt  done
3381bd00d539SAndreas Färberfi
3382414f0dabSblueswir1
33834617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
338476ad07a4SPeter Maydell  error_exit "pthread check failed" \
338576ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3386e5d355d1Saliguorifi
3387e5d355d1Saliguori
33885c312079SDr. David Alan Gilbert# check for pthread_setname_np
33895c312079SDr. David Alan Gilbertpthread_setname_np=no
33905c312079SDr. David Alan Gilbertcat > $TMPC << EOF
33915c312079SDr. David Alan Gilbert#include <pthread.h>
33925c312079SDr. David Alan Gilbert
33935c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
33945c312079SDr. David Alan Gilbertint main(void)
33955c312079SDr. David Alan Gilbert{
33965c312079SDr. David Alan Gilbert    pthread_t thread;
33975c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
33985c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
33995c312079SDr. David Alan Gilbert    return 0;
34005c312079SDr. David Alan Gilbert}
34015c312079SDr. David Alan GilbertEOF
34025c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
34035c312079SDr. David Alan Gilbert  pthread_setname_np=yes
34045c312079SDr. David Alan Gilbertfi
34055c312079SDr. David Alan Gilbert
3406bf9298b9Saliguori##########################################
3407f27aaf4bSChristian Brunner# rbd probe
3408f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3409f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3410f27aaf4bSChristian Brunner#include <stdio.h>
3411ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3412f27aaf4bSChristian Brunnerint main(void) {
3413ad32e9c0SJosh Durgin    rados_t cluster;
3414ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3415f27aaf4bSChristian Brunner    return 0;
3416f27aaf4bSChristian Brunner}
3417f27aaf4bSChristian BrunnerEOF
3418ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3419f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3420f27aaf4bSChristian Brunner    rbd=yes
3421f27aaf4bSChristian Brunner  else
3422f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
342321684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3424f27aaf4bSChristian Brunner    fi
3425f27aaf4bSChristian Brunner    rbd=no
3426f27aaf4bSChristian Brunner  fi
3427f27aaf4bSChristian Brunnerfi
3428f27aaf4bSChristian Brunner
3429f27aaf4bSChristian Brunner##########################################
34300a12ec87SRichard W.M. Jones# libssh2 probe
34314fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
34320a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
343365d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
343489138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
343589138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
34360a12ec87SRichard W.M. Jones    libssh2=yes
34370a12ec87SRichard W.M. Jones  else
34380a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
34394fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
34400a12ec87SRichard W.M. Jones    fi
34410a12ec87SRichard W.M. Jones    libssh2=no
34420a12ec87SRichard W.M. Jones  fi
34430a12ec87SRichard W.M. Jonesfi
34440a12ec87SRichard W.M. Jones
34450a12ec87SRichard W.M. Jones##########################################
34469a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
34479a2d462eSRichard W.M. Jones
34489a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
34499a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
34509a2d462eSRichard W.M. Jones#include <stdio.h>
34519a2d462eSRichard W.M. Jones#include <libssh2.h>
34529a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
34539a2d462eSRichard W.M. Jonesint main(void) {
34549a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
34559a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
34569a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
34579a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
34589a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
34599a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
34609a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
34619a2d462eSRichard W.M. Jones    return 0;
34629a2d462eSRichard W.M. Jones}
34639a2d462eSRichard W.M. JonesEOF
34649a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
34659a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
34669a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
34679a2d462eSRichard W.M. Jones  fi
34689a2d462eSRichard W.M. Jonesfi
34699a2d462eSRichard W.M. Jones
34709a2d462eSRichard W.M. Jones##########################################
34715c6c3a6cSChristoph Hellwig# linux-aio probe
34725c6c3a6cSChristoph Hellwig
34735c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
34745c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
34755c6c3a6cSChristoph Hellwig#include <libaio.h>
34765c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3477832ce9c2SScott Wood#include <stddef.h>
34785c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
34795c6c3a6cSChristoph HellwigEOF
34805c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
34815c6c3a6cSChristoph Hellwig    linux_aio=yes
34825c6c3a6cSChristoph Hellwig  else
34835c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
348421684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
34855c6c3a6cSChristoph Hellwig    fi
34863cfcae3cSLuiz Capitulino    linux_aio=no
34875c6c3a6cSChristoph Hellwig  fi
34885c6c3a6cSChristoph Hellwigfi
34895c6c3a6cSChristoph Hellwig
34905c6c3a6cSChristoph Hellwig##########################################
34913b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
34923b8acc11SPaolo Bonzini
34933b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
34943b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
34953b8acc11SPaolo Bonzinielse
34963b8acc11SPaolo Bonzini  tpm_passthrough=no
34973b8acc11SPaolo Bonzinifi
34983b8acc11SPaolo Bonzini
34993b8acc11SPaolo Bonzini##########################################
3500758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3501758e8e38SVenkateswararao Jujjuri (JV)
3502758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3503758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3504758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3505758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3506f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3507f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3508f2338fb4SPavel Borzenkov#else
35094f26f2b6SAvi Kivity#include <sys/xattr.h>
3510f2338fb4SPavel Borzenkov#endif
3511758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3512758e8e38SVenkateswararao Jujjuri (JV)EOF
35134f26f2b6SAvi Kivity  if compile_prog "" "" ; then
35144f26f2b6SAvi Kivity    attr=yes
35154f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3516f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3517758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3518758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
35194f26f2b6SAvi Kivity    libattr=yes
3520758e8e38SVenkateswararao Jujjuri (JV)  else
3521758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
352221684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3523758e8e38SVenkateswararao Jujjuri (JV)    fi
3524758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3525758e8e38SVenkateswararao Jujjuri (JV)  fi
3526758e8e38SVenkateswararao Jujjuri (JV)fi
3527758e8e38SVenkateswararao Jujjuri (JV)
3528758e8e38SVenkateswararao Jujjuri (JV)##########################################
3529bf9298b9Saliguori# iovec probe
3530bf9298b9Saliguoricat > $TMPC <<EOF
3531db34f0b3Sblueswir1#include <sys/types.h>
3532bf9298b9Saliguori#include <sys/uio.h>
3533db34f0b3Sblueswir1#include <unistd.h>
3534f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3535bf9298b9SaliguoriEOF
3536bf9298b9Saliguoriiovec=no
353752166aa0SJuan Quintelaif compile_prog "" "" ; then
3538bf9298b9Saliguori  iovec=yes
3539bf9298b9Saliguorifi
3540bf9298b9Saliguori
3541f652e6afSaurel32##########################################
3542ceb42de8Saliguori# preadv probe
3543ceb42de8Saliguoricat > $TMPC <<EOF
3544ceb42de8Saliguori#include <sys/types.h>
3545ceb42de8Saliguori#include <sys/uio.h>
3546ceb42de8Saliguori#include <unistd.h>
3547c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3548ceb42de8SaliguoriEOF
3549ceb42de8Saliguoripreadv=no
355052166aa0SJuan Quintelaif compile_prog "" "" ; then
3551ceb42de8Saliguori  preadv=yes
3552ceb42de8Saliguorifi
3553ceb42de8Saliguori
3554ceb42de8Saliguori##########################################
3555f652e6afSaurel32# fdt probe
3556e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3557e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3558e169e1e1SPeter Maydellfdt_required=no
3559e169e1e1SPeter Maydellfor target in $target_list; do
3560e169e1e1SPeter Maydell  case $target in
3561df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3562e169e1e1SPeter Maydell      fdt_required=yes
3563e169e1e1SPeter Maydell    ;;
3564e169e1e1SPeter Maydell  esac
3565e169e1e1SPeter Maydelldone
3566e169e1e1SPeter Maydell
3567e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3568e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3569e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3570e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3571e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3572e169e1e1SPeter Maydell  fi
3573e169e1e1SPeter Maydell  fdt=yes
3574e169e1e1SPeter Maydellfi
3575e169e1e1SPeter Maydell
35762df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3577b41af4baSJuan Quintela  fdt_libs="-lfdt"
357896ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
35796e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3580f652e6afSaurel32  cat > $TMPC << EOF
358131ce0adbSThomas Huth#include <libfdt.h>
358296ce6545SPeter Crosthwaite#include <libfdt_env.h>
35836e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3584f652e6afSaurel32EOF
358552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3586a540f158SPeter Crosthwaite    # system DTC is good - use it
3587f652e6afSaurel32    fdt=yes
3588*aef45d51SDaniel P. Berrange  else
3589*aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
3590*aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
3591*aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
3592*aef45d51SDaniel P. Berrange      fi
3593*aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3594a540f158SPeter Crosthwaite          fdt=yes
3595a540f158SPeter Crosthwaite          dtc_internal="yes"
3596a540f158SPeter Crosthwaite          mkdir -p dtc
3597cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
3598a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3599a540f158SPeter Crosthwaite              symlink "$source_path/dtc/scripts" "dtc/scripts"
36002df87df7SJuan Quintela          fi
3601a540f158SPeter Crosthwaite          fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3602a540f158SPeter Crosthwaite          fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3603a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
3604*aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
3605*aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3606*aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
3607a540f158SPeter Crosthwaite      else
3608a540f158SPeter Crosthwaite          # don't have and don't want
3609de3a354aSMichael Walle          fdt_libs=
36102df87df7SJuan Quintela          fdt=no
3611f652e6afSaurel32      fi
3612f652e6afSaurel32  fi
3613*aef45d51SDaniel P. Berrangefi
3614f652e6afSaurel32
3615a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3616a540f158SPeter Crosthwaite
361720ff075bSMichael Walle##########################################
3618fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3619b1546f32SGerd Hoffmann
3620da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3621014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3622fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3623f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3624f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3625da076ffeSGerd Hoffmann    opengl=yes
3626925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3627925a0400SGerd Hoffmann        gtk_gl="yes"
3628925a0400SGerd Hoffmann    fi
3629cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
363020ff075bSMichael Walle  else
3631da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3632dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
363320ff075bSMichael Walle    fi
3634f676c67eSJeremy White    opengl_cflags=""
3635da076ffeSGerd Hoffmann    opengl_libs=""
3636da076ffeSGerd Hoffmann    opengl=no
363720ff075bSMichael Walle  fi
363820ff075bSMichael Wallefi
363920ff075bSMichael Walle
3640014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3641014cb152SGerd Hoffmann  cat > $TMPC << EOF
3642014cb152SGerd Hoffmann#include <epoxy/egl.h>
3643014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3644014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3645014cb152SGerd Hoffmann#endif
3646014cb152SGerd Hoffmannint main(void) { return 0; }
3647014cb152SGerd HoffmannEOF
3648014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3649014cb152SGerd Hoffmann    opengl_dmabuf=yes
3650014cb152SGerd Hoffmann  fi
3651014cb152SGerd Hoffmannfi
3652c9a12e75SChrysostomos Nanakos
3653c9a12e75SChrysostomos Nanakos
3654eb100396SBharata B Rao##########################################
3655eb100396SBharata B Rao# glusterfs probe
3656eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
365765d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3658e01bee08SBharata B Rao    glusterfs="yes"
365989138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
366089138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3661d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3662d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3663d85fa9ebSJeff Cody    fi
366465d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
36650c14fb47SBharata B Rao      glusterfs_discard="yes"
36660c14fb47SBharata B Rao    fi
36677c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3668df3a429aSNiels de Vos      glusterfs_fallocate="yes"
36697c815372SBharata B Rao      glusterfs_zerofill="yes"
36707c815372SBharata B Rao    fi
3671eb100396SBharata B Rao  else
3672eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
36738efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
36748efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3675eb100396SBharata B Rao    fi
3676e01bee08SBharata B Rao    glusterfs="no"
3677eb100396SBharata B Rao  fi
3678eb100396SBharata B Raofi
3679eb100396SBharata B Rao
368039386ac7Saurel32# Check for inotify functions when we are building linux-user
36813b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36823b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36833b3f24adSaurel32# don't provide them even if kernel supports them.
36843b3f24adSaurel32#
36853b3f24adSaurel32inotify=no
36863b3f24adSaurel32cat > $TMPC << EOF
36873b3f24adSaurel32#include <sys/inotify.h>
36883b3f24adSaurel32
36893b3f24adSaurel32int
36903b3f24adSaurel32main(void)
36913b3f24adSaurel32{
36923b3f24adSaurel32	/* try to start inotify */
36938690e420Saurel32	return inotify_init();
36943b3f24adSaurel32}
36953b3f24adSaurel32EOF
369652166aa0SJuan Quintelaif compile_prog "" "" ; then
36973b3f24adSaurel32  inotify=yes
36983b3f24adSaurel32fi
36993b3f24adSaurel32
3700c05c7a73SRiku Voipioinotify1=no
3701c05c7a73SRiku Voipiocat > $TMPC << EOF
3702c05c7a73SRiku Voipio#include <sys/inotify.h>
3703c05c7a73SRiku Voipio
3704c05c7a73SRiku Voipioint
3705c05c7a73SRiku Voipiomain(void)
3706c05c7a73SRiku Voipio{
3707c05c7a73SRiku Voipio    /* try to start inotify */
3708c05c7a73SRiku Voipio    return inotify_init1(0);
3709c05c7a73SRiku Voipio}
3710c05c7a73SRiku VoipioEOF
3711c05c7a73SRiku Voipioif compile_prog "" "" ; then
3712c05c7a73SRiku Voipio  inotify1=yes
3713c05c7a73SRiku Voipiofi
3714c05c7a73SRiku Voipio
3715099d6b0fSRiku Voipio# check if pipe2 is there
3716099d6b0fSRiku Voipiopipe2=no
3717099d6b0fSRiku Voipiocat > $TMPC << EOF
3718099d6b0fSRiku Voipio#include <unistd.h>
3719099d6b0fSRiku Voipio#include <fcntl.h>
3720099d6b0fSRiku Voipio
3721099d6b0fSRiku Voipioint main(void)
3722099d6b0fSRiku Voipio{
3723099d6b0fSRiku Voipio    int pipefd[2];
37249bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3725099d6b0fSRiku Voipio}
3726099d6b0fSRiku VoipioEOF
372752166aa0SJuan Quintelaif compile_prog "" "" ; then
3728099d6b0fSRiku Voipio  pipe2=yes
3729099d6b0fSRiku Voipiofi
3730099d6b0fSRiku Voipio
373140ff6d7eSKevin Wolf# check if accept4 is there
373240ff6d7eSKevin Wolfaccept4=no
373340ff6d7eSKevin Wolfcat > $TMPC << EOF
373440ff6d7eSKevin Wolf#include <sys/socket.h>
373540ff6d7eSKevin Wolf#include <stddef.h>
373640ff6d7eSKevin Wolf
373740ff6d7eSKevin Wolfint main(void)
373840ff6d7eSKevin Wolf{
373940ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
374040ff6d7eSKevin Wolf    return 0;
374140ff6d7eSKevin Wolf}
374240ff6d7eSKevin WolfEOF
374340ff6d7eSKevin Wolfif compile_prog "" "" ; then
374440ff6d7eSKevin Wolf  accept4=yes
374540ff6d7eSKevin Wolffi
374640ff6d7eSKevin Wolf
37473ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
37483ce34dfbSvibisreenivasansplice=no
37493ce34dfbSvibisreenivasancat > $TMPC << EOF
37503ce34dfbSvibisreenivasan#include <unistd.h>
37513ce34dfbSvibisreenivasan#include <fcntl.h>
37523ce34dfbSvibisreenivasan#include <limits.h>
37533ce34dfbSvibisreenivasan
37543ce34dfbSvibisreenivasanint main(void)
37553ce34dfbSvibisreenivasan{
375666ea0f22SStefan Weil    int len, fd = 0;
37573ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
37583ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
37593ce34dfbSvibisreenivasan    return 0;
37603ce34dfbSvibisreenivasan}
37613ce34dfbSvibisreenivasanEOF
376252166aa0SJuan Quintelaif compile_prog "" "" ; then
37633ce34dfbSvibisreenivasan  splice=yes
37643ce34dfbSvibisreenivasanfi
37653ce34dfbSvibisreenivasan
3766dcc38d1cSMarcelo Tosatti##########################################
3767a99d57bbSWanlong Gao# libnuma probe
3768a99d57bbSWanlong Gao
3769a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3770a99d57bbSWanlong Gao  cat > $TMPC << EOF
3771a99d57bbSWanlong Gao#include <numa.h>
3772a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3773a99d57bbSWanlong GaoEOF
3774a99d57bbSWanlong Gao
3775a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3776a99d57bbSWanlong Gao    numa=yes
3777a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3778a99d57bbSWanlong Gao  else
3779a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3780a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3781a99d57bbSWanlong Gao    fi
3782a99d57bbSWanlong Gao    numa=no
3783a99d57bbSWanlong Gao  fi
3784a99d57bbSWanlong Gaofi
3785a99d57bbSWanlong Gao
37867b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37877b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37887b01cb97SAlexandre Derumier    exit 1
37897b01cb97SAlexandre Derumierfi
37907b01cb97SAlexandre Derumier
3791a99d57bbSWanlong Gao##########################################
37922847b469SFam Zheng# tcmalloc probe
37932847b469SFam Zheng
37942847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
37952847b469SFam Zheng  cat > $TMPC << EOF
37962847b469SFam Zheng#include <stdlib.h>
37972847b469SFam Zhengint main(void) { malloc(1); return 0; }
37982847b469SFam ZhengEOF
37992847b469SFam Zheng
38002847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
38012847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
38022847b469SFam Zheng  else
38032847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
38042847b469SFam Zheng  fi
38052847b469SFam Zhengfi
38062847b469SFam Zheng
38072847b469SFam Zheng##########################################
38087b01cb97SAlexandre Derumier# jemalloc probe
38097b01cb97SAlexandre Derumier
38107b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
38117b01cb97SAlexandre Derumier  cat > $TMPC << EOF
38127b01cb97SAlexandre Derumier#include <stdlib.h>
38137b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
38147b01cb97SAlexandre DerumierEOF
38157b01cb97SAlexandre Derumier
38167b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
38177b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
38187b01cb97SAlexandre Derumier  else
38197b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
38207b01cb97SAlexandre Derumier  fi
38217b01cb97SAlexandre Derumierfi
38227b01cb97SAlexandre Derumier
38237b01cb97SAlexandre Derumier##########################################
3824dcc38d1cSMarcelo Tosatti# signalfd probe
3825dcc38d1cSMarcelo Tosattisignalfd="no"
3826dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3827dcc38d1cSMarcelo Tosatti#include <unistd.h>
3828dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3829dcc38d1cSMarcelo Tosatti#include <signal.h>
3830dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3831dcc38d1cSMarcelo TosattiEOF
3832dcc38d1cSMarcelo Tosatti
3833dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3834dcc38d1cSMarcelo Tosatti  signalfd=yes
3835dcc38d1cSMarcelo Tosattifi
3836dcc38d1cSMarcelo Tosatti
3837c2882b96SRiku Voipio# check if eventfd is supported
3838c2882b96SRiku Voipioeventfd=no
3839c2882b96SRiku Voipiocat > $TMPC << EOF
3840c2882b96SRiku Voipio#include <sys/eventfd.h>
3841c2882b96SRiku Voipio
3842c2882b96SRiku Voipioint main(void)
3843c2882b96SRiku Voipio{
384455cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3845c2882b96SRiku Voipio}
3846c2882b96SRiku VoipioEOF
3847c2882b96SRiku Voipioif compile_prog "" "" ; then
3848c2882b96SRiku Voipio  eventfd=yes
3849c2882b96SRiku Voipiofi
3850c2882b96SRiku Voipio
3851751bcc39SMarc-André Lureau# check if memfd is supported
3852751bcc39SMarc-André Lureaumemfd=no
3853751bcc39SMarc-André Lureaucat > $TMPC << EOF
3854751bcc39SMarc-André Lureau#include <sys/memfd.h>
3855751bcc39SMarc-André Lureau
3856751bcc39SMarc-André Lureauint main(void)
3857751bcc39SMarc-André Lureau{
3858751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3859751bcc39SMarc-André Lureau}
3860751bcc39SMarc-André LureauEOF
3861751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3862751bcc39SMarc-André Lureau  memfd=yes
3863751bcc39SMarc-André Lureaufi
3864751bcc39SMarc-André Lureau
3865751bcc39SMarc-André Lureau
3866751bcc39SMarc-André Lureau
3867d0927938SUlrich Hecht# check for fallocate
3868d0927938SUlrich Hechtfallocate=no
3869d0927938SUlrich Hechtcat > $TMPC << EOF
3870d0927938SUlrich Hecht#include <fcntl.h>
3871d0927938SUlrich Hecht
3872d0927938SUlrich Hechtint main(void)
3873d0927938SUlrich Hecht{
3874d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3875d0927938SUlrich Hecht    return 0;
3876d0927938SUlrich Hecht}
3877d0927938SUlrich HechtEOF
38788fb03151SPeter Maydellif compile_prog "" "" ; then
3879d0927938SUlrich Hecht  fallocate=yes
3880d0927938SUlrich Hechtfi
3881d0927938SUlrich Hecht
38823d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38833d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38843d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38853d4fa43eSKusanagi Kouichi#include <fcntl.h>
38863d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38873d4fa43eSKusanagi Kouichi
38883d4fa43eSKusanagi Kouichiint main(void)
38893d4fa43eSKusanagi Kouichi{
38903d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38913d4fa43eSKusanagi Kouichi    return 0;
38923d4fa43eSKusanagi Kouichi}
38933d4fa43eSKusanagi KouichiEOF
38943d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38953d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38963d4fa43eSKusanagi Kouichifi
38973d4fa43eSKusanagi Kouichi
3898b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3899b953f075SDenis V. Lunevfallocate_zero_range=no
3900b953f075SDenis V. Lunevcat > $TMPC << EOF
3901b953f075SDenis V. Lunev#include <fcntl.h>
3902b953f075SDenis V. Lunev#include <linux/falloc.h>
3903b953f075SDenis V. Lunev
3904b953f075SDenis V. Lunevint main(void)
3905b953f075SDenis V. Lunev{
3906b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3907b953f075SDenis V. Lunev    return 0;
3908b953f075SDenis V. Lunev}
3909b953f075SDenis V. LunevEOF
3910b953f075SDenis V. Lunevif compile_prog "" "" ; then
3911b953f075SDenis V. Lunev  fallocate_zero_range=yes
3912b953f075SDenis V. Lunevfi
3913b953f075SDenis V. Lunev
3914ed911435SKevin Wolf# check for posix_fallocate
3915ed911435SKevin Wolfposix_fallocate=no
3916ed911435SKevin Wolfcat > $TMPC << EOF
3917ed911435SKevin Wolf#include <fcntl.h>
3918ed911435SKevin Wolf
3919ed911435SKevin Wolfint main(void)
3920ed911435SKevin Wolf{
3921ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3922ed911435SKevin Wolf    return 0;
3923ed911435SKevin Wolf}
3924ed911435SKevin WolfEOF
3925ed911435SKevin Wolfif compile_prog "" "" ; then
3926ed911435SKevin Wolf    posix_fallocate=yes
3927ed911435SKevin Wolffi
3928ed911435SKevin Wolf
3929c727f47dSPeter Maydell# check for sync_file_range
3930c727f47dSPeter Maydellsync_file_range=no
3931c727f47dSPeter Maydellcat > $TMPC << EOF
3932c727f47dSPeter Maydell#include <fcntl.h>
3933c727f47dSPeter Maydell
3934c727f47dSPeter Maydellint main(void)
3935c727f47dSPeter Maydell{
3936c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3937c727f47dSPeter Maydell    return 0;
3938c727f47dSPeter Maydell}
3939c727f47dSPeter MaydellEOF
39408fb03151SPeter Maydellif compile_prog "" "" ; then
3941c727f47dSPeter Maydell  sync_file_range=yes
3942c727f47dSPeter Maydellfi
3943c727f47dSPeter Maydell
3944dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3945dace20dcSPeter Maydellfiemap=no
3946dace20dcSPeter Maydellcat > $TMPC << EOF
3947dace20dcSPeter Maydell#include <sys/ioctl.h>
3948dace20dcSPeter Maydell#include <linux/fs.h>
3949dace20dcSPeter Maydell#include <linux/fiemap.h>
3950dace20dcSPeter Maydell
3951dace20dcSPeter Maydellint main(void)
3952dace20dcSPeter Maydell{
3953dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3954dace20dcSPeter Maydell    return 0;
3955dace20dcSPeter Maydell}
3956dace20dcSPeter MaydellEOF
39578fb03151SPeter Maydellif compile_prog "" "" ; then
3958dace20dcSPeter Maydell  fiemap=yes
3959dace20dcSPeter Maydellfi
3960dace20dcSPeter Maydell
3961d0927938SUlrich Hecht# check for dup3
3962d0927938SUlrich Hechtdup3=no
3963d0927938SUlrich Hechtcat > $TMPC << EOF
3964d0927938SUlrich Hecht#include <unistd.h>
3965d0927938SUlrich Hecht
3966d0927938SUlrich Hechtint main(void)
3967d0927938SUlrich Hecht{
3968d0927938SUlrich Hecht    dup3(0, 0, 0);
3969d0927938SUlrich Hecht    return 0;
3970d0927938SUlrich Hecht}
3971d0927938SUlrich HechtEOF
397278f5d726SJan Kiszkaif compile_prog "" "" ; then
3973d0927938SUlrich Hecht  dup3=yes
3974d0927938SUlrich Hechtfi
3975d0927938SUlrich Hecht
39764e0c6529SAlex Bligh# check for ppoll support
39774e0c6529SAlex Blighppoll=no
39784e0c6529SAlex Blighcat > $TMPC << EOF
39794e0c6529SAlex Bligh#include <poll.h>
39804e0c6529SAlex Bligh
39814e0c6529SAlex Blighint main(void)
39824e0c6529SAlex Bligh{
39834e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39844e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39854e0c6529SAlex Bligh    return 0;
39864e0c6529SAlex Bligh}
39874e0c6529SAlex BlighEOF
39884e0c6529SAlex Blighif compile_prog "" "" ; then
39894e0c6529SAlex Bligh  ppoll=yes
39904e0c6529SAlex Blighfi
39914e0c6529SAlex Bligh
3992cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3993cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3994cd758dd0SAlex Blighcat > $TMPC << EOF
3995cd758dd0SAlex Bligh#include <sys/prctl.h>
3996cd758dd0SAlex Bligh
3997cd758dd0SAlex Blighint main(void)
3998cd758dd0SAlex Bligh{
3999cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4000cd758dd0SAlex Bligh    return 0;
4001cd758dd0SAlex Bligh}
4002cd758dd0SAlex BlighEOF
4003cd758dd0SAlex Blighif compile_prog "" "" ; then
4004cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4005cd758dd0SAlex Blighfi
4006cd758dd0SAlex Bligh
40073b6edd16SPeter Maydell# check for epoll support
40083b6edd16SPeter Maydellepoll=no
40093b6edd16SPeter Maydellcat > $TMPC << EOF
40103b6edd16SPeter Maydell#include <sys/epoll.h>
40113b6edd16SPeter Maydell
40123b6edd16SPeter Maydellint main(void)
40133b6edd16SPeter Maydell{
40143b6edd16SPeter Maydell    epoll_create(0);
40153b6edd16SPeter Maydell    return 0;
40163b6edd16SPeter Maydell}
40173b6edd16SPeter MaydellEOF
40188fb03151SPeter Maydellif compile_prog "" "" ; then
40193b6edd16SPeter Maydell  epoll=yes
40203b6edd16SPeter Maydellfi
40213b6edd16SPeter Maydell
4022227f0214SPeter Maydell# epoll_create1 is a later addition
4023227f0214SPeter Maydell# so we must check separately for its presence
40243b6edd16SPeter Maydellepoll_create1=no
40253b6edd16SPeter Maydellcat > $TMPC << EOF
40263b6edd16SPeter Maydell#include <sys/epoll.h>
40273b6edd16SPeter Maydell
40283b6edd16SPeter Maydellint main(void)
40293b6edd16SPeter Maydell{
403019e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
403119e83f6bSPeter Maydell     * a function being called. This is necessary so that on
403219e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
403319e83f6bSPeter Maydell     * the library but not declared in the header file we will
403419e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
403519e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
403619e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
403719e83f6bSPeter Maydell     */
4038c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
40393b6edd16SPeter Maydell}
40403b6edd16SPeter MaydellEOF
40418fb03151SPeter Maydellif compile_prog "" "" ; then
40423b6edd16SPeter Maydell  epoll_create1=yes
40433b6edd16SPeter Maydellfi
40443b6edd16SPeter Maydell
4045a8fd1abaSPeter Maydell# check for sendfile support
4046a8fd1abaSPeter Maydellsendfile=no
4047a8fd1abaSPeter Maydellcat > $TMPC << EOF
4048a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4049a8fd1abaSPeter Maydell
4050a8fd1abaSPeter Maydellint main(void)
4051a8fd1abaSPeter Maydell{
4052a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4053a8fd1abaSPeter Maydell}
4054a8fd1abaSPeter MaydellEOF
4055a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4056a8fd1abaSPeter Maydell  sendfile=yes
4057a8fd1abaSPeter Maydellfi
4058a8fd1abaSPeter Maydell
405951834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
406051834341SRiku Voipiotimerfd=no
406151834341SRiku Voipiocat > $TMPC << EOF
406251834341SRiku Voipio#include <sys/timerfd.h>
406351834341SRiku Voipio
406451834341SRiku Voipioint main(void)
406551834341SRiku Voipio{
406651834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
406751834341SRiku Voipio}
406851834341SRiku VoipioEOF
406951834341SRiku Voipioif compile_prog "" "" ; then
407051834341SRiku Voipio  timerfd=yes
407151834341SRiku Voipiofi
407251834341SRiku Voipio
40739af5c906SRiku Voipio# check for setns and unshare support
40749af5c906SRiku Voipiosetns=no
40759af5c906SRiku Voipiocat > $TMPC << EOF
40769af5c906SRiku Voipio#include <sched.h>
40779af5c906SRiku Voipio
40789af5c906SRiku Voipioint main(void)
40799af5c906SRiku Voipio{
40809af5c906SRiku Voipio    int ret;
40819af5c906SRiku Voipio    ret = setns(0, 0);
40829af5c906SRiku Voipio    ret = unshare(0);
40839af5c906SRiku Voipio    return ret;
40849af5c906SRiku Voipio}
40859af5c906SRiku VoipioEOF
40869af5c906SRiku Voipioif compile_prog "" "" ; then
40879af5c906SRiku Voipio  setns=yes
40889af5c906SRiku Voipiofi
40899af5c906SRiku Voipio
409038860a03SAleksandar Markovic# clock_adjtime probe
409138860a03SAleksandar Markovicclock_adjtime=no
409238860a03SAleksandar Markoviccat > $TMPC <<EOF
409338860a03SAleksandar Markovic#include <time.h>
409438860a03SAleksandar Markovic
409538860a03SAleksandar Markovicint main(void)
409638860a03SAleksandar Markovic{
409738860a03SAleksandar Markovic    return clock_adjtime(0, 0);
409838860a03SAleksandar Markovic}
409938860a03SAleksandar MarkovicEOF
410038860a03SAleksandar Markovicclock_adjtime=no
410138860a03SAleksandar Markovicif compile_prog "" "" ; then
410238860a03SAleksandar Markovic  clock_adjtime=yes
410338860a03SAleksandar Markovicfi
410438860a03SAleksandar Markovic
41055a03cd00SAleksandar Markovic# syncfs probe
41065a03cd00SAleksandar Markovicsyncfs=no
41075a03cd00SAleksandar Markoviccat > $TMPC <<EOF
41085a03cd00SAleksandar Markovic#include <unistd.h>
41095a03cd00SAleksandar Markovic
41105a03cd00SAleksandar Markovicint main(void)
41115a03cd00SAleksandar Markovic{
41125a03cd00SAleksandar Markovic    return syncfs(0);
41135a03cd00SAleksandar Markovic}
41145a03cd00SAleksandar MarkovicEOF
41155a03cd00SAleksandar Markovicsyncfs=no
41165a03cd00SAleksandar Markovicif compile_prog "" "" ; then
41175a03cd00SAleksandar Markovic  syncfs=yes
41185a03cd00SAleksandar Markovicfi
41195a03cd00SAleksandar Markovic
4120cc8ae6deSpbrook# Check if tools are available to build documentation.
4121a25dba17SJuan Quintelaif test "$docs" != "no" ; then
412201668d98SStefan Weil  if has makeinfo && has pod2man; then
4123a25dba17SJuan Quintela    docs=yes
412483a3ab8bSJuan Quintela  else
4125a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
412621684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
412783a3ab8bSJuan Quintela    fi
4128a25dba17SJuan Quintela    docs=no
412983a3ab8bSJuan Quintela  fi
4130cc8ae6deSpbrookfi
4131cc8ae6deSpbrook
4132f514f41cSStefan Weil# Search for bswap_32 function
41336ae9a1f4SJuan Quintelabyteswap_h=no
41346ae9a1f4SJuan Quintelacat > $TMPC << EOF
41356ae9a1f4SJuan Quintela#include <byteswap.h>
41366ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
41376ae9a1f4SJuan QuintelaEOF
413852166aa0SJuan Quintelaif compile_prog "" "" ; then
41396ae9a1f4SJuan Quintela  byteswap_h=yes
41406ae9a1f4SJuan Quintelafi
41416ae9a1f4SJuan Quintela
414275f13596SStefan Weil# Search for bswap32 function
41436ae9a1f4SJuan Quintelabswap_h=no
41446ae9a1f4SJuan Quintelacat > $TMPC << EOF
41456ae9a1f4SJuan Quintela#include <sys/endian.h>
41466ae9a1f4SJuan Quintela#include <sys/types.h>
41476ae9a1f4SJuan Quintela#include <machine/bswap.h>
41486ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
41496ae9a1f4SJuan QuintelaEOF
415052166aa0SJuan Quintelaif compile_prog "" "" ; then
41516ae9a1f4SJuan Quintela  bswap_h=yes
41526ae9a1f4SJuan Quintelafi
41536ae9a1f4SJuan Quintela
4154da93a1fdSaliguori##########################################
4155e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4156c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4157e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
41583c33ea96SPaolo Bonzini    libiscsi="yes"
4159ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4160ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4161c589b249SRonnie Sahlberg  else
4162c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4163e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4164c589b249SRonnie Sahlberg    fi
4165c589b249SRonnie Sahlberg    libiscsi="no"
4166c589b249SRonnie Sahlberg  fi
4167c589b249SRonnie Sahlbergfi
4168c589b249SRonnie Sahlberg
4169c589b249SRonnie Sahlberg##########################################
41708bacde8dSNatanael Copa# Do we need libm
41718bacde8dSNatanael Copacat > $TMPC << EOF
41728bacde8dSNatanael Copa#include <math.h>
4173f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
41748bacde8dSNatanael CopaEOF
41758bacde8dSNatanael Copaif compile_prog "" "" ; then
41768bacde8dSNatanael Copa  :
41778bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
41788bacde8dSNatanael Copa  LIBS="-lm $LIBS"
41798bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
41808bacde8dSNatanael Copaelse
418176ad07a4SPeter Maydell  error_exit "libm check failed"
41828bacde8dSNatanael Copafi
41838bacde8dSNatanael Copa
41848bacde8dSNatanael Copa##########################################
4185da93a1fdSaliguori# Do we need librt
41868bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
41878bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
41888bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
41898bacde8dSNatanael Copa# function in addition.
4190da93a1fdSaliguoricat > $TMPC <<EOF
4191da93a1fdSaliguori#include <signal.h>
4192da93a1fdSaliguori#include <time.h>
41938bacde8dSNatanael Copaint main(void) {
41948bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
41958bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
41968bacde8dSNatanael Copa}
4197da93a1fdSaliguoriEOF
4198da93a1fdSaliguori
419952166aa0SJuan Quintelaif compile_prog "" "" ; then
420007ffa4bdSJuan Quintela  :
42018bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
420218e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
420318e588b1SRick Liu  LIBS="$LIBS -lrt"
420418e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4205da93a1fdSaliguorifi
4206da93a1fdSaliguori
420731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
420878723752SPeter Maydell        "$haiku" != "yes" ; then
42096362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
42106362a53fSJuan Quintelafi
42116362a53fSJuan Quintela
4212de5071c5SBlue Swirl##########################################
4213cd4ec0b4SGerd Hoffmann# spice probe
4214cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4215cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4216cd4ec0b4SGerd Hoffmann#include <spice.h>
4217cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4218cd4ec0b4SGerd HoffmannEOF
4219710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4220710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
422165d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
422265d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4223cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4224cd4ec0b4SGerd Hoffmann    spice="yes"
4225cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4226cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
42272e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
42282e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4229cd4ec0b4SGerd Hoffmann  else
4230cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
42318efc9363SHu Tao      feature_not_found "spice" \
42328efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4233cd4ec0b4SGerd Hoffmann    fi
4234cd4ec0b4SGerd Hoffmann    spice="no"
4235cd4ec0b4SGerd Hoffmann  fi
4236cd4ec0b4SGerd Hoffmannfi
4237cd4ec0b4SGerd Hoffmann
42387b02f544SMarc-André Lureau# check for smartcard support
42397b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
42407b02f544SMarc-André Lureau    if $pkg_config libcacard; then
42417b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
42427b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
42437b02f544SMarc-André Lureau        smartcard="yes"
4244111a38b0SRobert Relyea    else
42457b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
42467b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4247111a38b0SRobert Relyea        fi
42487b02f544SMarc-André Lureau        smartcard="no"
4249111a38b0SRobert Relyea    fi
4250111a38b0SRobert Relyeafi
4251111a38b0SRobert Relyea
42522b2325ffSGerd Hoffmann# check for libusb
42532b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
425465d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
42552b2325ffSGerd Hoffmann        libusb="yes"
4256ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4257ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
42582b2325ffSGerd Hoffmann    else
42592b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
42608efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
42612b2325ffSGerd Hoffmann        fi
42622b2325ffSGerd Hoffmann        libusb="no"
42632b2325ffSGerd Hoffmann    fi
42642b2325ffSGerd Hoffmannfi
42652b2325ffSGerd Hoffmann
426669354a83SHans de Goede# check for usbredirparser for usb network redirection support
426769354a83SHans de Goedeif test "$usb_redir" != "no" ; then
426865d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
426969354a83SHans de Goede        usb_redir="yes"
4270ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4271ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
427269354a83SHans de Goede    else
427369354a83SHans de Goede        if test "$usb_redir" = "yes"; then
427421684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
427569354a83SHans de Goede        fi
427669354a83SHans de Goede        usb_redir="no"
427769354a83SHans de Goede    fi
427869354a83SHans de Goedefi
427969354a83SHans de Goede
4280cd4ec0b4SGerd Hoffmann##########################################
4281d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4282d9840e25STomoki Sekiyama
4283d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4284d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4285690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4286d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4287d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4288690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4289d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4290d9840e25STomoki Sekiyama	  ;;
4291690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4292d9840e25STomoki Sekiyama  esac
4293d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4294d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4295d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4296d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4297d9840e25STomoki SekiyamaEOF
4298d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4299d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4300d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4301315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4302f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4303d9840e25STomoki Sekiyama  else
4304d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4305d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4306d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4307d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4308d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4309d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4310d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4311d9840e25STomoki Sekiyama    fi
4312d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4313d9840e25STomoki Sekiyama  fi
4314d9840e25STomoki Sekiyamafi
4315d9840e25STomoki Sekiyama
4316d9840e25STomoki Sekiyama##########################################
4317d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4318d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4319d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4320d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4321d9840e25STomoki Sekiyama
4322d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4323d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4324d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4325d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4326d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4327d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4328d9840e25STomoki Sekiyama    else
4329d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4330d9840e25STomoki Sekiyama    fi
4331d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4332d9840e25STomoki Sekiyama    win_sdk=""
4333d9840e25STomoki Sekiyama  fi
4334d9840e25STomoki Sekiyamafi
4335d9840e25STomoki Sekiyama
4336d9840e25STomoki Sekiyama##########################################
433750cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
433850cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
433950cbebb9SMichael Roth  cat > $TMPC << EOF
434050cbebb9SMichael Roth#include <windows.h>
434150cbebb9SMichael Roth#include <ntddscsi.h>
434250cbebb9SMichael Rothint main(void) {
434350cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
434450cbebb9SMichael Roth#error Missing required ioctl definitions
434550cbebb9SMichael Roth#endif
434650cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
434750cbebb9SMichael Roth  return addr.Lun;
434850cbebb9SMichael Roth}
434950cbebb9SMichael RothEOF
435050cbebb9SMichael Roth  if compile_prog "" "" ; then
435150cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4352c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
435350cbebb9SMichael Roth  fi
435450cbebb9SMichael Rothfi
435550cbebb9SMichael Roth
435650cbebb9SMichael Roth##########################################
43579d9e1521SGerd Hoffmann# virgl renderer probe
43589d9e1521SGerd Hoffmann
43599d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
43609d9e1521SGerd Hoffmann  cat > $TMPC << EOF
43619d9e1521SGerd Hoffmann#include <virglrenderer.h>
43629d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
43639d9e1521SGerd HoffmannEOF
43649d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
43659d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
43669d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
43679d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
43689d9e1521SGerd Hoffmann    virglrenderer="yes"
43699d9e1521SGerd Hoffmann  else
43709d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
43719d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
43729d9e1521SGerd Hoffmann    fi
43739d9e1521SGerd Hoffmann    virglrenderer="no"
43749d9e1521SGerd Hoffmann  fi
43759d9e1521SGerd Hoffmannfi
43769d9e1521SGerd Hoffmann
43779d9e1521SGerd Hoffmann##########################################
43785f6b9e8fSBlue Swirl# check if we have fdatasync
43795f6b9e8fSBlue Swirl
43805f6b9e8fSBlue Swirlfdatasync=no
43815f6b9e8fSBlue Swirlcat > $TMPC << EOF
43825f6b9e8fSBlue Swirl#include <unistd.h>
4383d1722a27SAlexandre Raymondint main(void) {
4384d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4385d1722a27SAlexandre Raymondreturn fdatasync(0);
4386d1722a27SAlexandre Raymond#else
4387e172fe11SStefan Weil#error Not supported
4388d1722a27SAlexandre Raymond#endif
4389d1722a27SAlexandre Raymond}
43905f6b9e8fSBlue SwirlEOF
43915f6b9e8fSBlue Swirlif compile_prog "" "" ; then
43925f6b9e8fSBlue Swirl    fdatasync=yes
43935f6b9e8fSBlue Swirlfi
43945f6b9e8fSBlue Swirl
439594a420b1SStefan Hajnoczi##########################################
4396e78815a5SAndreas Färber# check if we have madvise
4397e78815a5SAndreas Färber
4398e78815a5SAndreas Färbermadvise=no
4399e78815a5SAndreas Färbercat > $TMPC << EOF
4400e78815a5SAndreas Färber#include <sys/types.h>
4401e78815a5SAndreas Färber#include <sys/mman.h>
4402832ce9c2SScott Wood#include <stddef.h>
4403e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4404e78815a5SAndreas FärberEOF
4405e78815a5SAndreas Färberif compile_prog "" "" ; then
4406e78815a5SAndreas Färber    madvise=yes
4407e78815a5SAndreas Färberfi
4408e78815a5SAndreas Färber
4409e78815a5SAndreas Färber##########################################
4410e78815a5SAndreas Färber# check if we have posix_madvise
4411e78815a5SAndreas Färber
4412e78815a5SAndreas Färberposix_madvise=no
4413e78815a5SAndreas Färbercat > $TMPC << EOF
4414e78815a5SAndreas Färber#include <sys/mman.h>
4415832ce9c2SScott Wood#include <stddef.h>
4416e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4417e78815a5SAndreas FärberEOF
4418e78815a5SAndreas Färberif compile_prog "" "" ; then
4419e78815a5SAndreas Färber    posix_madvise=yes
4420e78815a5SAndreas Färberfi
4421e78815a5SAndreas Färber
4422e78815a5SAndreas Färber##########################################
44230a852417SPaul Durrant# check if we have posix_syslog
44240a852417SPaul Durrant
44250a852417SPaul Durrantposix_syslog=no
44260a852417SPaul Durrantcat > $TMPC << EOF
44270a852417SPaul Durrant#include <syslog.h>
44280a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
44290a852417SPaul DurrantEOF
44300a852417SPaul Durrantif compile_prog "" "" ; then
44310a852417SPaul Durrant    posix_syslog=yes
44320a852417SPaul Durrantfi
44330a852417SPaul Durrant
44340a852417SPaul Durrant##########################################
4435401bc051SPeter Maydell# check if we have sem_timedwait
4436401bc051SPeter Maydell
4437401bc051SPeter Maydellsem_timedwait=no
4438401bc051SPeter Maydellcat > $TMPC << EOF
4439401bc051SPeter Maydell#include <semaphore.h>
4440401bc051SPeter Maydellint main(void) { return sem_timedwait(0, 0); }
4441401bc051SPeter MaydellEOF
4442401bc051SPeter Maydellif compile_prog "" "" ; then
4443401bc051SPeter Maydell    sem_timedwait=yes
4444401bc051SPeter Maydellfi
4445401bc051SPeter Maydell
4446401bc051SPeter Maydell##########################################
444794a420b1SStefan Hajnoczi# check if trace backend exists
444894a420b1SStefan Hajnoczi
44495b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
445094a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
44515b808275SLluís Vilanova  error_exit "invalid trace backends" \
44525b808275SLluís Vilanova      "Please choose supported trace backends."
445394a420b1SStefan Hajnoczifi
445494a420b1SStefan Hajnoczi
44557e24e92aSStefan Hajnoczi##########################################
44567e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
44575b808275SLluís Vilanovaif have_backend "ust"; then
44587e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4459bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
44607e24e92aSStefan Hajnocziint main(void) { return 0; }
44617e24e92aSStefan HajnocziEOF
4462c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4463bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
446489138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
44657e24e92aSStefan Hajnoczi    else
4466c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4467bf15f63cSMohamad Gebai    fi
4468bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
446989138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4470bf15f63cSMohamad Gebai    else
4471bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4472bf15f63cSMohamad Gebai    fi
4473bf15f63cSMohamad Gebai
4474bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4475bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4476bf15f63cSMohamad Gebai  else
4477bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44787e24e92aSStefan Hajnoczi  fi
44797e24e92aSStefan Hajnoczifi
4480b3d08c02SDaniel P. Berrange
4481b3d08c02SDaniel P. Berrange##########################################
4482b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44835b808275SLluís Vilanovaif have_backend "dtrace"; then
4484b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
448576ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4486b3d08c02SDaniel P. Berrange  fi
4487c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4488c276b17dSDaniel P. Berrange  if has 'stap' ; then
4489c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4490c276b17dSDaniel P. Berrange  fi
4491b3d08c02SDaniel P. Berrangefi
4492b3d08c02SDaniel P. Berrange
44937e24e92aSStefan Hajnoczi##########################################
4494519175a2SAlex Barcelo# check and set a backend for coroutine
4495d0e2fce5SAneesh Kumar K.V
44967c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
449733c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
449833c53c54SDaniel P. Berrange# specific one.
44997c2acc70SPeter Maydell
45007c2acc70SPeter Maydellucontext_works=no
4501d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4502d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4503d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4504cdf84806SPeter Maydell#ifdef __stub_makecontext
4505cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4506cdf84806SPeter Maydell#endif
450775cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4508d0e2fce5SAneesh Kumar K.VEOF
4509d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
45107c2acc70SPeter Maydell    ucontext_works=yes
4511d0e2fce5SAneesh Kumar K.V  fi
4512519175a2SAlex Barcelofi
45137c2acc70SPeter Maydell
45147c2acc70SPeter Maydellif test "$coroutine" = ""; then
45157c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
45167c2acc70SPeter Maydell    coroutine=win32
45177c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
45187c2acc70SPeter Maydell    coroutine=ucontext
4519519175a2SAlex Barcelo  else
45207c2acc70SPeter Maydell    coroutine=sigaltstack
45217c2acc70SPeter Maydell  fi
45227c2acc70SPeter Maydellelse
45237c2acc70SPeter Maydell  case $coroutine in
45247c2acc70SPeter Maydell  windows)
45257c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
45267c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
45277c2acc70SPeter Maydell    fi
45287c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
45297c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
45307c2acc70SPeter Maydell    coroutine=win32
45317c2acc70SPeter Maydell    ;;
45327c2acc70SPeter Maydell  ucontext)
45337c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
45347c2acc70SPeter Maydell      feature_not_found "ucontext"
45357c2acc70SPeter Maydell    fi
45367c2acc70SPeter Maydell    ;;
453733c53c54SDaniel P. Berrange  sigaltstack)
45387c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
45397c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
45407c2acc70SPeter Maydell    fi
45417c2acc70SPeter Maydell    ;;
45427c2acc70SPeter Maydell  *)
454376ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
45447c2acc70SPeter Maydell    ;;
45457c2acc70SPeter Maydell  esac
4546d0e2fce5SAneesh Kumar K.Vfi
4547d0e2fce5SAneesh Kumar K.V
454870c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
454970c60c08SStefan Hajnoczi  coroutine_pool=yes
455070c60c08SStefan Hajnoczifi
455170c60c08SStefan Hajnoczi
45527d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
45537d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
45547d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
45557d992e4dSPeter Lieven  fi
45567d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
45577d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
45587d992e4dSPeter Lieven    coroutine_pool=no
45597d992e4dSPeter Lieven  fi
45607d992e4dSPeter Lievenfi
45617d992e4dSPeter Lieven
45627d992e4dSPeter Lieven
4563d0e2fce5SAneesh Kumar K.V##########################################
4564d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4565d2042378SAneesh Kumar K.V
45664e1797f9SStefan Weilopen_by_handle_at=no
4567d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4568d2042378SAneesh Kumar K.V#include <fcntl.h>
4569acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4570acc55ba8SStefan Weil# error missing definition
4571acc55ba8SStefan Weil#else
457275cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4573acc55ba8SStefan Weil#endif
4574d2042378SAneesh Kumar K.VEOF
4575d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4576d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4577d2042378SAneesh Kumar K.Vfi
4578d2042378SAneesh Kumar K.V
4579e06a765eSHarsh Prateek Bora########################################
4580e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4581e06a765eSHarsh Prateek Bora
4582e06a765eSHarsh Prateek Boralinux_magic_h=no
4583e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4584e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4585e06a765eSHarsh Prateek Boraint main(void) {
458675cafad7SStefan Weil  return 0;
4587e06a765eSHarsh Prateek Bora}
4588e06a765eSHarsh Prateek BoraEOF
4589e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4590e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4591e06a765eSHarsh Prateek Borafi
4592e06a765eSHarsh Prateek Bora
45938ab1bf12SLuiz Capitulino########################################
4594c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4595c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4596c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4597c95e3080SKevin Wolf# only a warning.
4598c95e3080SKevin Wolf#
4599c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4600c95e3080SKevin Wolf# the build doesn't fail anyway.
4601c95e3080SKevin Wolf
460206d71fa1SPeter Maydellpragma_disable_unused_but_set=no
460306d71fa1SPeter Maydellcat > $TMPC << EOF
4604e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
460506d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4606c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4607e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4608c95e3080SKevin Wolf
460906d71fa1SPeter Maydellint main(void) {
461006d71fa1SPeter Maydell    return 0;
461106d71fa1SPeter Maydell}
461206d71fa1SPeter MaydellEOF
461306d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4614cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4615c95e3080SKevin Wolfelse
4616c95e3080SKevin Wolf    werror=no
461706d71fa1SPeter Maydellfi
461806d71fa1SPeter Maydell
461906d71fa1SPeter Maydell########################################
4620541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
46213f4349dcSKevin Wolf
46223f4349dcSKevin Wolfvalgrind_h=no
46233f4349dcSKevin Wolfcat > $TMPC << EOF
46243f4349dcSKevin Wolf#include <valgrind/valgrind.h>
46253f4349dcSKevin Wolfint main(void) {
46263f4349dcSKevin Wolf  return 0;
46273f4349dcSKevin Wolf}
46283f4349dcSKevin WolfEOF
46293f4349dcSKevin Wolfif compile_prog "" "" ; then
46303f4349dcSKevin Wolf    valgrind_h=yes
46313f4349dcSKevin Wolffi
46323f4349dcSKevin Wolf
46333f4349dcSKevin Wolf########################################
46348ab1bf12SLuiz Capitulino# check if environ is declared
46358ab1bf12SLuiz Capitulino
46368ab1bf12SLuiz Capitulinohas_environ=no
46378ab1bf12SLuiz Capitulinocat > $TMPC << EOF
46388ab1bf12SLuiz Capitulino#include <unistd.h>
46398ab1bf12SLuiz Capitulinoint main(void) {
4640c075a723SBlue Swirl    environ = 0;
46418ab1bf12SLuiz Capitulino    return 0;
46428ab1bf12SLuiz Capitulino}
46438ab1bf12SLuiz CapitulinoEOF
46448ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
46458ab1bf12SLuiz Capitulino    has_environ=yes
46468ab1bf12SLuiz Capitulinofi
46478ab1bf12SLuiz Capitulino
464876a347e1SRichard Henderson########################################
464976a347e1SRichard Henderson# check if cpuid.h is usable.
465076a347e1SRichard Henderson
465176a347e1SRichard Hendersoncat > $TMPC << EOF
465276a347e1SRichard Henderson#include <cpuid.h>
465376a347e1SRichard Hendersonint main(void) {
4654774d566cSPeter Maydell    unsigned a, b, c, d;
4655774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4656774d566cSPeter Maydell
4657774d566cSPeter Maydell    if (max >= 1) {
4658774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4659774d566cSPeter Maydell    }
4660774d566cSPeter Maydell
4661774d566cSPeter Maydell    if (max >= 7) {
4662774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4663774d566cSPeter Maydell    }
4664774d566cSPeter Maydell
466576a347e1SRichard Henderson    return 0;
466676a347e1SRichard Henderson}
466776a347e1SRichard HendersonEOF
466876a347e1SRichard Hendersonif compile_prog "" "" ; then
466976a347e1SRichard Henderson    cpuid_h=yes
467076a347e1SRichard Hendersonfi
467176a347e1SRichard Henderson
46725dd89908SRichard Henderson##########################################
46735dd89908SRichard Henderson# avx2 optimization requirement check
46745dd89908SRichard Henderson#
46755dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
46765dd89908SRichard Henderson# since we won't be able to select the new routines.
46775dd89908SRichard Henderson
46785dd89908SRichard Hendersonif test $cpuid_h = yes; then
46795dd89908SRichard Henderson  cat > $TMPC << EOF
46805dd89908SRichard Henderson#pragma GCC push_options
46815dd89908SRichard Henderson#pragma GCC target("avx2")
46825dd89908SRichard Henderson#include <cpuid.h>
46835dd89908SRichard Henderson#include <immintrin.h>
46845dd89908SRichard Hendersonstatic int bar(void *a) {
46855dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
46865dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
46875dd89908SRichard Henderson}
46885dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
46895dd89908SRichard HendersonEOF
46905dd89908SRichard Henderson  if compile_object "" ; then
46915dd89908SRichard Henderson    avx2_opt="yes"
46925dd89908SRichard Henderson  fi
46935dd89908SRichard Hendersonfi
46945dd89908SRichard Henderson
4695f540166bSRichard Henderson########################################
4696f540166bSRichard Henderson# check if __[u]int128_t is usable.
4697f540166bSRichard Henderson
4698f540166bSRichard Hendersonint128=no
4699f540166bSRichard Hendersoncat > $TMPC << EOF
4700a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4701a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4702a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4703a00f66abSStefan Weil# endif
4704a00f66abSStefan Weil#endif
4705f540166bSRichard Henderson__int128_t a;
4706f540166bSRichard Henderson__uint128_t b;
4707f540166bSRichard Hendersonint main (void) {
4708f540166bSRichard Henderson  a = a + b;
4709f540166bSRichard Henderson  b = a * b;
4710464e3671SPeter Maydell  a = a * a;
4711f540166bSRichard Henderson  return 0;
4712f540166bSRichard Henderson}
4713f540166bSRichard HendersonEOF
4714f540166bSRichard Hendersonif compile_prog "" "" ; then
4715f540166bSRichard Henderson    int128=yes
4716f540166bSRichard Hendersonfi
471776a347e1SRichard Henderson
47187ebee43eSRichard Henderson#########################################
47197ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
47207ebee43eSRichard Henderson
47217ebee43eSRichard Hendersonatomic128=no
47227ebee43eSRichard Hendersonif test "$int128" = "yes"; then
47237ebee43eSRichard Henderson  cat > $TMPC << EOF
47247ebee43eSRichard Hendersonint main(void)
47257ebee43eSRichard Henderson{
47267ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
47277ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
47287ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
47297ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
47307ebee43eSRichard Henderson  return 0;
47317ebee43eSRichard Henderson}
47327ebee43eSRichard HendersonEOF
47337ebee43eSRichard Henderson  if compile_prog "" "" ; then
47347ebee43eSRichard Henderson    atomic128=yes
47357ebee43eSRichard Henderson  fi
47367ebee43eSRichard Hendersonfi
47377ebee43eSRichard Henderson
4738df79b996SRichard Henderson#########################################
4739df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4740df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4741df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4742df79b996SRichard Henderson
4743df79b996SRichard Hendersoncat > $TMPC << EOF
4744df79b996SRichard Henderson#include <stdint.h>
4745df79b996SRichard Hendersonint main(void)
4746df79b996SRichard Henderson{
4747df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4748df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4749df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4750df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4751df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4752df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4753df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4754df79b996SRichard Henderson#else
4755df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4756df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4757df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4758df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4759df79b996SRichard Henderson#endif
4760df79b996SRichard Henderson  return 0;
4761df79b996SRichard Henderson}
4762df79b996SRichard HendersonEOF
4763df79b996SRichard Hendersonif compile_prog "" "" ; then
4764df79b996SRichard Henderson  atomic64=yes
4765df79b996SRichard Hendersonfi
4766df79b996SRichard Henderson
47671e6e9acaSRichard Henderson########################################
47681e6e9acaSRichard Henderson# check if getauxval is available.
47691e6e9acaSRichard Henderson
47701e6e9acaSRichard Hendersongetauxval=no
47711e6e9acaSRichard Hendersoncat > $TMPC << EOF
47721e6e9acaSRichard Henderson#include <sys/auxv.h>
47731e6e9acaSRichard Hendersonint main(void) {
47741e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
47751e6e9acaSRichard Henderson}
47761e6e9acaSRichard HendersonEOF
47771e6e9acaSRichard Hendersonif compile_prog "" "" ; then
47781e6e9acaSRichard Henderson    getauxval=yes
47791e6e9acaSRichard Hendersonfi
47801e6e9acaSRichard Henderson
4781fd0e6053SJohn Snow########################################
4782fd0e6053SJohn Snow# check if ccache is interfering with
4783fd0e6053SJohn Snow# semantic analysis of macros
4784fd0e6053SJohn Snow
47855e4dfd3dSJohn Snowunset CCACHE_CPP2
4786fd0e6053SJohn Snowccache_cpp2=no
4787fd0e6053SJohn Snowcat > $TMPC << EOF
4788fd0e6053SJohn Snowstatic const int Z = 1;
4789fd0e6053SJohn Snow#define fn() ({ Z; })
4790fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4791fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4792fd0e6053SJohn Snow#define ID(X) (X)
4793fd0e6053SJohn Snowint main(int argc, char *argv[])
4794fd0e6053SJohn Snow{
4795fd0e6053SJohn Snow    int x = 0, y = 0;
4796fd0e6053SJohn Snow    x = ID(x);
4797fd0e6053SJohn Snow    x = fn();
4798fd0e6053SJohn Snow    fn();
4799fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4800fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4801fd0e6053SJohn Snow    return 0;
4802fd0e6053SJohn Snow}
4803fd0e6053SJohn SnowEOF
4804fd0e6053SJohn Snow
4805fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4806fd0e6053SJohn Snow    ccache_cpp2=yes
4807fd0e6053SJohn Snowfi
4808fd0e6053SJohn Snow
4809b553a042SJohn Snow#################################################
4810b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4811b553a042SJohn Snow
4812b553a042SJohn Snowif test "$fortify_source" != "no"; then
4813b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4814b553a042SJohn Snow    fortify_source="no";
4815e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4816cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4817b553a042SJohn Snow    fortify_source="no";
4818b553a042SJohn Snow  else
4819b553a042SJohn Snow    fortify_source="yes"
4820b553a042SJohn Snow  fi
4821b553a042SJohn Snowfi
4822b553a042SJohn Snow
4823d2042378SAneesh Kumar K.V##########################################
4824277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4825277abf15SJan Vesely
4826277abf15SJan Veselyhave_fsxattr=no
4827277abf15SJan Veselycat > $TMPC << EOF
4828277abf15SJan Vesely#include <linux/fs.h>
4829277abf15SJan Veselystruct fsxattr foo;
4830277abf15SJan Veselyint main(void) {
4831277abf15SJan Vesely  return 0;
4832277abf15SJan Vesely}
4833277abf15SJan VeselyEOF
4834277abf15SJan Veselyif compile_prog "" "" ; then
4835277abf15SJan Vesely    have_fsxattr=yes
4836277abf15SJan Veselyfi
4837277abf15SJan Vesely
4838b66e10e4SPeter Maydell##########################################
4839b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4840575b22b1SLaurent Vivierhave_rtnetlink=no
4841575b22b1SLaurent Viviercat > $TMPC << EOF
4842575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4843575b22b1SLaurent Vivierint main(void) {
4844575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4845575b22b1SLaurent Vivier}
4846575b22b1SLaurent VivierEOF
4847575b22b1SLaurent Vivierif compile_prog "" "" ; then
4848575b22b1SLaurent Vivier    have_rtnetlink=yes
4849575b22b1SLaurent Vivierfi
4850575b22b1SLaurent Vivier
48516a02c806SStefan Hajnoczi##########################################
48526a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
48536a02c806SStefan Hajnoczihave_af_vsock=no
48546a02c806SStefan Hajnoczicat > $TMPC << EOF
48556a02c806SStefan Hajnoczi#include <errno.h>
48566a02c806SStefan Hajnoczi#include <sys/types.h>
48576a02c806SStefan Hajnoczi#include <sys/socket.h>
48586a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
48596a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
48606a02c806SStefan Hajnoczi#endif
48616a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
48626a02c806SStefan Hajnocziint main(void) {
48636a02c806SStefan Hajnoczi    int sock, ret;
48646a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
48656a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
48666a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
48676a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
48686a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
48696a02c806SStefan Hajnoczi        return 0;
48706a02c806SStefan Hajnoczi    }
48716a02c806SStefan Hajnoczi    return -1;
48726a02c806SStefan Hajnoczi}
48736a02c806SStefan HajnocziEOF
48746a02c806SStefan Hajnocziif compile_prog "" "" ; then
48756a02c806SStefan Hajnoczi    have_af_vsock=yes
48766a02c806SStefan Hajnoczifi
48776a02c806SStefan Hajnoczi
4878f0d92b56SLongpeng(Mike)##########################################
4879f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
4880f0d92b56SLongpeng(Mike)hava_afalg=no
4881f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
4882f0d92b56SLongpeng(Mike)#include <errno.h>
4883f0d92b56SLongpeng(Mike)#include <sys/types.h>
4884f0d92b56SLongpeng(Mike)#include <sys/socket.h>
4885f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
4886f0d92b56SLongpeng(Mike)int main(void) {
4887f0d92b56SLongpeng(Mike)    int sock;
4888f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
4889f0d92b56SLongpeng(Mike)    return sock;
4890f0d92b56SLongpeng(Mike)}
4891f0d92b56SLongpeng(Mike)EOF
4892f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4893f0d92b56SLongpeng(Mike)    have_afalg=yes
4894f0d92b56SLongpeng(Mike)fi
4895f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4896f0d92b56SLongpeng(Mike)then
4897f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4898f0d92b56SLongpeng(Mike)    then
4899f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4900f0d92b56SLongpeng(Mike)    fi
4901f0d92b56SLongpeng(Mike)fi
4902f0d92b56SLongpeng(Mike)
4903f0d92b56SLongpeng(Mike)
49046969ec6cSJames Clarke#################################################
49056969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
49066969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
49076969ec6cSJames Clarke# given. It does no harm to give it on other
49086969ec6cSJames Clarke# platforms too.
49096969ec6cSJames Clarke
49106969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
49116969ec6cSJames Clarke#       contains -Wmissing-prototypes
49126969ec6cSJames Clarkecat > $TMPC << EOF
49136969ec6cSJames Clarkeextern int foo(void);
49146969ec6cSJames Clarkeint foo(void) { return 0; }
49156969ec6cSJames ClarkeEOF
49166969ec6cSJames Clarkeif ! compile_object ""; then
49176969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
49186969ec6cSJames Clarkefi
49197ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
49207ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
49217ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
49227ecf44a5SPaolo Bonzini    break
49237ecf44a5SPaolo Bonzini  fi
49247ecf44a5SPaolo Bonzinidone
49257ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
49267ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
49276969ec6cSJames Clarkefi
49286969ec6cSJames Clarke
4929277abf15SJan Vesely##########################################
49304d04351fSChristopher Covington# check for sysmacros.h
49314d04351fSChristopher Covington
49324d04351fSChristopher Covingtonhave_sysmacros=no
49334d04351fSChristopher Covingtoncat > $TMPC << EOF
49344d04351fSChristopher Covington#include <sys/sysmacros.h>
49354d04351fSChristopher Covingtonint main(void) {
49364d04351fSChristopher Covington    return makedev(0, 0);
49374d04351fSChristopher Covington}
49384d04351fSChristopher CovingtonEOF
49394d04351fSChristopher Covingtonif compile_prog "" "" ; then
49404d04351fSChristopher Covington    have_sysmacros=yes
49414d04351fSChristopher Covingtonfi
49424d04351fSChristopher Covington
49434d04351fSChristopher Covington##########################################
4944da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
4945da92c3ffSAshish Mittal# Check if libvxhs is installed
4946da92c3ffSAshish Mittal
4947da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
4948da92c3ffSAshish Mittal  cat > $TMPC <<EOF
4949da92c3ffSAshish Mittal#include <stdint.h>
4950da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
4951da92c3ffSAshish Mittal
4952da92c3ffSAshish Mittalvoid *vxhs_callback;
4953da92c3ffSAshish Mittal
4954da92c3ffSAshish Mittalint main(void) {
4955da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
4956da92c3ffSAshish Mittal    return 0;
4957da92c3ffSAshish Mittal}
4958da92c3ffSAshish MittalEOF
4959da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
4960da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
4961da92c3ffSAshish Mittal    vxhs=yes
4962da92c3ffSAshish Mittal  else
4963da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
4964da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
4965da92c3ffSAshish Mittal    fi
4966da92c3ffSAshish Mittal    vxhs=no
4967da92c3ffSAshish Mittal  fi
4968da92c3ffSAshish Mittalfi
4969da92c3ffSAshish Mittal
4970da92c3ffSAshish Mittal##########################################
497149e00a18SAndreas Grapentin# check for _Static_assert()
497249e00a18SAndreas Grapentin
497349e00a18SAndreas Grapentinhave_static_assert=no
497449e00a18SAndreas Grapentincat > $TMPC << EOF
497549e00a18SAndreas Grapentin_Static_assert(1, "success");
497649e00a18SAndreas Grapentinint main(void) {
497749e00a18SAndreas Grapentin    return 0;
497849e00a18SAndreas Grapentin}
497949e00a18SAndreas GrapentinEOF
498049e00a18SAndreas Grapentinif compile_prog "" "" ; then
498149e00a18SAndreas Grapentin    have_static_assert=yes
498249e00a18SAndreas Grapentinfi
498349e00a18SAndreas Grapentin
498449e00a18SAndreas Grapentin##########################################
4985e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
4986e674605fSTomáš Golembiovský
4987e674605fSTomáš Golembiovskýhave_utmpx=no
4988e674605fSTomáš Golembiovskýcat > $TMPC << EOF
4989e674605fSTomáš Golembiovský#include <utmpx.h>
4990e674605fSTomáš Golembiovskýstruct utmpx user_info;
4991e674605fSTomáš Golembiovskýint main(void) {
4992e674605fSTomáš Golembiovský    return 0;
4993e674605fSTomáš Golembiovský}
4994e674605fSTomáš GolembiovskýEOF
4995e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
4996e674605fSTomáš Golembiovský    have_utmpx=yes
4997e674605fSTomáš Golembiovskýfi
4998e674605fSTomáš Golembiovský
4999e674605fSTomáš Golembiovský##########################################
5000e86ecd4bSJuan Quintela# End of CC checks
5001e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5002e86ecd4bSJuan Quintela
50031d728c39SBlue Swirlif test "$gcov" = "yes" ; then
50041d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
50051d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5006b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5007e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5008ce278618SPeter Maydellelif test "$debug" = "no"; then
5009ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
5010e86ecd4bSJuan Quintelafi
5011a316e378SJuan Quintela
50126542aa9cSPeter Lieven##########################################
50136542aa9cSPeter Lieven# Do we have libnfs
50146542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5015b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
50166542aa9cSPeter Lieven    libnfs="yes"
50176542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
50186542aa9cSPeter Lieven  else
50196542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
50208efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
50216542aa9cSPeter Lieven    fi
50226542aa9cSPeter Lieven    libnfs="no"
50236542aa9cSPeter Lieven  fi
50246542aa9cSPeter Lievenfi
50251d728c39SBlue Swirl
50266ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
50276ca026cbSPeter Maydellif test "$werror" = "yes"; then
50286ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
50296ca026cbSPeter Maydellfi
50306ca026cbSPeter Maydell
5031e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
5032e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
50331156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
5034e86ecd4bSJuan Quintela    fi
5035e86ecd4bSJuan Quintelafi
5036e86ecd4bSJuan Quintela
503794dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
503894dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
503994dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
504094dd53c5SGerd Hoffmannelse
504194dd53c5SGerd Hoffmann    POD2MAN="pod2man"
504294dd53c5SGerd Hoffmannfi
504394dd53c5SGerd Hoffmann
5044952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5045952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5046952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5047e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5048952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5049952afb71SBlue Swirl        fi
5050952afb71SBlue Swirl    done
5051952afb71SBlue Swirlfi
5052952afb71SBlue Swirl
505310ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5054e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5055528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5056834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
50575a67135aSbellard
5058e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5059e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5060e0580342SKamil Rytarowski  ivshmem=yes
5061e0580342SKamil Rytarowskifi
5062e0580342SKamil Rytarowski
50634b1c11fdSDaniel P. Berrangetools=""
50644b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5065ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
50664b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
50674b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5068b1449edbSKamil Rytarowski  fi
5069b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5070a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
50714b1c11fdSDaniel P. Berrange  fi
50724b1c11fdSDaniel P. Berrangefi
50734b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5074b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
5075b855f8d1SPaolo Bonzini    if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5076983eef5aSMeador Inge      virtfs=yes
507717bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5078983eef5aSMeador Inge    else
5079983eef5aSMeador Inge      if test "$virtfs" = yes; then
5080b855f8d1SPaolo Bonzini        error_exit "VirtFS requires libcap devel and libattr devel"
5081983eef5aSMeador Inge      fi
508217500370SAndreas Färber      virtfs=no
5083983eef5aSMeador Inge    fi
5084fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
5085fe8fc5aeSPaolo Bonzini      mpath=yes
5086fe8fc5aeSPaolo Bonzini    else
5087fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
5088fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
5089fe8fc5aeSPaolo Bonzini      fi
5090fe8fc5aeSPaolo Bonzini      mpath=no
5091fe8fc5aeSPaolo Bonzini    fi
5092b855f8d1SPaolo Bonzini    tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5093b855f8d1SPaolo Bonzini  else
5094b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5095b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5096b855f8d1SPaolo Bonzini    fi
5097b855f8d1SPaolo Bonzini    virtfs=no
5098fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
5099fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
5100fe8fc5aeSPaolo Bonzini    fi
5101fe8fc5aeSPaolo Bonzini    mpath=no
510217bff52bSM. Mohan Kumar  fi
5103d138cee9SMichael Rothfi
51049d6bc27bSMichael Roth
51059d6bc27bSMichael Roth# Probe for guest agent support/options
51069d6bc27bSMichael Roth
5107e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5108b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5109fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5110e8ef31a3SMichael Tokarev      guest_agent=yes
5111e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5112e8ef31a3SMichael Tokarev      guest_agent=no
5113e8ef31a3SMichael Tokarev  else
5114e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5115ca35f780SPaolo Bonzini  fi
51164b1c11fdSDaniel P. Berrangefi
5117ca35f780SPaolo Bonzini
51189d6bc27bSMichael Roth# Guest agent Window MSI  package
51199d6bc27bSMichael Roth
51209d6bc27bSMichael Rothif test "$guest_agent" != yes; then
51219d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
51229d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
51239d6bc27bSMichael Roth  fi
51249d6bc27bSMichael Roth  guest_agent_msi=no
51259d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
51269d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
51279d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
51289d6bc27bSMichael Roth  fi
51299d6bc27bSMichael Roth  guest_agent_msi=no
51309d6bc27bSMichael Rothelif ! has wixl; then
51319d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
51329d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
51339d6bc27bSMichael Roth  fi
51349d6bc27bSMichael Roth  guest_agent_msi=no
51351a34904eSMichael Rothelse
51361a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
51371a34904eSMichael Roth  # disabled explicitly
51381a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
51391a34904eSMichael Roth    guest_agent_msi=yes
51401a34904eSMichael Roth  fi
51419d6bc27bSMichael Rothfi
51429d6bc27bSMichael Roth
51431a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
51449d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
51459d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
51469d6bc27bSMichael Roth  fi
51479d6bc27bSMichael Roth
51489d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
51499d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
51509d6bc27bSMichael Roth  fi
51519d6bc27bSMichael Roth
51529d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
51539d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
51549d6bc27bSMichael Roth  fi
51559d6bc27bSMichael Roth
51569d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
515789138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
51589d6bc27bSMichael Roth  fi
51599d6bc27bSMichael Roth
516089138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
51619d6bc27bSMichael Roth
51629d6bc27bSMichael Roth  case "$cpu" in
51639d6bc27bSMichael Roth  x86_64)
51649d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
51659d6bc27bSMichael Roth    ;;
51669d6bc27bSMichael Roth  i386)
51679d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
51689d6bc27bSMichael Roth    ;;
51699d6bc27bSMichael Roth  *)
51709d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
51719d6bc27bSMichael Roth    ;;
51729d6bc27bSMichael Roth  esac
51739d6bc27bSMichael Rothfi
51749d6bc27bSMichael Roth
5175ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5176ca35f780SPaolo Bonziniroms=
5177ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5178ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5179ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5180e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5181e57218b6SPeter Maydell    # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5182e57218b6SPeter Maydell    # variant; and Windows uses i386pe.
5183e57218b6SPeter Maydell    for emu in elf_i386 elf_i386_fbsd i386pe; do
5184e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5185e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5186ca35f780SPaolo Bonzini            roms="optionrom"
5187e57218b6SPeter Maydell            break
5188e57218b6SPeter Maydell        fi
5189e57218b6SPeter Maydell    done
5190ca35f780SPaolo Bonzinifi
5191d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
519239ac8455SDavid Gibson  roms="$roms spapr-rtas"
519339ac8455SDavid Gibsonfi
5194ca35f780SPaolo Bonzini
51959933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
51969933c305SChristian Borntraeger  roms="$roms s390-ccw"
51979933c305SChristian Borntraegerfi
51989933c305SChristian Borntraeger
5199964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
520092fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5201964c6fa1SRichard Henderson  textseg_addr=
5202964c6fa1SRichard Henderson  case "$cpu" in
5203479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5204479eb121SRichard Henderson      # ??? Rationale for choosing this address
5205964c6fa1SRichard Henderson      textseg_addr=0x60000000
5206964c6fa1SRichard Henderson      ;;
5207964c6fa1SRichard Henderson    mips)
5208479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5209479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5210479eb121SRichard Henderson      textseg_addr=0x60000000
5211964c6fa1SRichard Henderson      ;;
5212964c6fa1SRichard Henderson  esac
5213964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5214964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5215964c6fa1SRichard Henderson    int main(void) { return 0; }
5216964c6fa1SRichard HendersonEOF
5217964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5218964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5219964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5220964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5221964c6fa1SRichard Henderson      # at least.
522292fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
522392fe2ba8SPeter Maydell        error_exit \
522492fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
522592fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
522692fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
522792fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
522892fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
522992fe2ba8SPeter Maydell            "--disable-user option to configure."
523092fe2ba8SPeter Maydell      fi
523192fe2ba8SPeter Maydell
5232964c6fa1SRichard Henderson      $ld --verbose | sed \
5233964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5234964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5235964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5236964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5237964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5238964c6fa1SRichard Henderson    fi
5239964c6fa1SRichard Henderson  fi
5240964c6fa1SRichard Hendersonfi
5241964c6fa1SRichard Henderson
524211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
524311cde1c8SBruno 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.
524411cde1c8SBruno Dominguezif has $cxx; then
524511cde1c8SBruno Dominguez    cat > $TMPC <<EOF
524611cde1c8SBruno Dominguezint c_function(void);
524711cde1c8SBruno Dominguezint main(void) { return c_function(); }
524811cde1c8SBruno DominguezEOF
524911cde1c8SBruno Dominguez
525011cde1c8SBruno Dominguez    compile_object
525111cde1c8SBruno Dominguez
525211cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
525311cde1c8SBruno Dominguezextern "C" {
525411cde1c8SBruno Dominguez   int c_function(void);
525511cde1c8SBruno Dominguez}
525611cde1c8SBruno Dominguezint c_function(void) { return 42; }
525711cde1c8SBruno DominguezEOF
525811cde1c8SBruno Dominguez
525911cde1c8SBruno Dominguez    update_cxxflags
526011cde1c8SBruno Dominguez
526111cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
526211cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
526311cde1c8SBruno Dominguez        :
526411cde1c8SBruno Dominguez    else
526511cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
526611cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
526711cde1c8SBruno Dominguez        cxx=
526811cde1c8SBruno Dominguez    fi
526911cde1c8SBruno Dominguezelse
527011cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
527111cde1c8SBruno Dominguez    cxx=
527211cde1c8SBruno Dominguezfi
527311cde1c8SBruno Dominguez
527402d34f62SCole Robinsonecho_version() {
527502d34f62SCole Robinson    if test "$1" = "yes" ; then
527602d34f62SCole Robinson        echo "($2)"
527702d34f62SCole Robinson    fi
527802d34f62SCole Robinson}
527902d34f62SCole Robinson
528050e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
528150e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
528250e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
52835ca9388aSGerd Hoffmann
52847d13299dSbellardecho "Install prefix    $prefix"
528589138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
52863d5eecabSGerd Hoffmannecho "firmware path     $(eval echo $firmwarepath)"
528789138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
528889138857SStefan Weilecho "library directory $(eval echo $libdir)"
528989138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
529089138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
529189138857SStefan Weilecho "include directory $(eval echo $includedir)"
529289138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
529311d9f695Sbellardif test "$mingw32" = "no" ; then
529489138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
529589138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
529643ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
52975a699bbbSLaszlo Ersekelse
52985a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5299d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
530011d9f695Sbellardfi
53015a67135aSbellardecho "Source path       $source_path"
5302*aef45d51SDaniel P. Berrangeecho "GIT submodules    $git_submodules"
53037d13299dSbellardecho "C compiler        $cc"
530483469015Sbellardecho "Host C compiler   $host_cc"
530583f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
53063c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
530745d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
53080c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5309a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
53100c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
53117d13299dSbellardecho "make              $make"
53126a882643Spbrookecho "install           $install"
5313c886edfbSBlue Swirlecho "python            $python"
5314e2d8830eSBradif test "$slirp" = "yes" ; then
5315e2d8830eSBrad    echo "smbd              $smbd"
5316e2d8830eSBradfi
531717969268SFam Zhengecho "module support    $modules"
5318a98fd896Sbellardecho "host CPU          $cpu"
5319de83cd02Sbellardecho "host big endian   $bigendian"
532097a847bcSbellardecho "target list       $target_list"
53217d13299dSbellardecho "gprof enabled     $gprof"
532203b4fe7dSaliguoriecho "sparse enabled    $sparse"
53231625af87Saliguoriecho "strip binaries    $strip_opt"
532405c2a3e7Sbellardecho "profiler          $profiler"
532543ce4dfeSbellardecho "static build      $static"
53265b0753e0Sbellardif test "$darwin" = "yes" ; then
53275b0753e0Sbellard    echo "Cocoa support     $cocoa"
53285b0753e0Sbellardfi
532989138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
533089138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5331925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
533289138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5333a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5334ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5335b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
533691bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
533737788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
533889138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5339fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
53409a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
53414d3b6f6eSbalrogecho "curses support    $curses"
53429d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5343769ce76dSAlexander Grafecho "curl support      $curl"
534467b915a5Sbellardecho "mingw32 support   $mingw32"
53450c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5346b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5347b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5348983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5349fe8fc5aeSPaolo Bonziniecho "Multipath support $mpath"
5350821601eaSJes Sorensenecho "VNC support       $vnc"
5351821601eaSJes Sorensenif test "$vnc" = "yes" ; then
53522f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
53532f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5354efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5355821601eaSJes Sorensenfi
53563142255cSblueswir1if test -n "$sparc_cpu"; then
53573142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
53583142255cSblueswir1fi
5359e37630caSaliguoriecho "xen support       $xen"
53603996e85cSPaul Durrantif test "$xen" = "yes" ; then
53613996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
536264a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
53633996e85cSPaul Durrantfi
53642e4d9fb1Saurel32echo "brlapi support    $brlapi"
5365a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5366a25dba17SJuan Quintelaecho "Documentation     $docs"
536740d6444eSAvi Kivityecho "PIE               $pie"
53688a16d273Sthsecho "vde support       $vde"
536958952137SVincenzo Maffioneecho "netmap support    $netmap"
53705c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5371758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
537277755340Sthsecho "Install blobs     $blobs"
5373b31a0277SJuan Quintelaecho "KVM support       $kvm"
5374b0cb0a66SVincent Palatinecho "HAX support       $hax"
5375b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5376b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5377b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
53789195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5379b3f6ea7eSPaolo Bonzinifi
5380b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5381f652e6afSaurel32echo "fdt support       $fdt"
5382ceb42de8Saliguoriecho "preadv support    $preadv"
53835f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5384e78815a5SAndreas Färberecho "madvise           $madvise"
5385e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
538647e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5387d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
53885e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5389fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5390e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
53915b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5392713572a7SMarc-André Lureauif have_backend "simple"; then
53939410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5394e00e36fbSStefan Weilfi
539589138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5396f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5397dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
53987b02f544SMarc-André Lureauecho "smartcard support $smartcard"
53992b2325ffSGerd Hoffmannecho "libusb            $libusb"
540069354a83SHans de Goedeecho "usb net redir     $usb_redir"
5401da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5402014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5403c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
54046542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5405d138cee9SMichael Rothecho "build guest agent $guest_agent"
5406d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
540750cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
54084c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5409f794573eSEduardo Otuboecho "seccomp support   $seccomp"
54107c2acc70SPeter Maydellecho "coroutine backend $coroutine"
541170c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
54127d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5413f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5414eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
54151d728c39SBlue Swirlecho "gcov              $gcov_tool"
54161d728c39SBlue Swirlecho "gcov enabled      $gcov"
5417ab214c29SStefan Bergerecho "TPM support       $tpm"
54180a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
54193b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
54203556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5421ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5422607dacd0Sqiaonuohanecho "lzo support       $lzo"
5423607dacd0Sqiaonuohanecho "snappy support    $snappy"
54246b383c08SPeter Wuecho "bzip2 support     $bzip2"
5425a99d57bbSWanlong Gaoecho "NUMA host support $numa"
54262847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
54277b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
542899f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5429a6b1d4c0SChanglong Xieecho "replication support $replication"
5430da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
543167b915a5Sbellard
54321ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
543324b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5434e8cd23deSbellardfi
543597a847bcSbellard
5436898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5437898be3e0SPeter Maydell    echo
5438898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5439898be3e0SPeter Maydell    echo
5440898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5441898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5442898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5443898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5444898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5445898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5446898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5447898be3e0SPeter Maydellfi
5448898be3e0SPeter Maydell
5449898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5450898be3e0SPeter Maydell    echo
5451898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5452898be3e0SPeter Maydell    echo
5453c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5454c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5455898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5456898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5457898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5458898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5459898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5460898be3e0SPeter Maydellfi
5461898be3e0SPeter Maydell
546298ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
546397a847bcSbellard
5464dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5465dbd99ae3SStefan Weil
546698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
546798ec69acSJuan Quintelaecho >> $config_host_mak
546898ec69acSJuan Quintela
5469e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
547099d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
547199d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
54723aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
54738bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
54740f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
547599d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
547699d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
547722d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
54789afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
54793d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
54809afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5481e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
54825a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5483785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
54845a699bbbSLaszlo Ersekfi
5485f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5486f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
548711cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5488f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5489834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5490f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5491*aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5492804edf29SJuan Quintela
549398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5494727e5283SPaolo Bonzini
5495f8393946Saurel32if test "$debug_tcg" = "yes" ; then
54962358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5497f8393946Saurel32fi
54981625af87Saliguoriif test "$strip_opt" = "yes" ; then
549952ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
55001625af87Saliguorifi
55017d13299dSbellardif test "$bigendian" = "yes" ; then
5502e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
550397a847bcSbellardfi
550467b915a5Sbellardif test "$mingw32" = "yes" ; then
550598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
550689138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
55079fe6de94SBlue Swirl  version_major=${rc_version%%.*}
55089fe6de94SBlue Swirl  rc_version=${rc_version#*.}
55099fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
55109fe6de94SBlue Swirl  rc_version=${rc_version#*.}
55119fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
55129fe6de94SBlue Swirl  version_micro=0
55139fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
55149fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5515d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5516d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5517f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5518d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5519d9840e25STomoki Sekiyama  fi
552050cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
552150cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
552250cbebb9SMichael Roth  fi
55231a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
55249dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
55259dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
55269dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
55279dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
55289dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
55299dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
55309dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
55319dacf32dSYossi Hindin  fi
5532210fa556Spbrookelse
553335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5534210fa556Spbrookfi
5535128ab2ffSblueswir1
5536dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5537dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5538dffcb71cSMark McLoughlinfi
5539dffcb71cSMark McLoughlin
554083fb7adfSbellardif test "$darwin" = "yes" ; then
554198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
554283fb7adfSbellardfi
5543b29fe3edSmalc
5544ec530c81Sbellardif test "$solaris" = "yes" ; then
554598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5546ec530c81Sbellardfi
5547179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5548179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5549179cf400SAndreas Färberfi
555097a847bcSbellardif test "$static" = "yes" ; then
555198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
555297a847bcSbellardfi
55531ba16968SStefan Weilif test "$profiler" = "yes" ; then
55542358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
555505c2a3e7Sbellardfi
5556c20709aaSbellardif test "$slirp" = "yes" ; then
555798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5558e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5559c20709aaSbellardfi
55608a16d273Sthsif test "$vde" = "yes" ; then
556198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5562e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
55638a16d273Sthsfi
556458952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
556558952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
556658952137SVincenzo Maffionefi
5567015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5568015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5569015a33bdSGongleifi
557047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
557147e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
557247e98658SCorey Bryantfi
55732358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
55740c58ac1cSmalcfor drv in $audio_drv_list; do
557589138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
557698ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
55770c58ac1cSmalcdone
5578b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5579b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5580b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5581b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5582b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
558367f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
558467f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
558567f86e8eSJuan Quintelafi
5586d5631638Smalcif test "$audio_win_int" = "yes" ; then
5587d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5588d5631638Smalcfi
5589b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5590b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5591821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5592821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5593821601eaSJes Sorensenfi
55942f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
559598ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
55962f9606b3Saliguorifi
5597821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
55982f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
55992f6f5c7aSCorentin Charyfi
5600821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5601efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5602efe556adSCorentin Charyfi
560376655d6dSaliguoriif test "$fnmatch" = "yes" ; then
56042358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
560576655d6dSaliguorifi
5606dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5607dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5608dce512deSChristoph Hellwigfi
560989138857SStefan Weilqemu_version=$(head $source_path/VERSION)
561098ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
56112358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
561298ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
561398ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5614a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
561598ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5616cc8ae6deSpbrookfi
561717969268SFam Zhengif test "$modules" = "yes"; then
5618e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5619e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
562089138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
562117969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
562217969268SFam Zhengfi
56231ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
562498ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5625a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
56268ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
56278ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
562849ecc3faSbellardfi
562949ecc3faSbellardif test "$cocoa" = "yes" ; then
563098ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
563149ecc3faSbellardfi
56324d3b6f6eSbalrogif test "$curses" = "yes" ; then
563398ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5634ab4e5602SJan Kiszkafi
5635099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
56362358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5637099d6b0fSRiku Voipiofi
563840ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
563940ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
564040ff6d7eSKevin Wolffi
56413ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
56422358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
56433ce34dfbSvibisreenivasanfi
5644c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5645c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5646c2882b96SRiku Voipiofi
5647751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5648751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5649751bcc39SMarc-André Lureaufi
5650d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5651d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5652d0927938SUlrich Hechtfi
56533d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
56543d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
56553d4fa43eSKusanagi Kouichifi
5656b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5657b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5658b953f075SDenis V. Lunevfi
5659ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5660ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5661ed911435SKevin Wolffi
5662c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5663c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5664c727f47dSPeter Maydellfi
5665dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5666dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5667dace20dcSPeter Maydellfi
5668d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5669d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5670d0927938SUlrich Hechtfi
56714e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
56724e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
56734e0c6529SAlex Blighfi
5674cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5675cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5676cd758dd0SAlex Blighfi
56773b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
56783b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
56793b6edd16SPeter Maydellfi
56803b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
56813b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
56823b6edd16SPeter Maydellfi
5683a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5684a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5685a8fd1abaSPeter Maydellfi
568651834341SRiku Voipioif test "$timerfd" = "yes" ; then
568751834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
568851834341SRiku Voipiofi
56899af5c906SRiku Voipioif test "$setns" = "yes" ; then
56909af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
56919af5c906SRiku Voipiofi
569238860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
569338860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
569438860a03SAleksandar Markovicfi
56955a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
56965a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
56975a03cd00SAleksandar Markovicfi
56983b3f24adSaurel32if test "$inotify" = "yes" ; then
56992358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
57003b3f24adSaurel32fi
5701c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5702c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5703c05c7a73SRiku Voipiofi
5704401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
5705401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5706401bc051SPeter Maydellfi
57076ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
57086ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
57096ae9a1f4SJuan Quintelafi
57106ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
57116ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
57126ae9a1f4SJuan Quintelafi
5713769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5714d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5715b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
57166ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5717769ce76dSAlexander Graffi
57182e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
571998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
57208eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
57212e4d9fb1Saurel32fi
5722fb599c9aSbalrogif test "$bluez" = "yes" ; then
572398ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5724ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5725fb599c9aSbalrogfi
5726d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
57279d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
57289d41401bSMichael S. Tsirkinfi
5729a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5730a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5731a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5732a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5733014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5734925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5735925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5736925a0400SGerd Hoffmann  fi
5737bbbf9bfbSStefan Weilfi
5738a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5739ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5740ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5741ddbb0d09SDaniel P. Berrangefi
5742b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5743b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5744b917da4cSDaniel P. Berrangefi
574591bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
574691bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
57471f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
57481f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
57491f923c70SLongpeng(Mike)  fi
575037788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
575137788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
575237788f25SDaniel P. Berrange  fi
575362893b67SDaniel P. Berrangefi
575491bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
575591bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5756becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5757fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5758fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5759fff2f982SDaniel P. Berrange  fi
5760ed754746SDaniel P. Berrangefi
57619a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
57629a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
57639a2fd434SDaniel P. Berrangefi
5764559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5765559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5766559607eaSDaniel P. Berrangefi
57676b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
57686b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
57696b39b063SEric Blakefi
5770277abf15SJan Vesely
5771277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5772277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5773277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5774277abf15SJan Vesely# if this macro is set.
5775277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5776277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5777277abf15SJan Veselyfi
5778bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5779bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5780a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5781a4ccabcfSAnthony Liguorifi
57829d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
57839d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
57849d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
57859d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
57869d9e1521SGerd Hoffmannfi
5787e37630caSaliguoriif test "$xen" = "yes" ; then
57886dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5789d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
579064a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
579164a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
579264a7ad6fSIan Campbell  fi
5793e37630caSaliguorifi
57945c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
57955c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
57965c6c3a6cSChristoph Hellwigfi
5797758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5798758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5799758e8e38SVenkateswararao Jujjuri (JV)fi
58004f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
58014f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
58024f26f2b6SAvi Kivityfi
5803983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5804758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5805758e8e38SVenkateswararao Jujjuri (JV)fi
5806fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
5807fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
5808fe8fc5aeSPaolo Bonzinifi
58095e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
58105e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
58115e9be92dSNicholas Bellingerfi
5812e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
581303ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
581403ce5744SNikolay Nikolaevfi
5815fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5816fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5817fc0b9b0eSStefan Hajnoczifi
5818e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5819e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5820e6a74868SMarc-André Lureaufi
582177755340Sthsif test "$blobs" = "yes" ; then
582298ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
582377755340Sthsfi
5824bf9298b9Saliguoriif test "$iovec" = "yes" ; then
58252358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5826bf9298b9Saliguorifi
5827ceb42de8Saliguoriif test "$preadv" = "yes" ; then
58282358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5829ceb42de8Saliguorifi
5830f652e6afSaurel32if test "$fdt" = "yes" ; then
58313f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5832f652e6afSaurel32fi
5833dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5834dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5835dcc38d1cSMarcelo Tosattifi
5836b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
5837b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
58389195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
58399195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
58409195b2c2SStefan Weil  fi
5841b3f6ea7eSPaolo Bonzinifi
58425f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
58435f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
58445f6b9e8fSBlue Swirlfi
5845e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5846e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5847e78815a5SAndreas Färberfi
5848e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5849e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5850e78815a5SAndreas Färberfi
585197a847bcSbellard
5852cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5853cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5854cd4ec0b4SGerd Hoffmannfi
5855cd4ec0b4SGerd Hoffmann
58567b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
58577b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
58587b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
58597b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
5860111a38b0SRobert Relyeafi
5861111a38b0SRobert Relyea
58622b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
58632b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5864b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
5865b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
58662b2325ffSGerd Hoffmannfi
58672b2325ffSGerd Hoffmann
586869354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
586969354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5870cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
5871cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
587269354a83SHans de Goedefi
587369354a83SHans de Goede
5874da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5875da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5876da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5877014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5878014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5879014cb152SGerd Hoffmann  fi
588020ff075bSMichael Wallefi
588120ff075bSMichael Walle
588299f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
588399f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
588499f2dbd3SLiang Lifi
588599f2dbd3SLiang Li
5886607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5887607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5888607dacd0Sqiaonuohanfi
5889607dacd0Sqiaonuohan
5890607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5891607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5892607dacd0Sqiaonuohanfi
5893607dacd0Sqiaonuohan
58946b383c08SPeter Wuif test "$bzip2" = "yes" ; then
58956b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
58966b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
58976b383c08SPeter Wufi
58986b383c08SPeter Wu
5899c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5900d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
59016ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
59026ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5903c589b249SRonnie Sahlbergfi
5904c589b249SRonnie Sahlberg
59056542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
59064be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
59074be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
59086542aa9cSPeter Lievenfi
59096542aa9cSPeter Lieven
5910f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5911f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5912c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
5913c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
5914f794573eSEduardo Otubofi
5915f794573eSEduardo Otubo
591683fb7adfSbellard# XXX: suppress that
59177d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
59182358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
59197d3505c5Sbellardfi
59207d3505c5Sbellard
59214d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
59224d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
59234d9310f4SDaniel P. Berrangefi
59243556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
59253556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
59263556c233SPaolo Bonzinifi
5927f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5928d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
59296ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
59306ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5931f27aaf4bSChristian Brunnerfi
593220ff6c80SAnthony Liguori
59337c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
593470c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
593570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
593670c60c08SStefan Hajnoczielse
593770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
593870c60c08SStefan Hajnoczifi
5939d0e2fce5SAneesh Kumar K.V
59407d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
59417d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
59427d992e4dSPeter Lievenfi
59437d992e4dSPeter Lieven
5944f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5945f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5946f0d92b56SLongpeng(Mike)fi
5947f0d92b56SLongpeng(Mike)
5948d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5949d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5950d2042378SAneesh Kumar K.Vfi
5951d2042378SAneesh Kumar K.V
5952e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5953e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5954e06a765eSHarsh Prateek Borafi
5955e06a765eSHarsh Prateek Bora
5956cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5957cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
595806d71fa1SPeter Maydellfi
595906d71fa1SPeter Maydell
59603f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
59613f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
59623f4349dcSKevin Wolffi
59633f4349dcSKevin Wolf
59648ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
59658ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
59668ab1bf12SLuiz Capitulinofi
59678ab1bf12SLuiz Capitulino
596876a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
596976a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
597076a347e1SRichard Hendersonfi
597176a347e1SRichard Henderson
5972f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5973f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5974f540166bSRichard Hendersonfi
5975f540166bSRichard Henderson
59767ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
59777ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
59787ebee43eSRichard Hendersonfi
59797ebee43eSRichard Henderson
5980df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5981df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5982df79b996SRichard Hendersonfi
5983df79b996SRichard Henderson
59841e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
59851e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
59861e6e9acaSRichard Hendersonfi
59871e6e9acaSRichard Henderson
5988eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5989d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
59906ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
59916ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5992eb100396SBharata B Raofi
5993eb100396SBharata B Rao
5994d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5995d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5996d85fa9ebSJeff Codyfi
5997d85fa9ebSJeff Cody
59980c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
59990c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
60000c14fb47SBharata B Raofi
60010c14fb47SBharata B Rao
6002df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6003df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6004df3a429aSNiels de Vosfi
6005df3a429aSNiels de Vos
60067c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
60077c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
60087c815372SBharata B Raofi
60097c815372SBharata B Rao
60100a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
6011d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
60126ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
60136ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
60140a12ec87SRichard W.M. Jonesfi
60150a12ec87SRichard W.M. Jones
6016ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6017ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6018ed1701c6SDr. David Alan Gilbertfi
6019ed1701c6SDr. David Alan Gilbert
60203b8acc11SPaolo Bonzini# TPM passthrough support?
60213b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
60223b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
60233b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
60243b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
60253b8acc11SPaolo Bonzini  fi
60263b8acc11SPaolo Bonzinifi
60273b8acc11SPaolo Bonzini
60285b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
60295b808275SLluís Vilanovaif have_backend "nop"; then
60306d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
603122890ab5SPrerna Saxenafi
60325b808275SLluís Vilanovaif have_backend "simple"; then
60336d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
60346d8a764eSLluís  # Set the appropriate trace file.
6035953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
60369410b56cSPrerna Saxenafi
6037ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6038ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
60396d8a764eSLluísfi
60405b808275SLluís Vilanovaif have_backend "ust"; then
60416d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
60426d8a764eSLluísfi
60435b808275SLluís Vilanovaif have_backend "dtrace"; then
60446d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
60456d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
60466d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
60476d8a764eSLluís  fi
6048c276b17dSDaniel P. Berrangefi
60495b808275SLluís Vilanovaif have_backend "ftrace"; then
6050781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6051781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6052781e9545SEiichi Tsukata  else
605321684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6054781e9545SEiichi Tsukata  fi
6055781e9545SEiichi Tsukatafi
60560a852417SPaul Durrantif have_backend "syslog"; then
60570a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
60580a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
60590a852417SPaul Durrant  else
60600a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
60610a852417SPaul Durrant  fi
60620a852417SPaul Durrantfi
60639410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
60649410b56cSPrerna Saxena
60652da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
60662da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6067392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
60682da776dbSMichael R. Hinesfi
60692da776dbSMichael R. Hines
6070575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6071575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6072575b22b1SLaurent Vivierfi
6073575b22b1SLaurent Vivier
6074a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6075a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6076a6b1d4c0SChanglong Xiefi
6077a6b1d4c0SChanglong Xie
60786a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
60796a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
60806a02c806SStefan Hajnoczifi
60816a02c806SStefan Hajnoczi
60824d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
60834d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
60844d04351fSChristopher Covingtonfi
60854d04351fSChristopher Covington
608649e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
608749e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
608849e00a18SAndreas Grapentinfi
608949e00a18SAndreas Grapentin
6090e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6091e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6092e674605fSTomáš Golembiovskýfi
6093e674605fSTomáš Golembiovský
6094e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6095e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6096e0580342SKamil Rytarowskifi
6097e0580342SKamil Rytarowski
60985c312079SDr. David Alan Gilbert# Hold two types of flag:
60995c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
61005c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
61015c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
61025c312079SDr. David Alan Gilbert#                                     platform
61035c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
61045c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
61055c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
61065c312079SDr. David Alan Gilbertfi
61075c312079SDr. David Alan Gilbert
6108da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6109da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6110da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6111da92c3ffSAshish Mittalfi
6112da92c3ffSAshish Mittal
61135b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
61145b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
61155b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
61165b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
61175b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
61185b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6119c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
61205b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
612140d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
612240d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
61235b5e3037SPaolo Bonzinielse
61245b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
61255b5e3037SPaolo Bonzinifi
61265b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
61275b5e3037SPaolo Bonzini
612898ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
612998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6130804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6131804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
61321901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
61331901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
61341901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
613521655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6136c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6137804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6138a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6139a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6140a31a8642SMichael S. Tsirkinfi
61412b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6142804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
614383f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
61443c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6145804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
614645d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6147cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
61485f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
61493dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6150804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6151804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
61524852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
61539fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6154e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
615546eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6156a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
615711cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6158f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6159e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6160e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
616180fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
61622944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6163e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6164e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6165e39f0062SPaolo Bonzinifi
616642da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
616742da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
616842da6041SGerd Hoffmannelse
616942da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
617042da6041SGerd Hoffmannfi
6171e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
617246eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
61736969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6174e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
617573da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
61763e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6177409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6178804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
617917969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
618017969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6181957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
618290246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
618390246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
618494dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6185cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
61861d728c39SBlue Swirlif test "$gcov" = "yes" ; then
61871d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
61881d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
61891d728c39SBlue Swirlfi
6190804edf29SJuan Quintela
61916efd7517SPeter Maydell# use included Linux headers
61926efd7517SPeter Maydellif test "$linux" = "yes" ; then
6193a307beb6SAndreas Färber  mkdir -p linux-headers
61946efd7517SPeter Maydell  case "$cpu" in
6195c72b26ecSRichard Henderson  i386|x86_64|x32)
619608312a63SPeter Maydell    linux_arch=x86
61976efd7517SPeter Maydell    ;;
61986efd7517SPeter Maydell  ppcemb|ppc|ppc64)
619908312a63SPeter Maydell    linux_arch=powerpc
62006efd7517SPeter Maydell    ;;
62016efd7517SPeter Maydell  s390x)
620208312a63SPeter Maydell    linux_arch=s390
620308312a63SPeter Maydell    ;;
62041f080313SClaudio Fontana  aarch64)
62051f080313SClaudio Fontana    linux_arch=arm64
62061f080313SClaudio Fontana    ;;
6207222e7d11SSanjay Lal  mips64)
6208222e7d11SSanjay Lal    linux_arch=mips
6209222e7d11SSanjay Lal    ;;
621008312a63SPeter Maydell  *)
621108312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
621208312a63SPeter Maydell    linux_arch="$cpu"
62136efd7517SPeter Maydell    ;;
62146efd7517SPeter Maydell  esac
621508312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
621608312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
621708312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
621808312a63SPeter Maydell    fi
62196efd7517SPeter Maydellfi
62206efd7517SPeter Maydell
622197a847bcSbellardfor target in $target_list; do
622297a847bcSbellardtarget_dir="$target"
622325be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
622489138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
622597a847bcSbellardtarget_bigendian="no"
62261f3d3c8fSJuan Quintela
6227c1799a84SPaolo Bonzinicase "$target_name" in
62284a09d0bbSRichard Henderson  armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6229ea2d6a39SJuan Quintela  target_bigendian=yes
6230ea2d6a39SJuan Quintela  ;;
6231ea2d6a39SJuan Quintelaesac
623297a847bcSbellardtarget_softmmu="no"
6233997344f3Sbellardtarget_user_only="no"
6234831b7825Sthstarget_linux_user="no"
623584778508Sblueswir1target_bsd_user="no"
62369e407a85Spbrookcase "$target" in
6237c1799a84SPaolo Bonzini  ${target_name}-softmmu)
62389e407a85Spbrook    target_softmmu="yes"
62399e407a85Spbrook    ;;
6240c1799a84SPaolo Bonzini  ${target_name}-linux-user)
62419e407a85Spbrook    target_user_only="yes"
62429e407a85Spbrook    target_linux_user="yes"
62439e407a85Spbrook    ;;
6244c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
624584778508Sblueswir1    target_user_only="yes"
624684778508Sblueswir1    target_bsd_user="yes"
624784778508Sblueswir1    ;;
62489e407a85Spbrook  *)
624976ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
62509e407a85Spbrook    exit 1
62519e407a85Spbrook    ;;
62529e407a85Spbrookesac
6253831b7825Sths
625497a847bcSbellardmkdir -p $target_dir
625525be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
625697a847bcSbellard
6257e5fe0c52Spbrookbflt="no"
6258ca759f9eSAlex Bennéemttcg="no"
625989138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
626056aebc89Spbrookgdb_xml_files=""
62617ba1e619Saliguori
6262c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
62636acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6264e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6265e73aae67SJuan Quintela
6266c1799a84SPaolo Bonzinicase "$target_name" in
62672408a527Saurel32  i386)
6268b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
62692408a527Saurel32  ;;
62702408a527Saurel32  x86_64)
62716acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6272b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
62732408a527Saurel32  ;;
62742408a527Saurel32  alpha)
62755ee4f3c2SRichard Henderson    mttcg="yes"
62762408a527Saurel32  ;;
62772408a527Saurel32  arm|armeb)
6278b498c8a0SJuan Quintela    TARGET_ARCH=arm
6279e5fe0c52Spbrook    bflt="yes"
6280ca759f9eSAlex Bennée    mttcg="yes"
628156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62822408a527Saurel32  ;;
62836a49fa95SAlexander Graf  aarch64)
62846a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
62856a49fa95SAlexander Graf    bflt="yes"
6286ca759f9eSAlex Bennée    mttcg="yes"
62878f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62886a49fa95SAlexander Graf  ;;
62892408a527Saurel32  cris)
62902408a527Saurel32  ;;
629161766fe9SRichard Henderson  hppa)
629261766fe9SRichard Henderson  ;;
6293613a22c9SMichael Walle  lm32)
6294613a22c9SMichael Walle  ;;
62952408a527Saurel32  m68k)
62960938cda5Saurel32    bflt="yes"
62975a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
62982408a527Saurel32  ;;
6299877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6300877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
630172b675caSEdgar E. Iglesias    bflt="yes"
630272b675caSEdgar E. Iglesias  ;;
63032408a527Saurel32  mips|mipsel)
6304b498c8a0SJuan Quintela    TARGET_ARCH=mips
630525be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
63062408a527Saurel32  ;;
63072408a527Saurel32  mipsn32|mipsn32el)
6308597e2cecSRichard Henderson    TARGET_ARCH=mips64
63096acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
631025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6311597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
63122408a527Saurel32  ;;
63132408a527Saurel32  mips64|mips64el)
6314b498c8a0SJuan Quintela    TARGET_ARCH=mips64
63156acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
631625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
63172408a527Saurel32  ;;
6318d15a9c23SAnthony Green  moxie)
6319d15a9c23SAnthony Green  ;;
6320e671711cSMarek Vasut  nios2)
6321e671711cSMarek Vasut  ;;
63224a09d0bbSRichard Henderson  or1k)
6323e67db06eSJia Liu    TARGET_ARCH=openrisc
6324e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6325e67db06eSJia Liu  ;;
63262408a527Saurel32  ppc)
6327c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
63282408a527Saurel32  ;;
63292408a527Saurel32  ppcemb)
63306acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6331e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6332c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
63332408a527Saurel32  ;;
63342408a527Saurel32  ppc64)
63356acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6336e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6337f0b0685dSNikunj A Dadhania    mttcg=yes
63381438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
63392408a527Saurel32  ;;
63409c35126cSDoug Kwan  ppc64le)
63419c35126cSDoug Kwan    TARGET_ARCH=ppc64
63429c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
63439c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6344f0b0685dSNikunj A Dadhania    mttcg=yes
63451438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
63469c35126cSDoug Kwan  ;;
63472408a527Saurel32  ppc64abi32)
6348b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
63496acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6350e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
635125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
63521438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
63532408a527Saurel32  ;;
63542408a527Saurel32  sh4|sh4eb)
6355b498c8a0SJuan Quintela    TARGET_ARCH=sh4
63564dbed897Spbrook    bflt="yes"
63572408a527Saurel32  ;;
63582408a527Saurel32  sparc)
63592408a527Saurel32  ;;
63602408a527Saurel32  sparc64)
63616acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
63622408a527Saurel32  ;;
63632408a527Saurel32  sparc32plus)
6364b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
63656acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6366e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
636725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
63682408a527Saurel32  ;;
636924e804ecSAlexander Graf  s390x)
637086158a2aSChristian 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"
637124e804ecSAlexander Graf  ;;
6372444e06b1SChen Gang  tilegx)
6373444e06b1SChen Gang  ;;
63745ecaa4edSPeter Crosthwaite  tricore)
63755ecaa4edSPeter Crosthwaite  ;;
6376d2fbca94SGuan Xuetao  unicore32)
6377d2fbca94SGuan Xuetao  ;;
6378cfa550c6SMax Filippov  xtensa|xtensaeb)
6379cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6380cfa550c6SMax Filippov  ;;
63812408a527Saurel32  *)
638276ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
63832408a527Saurel32  ;;
63842408a527Saurel32esac
63855e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
63865e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
63875e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
63885e8861a0SPaolo Bonzinifi
63895e8861a0SPaolo Bonzini
63905e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
63915e8861a0SPaolo Bonzini
639299afc91dSDaniel P. Berrangeupper() {
639399afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
639499afc91dSDaniel P. Berrange}
639599afc91dSDaniel P. Berrange
639689138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
639725be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6398c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
639925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6400e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6401e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6402e6e91b9cSJuan Quintelafi
640325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6404adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6405adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6406adfc3e91SStacey Sonfi
64073b6b7550SPaolo Bonzini
64083b6b7550SPaolo Bonziniif supported_xen_target $target; then
640925be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6410eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6411eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6412eb6fda0fSAnthony PERARD    fi
6413432d268cSJun Nakajimafi
64143b6b7550SPaolo Bonziniif supported_kvm_target $target; then
641525be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
64161ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6417d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6418e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
6419e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6420e6a74868SMarc-André Lureau        fi
6421d5970055SMichael S. Tsirkin    fi
6422c59249f9SJuan Quintelafi
64233b6b7550SPaolo Bonziniif supported_hax_target $target; then
6424b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6425b0cb0a66SVincent Palatinfi
6426de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
642725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
642897a847bcSbellardfi
642997a847bcSbellardif test "$target_softmmu" = "yes" ; then
643025be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6431ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6432ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6433ca759f9eSAlex Bennée  fi
6434de83cd02Sbellardfi
6435997344f3Sbellardif test "$target_user_only" = "yes" ; then
643625be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6437a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6438997344f3Sbellardfi
6439831b7825Sthsif test "$target_linux_user" = "yes" ; then
644025be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6441831b7825Sthsfi
644256aebc89Spbrooklist=""
644356aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
644456aebc89Spbrook  for x in $gdb_xml_files; do
644556aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
644656aebc89Spbrook  done
644725be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
64483d0f1517SJuan Quintelafi
6449de83cd02Sbellard
6450e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
645125be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6452e5fe0c52Spbrookfi
645384778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
645425be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
645584778508Sblueswir1fi
64565b0753e0Sbellard
64574afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6458fa282484SJuan Quintela
64594afddb55SJuan Quintelacflags=""
6460fa282484SJuan Quintelaldflags=""
64619b8e111fSJuan Quintela
6462c765fcacSPeter Crosthwaitedisas_config() {
6463c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6464c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6465c765fcacSPeter Crosthwaite}
6466c765fcacSPeter Crosthwaite
646764656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
646864656024SJuan Quintela  case "$i" in
646964656024SJuan Quintela  alpha)
6470c765fcacSPeter Crosthwaite    disas_config "ALPHA"
647164656024SJuan Quintela  ;;
647282295d8aSRichard Henderson  aarch64)
647382295d8aSRichard Henderson    if test -n "${cxx}"; then
6474c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
647582295d8aSRichard Henderson    fi
647682295d8aSRichard Henderson  ;;
647764656024SJuan Quintela  arm)
6478c765fcacSPeter Crosthwaite    disas_config "ARM"
6479999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6480c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6481999b53ecSClaudio Fontana    fi
648264656024SJuan Quintela  ;;
648364656024SJuan Quintela  cris)
6484c765fcacSPeter Crosthwaite    disas_config "CRIS"
648564656024SJuan Quintela  ;;
6486429b31a2SRichard Henderson  hppa)
6487429b31a2SRichard Henderson    disas_config "HPPA"
6488429b31a2SRichard Henderson  ;;
6489c72b26ecSRichard Henderson  i386|x86_64|x32)
6490c765fcacSPeter Crosthwaite    disas_config "I386"
649164656024SJuan Quintela  ;;
649279368f49SMichael Walle  lm32)
6493c765fcacSPeter Crosthwaite    disas_config "LM32"
649479368f49SMichael Walle  ;;
649564656024SJuan Quintela  m68k)
6496c765fcacSPeter Crosthwaite    disas_config "M68K"
649764656024SJuan Quintela  ;;
6498877fdc12SEdgar E. Iglesias  microblaze*)
6499c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
650064656024SJuan Quintela  ;;
650164656024SJuan Quintela  mips*)
6502c765fcacSPeter Crosthwaite    disas_config "MIPS"
650364656024SJuan Quintela  ;;
6504d15a9c23SAnthony Green  moxie*)
6505c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6506d15a9c23SAnthony Green  ;;
6507e671711cSMarek Vasut  nios2)
6508e671711cSMarek Vasut    disas_config "NIOS2"
6509e671711cSMarek Vasut  ;;
65104a09d0bbSRichard Henderson  or1k)
6511c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6512e67db06eSJia Liu  ;;
651364656024SJuan Quintela  ppc*)
6514c765fcacSPeter Crosthwaite    disas_config "PPC"
651564656024SJuan Quintela  ;;
651624e804ecSAlexander Graf  s390*)
6517c765fcacSPeter Crosthwaite    disas_config "S390"
651864656024SJuan Quintela  ;;
651964656024SJuan Quintela  sh4)
6520c765fcacSPeter Crosthwaite    disas_config "SH4"
652164656024SJuan Quintela  ;;
652264656024SJuan Quintela  sparc*)
6523c765fcacSPeter Crosthwaite    disas_config "SPARC"
652464656024SJuan Quintela  ;;
6525cfa550c6SMax Filippov  xtensa*)
6526c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6527cfa550c6SMax Filippov  ;;
652864656024SJuan Quintela  esac
652964656024SJuan Quinteladone
65309195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6531c765fcacSPeter Crosthwaite  disas_config "TCI"
65329195b2c2SStefan Weilfi
653364656024SJuan Quintela
65346ee7126fSJuan Quintelacase "$ARCH" in
65356ee7126fSJuan Quintelaalpha)
65366ee7126fSJuan Quintela  # Ensure there's only a single GP
65376ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
65386ee7126fSJuan Quintela;;
65396ee7126fSJuan Quintelaesac
65406ee7126fSJuan Quintela
6541d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
654225be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6543d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6544d02c1db3SJuan Quintela    cflags="-p $cflags"
6545d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6546d02c1db3SJuan Quintela  fi
6547d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6548d02c1db3SJuan Quintela    ldflags="-p $ldflags"
654925be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6550d02c1db3SJuan Quintela  fi
6551d02c1db3SJuan Quintelafi
6552d02c1db3SJuan Quintela
65539b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6554964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6555fa282484SJuan Quintelafi
6556fa282484SJuan Quintela
6557e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
6558e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
6559e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
6560e9a3591fSChristian Borntraeger# header if
6561e9a3591fSChristian Borntraeger#  - we build on s390x
6562e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
6563e9a3591fSChristian Borntraeger#  - KVM is enabled
6564e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
6565e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6566e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
6567e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
6568e9a3591fSChristian Borntraeger    fi
6569e9a3591fSChristian Borntraegerfi
6570e9a3591fSChristian Borntraeger
657125be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
657225be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6573fa282484SJuan Quintela
657497a847bcSbellarddone # for target in $targets
65757d13299dSbellard
6576a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6577a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6578a540f158SPeter Crosthwaitefi
6579a540f158SPeter Crosthwaite
6580a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6581a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6582a99d57bbSWanlong Gaofi
6583a99d57bbSWanlong Gao
6584fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6585fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6586fd0e6053SJohn Snowfi
6587fd0e6053SJohn Snow
6588d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6589b1fb9a63SFam ZhengDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
6590b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
65919933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
65922d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
65932dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6594c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6595c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6596aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6597ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6598446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
65999933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
66002d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
66014652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
66023a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6603753d11f2SRichard Hendersonfor bios_file in \
6604753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6605225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
66065acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6607753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6608753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6609e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6610753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
66114e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6612753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6613753d11f2SRichard Hendersondo
661489138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
66157ea78b74SJan Kiszkadone
661689138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6617c2304b52SMarcel Apfelbaumdo
661889138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6619c2304b52SMarcel Apfelbaumdone
6620d1807a4fSPaolo Bonzinimkdir -p $DIRS
66217d13299dSbellardfor f in $FILES ; do
6622cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6623f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6624f9245e10SPeter Maydell    fi
66257d13299dSbellarddone
66261ad2134fSPaul Brook
6627c34ebfdcSAnthony Liguori# temporary config to build submodules
66282d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6629c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
663037116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6631c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6632cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
66335f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6634c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6635c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
66363dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6637c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6638a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6639c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
6640c34ebfdcSAnthony Liguoridone
6641c34ebfdcSAnthony Liguori
6642fe31017fSMarc-André Lureau# set up tests data directory
6643fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6644fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6645fe31017fSMarc-André Lureaufi
6646fe31017fSMarc-André Lureau
664776c7560aSMax Reitz# set up qemu-iotests in this build directory
664876c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
664976c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
665076c7560aSMax Reitz
665176c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
665276c7560aSMax Reitzecho >> "$iotests_common_env"
665376c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
665476c7560aSMax Reitz
665576c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
665676c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
665776c7560aSMax Reitzfi
665876c7560aSMax Reitz
6659dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6660dc655404SMichael S. Tsirkincat <<EOD >config.status
6661dc655404SMichael S. Tsirkin#!/bin/sh
6662dc655404SMichael S. Tsirkin# Generated by configure.
6663dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6664dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6665dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6666dc655404SMichael S. TsirkinEOD
6667dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6668dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6669cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6670dc655404SMichael S. Tsirkinchmod +x config.status
6671dc655404SMichael S. Tsirkin
66728cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6673