xref: /openbmc/qemu/configure (revision 392fb6435173990e109bb0b58847f5413e03bf3a)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
148cd05ab6SPeter Maydell# Temporary directory used for files created while
158cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
168cd05ab6SPeter Maydell# we can safely blow away any previous version of it
178cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
188cd05ab6SPeter Maydell# it when configure exits.)
198cd05ab6SPeter MaydellTMPDIR1="config-temp"
208cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
218cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
228cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
238cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
248cd05ab6SPeter Maydell    exit 1
257d13299dSbellardfi
267d13299dSbellard
278cd05ab6SPeter MaydellTMPB="qemu-conf"
288cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
2966518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
309c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
318cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
326969ec6cSJames ClarkeTMPMO="${TMPDIR1}/${TMPB}.mo"
337d13299dSbellard
34da1d85e3SGerd Hoffmannrm -f config.log
359ac81bbbSmalc
36b48e3611SPeter Maydell# Print a helpful header at the top of config.log
37b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
38979ae168SPeter Maydellprintf "# Configured with:" >> config.log
39979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
40979ae168SPeter Maydellecho >> config.log
41b48e3611SPeter Maydellecho "#" >> config.log
42b48e3611SPeter Maydell
43d880a3baSPaolo Bonziniprint_error() {
44d880a3baSPaolo Bonzini    (echo
4576ad07a4SPeter Maydell    echo "ERROR: $1"
4676ad07a4SPeter Maydell    while test -n "$2"; do
4776ad07a4SPeter Maydell        echo "       $2"
4876ad07a4SPeter Maydell        shift
4976ad07a4SPeter Maydell    done
50d880a3baSPaolo Bonzini    echo) >&2
51d880a3baSPaolo Bonzini}
52d880a3baSPaolo Bonzini
53d880a3baSPaolo Bonzinierror_exit() {
54d880a3baSPaolo Bonzini    print_error "$@"
5576ad07a4SPeter Maydell    exit 1
5676ad07a4SPeter Maydell}
5776ad07a4SPeter Maydell
589c83ffd8SPeter Maydelldo_compiler() {
599c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
609c83ffd8SPeter Maydell    # is compiler binary to execute.
619c83ffd8SPeter Maydell    local compiler="$1"
629c83ffd8SPeter Maydell    shift
639c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
649c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
658dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
668dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
678dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
688dc38a78SPeter Maydell    # obvious to developers.
698dc38a78SPeter Maydell    if test "$werror" != "yes"; then
708dc38a78SPeter Maydell        return 0
718dc38a78SPeter Maydell    fi
728dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
738dc38a78SPeter Maydell    case "$*" in
748dc38a78SPeter Maydell        *-Werror*)
758dc38a78SPeter Maydell           return 0
768dc38a78SPeter Maydell        ;;
778dc38a78SPeter Maydell    esac
789c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
799c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
8076ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
8176ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8276ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8376ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
848dc38a78SPeter Maydell}
858dc38a78SPeter Maydell
869c83ffd8SPeter Maydelldo_cc() {
879c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
889c83ffd8SPeter Maydell}
899c83ffd8SPeter Maydell
909c83ffd8SPeter Maydelldo_cxx() {
919c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
929c83ffd8SPeter Maydell}
939c83ffd8SPeter Maydell
949c83ffd8SPeter Maydellupdate_cxxflags() {
959c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
969c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
979c83ffd8SPeter Maydell    # because they only make sense for C programs.
9811cde1c8SBruno Dominguez    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
9911cde1c8SBruno Dominguez
1009c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1019c83ffd8SPeter Maydell        case $arg in
1029c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1039c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1049c83ffd8SPeter Maydell                ;;
1059c83ffd8SPeter Maydell            *)
1069c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1079c83ffd8SPeter Maydell                ;;
1089c83ffd8SPeter Maydell        esac
1099c83ffd8SPeter Maydell    done
1109c83ffd8SPeter Maydell}
1119c83ffd8SPeter Maydell
11252166aa0SJuan Quintelacompile_object() {
113fd0e6053SJohn Snow  local_cflags="$1"
114fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
11552166aa0SJuan Quintela}
11652166aa0SJuan Quintela
11752166aa0SJuan Quintelacompile_prog() {
11852166aa0SJuan Quintela  local_cflags="$1"
11952166aa0SJuan Quintela  local_ldflags="$2"
1208dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
12152166aa0SJuan Quintela}
12252166aa0SJuan Quintela
12311568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
12411568d6dSPaolo Bonzinisymlink() {
12572b8b5a1SStefan Weil  rm -rf "$2"
126ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
12772b8b5a1SStefan Weil  ln -s "$1" "$2"
12811568d6dSPaolo Bonzini}
12911568d6dSPaolo Bonzini
1300dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1310dba6195SLoïc Minier# executable or a builtin)
1320dba6195SLoïc Minierhas() {
1330dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1340dba6195SLoïc Minier}
1350dba6195SLoïc Minier
1360dba6195SLoïc Minier# search for an executable in PATH
1370dba6195SLoïc Minierpath_of() {
1380dba6195SLoïc Minier    local_command="$1"
1390dba6195SLoïc Minier    local_ifs="$IFS"
1400dba6195SLoïc Minier    local_dir=""
1410dba6195SLoïc Minier
1420dba6195SLoïc Minier    # pathname has a dir component?
1430dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1440dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1450dba6195SLoïc Minier            echo "$local_command"
1460dba6195SLoïc Minier            return 0
1470dba6195SLoïc Minier        fi
1480dba6195SLoïc Minier    fi
1490dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1500dba6195SLoïc Minier        return 1
1510dba6195SLoïc Minier    fi
1520dba6195SLoïc Minier
1530dba6195SLoïc Minier    IFS=:
1540dba6195SLoïc Minier    for local_dir in $PATH; do
1550dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1560dba6195SLoïc Minier            echo "$local_dir/$local_command"
1570dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1580dba6195SLoïc Minier            return 0
1590dba6195SLoïc Minier        fi
1600dba6195SLoïc Minier    done
1610dba6195SLoïc Minier    # not found
1620dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1630dba6195SLoïc Minier    return 1
1640dba6195SLoïc Minier}
1650dba6195SLoïc Minier
1665b808275SLluís Vilanovahave_backend () {
1675b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1685b808275SLluís Vilanova}
1695b808275SLluís Vilanova
1703b6b7550SPaolo Bonziniglob() {
1713b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
1723b6b7550SPaolo Bonzini}
1733b6b7550SPaolo Bonzini
1743b6b7550SPaolo Bonzinisupported_hax_target() {
1753b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
1763b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1773b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
1783b6b7550SPaolo Bonzini        i386|x86_64)
1793b6b7550SPaolo Bonzini            return 0
1803b6b7550SPaolo Bonzini        ;;
1813b6b7550SPaolo Bonzini    esac
1823b6b7550SPaolo Bonzini    return 1
1833b6b7550SPaolo Bonzini}
1843b6b7550SPaolo Bonzini
1853b6b7550SPaolo Bonzinisupported_kvm_target() {
1863b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
1873b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
1883b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
1893b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
1903b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
1913b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
1923b6b7550SPaolo Bonzini        mips:mips | mipsel:mips | \
1933b6b7550SPaolo Bonzini        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
1943b6b7550SPaolo Bonzini        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
1953b6b7550SPaolo Bonzini        s390x:s390x)
1963b6b7550SPaolo Bonzini            return 0
1973b6b7550SPaolo Bonzini        ;;
1983b6b7550SPaolo Bonzini    esac
1993b6b7550SPaolo Bonzini    return 1
2003b6b7550SPaolo Bonzini}
2013b6b7550SPaolo Bonzini
2023b6b7550SPaolo Bonzinisupported_xen_target() {
2033b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2043b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
205b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
206b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
207b5ed2e11SPaolo Bonzini        i386|x86_64)
2083b6b7550SPaolo Bonzini            return 0
2093b6b7550SPaolo Bonzini        ;;
2103b6b7550SPaolo Bonzini    esac
2113b6b7550SPaolo Bonzini    return 1
2123b6b7550SPaolo Bonzini}
2133b6b7550SPaolo Bonzini
214d880a3baSPaolo Bonzinisupported_target() {
215d880a3baSPaolo Bonzini    case "$1" in
216d880a3baSPaolo Bonzini        *-softmmu)
217d880a3baSPaolo Bonzini            ;;
218d880a3baSPaolo Bonzini        *-linux-user)
219d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
220d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
221d880a3baSPaolo Bonzini                return 1
222d880a3baSPaolo Bonzini            fi
223d880a3baSPaolo Bonzini            ;;
224d880a3baSPaolo Bonzini        *-bsd-user)
225d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
226d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
227d880a3baSPaolo Bonzini                return 1
228d880a3baSPaolo Bonzini            fi
229d880a3baSPaolo Bonzini            ;;
230d880a3baSPaolo Bonzini        *)
231d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
232d880a3baSPaolo Bonzini            return 1
233d880a3baSPaolo Bonzini            ;;
234d880a3baSPaolo Bonzini    esac
235b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
236b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
237b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
238b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
239b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
240b3f6ea7eSPaolo Bonzini    return 1
241d880a3baSPaolo Bonzini}
242d880a3baSPaolo Bonzini
243e9a3591fSChristian Borntraeger
244e9a3591fSChristian Borntraegerld_has() {
245e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
246e9a3591fSChristian Borntraeger}
247e9a3591fSChristian Borntraeger
2487d13299dSbellard# default parameters
24989138857SStefan Weilsource_path=$(dirname "$0")
2502ff6b91eSJuan Quintelacpu=""
251a31a8642SMichael S. Tsirkiniasl="iasl"
2521e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
25343ce4dfeSbellardstatic="no"
2547d13299dSbellardcross_prefix=""
2550c58ac1cSmalcaudio_drv_list=""
256b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
257b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
258e49d021eSPeter Maydellhost_cc="cc"
25973da375eSJuan Quintelalibs_softmmu=""
2603e2e0e6bSJuan Quintelalibs_tools=""
26167f86e8eSJuan Quintelaaudio_pt_int=""
262d5631638Smalcaudio_win_int=""
2632b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
264957f1f99SMichael Rothlibs_qga=""
2655bc62e01SGerd Hoffmanndebug_info="yes"
26663678e17SSteven Noonanstack_protector=""
267ac0df51dSaliguori
268afb63ebdSStefan Weil# Don't accept a target_list environment variable.
269afb63ebdSStefan Weilunset target_list
270377529c0SPaolo Bonzini
271377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
272377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
273377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
274377529c0SPaolo Bonzini#              unless --disable-foo is given
275377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
276377529c0SPaolo Bonzini#              feature will searched for,
277377529c0SPaolo Bonzini#              if not found, configure exits with error
278377529c0SPaolo Bonzini#
279377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
280377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
281377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
282377529c0SPaolo Bonzini
283377529c0SPaolo Bonzinibluez=""
284377529c0SPaolo Bonzinibrlapi=""
285377529c0SPaolo Bonzinicurl=""
286377529c0SPaolo Bonzinicurses=""
287377529c0SPaolo Bonzinidocs=""
288377529c0SPaolo Bonzinifdt=""
28958952137SVincenzo Maffionenetmap="no"
290377529c0SPaolo Bonzinisdl=""
291ee8466d0SCole Robinsonsdlabi=""
292983eef5aSMeador Ingevirtfs=""
293821601eaSJes Sorensenvnc="yes"
294377529c0SPaolo Bonzinisparse="no"
295377529c0SPaolo Bonzinivde=""
296377529c0SPaolo Bonzinivnc_sasl=""
297377529c0SPaolo Bonzinivnc_jpeg=""
298377529c0SPaolo Bonzinivnc_png=""
299377529c0SPaolo Bonzinixen=""
300d5b93ddfSAnthony PERARDxen_ctrl_version=""
30164a7ad6fSIan Campbellxen_pv_domain_build="no"
302eb6fda0fSAnthony PERARDxen_pci_passthrough=""
303377529c0SPaolo Bonzinilinux_aio=""
30447e98658SCorey Bryantcap_ng=""
305377529c0SPaolo Bonziniattr=""
3064f26f2b6SAvi Kivitylibattr=""
307377529c0SPaolo Bonzinixfs=""
308b3f6ea7eSPaolo Bonzinitcg="yes"
309377529c0SPaolo Bonzini
310d41a75a2SBradvhost_net="no"
3115e9be92dSNicholas Bellingervhost_scsi="no"
312fc0b9b0eSStefan Hajnoczivhost_vsock="no"
313e6a74868SMarc-André Lureauvhost_user=""
314d41a75a2SBradkvm="no"
315b0cb0a66SVincent Palatinhax="no"
3162da776dbSMichael R. Hinesrdma=""
317377529c0SPaolo Bonzinigprof="no"
318377529c0SPaolo Bonzinidebug_tcg="no"
319377529c0SPaolo Bonzinidebug="no"
320b553a042SJohn Snowfortify_source=""
321377529c0SPaolo Bonzinistrip_opt="yes"
3229195b2c2SStefan Weiltcg_interpreter="no"
323377529c0SPaolo Bonzinibigendian="no"
324377529c0SPaolo Bonzinimingw32="no"
3251d728c39SBlue Swirlgcov="no"
3261d728c39SBlue Swirlgcov_tool="gcov"
327377529c0SPaolo BonziniEXESUF=""
32817969268SFam ZhengDSOSUF=".so"
32917969268SFam ZhengLDFLAGS_SHARED="-shared"
33017969268SFam Zhengmodules="no"
331377529c0SPaolo Bonziniprefix="/usr/local"
332377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
333528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
334850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
335377529c0SPaolo Bonzinibindir="\${prefix}/bin"
3363aa5d2beSAlon Levylibdir="\${prefix}/lib"
3378bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
3380f94d6daSAlon Levyincludedir="\${prefix}/include"
339377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
340785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
341377529c0SPaolo Bonziniconfsuffix="/qemu"
342377529c0SPaolo Bonzinislirp="yes"
343377529c0SPaolo Bonzinioss_lib=""
344377529c0SPaolo Bonzinibsd="no"
345377529c0SPaolo Bonzinilinux="no"
346377529c0SPaolo Bonzinisolaris="no"
347377529c0SPaolo Bonziniprofiler="no"
348377529c0SPaolo Bonzinicocoa="no"
349377529c0SPaolo Bonzinisoftmmu="yes"
350377529c0SPaolo Bonzinilinux_user="no"
351377529c0SPaolo Bonzinibsd_user="no"
352377529c0SPaolo Bonziniblobs="yes"
353377529c0SPaolo Bonzinipkgversion=""
35440d6444eSAvi Kivitypie=""
3553556c233SPaolo Bonziniqom_cast_debug="yes"
356baf86d6bSPaolo Bonzinitrace_backends="log"
357377529c0SPaolo Bonzinitrace_file="trace"
358377529c0SPaolo Bonzinispice=""
359377529c0SPaolo Bonzinirbd=""
3607b02f544SMarc-André Lureausmartcard=""
3612b2325ffSGerd Hoffmannlibusb=""
36269354a83SHans de Goedeusb_redir=""
363da076ffeSGerd Hoffmannopengl=""
364014cb152SGerd Hoffmannopengl_dmabuf="no"
3655dd89908SRichard Hendersoncpuid_h="no"
36699f2dbd3SLiang Liavx2_opt="no"
3671ece9905SAlon Levyzlib="yes"
368b25c9dffSStefan Weillzo=""
369b25c9dffSStefan Weilsnappy=""
3706b383c08SPeter Wubzip2=""
371e8ef31a3SMichael Tokarevguest_agent=""
372d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
37350cbebb9SMichael Rothguest_agent_ntddscsi="no"
3749dacf32dSYossi Hindinguest_agent_msi=""
375d9840e25STomoki Sekiyamavss_win32_sdk=""
376d9840e25STomoki Sekiyamawin_sdk="no"
3774b1c11fdSDaniel P. Berrangewant_tools="yes"
378c589b249SRonnie Sahlberglibiscsi=""
3796542aa9cSPeter Lievenlibnfs=""
380519175a2SAlex Barcelocoroutine=""
38170c60c08SStefan Hajnoczicoroutine_pool=""
3827d992e4dSPeter Lievendebug_stack_usage="no"
383f0d92b56SLongpeng(Mike)crypto_afalg="no"
384f794573eSEduardo Otuboseccomp=""
385eb100396SBharata B Raoglusterfs=""
386d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
3870c14fb47SBharata B Raoglusterfs_discard="no"
388df3a429aSNiels de Vosglusterfs_fallocate="no"
3897c815372SBharata B Raoglusterfs_zerofill="no"
390a4ccabcfSAnthony Liguorigtk=""
3919e04c683SStefan Weilgtkabi=""
392925a0400SGerd Hoffmanngtk_gl="no"
393a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
394ddbb0d09SDaniel P. Berrangegnutls=""
395b917da4cSDaniel P. Berrangegnutls_rnd=""
39691bfcdb0SDaniel P. Berrangenettle=""
397fff2f982SDaniel P. Berrangenettle_kdf="no"
39891bfcdb0SDaniel P. Berrangegcrypt=""
3991f923c70SLongpeng(Mike)gcrypt_hmac="no"
40037788f25SDaniel P. Berrangegcrypt_kdf="no"
401bbbf9bfbSStefan Weilvte=""
4029d9e1521SGerd Hoffmannvirglrenderer=""
403e91c793cSCole Robinsontpm="yes"
4040a12ec87SRichard W.M. Joneslibssh2=""
405ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
406a99d57bbSWanlong Gaonuma=""
4072847b469SFam Zhengtcmalloc="no"
4087b01cb97SAlexandre Derumierjemalloc="no"
409a6b1d4c0SChanglong Xiereplication="yes"
410da92c3ffSAshish Mittalvxhs=""
411377529c0SPaolo Bonzini
412898be3e0SPeter Maydellsupported_cpu="no"
413898be3e0SPeter Maydellsupported_os="no"
414fb59dabdSPeter Maydellbogus_os="no"
415898be3e0SPeter Maydell
416ac0df51dSaliguori# parse CC options first
417ac0df51dSaliguorifor opt do
41889138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
419ac0df51dSaliguori  case "$opt" in
420ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
421ac0df51dSaliguori  ;;
4223d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
423ac0df51dSaliguori  ;;
42483f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
42583f73fceSTomoki Sekiyama  ;;
426ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
427ca4deeb1SPaolo Bonzini  ;;
4282ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4292ff6b91eSJuan Quintela  ;;
430de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
431f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
432e2a2ed06SJuan Quintela  ;;
43311cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
43411cde1c8SBruno Dominguez                      EXTRA_CXXFLAGS="$optarg"
43511cde1c8SBruno Dominguez  ;;
436a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
437f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
438e2a2ed06SJuan Quintela  ;;
4395bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4405bc62e01SGerd Hoffmann  ;;
4415bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4425bc62e01SGerd Hoffmann  ;;
443ac0df51dSaliguori  esac
444ac0df51dSaliguoridone
445ac0df51dSaliguori# OS specific
446ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
44793148aa5SStefan Weil# we can eliminate its usage altogether.
448ac0df51dSaliguori
449e49d021eSPeter Maydell# Preferred compiler:
450e49d021eSPeter Maydell#  ${CC} (if set)
451e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
452e49d021eSPeter Maydell#  system compiler
453e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
454e49d021eSPeter Maydell  cc="$host_cc"
455e49d021eSPeter Maydellelse
456b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
457e49d021eSPeter Maydellfi
458e49d021eSPeter Maydell
45983f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
46083f73fceSTomoki Sekiyama  cxx="c++"
46183f73fceSTomoki Sekiyamaelse
46283f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
46383f73fceSTomoki Sekiyamafi
46483f73fceSTomoki Sekiyama
465b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
466cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4675f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4683dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
469b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
470b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
4714852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
472b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
473b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
47417884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
47517884d7bSSergei Trofimovichquery_pkg_config() {
47617884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
47717884d7bSSergei Trofimovich}
47817884d7bSSergei Trofimovichpkg_config=query_pkg_config
479b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
48047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
481ac0df51dSaliguori
48245d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
48345d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
48445d285abSPeter Maydell
485be17dc90SMichael S. Tsirkin# default flags for all hosts
4862d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
4872d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
4882d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
4892d31515bSPeter Maydell# provides these semantics.)
4902d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
491f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
492c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
493be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
494244f1441SYang ZhongQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
4955bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
4965bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
497be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
4985bc62e01SGerd Hoffmannfi
499be17dc90SMichael S. Tsirkin
500ca4deeb1SPaolo Bonzini# make source path absolute
50189138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
502ca4deeb1SPaolo Bonzini
503cab00a5aSMichael S. Tsirkin# running configure in the source tree?
504cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
505cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
506cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
507cab00a5aSMichael S. Tsirkinelse
508cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
509cab00a5aSMichael S. Tsirkinfi
510cab00a5aSMichael S. Tsirkin
511ac0df51dSaliguoricheck_define() {
512ac0df51dSaliguoricat > $TMPC <<EOF
513ac0df51dSaliguori#if !defined($1)
514fd786e1aSPeter Maydell#error $1 not defined
515ac0df51dSaliguori#endif
516ac0df51dSaliguoriint main(void) { return 0; }
517ac0df51dSaliguoriEOF
51852166aa0SJuan Quintela  compile_object
519ac0df51dSaliguori}
520ac0df51dSaliguori
521307119e7SGerd Hoffmanncheck_include() {
522307119e7SGerd Hoffmanncat > $TMPC <<EOF
523307119e7SGerd Hoffmann#include <$1>
524307119e7SGerd Hoffmannint main(void) { return 0; }
525307119e7SGerd HoffmannEOF
526307119e7SGerd Hoffmann  compile_object
527307119e7SGerd Hoffmann}
528307119e7SGerd Hoffmann
52993b25869SJohn Snowwrite_c_skeleton() {
53093b25869SJohn Snow    cat > $TMPC <<EOF
53193b25869SJohn Snowint main(void) { return 0; }
53293b25869SJohn SnowEOF
53393b25869SJohn Snow}
53493b25869SJohn Snow
535bbea4050SPeter Maydellif check_define __linux__ ; then
536bbea4050SPeter Maydell  targetos="Linux"
537bbea4050SPeter Maydellelif check_define _WIN32 ; then
538bbea4050SPeter Maydell  targetos='MINGW32'
539bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
540bbea4050SPeter Maydell  targetos='OpenBSD'
541bbea4050SPeter Maydellelif check_define __sun__ ; then
542bbea4050SPeter Maydell  targetos='SunOS'
543bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
544bbea4050SPeter Maydell  targetos='Haiku'
545951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
546951fedfcSPeter Maydell  targetos='FreeBSD'
547951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
548951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
549951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
550951fedfcSPeter Maydell  targetos='DragonFly'
551951fedfcSPeter Maydellelif check_define __NetBSD__; then
552951fedfcSPeter Maydell  targetos='NetBSD'
553951fedfcSPeter Maydellelif check_define __APPLE__; then
554951fedfcSPeter Maydell  targetos='Darwin'
555bbea4050SPeter Maydellelse
556951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
557951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
558951fedfcSPeter Maydell  # be the result of a missing compiler.
559951fedfcSPeter Maydell  targetos='bogus'
560951fedfcSPeter Maydell  bogus_os='yes'
561bbea4050SPeter Maydellfi
562bbea4050SPeter Maydell
563bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
564bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
565bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
566bbea4050SPeter Maydell# the correct CPU with the --cpu option.
567bbea4050SPeter Maydellcase $targetos in
568bbea4050SPeter MaydellDarwin)
569bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
570bbea4050SPeter Maydell  # run 64-bit userspace code.
571bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
572bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
573bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
574bbea4050SPeter Maydell    cpu="x86_64"
575bbea4050SPeter Maydell  fi
576bbea4050SPeter Maydell  ;;
577bbea4050SPeter MaydellSunOS)
57889138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
579bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
580bbea4050SPeter Maydell    cpu="x86_64"
581bbea4050SPeter Maydell  fi
582bbea4050SPeter Maydellesac
583bbea4050SPeter Maydell
5842ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
5852ff6b91eSJuan Quintela  # command line argument
5862ff6b91eSJuan Quintela  :
5872ff6b91eSJuan Quintelaelif check_define __i386__ ; then
588ac0df51dSaliguori  cpu="i386"
589ac0df51dSaliguorielif check_define __x86_64__ ; then
590c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
591c72b26ecSRichard Henderson    cpu="x32"
592c72b26ecSRichard Henderson  else
593ac0df51dSaliguori    cpu="x86_64"
594c72b26ecSRichard Henderson  fi
5953aa9bd6cSblueswir1elif check_define __sparc__ ; then
5963aa9bd6cSblueswir1  if check_define __arch64__ ; then
5973aa9bd6cSblueswir1    cpu="sparc64"
5983aa9bd6cSblueswir1  else
5993aa9bd6cSblueswir1    cpu="sparc"
6003aa9bd6cSblueswir1  fi
601fdf7ed96Smalcelif check_define _ARCH_PPC ; then
602fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
603fdf7ed96Smalc    cpu="ppc64"
604ac0df51dSaliguori  else
605fdf7ed96Smalc    cpu="ppc"
606fdf7ed96Smalc  fi
607afa05235SAurelien Jarnoelif check_define __mips__ ; then
608afa05235SAurelien Jarno  cpu="mips"
609477ba620SAurelien Jarnoelif check_define __ia64__ ; then
610477ba620SAurelien Jarno  cpu="ia64"
611d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
612d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
613d66ed0eaSAurelien Jarno    cpu="s390x"
614d66ed0eaSAurelien Jarno  else
615d66ed0eaSAurelien Jarno    cpu="s390"
616d66ed0eaSAurelien Jarno  fi
61721d89f84SPeter Maydellelif check_define __arm__ ; then
61821d89f84SPeter Maydell  cpu="arm"
6191f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6201f080313SClaudio Fontana  cpu="aarch64"
621fdf7ed96Smalcelse
62289138857SStefan Weil  cpu=$(uname -m)
623ac0df51dSaliguorifi
624ac0df51dSaliguori
625359bc95dSPeter MaydellARCH=
626359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
627359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6287d13299dSbellardcase "$cpu" in
6296499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
630898be3e0SPeter Maydell    cpu="$cpu"
631898be3e0SPeter Maydell    supported_cpu="yes"
632898be3e0SPeter Maydell  ;;
6337d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
63497a847bcSbellard    cpu="i386"
635898be3e0SPeter Maydell    supported_cpu="yes"
6367d13299dSbellard  ;;
637aaa5fa14Saurel32  x86_64|amd64)
638aaa5fa14Saurel32    cpu="x86_64"
639898be3e0SPeter Maydell    supported_cpu="yes"
640aaa5fa14Saurel32  ;;
64121d89f84SPeter Maydell  armv*b|armv*l|arm)
64221d89f84SPeter Maydell    cpu="arm"
643898be3e0SPeter Maydell    supported_cpu="yes"
6447d13299dSbellard  ;;
6451f080313SClaudio Fontana  aarch64)
6461f080313SClaudio Fontana    cpu="aarch64"
647898be3e0SPeter Maydell    supported_cpu="yes"
6481f080313SClaudio Fontana  ;;
649afa05235SAurelien Jarno  mips*)
650afa05235SAurelien Jarno    cpu="mips"
651898be3e0SPeter Maydell    supported_cpu="yes"
652afa05235SAurelien Jarno  ;;
6533142255cSblueswir1  sparc|sun4[cdmuv])
654ae228531Sbellard    cpu="sparc"
6556499fd15SPeter Maydell    supported_cpu="yes"
656ae228531Sbellard  ;;
6577d13299dSbellard  *)
658359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
659359bc95dSPeter Maydell    ARCH=unknown
6607d13299dSbellard  ;;
6617d13299dSbellardesac
662359bc95dSPeter Maydellif test -z "$ARCH"; then
663359bc95dSPeter Maydell  ARCH="$cpu"
664359bc95dSPeter Maydellfi
665e2d52ad3SJuan Quintela
6667d13299dSbellard# OS specific
6670dbfc675SJuan Quintela
668adfc3e91SStacey Son# host *BSD for user mode
669adfc3e91SStacey SonHOST_VARIANT_DIR=""
670adfc3e91SStacey Son
6717d13299dSbellardcase $targetos in
67267b915a5SbellardMINGW32*)
67367b915a5Sbellard  mingw32="yes"
674b0cb0a66SVincent Palatin  hax="yes"
6753cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
676307119e7SGerd Hoffmann  if check_include dsound.h; then
6773cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
678307119e7SGerd Hoffmann  else
679307119e7SGerd Hoffmann    audio_drv_list=""
680307119e7SGerd Hoffmann  fi
681898be3e0SPeter Maydell  supported_os="yes"
68267b915a5Sbellard;;
6835c40d2bdSthsGNU/kFreeBSD)
684a167ba50SAurelien Jarno  bsd="yes"
6850c58ac1cSmalc  audio_drv_list="oss"
6860bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
6875c40d2bdSths;;
6887d3505c5SbellardFreeBSD)
6897d3505c5Sbellard  bsd="yes"
6900db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6910c58ac1cSmalc  audio_drv_list="oss"
6920bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
693f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
694f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
695a7764f15SEd Maste  # needed for kinfo_getproc
696a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
69758952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
698adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
699898be3e0SPeter Maydell  supported_os="yes"
7007d3505c5Sbellard;;
701c5e97233Sblueswir1DragonFly)
702c5e97233Sblueswir1  bsd="yes"
7030db4a067SPaolo Bonzini  make="${MAKE-gmake}"
704c5e97233Sblueswir1  audio_drv_list="oss"
7050bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
706adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
707c5e97233Sblueswir1;;
7087d3505c5SbellardNetBSD)
7097d3505c5Sbellard  bsd="yes"
7100db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7110c58ac1cSmalc  audio_drv_list="oss"
7120bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7138ef92a88Sblueswir1  oss_lib="-lossaudio"
714adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
7153c2bdbc1SKamil Rytarowski  supported_os="yes"
7167d3505c5Sbellard;;
7177d3505c5SbellardOpenBSD)
7187d3505c5Sbellard  bsd="yes"
7190db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7204f6ab397SBrad Smith  audio_drv_list="sdl"
7210bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
722adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7237d3505c5Sbellard;;
72483fb7adfSbellardDarwin)
72583fb7adfSbellard  bsd="yes"
72683fb7adfSbellard  darwin="yes"
727b0cb0a66SVincent Palatin  hax="yes"
72817969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7291b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
730a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7310c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
7321b0f9cc2Saliguori  fi
733fd677642Sths  cocoa="yes"
7340c58ac1cSmalc  audio_drv_list="coreaudio"
73514382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
7360c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7377973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
738a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
739a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
740a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
741adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
742898be3e0SPeter Maydell  supported_os="yes"
74383fb7adfSbellard;;
744ec530c81SbellardSunOS)
745ec530c81Sbellard  solaris="yes"
7460db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7470db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
748fa58948dSBlue Swirl  ld="gld"
749e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7506b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7510c58ac1cSmalc    audio_drv_list="oss"
7526b4d2ba1Sths  fi
753c2de5c91Smalc  audio_possible_drivers="oss sdl"
754d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
755d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
756d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
757d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
758a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
759560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
760560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
761560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
762ec530c81Sbellard;;
763179cf400SAndreas FärberHaiku)
764179cf400SAndreas Färber  haiku="yes"
765179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
766179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
767179cf400SAndreas Färber;;
768898be3e0SPeter MaydellLinux)
7690c58ac1cSmalc  audio_drv_list="oss"
7700bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7715327cf48Sbellard  linux="yes"
772831b7825Sths  linux_user="yes"
773af2be207SJan Kiszka  kvm="yes"
774af2be207SJan Kiszka  vhost_net="yes"
7755e9be92dSNicholas Bellinger  vhost_scsi="yes"
776fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
777a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
778898be3e0SPeter Maydell  supported_os="yes"
779898be3e0SPeter Maydell;;
7807d13299dSbellardesac
7817d13299dSbellard
7827d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
783b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
78484778508Sblueswir1    bsd_user="yes"
7857d3505c5Sbellard  fi
78608de3949SAndreas Färberfi
7877d3505c5Sbellard
7880db4a067SPaolo Bonzini: ${make=${MAKE-make}}
7890db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
79052510f8bSStefan Weil: ${python=${PYTHON-python}}
791e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
7920db4a067SPaolo Bonzini
7933c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7943c4a4d0dSPeter Maydellif has clang; then
7953c4a4d0dSPeter Maydell  objcc=clang
7963c4a4d0dSPeter Maydellelse
7973c4a4d0dSPeter Maydell  objcc="$cc"
7983c4a4d0dSPeter Maydellfi
7993c4a4d0dSPeter Maydell
8003457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8013457a3f8SJuan Quintela  EXESUF=".exe"
80217969268SFam Zheng  DSOSUF=".dll"
803a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
804e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
805e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
80678e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
80778e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
808f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
80993b25869SJohn Snow  write_c_skeleton;
810f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
811f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
812f7cf5d5bSStefan Weil  fi
813c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
814683035deSPaolo Bonzini  mandir="\${prefix}"
815528ae5b8SEduardo Habkost  datadir="\${prefix}"
816850da188SEduardo Habkost  qemu_docdir="\${prefix}"
817683035deSPaolo Bonzini  bindir="\${prefix}"
818683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8195a699bbbSLaszlo Ersek  local_statedir=
820683035deSPaolo Bonzini  confsuffix=""
821161a56a9SVinzenz Feenstra  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -liphlpapi -lnetapi32 $libs_qga"
8223457a3f8SJuan Quintelafi
8233457a3f8SJuan Quintela
824487fefdbSAnthony Liguoriwerror=""
82585aa5189Sbellard
8267d13299dSbellardfor opt do
82789138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8287d13299dSbellard  case "$opt" in
8292efc3265Sbellard  --help|-h) show_help=yes
8302efc3265Sbellard  ;;
83199123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
83299123e13SMike Frysinger  ;;
833b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8347d13299dSbellard  ;;
835b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
83632ce6337Sbellard  ;;
837ca4deeb1SPaolo Bonzini  --source-path=*)
8387d13299dSbellard  ;;
839ac0df51dSaliguori  --cross-prefix=*)
8407d13299dSbellard  ;;
841ac0df51dSaliguori  --cc=*)
8427d13299dSbellard  ;;
843b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
84483469015Sbellard  ;;
84583f73fceSTomoki Sekiyama  --cxx=*)
84683f73fceSTomoki Sekiyama  ;;
847e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
848e007dbecSMichael S. Tsirkin  ;;
8493c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8503c4a4d0dSPeter Maydell  ;;
851b1a550a0Spbrook  --make=*) make="$optarg"
8527d13299dSbellard  ;;
8536a882643Spbrook  --install=*) install="$optarg"
8546a882643Spbrook  ;;
855c886edfbSBlue Swirl  --python=*) python="$optarg"
856c886edfbSBlue Swirl  ;;
8571d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
8581d728c39SBlue Swirl  ;;
859e2d8830eSBrad  --smbd=*) smbd="$optarg"
860e2d8830eSBrad  ;;
861e2a2ed06SJuan Quintela  --extra-cflags=*)
8627d13299dSbellard  ;;
86311cde1c8SBruno Dominguez  --extra-cxxflags=*)
86411cde1c8SBruno Dominguez  ;;
865e2a2ed06SJuan Quintela  --extra-ldflags=*)
8667d13299dSbellard  ;;
8675bc62e01SGerd Hoffmann  --enable-debug-info)
8685bc62e01SGerd Hoffmann  ;;
8695bc62e01SGerd Hoffmann  --disable-debug-info)
8705bc62e01SGerd Hoffmann  ;;
87117969268SFam Zheng  --enable-modules)
87217969268SFam Zheng      modules="yes"
87317969268SFam Zheng  ;;
8743aa88b31SStefan Hajnoczi  --disable-modules)
8753aa88b31SStefan Hajnoczi      modules="no"
8763aa88b31SStefan Hajnoczi  ;;
8772ff6b91eSJuan Quintela  --cpu=*)
8787d13299dSbellard  ;;
879b1a550a0Spbrook  --target-list=*) target_list="$optarg"
880de83cd02Sbellard  ;;
8815b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8825b808275SLluís Vilanova  ;;
8835b808275SLluís Vilanova  # XXX: backwards compatibility
8845b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
88594a420b1SStefan Hajnoczi  ;;
88674242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8879410b56cSPrerna Saxena  ;;
8887d13299dSbellard  --enable-gprof) gprof="yes"
8897d13299dSbellard  ;;
8901d728c39SBlue Swirl  --enable-gcov) gcov="yes"
8911d728c39SBlue Swirl  ;;
89279427693SLoïc Minier  --static)
89379427693SLoïc Minier    static="yes"
89479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
89517884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
89643ce4dfeSbellard  ;;
8970b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
8980b24e75fSPaolo Bonzini  ;;
8990b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9000b24e75fSPaolo Bonzini  ;;
9013aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9023aa5d2beSAlon Levy  ;;
9038bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9048bf188aaSMichael Tokarev  ;;
9050f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9060f94d6daSAlon Levy  ;;
907528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9080b24e75fSPaolo Bonzini  ;;
909023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
910023d3d67SEduardo Habkost  ;;
911850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9120b24e75fSPaolo Bonzini  ;;
913ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
91407381cc1SAnthony Liguori  ;;
915785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
916785c23aeSLuiz Capitulino  ;;
917785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
918023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
919023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
920023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
921023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
922023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
923023ddd74SMax Filippov    # lots of directory switches by default.
924023ddd74SMax Filippov  ;;
92597a847bcSbellard  --disable-sdl) sdl="no"
92697a847bcSbellard  ;;
927c4198157SJuan Quintela  --enable-sdl) sdl="yes"
928c4198157SJuan Quintela  ;;
92947c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
93047c03744SDave Airlie  ;;
9313556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9323556c233SPaolo Bonzini  ;;
9333556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9343556c233SPaolo Bonzini  ;;
935983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
936983eef5aSMeador Inge  ;;
937983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
938983eef5aSMeador Inge  ;;
939821601eaSJes Sorensen  --disable-vnc) vnc="no"
940821601eaSJes Sorensen  ;;
941821601eaSJes Sorensen  --enable-vnc) vnc="yes"
942821601eaSJes Sorensen  ;;
9432f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
9442f6a1ab0Sblueswir1  ;;
9450c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9460c58ac1cSmalc  ;;
94789138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
948b64ec4e4SFam Zheng  ;;
94989138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
950eb852011SMarkus Armbruster  ;;
951f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
952f8393946Saurel32  ;;
953f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
954f8393946Saurel32  ;;
955f3d08ee6SPaul Brook  --enable-debug)
956f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
957f3d08ee6SPaul Brook      debug_tcg="yes"
958f3d08ee6SPaul Brook      debug="yes"
959f3d08ee6SPaul Brook      strip_opt="no"
960b553a042SJohn Snow      fortify_source="no"
961f3d08ee6SPaul Brook  ;;
96203b4fe7dSaliguori  --enable-sparse) sparse="yes"
96303b4fe7dSaliguori  ;;
96403b4fe7dSaliguori  --disable-sparse) sparse="no"
96503b4fe7dSaliguori  ;;
9661625af87Saliguori  --disable-strip) strip_opt="no"
9671625af87Saliguori  ;;
9682f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
9692f9606b3Saliguori  ;;
970ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
971ea784e3bSJuan Quintela  ;;
9722f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
9732f6f5c7aSCorentin Chary  ;;
9742f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
9752f6f5c7aSCorentin Chary  ;;
976efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
977efe556adSCorentin Chary  ;;
978efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
979efe556adSCorentin Chary  ;;
980443f1376Sbellard  --disable-slirp) slirp="no"
981c20709aaSbellard  ;;
982e0e6c8c0Saliguori  --disable-vde) vde="no"
9838a16d273Sths  ;;
984dfb278bdSJuan Quintela  --enable-vde) vde="yes"
985dfb278bdSJuan Quintela  ;;
98658952137SVincenzo Maffione  --disable-netmap) netmap="no"
98758952137SVincenzo Maffione  ;;
98858952137SVincenzo Maffione  --enable-netmap) netmap="yes"
98958952137SVincenzo Maffione  ;;
990e37630caSaliguori  --disable-xen) xen="no"
991e37630caSaliguori  ;;
992fc321b4bSJuan Quintela  --enable-xen) xen="yes"
993fc321b4bSJuan Quintela  ;;
994eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
995eb6fda0fSAnthony PERARD  ;;
996eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
997eb6fda0fSAnthony PERARD  ;;
99864a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
99964a7ad6fSIan Campbell  ;;
100064a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
100164a7ad6fSIan Campbell  ;;
10022e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10032e4d9fb1Saurel32  ;;
10044ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10054ffcedb6SJuan Quintela  ;;
1006fb599c9aSbalrog  --disable-bluez) bluez="no"
1007fb599c9aSbalrog  ;;
1008a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1009a20a6f46SJuan Quintela  ;;
10107ba1e619Saliguori  --disable-kvm) kvm="no"
10117ba1e619Saliguori  ;;
1012b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1013b31a0277SJuan Quintela  ;;
1014b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1015180fb750Szhanghailiang  ;;
1016b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1017180fb750Szhanghailiang  ;;
10189195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
10199195b2c2SStefan Weil  ;;
10209195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
10219195b2c2SStefan Weil  ;;
102247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
102347e98658SCorey Bryant  ;;
102447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
102547e98658SCorey Bryant  ;;
1026b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1027b3f6ea7eSPaolo Bonzini  ;;
1028b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1029b3f6ea7eSPaolo Bonzini  ;;
1030cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1031cd4ec0b4SGerd Hoffmann  ;;
1032cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1033cd4ec0b4SGerd Hoffmann  ;;
1034c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1035c589b249SRonnie Sahlberg  ;;
1036c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1037c589b249SRonnie Sahlberg  ;;
10386542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
10396542aa9cSPeter Lieven  ;;
10406542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
10416542aa9cSPeter Lieven  ;;
104205c2a3e7Sbellard  --enable-profiler) profiler="yes"
104305c2a3e7Sbellard  ;;
104414821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
104514821030SPavel Borzenkov  ;;
1046c2de5c91Smalc  --enable-cocoa)
1047c2de5c91Smalc      cocoa="yes" ;
104889138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
10495b0753e0Sbellard  ;;
1050cad25d69Spbrook  --disable-system) softmmu="no"
10510a8e90f4Spbrook  ;;
1052cad25d69Spbrook  --enable-system) softmmu="yes"
10530a8e90f4Spbrook  ;;
10540953a80fSZachary Amsden  --disable-user)
10550953a80fSZachary Amsden      linux_user="no" ;
10560953a80fSZachary Amsden      bsd_user="no" ;
10570953a80fSZachary Amsden  ;;
10580953a80fSZachary Amsden  --enable-user) ;;
1059831b7825Sths  --disable-linux-user) linux_user="no"
10600a8e90f4Spbrook  ;;
1061831b7825Sths  --enable-linux-user) linux_user="yes"
1062831b7825Sths  ;;
106384778508Sblueswir1  --disable-bsd-user) bsd_user="no"
106484778508Sblueswir1  ;;
106584778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
106684778508Sblueswir1  ;;
106740d6444eSAvi Kivity  --enable-pie) pie="yes"
106834005a00SKirill A. Shutemov  ;;
106940d6444eSAvi Kivity  --disable-pie) pie="no"
107034005a00SKirill A. Shutemov  ;;
107185aa5189Sbellard  --enable-werror) werror="yes"
107285aa5189Sbellard  ;;
107385aa5189Sbellard  --disable-werror) werror="no"
107485aa5189Sbellard  ;;
107563678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
107663678e17SSteven Noonan  ;;
107763678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
107863678e17SSteven Noonan  ;;
10794d3b6f6eSbalrog  --disable-curses) curses="no"
10804d3b6f6eSbalrog  ;;
1081c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1082c584a6d0SJuan Quintela  ;;
1083769ce76dSAlexander Graf  --disable-curl) curl="no"
1084769ce76dSAlexander Graf  ;;
1085788c8196SJuan Quintela  --enable-curl) curl="yes"
1086788c8196SJuan Quintela  ;;
10872df87df7SJuan Quintela  --disable-fdt) fdt="no"
10882df87df7SJuan Quintela  ;;
10892df87df7SJuan Quintela  --enable-fdt) fdt="yes"
10902df87df7SJuan Quintela  ;;
10915c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
10925c6c3a6cSChristoph Hellwig  ;;
10935c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
10945c6c3a6cSChristoph Hellwig  ;;
1095758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1096758e8e38SVenkateswararao Jujjuri (JV)  ;;
1097758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1098758e8e38SVenkateswararao Jujjuri (JV)  ;;
109977755340Sths  --disable-blobs) blobs="no"
110077755340Sths  ;;
11014a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
11024a19f1ecSpbrook  ;;
1103519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1104519175a2SAlex Barcelo  ;;
110570c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
110670c60c08SStefan Hajnoczi  ;;
110770c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
110870c60c08SStefan Hajnoczi  ;;
11097d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
11107d992e4dSPeter Lieven  ;;
1111f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1112f0d92b56SLongpeng(Mike)  ;;
1113f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1114f0d92b56SLongpeng(Mike)  ;;
1115a25dba17SJuan Quintela  --disable-docs) docs="no"
111670ec5dc0SAnthony Liguori  ;;
1117a25dba17SJuan Quintela  --enable-docs) docs="yes"
111883a3ab8bSJuan Quintela  ;;
1119d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1120d5970055SMichael S. Tsirkin  ;;
1121d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1122d5970055SMichael S. Tsirkin  ;;
11235e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
11245e9be92dSNicholas Bellinger  ;;
11255e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
11265e9be92dSNicholas Bellinger  ;;
1127fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1128fc0b9b0eSStefan Hajnoczi  ;;
1129fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1130fc0b9b0eSStefan Hajnoczi  ;;
1131da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
113220ff075bSMichael Walle  ;;
1133da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
113420ff075bSMichael Walle  ;;
1135f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1136f27aaf4bSChristian Brunner  ;;
1137f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1138f27aaf4bSChristian Brunner  ;;
11398c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
11408c84cf11SSergei Trofimovich  ;;
11418c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
11428c84cf11SSergei Trofimovich  ;;
11437b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1144111a38b0SRobert Relyea  ;;
11457b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1146111a38b0SRobert Relyea  ;;
11472b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
11482b2325ffSGerd Hoffmann  ;;
11492b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
11502b2325ffSGerd Hoffmann  ;;
115169354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
115269354a83SHans de Goede  ;;
115369354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
115469354a83SHans de Goede  ;;
11551ece9905SAlon Levy  --disable-zlib-test) zlib="no"
11561ece9905SAlon Levy  ;;
1157b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1158b25c9dffSStefan Weil  ;;
1159607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1160607dacd0Sqiaonuohan  ;;
1161b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1162b25c9dffSStefan Weil  ;;
1163607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1164607dacd0Sqiaonuohan  ;;
11656b383c08SPeter Wu  --disable-bzip2) bzip2="no"
11666b383c08SPeter Wu  ;;
11676b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
11686b383c08SPeter Wu  ;;
1169d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1170d138cee9SMichael Roth  ;;
1171d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1172d138cee9SMichael Roth  ;;
11739dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
11749dacf32dSYossi Hindin  ;;
11759dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
11769dacf32dSYossi Hindin  ;;
1177d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1178d9840e25STomoki Sekiyama  ;;
1179d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1180d9840e25STomoki Sekiyama  ;;
1181d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1182d9840e25STomoki Sekiyama  ;;
1183d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1184d9840e25STomoki Sekiyama  ;;
1185d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1186d9840e25STomoki Sekiyama  ;;
1187d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1188d9840e25STomoki Sekiyama  ;;
11894b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
11904b1c11fdSDaniel P. Berrange  ;;
11914b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
11924b1c11fdSDaniel P. Berrange  ;;
1193f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1194f794573eSEduardo Otubo  ;;
1195f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1196f794573eSEduardo Otubo  ;;
1197eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1198eb100396SBharata B Rao  ;;
1199eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1200eb100396SBharata B Rao  ;;
120152b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
120252b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1203583f6e7bSStefan Hajnoczi  ;;
1204cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1205cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1206cb6414dfSFam Zheng  ;;
1207315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1208315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1209315d3184SFam Zheng  ;;
1210a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1211a4ccabcfSAnthony Liguori  ;;
1212a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1213a4ccabcfSAnthony Liguori  ;;
1214a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1215a1c5e949SDaniel P. Berrange  ;;
1216ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1217ddbb0d09SDaniel P. Berrange  ;;
1218ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1219ddbb0d09SDaniel P. Berrange  ;;
122091bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
122191bfcdb0SDaniel P. Berrange  ;;
122291bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
122391bfcdb0SDaniel P. Berrange  ;;
122491bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
122591bfcdb0SDaniel P. Berrange  ;;
122691bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
122791bfcdb0SDaniel P. Berrange  ;;
12282da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
12292da776dbSMichael R. Hines  ;;
12302da776dbSMichael R. Hines  --disable-rdma) rdma="no"
12312da776dbSMichael R. Hines  ;;
1232528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1233528de90aSDaniel P. Berrange  ;;
1234bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1235bbbf9bfbSStefan Weil  ;;
1236bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1237bbbf9bfbSStefan Weil  ;;
12389d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
12399d9e1521SGerd Hoffmann  ;;
12409d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
12419d9e1521SGerd Hoffmann  ;;
1242e91c793cSCole Robinson  --disable-tpm) tpm="no"
1243e91c793cSCole Robinson  ;;
1244ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1245ab214c29SStefan Berger  ;;
12460a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
12470a12ec87SRichard W.M. Jones  ;;
12480a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
12490a12ec87SRichard W.M. Jones  ;;
1250ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1251ed1701c6SDr. David Alan Gilbert  ;;
1252ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1253ed1701c6SDr. David Alan Gilbert  ;;
1254a99d57bbSWanlong Gao  --disable-numa) numa="no"
1255a99d57bbSWanlong Gao  ;;
1256a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1257a99d57bbSWanlong Gao  ;;
12582847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
12592847b469SFam Zheng  ;;
12602847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
12612847b469SFam Zheng  ;;
12627b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
12637b01cb97SAlexandre Derumier  ;;
12647b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
12657b01cb97SAlexandre Derumier  ;;
1266a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1267a6b1d4c0SChanglong Xie  ;;
1268a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1269a6b1d4c0SChanglong Xie  ;;
1270da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1271da92c3ffSAshish Mittal  ;;
1272da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1273da92c3ffSAshish Mittal  ;;
1274e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1275e6a74868SMarc-André Lureau  ;;
1276e6a74868SMarc-André Lureau  --enable-vhost-user)
1277e6a74868SMarc-André Lureau      vhost_user="yes"
1278e6a74868SMarc-André Lureau      if test "$mingw32" = "yes"; then
1279e6a74868SMarc-André Lureau          error_exit "vhost-user isn't available on win32"
1280e6a74868SMarc-André Lureau      fi
1281e6a74868SMarc-André Lureau  ;;
12822d2ad6d0SFam Zheng  *)
12832d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
12842d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
12852d2ad6d0SFam Zheng      exit 1
12867f1559c6Sbalrog  ;;
12877d13299dSbellard  esac
12887d13299dSbellarddone
12897d13299dSbellard
1290e6a74868SMarc-André Lureauif test "$vhost_user" = ""; then
1291e6a74868SMarc-André Lureau    if test "$mingw32" = "yes"; then
1292e6a74868SMarc-André Lureau        vhost_user="no"
1293e6a74868SMarc-André Lureau    else
1294e6a74868SMarc-André Lureau        vhost_user="yes"
1295e6a74868SMarc-André Lureau    fi
1296e6a74868SMarc-André Lureaufi
1297e6a74868SMarc-André Lureau
129840293e58Sbellardcase "$cpu" in
1299e3608d66SRichard Henderson    ppc)
1300e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1301e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1302e3608d66SRichard Henderson           ;;
1303e3608d66SRichard Henderson    ppc64)
1304e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1305e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1306e3608d66SRichard Henderson           ;;
13079b9c37c3SRichard Henderson    sparc)
1308f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1309f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
13103142255cSblueswir1           ;;
1311ed968ff1SJuan Quintela    sparc64)
131279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1313f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
13143142255cSblueswir1           ;;
131576d83bdeSths    s390)
1316061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
131728d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
131828d7cc49SRichard Henderson           ;;
131928d7cc49SRichard Henderson    s390x)
1320061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
132128d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
132276d83bdeSths           ;;
132340293e58Sbellard    i386)
132479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
13250c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
13262b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
132740293e58Sbellard           ;;
132840293e58Sbellard    x86_64)
13297ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
13307ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
13317ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
13327ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
13330c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
13342b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1335379f6698SPaul Brook           ;;
1336c72b26ecSRichard Henderson    x32)
1337c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1338c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1339c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1340c72b26ecSRichard Henderson           ;;
134130163d89SPeter Maydell    # No special flags required for other host CPUs
13423142255cSblueswir1esac
13433142255cSblueswir1
134479f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
134579f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
134679f3b12fSPeter Crosthwaite
1347affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1348affc88ccSPeter Maydell# support, even if we're using TCI.
1349affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1350affc88ccSPeter Maydell  bsd_user="no"
1351affc88ccSPeter Maydell  linux_user="no"
1352affc88ccSPeter Maydellfi
1353affc88ccSPeter Maydell
135460e0df25SPeter Maydelldefault_target_list=""
135560e0df25SPeter Maydell
13566e92f823SPeter Maydellmak_wilds=""
13576e92f823SPeter Maydell
135860e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
13596e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
136060e0df25SPeter Maydellfi
136160e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
13626e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
136360e0df25SPeter Maydellfi
136460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
13656e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
136660e0df25SPeter Maydellfi
136760e0df25SPeter Maydell
13686e92f823SPeter Maydellfor config in $mak_wilds; do
13696e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
13706e92f823SPeter Maydelldone
13716e92f823SPeter Maydell
1372c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
137364a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1374c53eeaf7SStefan Hajnoczi
1375af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1376af5db58eSpbrookcat << EOF
1377af5db58eSpbrook
1378af5db58eSpbrookUsage: configure [options]
1379af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1380af5db58eSpbrook
138108fb77edSStefan WeilStandard options:
138208fb77edSStefan Weil  --help                   print this message
138308fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
138408fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
138508fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
138608fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
138708fb77edSStefan Weil$(echo Available targets: $default_target_list | \
138808fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
138908fb77edSStefan Weil
139008fb77edSStefan WeilAdvanced options (experts only):
139108fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
139208fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
139308fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
139408fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
139508fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
139608fb77edSStefan Weil                           build time
139708fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
139808fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
139908fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
140011cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
140108fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
140208fb77edSStefan Weil  --make=MAKE              use specified make [$make]
140308fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
140408fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
140508fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
140608fb77edSStefan Weil  --static                 enable static build [$static]
140708fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
140808fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
140908fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
141008fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
141108fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
141208fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
141308fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1414e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
141508fb77edSStefan Weil  --enable-debug           enable common debug build options
141608fb77edSStefan Weil  --disable-strip          disable stripping binaries
141708fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
141863678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
141908fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
142008fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
142108fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
142208fb77edSStefan Weil  --block-drv-rw-whitelist=L
142308fb77edSStefan Weil                           set block driver read-write whitelist
142408fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
142508fb77edSStefan Weil  --block-drv-ro-whitelist=L
142608fb77edSStefan Weil                           set block driver read-only whitelist
142708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
14285b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1429c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
143008fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
143108fb77edSStefan Weil                           Default:trace-<pid>
1432c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1433c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1434c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1435c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
143608fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
143733c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
143808fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
143908fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1440c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1441c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1442c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1443a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1444c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1445c12d66aaSLin Ma  --enable-profiler        profiler support
1446c12d66aaSLin Ma  --enable-xen-pv-domain-build
1447c12d66aaSLin Ma                           xen pv domain builder
1448c12d66aaSLin Ma  --enable-debug-stack-usage
1449c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1450c23f23b9SMichael Tokarev
1451c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1452c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1453c23f23b9SMichael Tokarev
1454c23f23b9SMichael Tokarev  system          all system emulation targets
1455c23f23b9SMichael Tokarev  user            supported user emulation targets
1456c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1457c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1458c23f23b9SMichael Tokarev  docs            build documentation
1459c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1460c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1461c23f23b9SMichael Tokarev  pie             Position Independent Executables
1462c23f23b9SMichael Tokarev  modules         modules support
1463c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1464c23f23b9SMichael Tokarev  debug-info      debugging information
1465c23f23b9SMichael Tokarev  sparse          sparse checker
1466c23f23b9SMichael Tokarev
1467ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
146891bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
146991bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1470c23f23b9SMichael Tokarev  sdl             SDL UI
1471c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1472c23f23b9SMichael Tokarev  gtk             gtk UI
1473c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1474c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1475c23f23b9SMichael Tokarev  curses          curses UI
1476c23f23b9SMichael Tokarev  vnc             VNC UI support
1477c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1478c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1479c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1480c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1481c23f23b9SMichael Tokarev  virtfs          VirtFS
1482c23f23b9SMichael Tokarev  xen             xen backend driver support
1483c23f23b9SMichael Tokarev  xen-pci-passthrough
1484c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1485c23f23b9SMichael Tokarev  curl            curl connectivity
1486c23f23b9SMichael Tokarev  fdt             fdt device tree
1487c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1488c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1489b0cb0a66SVincent Palatin  hax             HAX acceleration support
1490c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1491c23f23b9SMichael Tokarev  vde             support for vde network
1492c23f23b9SMichael Tokarev  netmap          support for netmap network
1493c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1494c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1495c23f23b9SMichael Tokarev  attr            attr and xattr support
1496c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1497c23f23b9SMichael Tokarev  spice           spice
1498c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1499c23f23b9SMichael Tokarev  libiscsi        iscsi support
1500c23f23b9SMichael Tokarev  libnfs          nfs support
15017b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1502c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1503ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1504c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1505c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1506c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1507c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1508c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1509c23f23b9SMichael Tokarev  seccomp         seccomp support
1510c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1511c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1512c23f23b9SMichael Tokarev  tpm             TPM support
1513c23f23b9SMichael Tokarev  libssh2         ssh block device support
1514c23f23b9SMichael Tokarev  numa            libnuma support
1515c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
15167b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1517a6b1d4c0SChanglong Xie  replication     replication support
1518c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1519c12d66aaSLin Ma  opengl          opengl support
1520c12d66aaSLin Ma  virglrenderer   virgl rendering support
1521c12d66aaSLin Ma  xfsctl          xfsctl support
1522c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1523c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1524da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
1525f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1526e6a74868SMarc-André Lureau  vhost-user      vhost-user support
152708fb77edSStefan Weil
152808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1529af5db58eSpbrookEOF
15302d2ad6d0SFam Zhengexit 0
1531af5db58eSpbrookfi
1532af5db58eSpbrook
1533c53eeaf7SStefan Hajnocziif ! has $python; then
1534c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1535c53eeaf7SStefan Hajnoczifi
1536c53eeaf7SStefan Hajnoczi
1537c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1538c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1539c53eeaf7SStefan Hajnocziif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1540c53eeaf7SStefan Hajnoczi  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1541c53eeaf7SStefan Hajnoczi      "Note that Python 3 or later is not yet supported." \
1542c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1543c53eeaf7SStefan Hajnoczifi
1544c53eeaf7SStefan Hajnoczi
1545c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1546c53eeaf7SStefan Hajnoczipython="$python -B"
1547c53eeaf7SStefan Hajnoczi
1548359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1549359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1550359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1551359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1552359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1553359bc95dSPeter Maydell    else
155476ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1555359bc95dSPeter Maydell    fi
1556359bc95dSPeter Maydellfi
1557359bc95dSPeter Maydell
15589c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
15599c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
15609c83ffd8SPeter Maydellif test -z "$werror" ; then
15619c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1562e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
15639c83ffd8SPeter Maydell        werror="yes"
15649c83ffd8SPeter Maydell    else
15659c83ffd8SPeter Maydell        werror="no"
15669c83ffd8SPeter Maydell    fi
15679c83ffd8SPeter Maydellfi
15689c83ffd8SPeter Maydell
15698d05095cSPaolo Bonzini# check that the C compiler works.
157093b25869SJohn Snowwrite_c_skeleton;
15718d05095cSPaolo Bonziniif compile_object ; then
15728d05095cSPaolo Bonzini  : C compiler works ok
15738d05095cSPaolo Bonzinielse
157476ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
15758d05095cSPaolo Bonzinifi
15760ef74c74SPeter Maydellif ! compile_prog ; then
15770ef74c74SPeter Maydell    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
15780ef74c74SPeter Maydellfi
15798d05095cSPaolo Bonzini
1580fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1581fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1582fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1583fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1584fb59dabdSPeter Maydell    # host OS we should stop now.
1585951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1586fb59dabdSPeter Maydellfi
1587fb59dabdSPeter Maydell
15888d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
15898d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1590ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1591435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1592b98fcfd8SPaolo Bonzinigcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
159371429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
15946ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
15956ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
15966ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
15976ca026cbSPeter Maydell# so it's too error prone.
159893b25869SJohn Snow
159993b25869SJohn Snowcc_has_warning_flag() {
160093b25869SJohn Snow    write_c_skeleton;
160193b25869SJohn Snow
1602a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1603a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1604a1d29d6cSPeter Maydell    # warning options).
160593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
160693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
160793b25869SJohn Snow}
160893b25869SJohn Snow
160993b25869SJohn Snowfor flag in $gcc_flags; do
161093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16118d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16128d05095cSPaolo Bonzini    fi
16138d05095cSPaolo Bonzinidone
16148d05095cSPaolo Bonzini
161563678e17SSteven Noonanif test "$stack_protector" != "no"; then
1616fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1617fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1618fccd35a0SRodrigo Rebello{
1619fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1620fccd35a0SRodrigo Rebello    while (*c) {
1621fccd35a0SRodrigo Rebello        *p++ = *c++;
1622fccd35a0SRodrigo Rebello    }
1623fccd35a0SRodrigo Rebello    return 0;
1624fccd35a0SRodrigo Rebello}
1625fccd35a0SRodrigo RebelloEOF
162663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16273b463a3fSMiroslav Rezanina  sp_on=0
162863678e17SSteven Noonan  for flag in $gcc_flags; do
1629590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1630590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1631590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1632590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
163363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16343b463a3fSMiroslav Rezanina      sp_on=1
163563678e17SSteven Noonan      break
163663678e17SSteven Noonan    fi
163763678e17SSteven Noonan  done
16383b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
16393b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
16403b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
16413b463a3fSMiroslav Rezanina    fi
16423b463a3fSMiroslav Rezanina  fi
164337746c5eSMarc-André Lureaufi
164437746c5eSMarc-André Lureau
1645cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1646cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1647cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1648cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1649cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1650cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1651cbdd1999SPaolo Bonziniint main(void) { return 0; }
1652cbdd1999SPaolo Bonzini#else
1653cbdd1999SPaolo Bonzini#error No bug in this compiler.
1654cbdd1999SPaolo Bonzini#endif
1655cbdd1999SPaolo BonziniEOF
1656cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1657cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1658cbdd1999SPaolo Bonzinifi
1659cbdd1999SPaolo Bonzini
166040d6444eSAvi Kivityif test "$static" = "yes" ; then
1661aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1662aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1663aa0d1f44SPaolo Bonzini  fi
166440d6444eSAvi Kivity  if test "$pie" = "yes" ; then
166576ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
166640d6444eSAvi Kivity  else
166740d6444eSAvi Kivity    pie="no"
166840d6444eSAvi Kivity  fi
166940d6444eSAvi Kivityfi
167040d6444eSAvi Kivity
1671768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1672768b7855SEmilio G. Cota  cat > $TMPC << EOF
1673768b7855SEmilio G. Cotastatic __thread int tls_var;
1674768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1675768b7855SEmilio G. CotaEOF
1676768b7855SEmilio G. Cota
1677768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1678768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1679768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1680768b7855SEmilio G. Cotafi
1681768b7855SEmilio G. Cota
168240d6444eSAvi Kivityif test "$pie" = ""; then
168340d6444eSAvi Kivity  case "$cpu-$targetos" in
1684c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
168540d6444eSAvi Kivity      ;;
168640d6444eSAvi Kivity    *)
168740d6444eSAvi Kivity      pie="no"
168840d6444eSAvi Kivity      ;;
168940d6444eSAvi Kivity  esac
169040d6444eSAvi Kivityfi
169140d6444eSAvi Kivity
169240d6444eSAvi Kivityif test "$pie" != "no" ; then
169340d6444eSAvi Kivity  cat > $TMPC << EOF
169421d4a791SAvi Kivity
169521d4a791SAvi Kivity#ifdef __linux__
169621d4a791SAvi Kivity#  define THREAD __thread
169721d4a791SAvi Kivity#else
169821d4a791SAvi Kivity#  define THREAD
169921d4a791SAvi Kivity#endif
170021d4a791SAvi Kivity
170121d4a791SAvi Kivitystatic THREAD int tls_var;
170221d4a791SAvi Kivity
170321d4a791SAvi Kivityint main(void) { return tls_var; }
170421d4a791SAvi Kivity
170540d6444eSAvi KivityEOF
170640d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
170740d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
170840d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
170940d6444eSAvi Kivity    pie="yes"
171040d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
171140d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
171240d6444eSAvi Kivity    fi
171340d6444eSAvi Kivity  else
171440d6444eSAvi Kivity    if test "$pie" = "yes"; then
171576ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
171640d6444eSAvi Kivity    else
171740d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
171840d6444eSAvi Kivity      pie="no"
171940d6444eSAvi Kivity    fi
172040d6444eSAvi Kivity  fi
172146eef33bSBrad
1722e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
172346eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
172446eef33bSBrad    LDFLAGS_NOPIE="-nopie"
172546eef33bSBrad  fi
172640d6444eSAvi Kivityfi
172740d6444eSAvi Kivity
172809dada40SPaolo Bonzini##########################################
172909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
173009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
173109dada40SPaolo Bonzini# specification is necessary
173209dada40SPaolo Bonzini
173309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
173409dada40SPaolo Bonzini  cat > $TMPC << EOF
173509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
173609dada40SPaolo Bonzini{
173709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
173809dada40SPaolo Bonzini}
173909dada40SPaolo Bonzini
174009dada40SPaolo Bonziniint main(void)
174109dada40SPaolo Bonzini{
174209dada40SPaolo Bonzini  int val = 42;
17431405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
174409dada40SPaolo Bonzini  sfaa(&val);
174509dada40SPaolo Bonzini  return val;
174609dada40SPaolo Bonzini}
174709dada40SPaolo BonziniEOF
174809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
174909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
175009dada40SPaolo Bonzini  fi
175109dada40SPaolo Bonzinifi
175209dada40SPaolo Bonzini
175309dada40SPaolo Bonzini#########################################
1754ec530c81Sbellard# Solaris specific configure tool chain decisions
175509dada40SPaolo Bonzini
1756ec530c81Sbellardif test "$solaris" = "yes" ; then
17576792aa11SLoïc Minier  if has $install; then
17586792aa11SLoïc Minier    :
17596792aa11SLoïc Minier  else
176076ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
176176ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
176276ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1763ec530c81Sbellard  fi
176489138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
176576ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
176676ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
176776ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1768ec530c81Sbellard  fi
17696792aa11SLoïc Minier  if has ar; then
17706792aa11SLoïc Minier    :
17716792aa11SLoïc Minier  else
1772ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
177376ad07a4SPeter Maydell      error_exit "No path includes ar" \
177476ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1775ec530c81Sbellard    fi
177676ad07a4SPeter Maydell    error_exit "No path includes ar"
1777ec530c81Sbellard  fi
1778ec530c81Sbellardfi
1779ec530c81Sbellard
1780afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1781d880a3baSPaolo Bonzini    for target in $default_target_list; do
1782d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1783d880a3baSPaolo Bonzini            target_list="$target_list $target"
1784d880a3baSPaolo Bonzini    done
1785d880a3baSPaolo Bonzini    target_list="${target_list# }"
1786121afa9eSAnthony Liguorielse
178789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1788d880a3baSPaolo Bonzini    for target in $target_list; do
178925b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
179025b48338SPeter Maydell        # friendly error message than if we let it fall through.
179125b48338SPeter Maydell        case " $default_target_list " in
179225b48338SPeter Maydell            *" $target "*)
179325b48338SPeter Maydell                ;;
179425b48338SPeter Maydell            *)
179525b48338SPeter Maydell                error_exit "Unknown target name '$target'"
179625b48338SPeter Maydell                ;;
179725b48338SPeter Maydell        esac
1798d880a3baSPaolo Bonzini        supported_target $target || exit 1
179925b48338SPeter Maydell    done
1800d880a3baSPaolo Bonzinifi
180125b48338SPeter Maydell
1802f55fe278SPaolo Bonzini# see if system emulation was really requested
1803f55fe278SPaolo Bonzinicase " $target_list " in
1804f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1805f55fe278SPaolo Bonzini  ;;
1806f55fe278SPaolo Bonzini  *) softmmu=no
1807f55fe278SPaolo Bonzini  ;;
1808f55fe278SPaolo Bonziniesac
18095327cf48Sbellard
1810249247c9SJuan Quintelafeature_not_found() {
1811249247c9SJuan Quintela  feature=$1
181221684af0SStewart Smith  remedy=$2
1813249247c9SJuan Quintela
181476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
181521684af0SStewart Smith      "configure was not able to find it." \
181621684af0SStewart Smith      "$remedy"
1817249247c9SJuan Quintela}
1818249247c9SJuan Quintela
18197d13299dSbellard# ---
18207d13299dSbellard# big/little endian test
18217d13299dSbellardcat > $TMPC << EOF
182261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
182361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
182461cc919fSMike Frysingerextern int foo(short *, short *);
182561cc919fSMike Frysingerint main(int argc, char *argv[]) {
182661cc919fSMike Frysinger    return foo(big_endian, little_endian);
18277d13299dSbellard}
18287d13299dSbellardEOF
18297d13299dSbellard
183061cc919fSMike Frysingerif compile_object ; then
183161cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
183261cc919fSMike Frysinger        bigendian="yes"
183361cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
183461cc919fSMike Frysinger        bigendian="no"
18357d13299dSbellard    else
18367d13299dSbellard        echo big/little test failed
18377d13299dSbellard    fi
18387d13299dSbellardelse
183961cc919fSMike Frysinger    echo big/little test failed
18407d13299dSbellardfi
18417d13299dSbellard
1842b0a47e79SJuan Quintela##########################################
1843a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1844a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1845a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1846a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1847a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1848a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1849a30878e7SPeter Maydell    fi
1850a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1851a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1852a30878e7SPeter Maydell    fi
1853a30878e7SPeter Maydell    gtk=no
1854a30878e7SPeter Maydell    sdl=no
1855a30878e7SPeter Maydellfi
1856a30878e7SPeter Maydell
18576b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
18586b39b063SEric Blakecat > $TMPC << EOF
18596b39b063SEric Blake#include <stdint.h>
18606b39b063SEric Blake#include <stdio.h>
18616b39b063SEric Blakeint main(int argc, char *argv[]) {
18626b39b063SEric Blake    return printf("%zu", SIZE_MAX);
18636b39b063SEric Blake}
18646b39b063SEric BlakeEOF
18656b39b063SEric Blakehave_broken_size_max=no
18666b39b063SEric Blakeif ! compile_object -Werror ; then
18676b39b063SEric Blake    have_broken_size_max=yes
18686b39b063SEric Blakefi
18696b39b063SEric Blake
1870a30878e7SPeter Maydell##########################################
1871015a33bdSGonglei# L2TPV3 probe
1872015a33bdSGonglei
1873015a33bdSGongleicat > $TMPC <<EOF
1874015a33bdSGonglei#include <sys/socket.h>
1875bff6cb72SMichael Tokarev#include <linux/ip.h>
1876015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1877015a33bdSGongleiEOF
1878015a33bdSGongleiif compile_prog "" "" ; then
1879015a33bdSGonglei  l2tpv3=yes
1880015a33bdSGongleielse
1881015a33bdSGonglei  l2tpv3=no
1882015a33bdSGongleifi
1883015a33bdSGonglei
1884015a33bdSGonglei##########################################
18854d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
18864d9310f4SDaniel P. Berrange
18874d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
18884d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
18894d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
18904d9310f4SDaniel P. Berrange    #
18914d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
18924d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
18934d9310f4SDaniel P. Berrange    #
18944d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
18954d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
18964d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
18974d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
18984d9310f4SDaniel P. Berrange    # that for you.
18994d9310f4SDaniel P. Berrange    #
19004d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
19014d9310f4SDaniel P. Berrange    # are not in fact redundant.
19024d9310f4SDaniel P. Berrangecat > $TMPC << EOF
19034d9310f4SDaniel P. Berrange#include <unistd.h>
19044d9310f4SDaniel P. Berrange#include <time.h>
19054d9310f4SDaniel P. Berrange#undef localtime_r
19064d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
19074d9310f4SDaniel P. BerrangeEOF
19084d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
19094d9310f4SDaniel P. Berrange        localtime_r="yes"
19104d9310f4SDaniel P. Berrange    else
19114d9310f4SDaniel P. Berrange        localtime_r="no"
19124d9310f4SDaniel P. Berrange    fi
19134d9310f4SDaniel P. Berrangefi
19144d9310f4SDaniel P. Berrange
19154d9310f4SDaniel P. Berrange##########################################
1916779ab5e3SStefan Weil# pkg-config probe
1917779ab5e3SStefan Weil
1918779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
191976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1920779ab5e3SStefan Weilfi
1921779ab5e3SStefan Weil
1922779ab5e3SStefan Weil##########################################
1923b0a47e79SJuan Quintela# NPTL probe
1924b0a47e79SJuan Quintela
192524cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1926bd0c5661Spbrook  cat > $TMPC <<EOF
1927bd0c5661Spbrook#include <sched.h>
192830813ceaSpbrook#include <linux/futex.h>
1929182eacc0SStefan Weilint main(void) {
1930bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1931bd0c5661Spbrook#error bork
1932bd0c5661Spbrook#endif
1933182eacc0SStefan Weil  return 0;
1934bd0c5661Spbrook}
1935bd0c5661SpbrookEOF
193624cb36a6SPeter Maydell  if ! compile_object ; then
193721684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1938b0a47e79SJuan Quintela  fi
1939bd0c5661Spbrookfi
1940bd0c5661Spbrook
194199f2dbd3SLiang Li#########################################
1942ac62922eSbalrog# zlib check
1943ac62922eSbalrog
19441ece9905SAlon Levyif test "$zlib" != "no" ; then
1945ac62922eSbalrog    cat > $TMPC << EOF
1946ac62922eSbalrog#include <zlib.h>
1947ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1948ac62922eSbalrogEOF
194952166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1950ac62922eSbalrog        :
1951ac62922eSbalrog    else
195276ad07a4SPeter Maydell        error_exit "zlib check failed" \
195376ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1954ac62922eSbalrog    fi
19551ece9905SAlon Levyfi
1956eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1957ac62922eSbalrog
1958ac62922eSbalrog##########################################
1959607dacd0Sqiaonuohan# lzo check
1960607dacd0Sqiaonuohan
1961607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1962607dacd0Sqiaonuohan    cat > $TMPC << EOF
1963607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1964607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1965607dacd0SqiaonuohanEOF
1966607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1967607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
1968b25c9dffSStefan Weil        lzo="yes"
1969b25c9dffSStefan Weil    else
1970b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
1971b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
1972b25c9dffSStefan Weil        fi
1973b25c9dffSStefan Weil        lzo="no"
1974b25c9dffSStefan Weil    fi
1975607dacd0Sqiaonuohanfi
1976607dacd0Sqiaonuohan
1977607dacd0Sqiaonuohan##########################################
1978607dacd0Sqiaonuohan# snappy check
1979607dacd0Sqiaonuohan
1980607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1981607dacd0Sqiaonuohan    cat > $TMPC << EOF
1982607dacd0Sqiaonuohan#include <snappy-c.h>
1983607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1984607dacd0SqiaonuohanEOF
1985607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1986607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
1987b25c9dffSStefan Weil        snappy="yes"
1988b25c9dffSStefan Weil    else
1989b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
1990b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
1991b25c9dffSStefan Weil        fi
1992b25c9dffSStefan Weil        snappy="no"
1993b25c9dffSStefan Weil    fi
1994607dacd0Sqiaonuohanfi
1995607dacd0Sqiaonuohan
1996607dacd0Sqiaonuohan##########################################
19976b383c08SPeter Wu# bzip2 check
19986b383c08SPeter Wu
19996b383c08SPeter Wuif test "$bzip2" != "no" ; then
20006b383c08SPeter Wu    cat > $TMPC << EOF
20016b383c08SPeter Wu#include <bzlib.h>
20026b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
20036b383c08SPeter WuEOF
20046b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
20056b383c08SPeter Wu        bzip2="yes"
20066b383c08SPeter Wu    else
20076b383c08SPeter Wu        if test "$bzip2" = "yes"; then
20086b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
20096b383c08SPeter Wu        fi
20106b383c08SPeter Wu        bzip2="no"
20116b383c08SPeter Wu    fi
20126b383c08SPeter Wufi
20136b383c08SPeter Wu
20146b383c08SPeter Wu##########################################
2015f794573eSEduardo Otubo# libseccomp check
2016f794573eSEduardo Otubo
2017f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2018693e5910SAndrew Jones    case "$cpu" in
2019693e5910SAndrew Jones    i386|x86_64)
2020ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2021693e5910SAndrew Jones        ;;
20225ce43972SJames Hogan    mips)
20235ce43972SJames Hogan        libseccomp_minver="2.2.0"
20245ce43972SJames Hogan        ;;
2025693e5910SAndrew Jones    arm|aarch64)
2026693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2027693e5910SAndrew Jones        ;;
20283aa35fcfSThomas Huth    ppc|ppc64|s390x)
20293e684455SMichael Strosaker        libseccomp_minver="2.3.0"
20303e684455SMichael Strosaker        ;;
2031693e5910SAndrew Jones    *)
2032693e5910SAndrew Jones        libseccomp_minver=""
2033693e5910SAndrew Jones        ;;
2034693e5910SAndrew Jones    esac
2035693e5910SAndrew Jones
2036693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2037693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2038c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2039c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2040f794573eSEduardo Otubo        seccomp="yes"
2041f794573eSEduardo Otubo    else
2042f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2043693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2044693e5910SAndrew Jones                feature_not_found "libseccomp" \
2045693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2046693e5910SAndrew Jones            else
2047693e5910SAndrew Jones                feature_not_found "libseccomp" \
2048693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2049693e5910SAndrew Jones            fi
2050896848f0SEduardo Otubo        fi
2051e84d5956SYann E. MORIN        seccomp="no"
2052f794573eSEduardo Otubo    fi
2053f794573eSEduardo Otubofi
2054f794573eSEduardo Otubo##########################################
2055e37630caSaliguori# xen probe
2056e37630caSaliguori
2057fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2058c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2059c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2060c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2061c1cdd9d5SJuergen Gross
2062c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2063c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2064c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2065c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2066c1cdd9d5SJuergen Gross    xen=yes
2067c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2068c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
2069c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2070c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2071c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2072c1cdd9d5SJuergen Gross  else
2073c1cdd9d5SJuergen Gross
2074b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2075d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2076d5b93ddfSAnthony PERARD
207750ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
207850ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
207950ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
208050ced5b3SStefan Weil
208150ced5b3SStefan Weil    # Xen (any)
208250ced5b3SStefan Weil    cat > $TMPC <<EOF
208350ced5b3SStefan Weil#include <xenctrl.h>
208450ced5b3SStefan Weilint main(void) {
208550ced5b3SStefan Weil  return 0;
208650ced5b3SStefan Weil}
208750ced5b3SStefan WeilEOF
208850ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
208950ced5b3SStefan Weil      # Xen not found
209050ced5b3SStefan Weil      if test "$xen" = "yes" ; then
209121684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
209250ced5b3SStefan Weil      fi
209350ced5b3SStefan Weil      xen=no
209450ced5b3SStefan Weil
2095d5b93ddfSAnthony PERARD    # Xen unstable
209669deef08SPeter Maydell    elif
209769deef08SPeter Maydell        cat > $TMPC <<EOF &&
20985ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
20995ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
21005ba3d756SIgor Druzhininint main(void) {
21015ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
21025ba3d756SIgor Druzhinin
21035ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
21045ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
21055ba3d756SIgor Druzhinin
21065ba3d756SIgor Druzhinin  return 0;
21075ba3d756SIgor Druzhinin}
21085ba3d756SIgor DruzhininEOF
21095ba3d756SIgor Druzhinin        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
21105ba3d756SIgor Druzhinin      then
21115ba3d756SIgor Druzhinin      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
21125ba3d756SIgor Druzhinin      xen_ctrl_version=41000
21135ba3d756SIgor Druzhinin      xen=yes
21145ba3d756SIgor Druzhinin    elif
21155ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2116da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2117da8090ccSPaul Durrant#define __XEN_TOOLS__
2118da8090ccSPaul Durrant#include <xendevicemodel.h>
2119da8090ccSPaul Durrantint main(void) {
2120da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2121da8090ccSPaul Durrant
2122da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2123da8090ccSPaul Durrant  xendevicemodel_close(xd);
2124da8090ccSPaul Durrant
2125da8090ccSPaul Durrant  return 0;
2126da8090ccSPaul Durrant}
2127da8090ccSPaul DurrantEOF
2128da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2129da8090ccSPaul Durrant      then
2130da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2131f1167ee6SJuergen Gross      xen_ctrl_version=40900
2132da8090ccSPaul Durrant      xen=yes
2133da8090ccSPaul Durrant    elif
2134da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
21355eeb39c2SIan Campbell/*
21365eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
21375eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2138b6eb9b45SPaulina Szubarczyk *
2139b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2140b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2141b6eb9b45SPaulina Szubarczyk */
2142b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2143b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2144b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2145b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2146b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2147b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2148b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2149b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2150b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2151b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2152b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2153b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2154b6eb9b45SPaulina Szubarczyk#endif
2155b6eb9b45SPaulina Szubarczykint main(void) {
2156b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2157b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2158b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2159b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2160b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2161b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2162b6eb9b45SPaulina Szubarczyk
2163b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2164b6eb9b45SPaulina Szubarczyk
2165b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2166b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2167b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2168b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2169b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2170b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2171b6eb9b45SPaulina Szubarczyk
2172b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2173b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2174b6eb9b45SPaulina Szubarczyk
2175b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2176b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2177b6eb9b45SPaulina Szubarczyk
2178b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2179b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2180b6eb9b45SPaulina Szubarczyk
2181b6eb9b45SPaulina Szubarczyk  return 0;
2182b6eb9b45SPaulina Szubarczyk}
2183b6eb9b45SPaulina SzubarczykEOF
2184b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2185b6eb9b45SPaulina Szubarczyk      then
2186f1167ee6SJuergen Gross      xen_ctrl_version=40800
2187b6eb9b45SPaulina Szubarczyk      xen=yes
2188b6eb9b45SPaulina Szubarczyk    elif
2189b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2190b6eb9b45SPaulina Szubarczyk/*
2191b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2192b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
21935eeb39c2SIan Campbell */
21945eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
21955eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
21965eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21975eeb39c2SIan Campbell#include <xenctrl.h>
21985eeb39c2SIan Campbell#include <xenstore.h>
21995eeb39c2SIan Campbell#include <xenevtchn.h>
22005eeb39c2SIan Campbell#include <xengnttab.h>
22015eeb39c2SIan Campbell#include <xenforeignmemory.h>
22025eeb39c2SIan Campbell#include <stdint.h>
22035eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
22045eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
22055eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
22065eeb39c2SIan Campbell#endif
22075eeb39c2SIan Campbellint main(void) {
22085eeb39c2SIan Campbell  xc_interface *xc = NULL;
22095eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
22105eeb39c2SIan Campbell  xenevtchn_handle *xe;
22115eeb39c2SIan Campbell  xengnttab_handle *xg;
22125eeb39c2SIan Campbell  xen_domain_handle_t handle;
22135eeb39c2SIan Campbell
22145eeb39c2SIan Campbell  xs_daemon_open();
22155eeb39c2SIan Campbell
22165eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
22175eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
22185eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22195eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22205eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
22215eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
22225eeb39c2SIan Campbell
22235eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
22245eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
22255eeb39c2SIan Campbell
22265eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
22275eeb39c2SIan Campbell  xenevtchn_fd(xe);
22285eeb39c2SIan Campbell
22295eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
22305eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
22315eeb39c2SIan Campbell
22325eeb39c2SIan Campbell  return 0;
22335eeb39c2SIan Campbell}
22345eeb39c2SIan CampbellEOF
22355eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
22365eeb39c2SIan Campbell      then
2237f1167ee6SJuergen Gross      xen_ctrl_version=40701
22385eeb39c2SIan Campbell      xen=yes
22395eeb39c2SIan Campbell    elif
22405eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2241e37630caSaliguori#include <xenctrl.h>
2242cdadde39SRoger Pau Monne#include <stdint.h>
2243cdadde39SRoger Pau Monneint main(void) {
2244cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2245cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2246cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2247cdadde39SRoger Pau Monne  return 0;
2248cdadde39SRoger Pau Monne}
2249cdadde39SRoger Pau MonneEOF
2250cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2251cdadde39SRoger Pau Monne      then
2252f1167ee6SJuergen Gross      xen_ctrl_version=40700
2253cdadde39SRoger Pau Monne      xen=yes
2254cdadde39SRoger Pau Monne
2255cdadde39SRoger Pau Monne    # Xen 4.6
2256cdadde39SRoger Pau Monne    elif
2257cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2258cdadde39SRoger Pau Monne#include <xenctrl.h>
2259e108a3c1SAnthony PERARD#include <xenstore.h>
2260d5b93ddfSAnthony PERARD#include <stdint.h>
2261d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2262d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2263d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2264d5b93ddfSAnthony PERARD#endif
2265d5b93ddfSAnthony PERARDint main(void) {
2266d5b93ddfSAnthony PERARD  xc_interface *xc;
2267d5b93ddfSAnthony PERARD  xs_daemon_open();
2268d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2269d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2270d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2271b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22728688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2273d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
227420a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2275d8b441a3SJan Beulich  return 0;
2276d8b441a3SJan Beulich}
2277d8b441a3SJan BeulichEOF
2278d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2279d8b441a3SJan Beulich      then
2280f1167ee6SJuergen Gross      xen_ctrl_version=40600
2281d8b441a3SJan Beulich      xen=yes
2282d8b441a3SJan Beulich
2283d8b441a3SJan Beulich    # Xen 4.5
2284d8b441a3SJan Beulich    elif
2285d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2286d8b441a3SJan Beulich#include <xenctrl.h>
2287d8b441a3SJan Beulich#include <xenstore.h>
2288d8b441a3SJan Beulich#include <stdint.h>
2289d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2290d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2291d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2292d8b441a3SJan Beulich#endif
2293d8b441a3SJan Beulichint main(void) {
2294d8b441a3SJan Beulich  xc_interface *xc;
2295d8b441a3SJan Beulich  xs_daemon_open();
2296d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2297d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2298d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2299d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2300d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23013996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
23023996e85cSPaul Durrant  return 0;
23033996e85cSPaul Durrant}
23043996e85cSPaul DurrantEOF
23053996e85cSPaul Durrant        compile_prog "" "$xen_libs"
23063996e85cSPaul Durrant      then
2307f1167ee6SJuergen Gross      xen_ctrl_version=40500
23083996e85cSPaul Durrant      xen=yes
23093996e85cSPaul Durrant
23103996e85cSPaul Durrant    elif
23113996e85cSPaul Durrant        cat > $TMPC <<EOF &&
23123996e85cSPaul Durrant#include <xenctrl.h>
23133996e85cSPaul Durrant#include <xenstore.h>
23143996e85cSPaul Durrant#include <stdint.h>
23153996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
23163996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
23173996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
23183996e85cSPaul Durrant#endif
23193996e85cSPaul Durrantint main(void) {
23203996e85cSPaul Durrant  xc_interface *xc;
23213996e85cSPaul Durrant  xs_daemon_open();
23223996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
23233996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
23243996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
23253996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23263996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23278688e065SStefano Stabellini  return 0;
23288688e065SStefano Stabellini}
23298688e065SStefano StabelliniEOF
23308688e065SStefano Stabellini        compile_prog "" "$xen_libs"
233169deef08SPeter Maydell      then
2332f1167ee6SJuergen Gross      xen_ctrl_version=40200
23338688e065SStefano Stabellini      xen=yes
23348688e065SStefano Stabellini
2335e37630caSaliguori    else
2336fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2337edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2338edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2339fc321b4bSJuan Quintela      fi
2340fc321b4bSJuan Quintela      xen=no
2341e37630caSaliguori    fi
2342d5b93ddfSAnthony PERARD
2343d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2344f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
23455eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
23465eeb39c2SIan Campbell      fi
2347d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2348d5b93ddfSAnthony PERARD    fi
2349e37630caSaliguori  fi
2350c1cdd9d5SJuergen Grossfi
2351e37630caSaliguori
2352eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2353edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2354eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2355eb6fda0fSAnthony PERARD  else
2356eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
235776ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
235876ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2359eb6fda0fSAnthony PERARD    fi
2360eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2361eb6fda0fSAnthony PERARD  fi
2362eb6fda0fSAnthony PERARDfi
2363eb6fda0fSAnthony PERARD
236464a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
236564a7ad6fSIan Campbell   test "$xen" != "yes"; then
236664a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
236764a7ad6fSIan Campbell	       "which requires Xen support."
236864a7ad6fSIan Campbellfi
236964a7ad6fSIan Campbell
2370e37630caSaliguori##########################################
2371dfffc653SJuan Quintela# Sparse probe
2372dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
23730dba6195SLoïc Minier  if has cgcc; then
2374dfffc653SJuan Quintela    sparse=yes
2375dfffc653SJuan Quintela  else
2376dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
237721684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2378dfffc653SJuan Quintela    fi
2379dfffc653SJuan Quintela    sparse=no
2380dfffc653SJuan Quintela  fi
2381dfffc653SJuan Quintelafi
2382dfffc653SJuan Quintela
2383dfffc653SJuan Quintela##########################################
2384f676c67eSJeremy White# X11 probe
2385f676c67eSJeremy Whitex11_cflags=
2386f676c67eSJeremy Whitex11_libs=-lX11
2387f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
238889138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
238989138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2390f676c67eSJeremy Whitefi
2391f676c67eSJeremy White
2392f676c67eSJeremy White##########################################
2393a4ccabcfSAnthony Liguori# GTK probe
2394a4ccabcfSAnthony Liguori
23959e04c683SStefan Weilif test "$gtkabi" = ""; then
23965fe309ffSGerd Hoffmann    # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
23975fe309ffSGerd Hoffmann    # Use 2.0 as a fallback if that is available.
23985fe309ffSGerd Hoffmann    if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
23999e04c683SStefan Weil        gtkabi=3.0
24005fe309ffSGerd Hoffmann    elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
24019e04c683SStefan Weil        gtkabi=2.0
24025fe309ffSGerd Hoffmann    else
24035fe309ffSGerd Hoffmann        gtkabi=3.0
24049e04c683SStefan Weil    fi
24059e04c683SStefan Weilfi
24069e04c683SStefan Weil
2407a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2408528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
24090a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2410528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2411528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2412bbbf9bfbSStefan Weil    else
2413bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2414bbbf9bfbSStefan Weil    fi
2415bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
241689138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
241789138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
241889138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
24190a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2420f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2421f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
24220a337ed0SGerd Hoffmann        fi
2423bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2424bbbf9bfbSStefan Weil        gtk="yes"
2425bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
24265fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2427bbbf9bfbSStefan Weil    else
2428bbbf9bfbSStefan Weil        gtk="no"
2429bbbf9bfbSStefan Weil    fi
2430bbbf9bfbSStefan Weilfi
2431bbbf9bfbSStefan Weil
2432ddbb0d09SDaniel P. Berrange
2433ddbb0d09SDaniel P. Berrange##########################################
2434ddbb0d09SDaniel P. Berrange# GNUTLS probe
2435ddbb0d09SDaniel P. Berrange
243637371299SPeter Maydellgnutls_works() {
243737371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
243837371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
243937371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
244037371299SPeter Maydell    # builds doesn't work:
244137371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
244237371299SPeter Maydell    #
244337371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
244437371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
244537371299SPeter Maydell        return 1
244637371299SPeter Maydell    fi
244737371299SPeter Maydell
244837371299SPeter Maydell    write_c_skeleton
244937371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
245037371299SPeter Maydell}
245137371299SPeter Maydell
245262893b67SDaniel P. Berrangegnutls_gcrypt=no
2453ed754746SDaniel P. Berrangegnutls_nettle=no
2454ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
245537371299SPeter Maydell    if gnutls_works; then
245689138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
245789138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2458ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2459ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2460ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2461ddbb0d09SDaniel P. Berrange        gnutls="yes"
2462ddbb0d09SDaniel P. Berrange
2463b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2464b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2465b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2466b917da4cSDaniel P. Berrange	else
2467b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2468b917da4cSDaniel P. Berrange	fi
2469b917da4cSDaniel P. Berrange
247062893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
247162893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2472ed754746SDaniel P. Berrange	    gnutls_nettle=yes
247362893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
247489138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2475ed754746SDaniel P. Berrange		*gcrypt*)
2476ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2477ed754746SDaniel P. Berrange		    gnutls_nettle=no
2478ed754746SDaniel P. Berrange		    ;;
2479ed754746SDaniel P. Berrange		*nettle*)
2480ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2481ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2482ed754746SDaniel P. Berrange		    ;;
2483ed754746SDaniel P. Berrange		*)
2484ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2485ed754746SDaniel P. Berrange		    gnutls_nettle=no
2486ed754746SDaniel P. Berrange		    ;;
248762893b67SDaniel P. Berrange	    esac
248862893b67SDaniel P. Berrange	else
248962893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2490ed754746SDaniel P. Berrange	    gnutls_nettle=no
249162893b67SDaniel P. Berrange	fi
2492ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2493ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2494ddbb0d09SDaniel P. Berrange    else
2495ddbb0d09SDaniel P. Berrange        gnutls="no"
2496b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2497ddbb0d09SDaniel P. Berrange    fi
2498ddbb0d09SDaniel P. Berrangeelse
2499b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2500ddbb0d09SDaniel P. Berrangefi
2501ddbb0d09SDaniel P. Berrange
250291bfcdb0SDaniel P. Berrange
250391bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
250491bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
250591bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
250691bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
250791bfcdb0SDaniel P. Berrangethen
250891bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
250991bfcdb0SDaniel P. Berrange    then
251091bfcdb0SDaniel P. Berrange        gcrypt="no"
251191bfcdb0SDaniel P. Berrange    fi
251291bfcdb0SDaniel P. Berrangefi
251391bfcdb0SDaniel P. Berrange
251491bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
251591bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
251691bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
251791bfcdb0SDaniel P. Berrangeif test -z "$nettle"
251891bfcdb0SDaniel P. Berrangethen
251991bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
252091bfcdb0SDaniel P. Berrange    then
252191bfcdb0SDaniel P. Berrange        nettle="no"
252291bfcdb0SDaniel P. Berrange    fi
252391bfcdb0SDaniel P. Berrangefi
252491bfcdb0SDaniel P. Berrange
252591bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
252691bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
252791bfcdb0SDaniel P. Berrange    then
252891bfcdb0SDaniel P. Berrange	return 1
252991bfcdb0SDaniel P. Berrange    fi
253091bfcdb0SDaniel P. Berrange
253191bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
253291bfcdb0SDaniel P. Berrange    then
253389138857SStefan Weil	host=$(libgcrypt-config --host)
253491bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
253591bfcdb0SDaniel P. Berrange	then
253691bfcdb0SDaniel P. Berrange	    return 1
253791bfcdb0SDaniel P. Berrange	fi
253891bfcdb0SDaniel P. Berrange    fi
253991bfcdb0SDaniel P. Berrange
254091bfcdb0SDaniel P. Berrange    return 0
254191bfcdb0SDaniel P. Berrange}
254291bfcdb0SDaniel P. Berrange
254391bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
254491bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
254589138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
254689138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
254791bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
254891bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
254991bfcdb0SDaniel P. Berrange        # turn breaks static builds...
255091bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
255191bfcdb0SDaniel P. Berrange        then
255291bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
255391bfcdb0SDaniel P. Berrange        fi
255462893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
255562893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
255662893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
255791bfcdb0SDaniel P. Berrange        gcrypt="yes"
255891bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
255991bfcdb0SDaniel P. Berrange           nettle="no"
256091bfcdb0SDaniel P. Berrange        fi
256137788f25SDaniel P. Berrange
256237788f25SDaniel P. Berrange        cat > $TMPC << EOF
256337788f25SDaniel P. Berrange#include <gcrypt.h>
256437788f25SDaniel P. Berrangeint main(void) {
256537788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
256637788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
256737788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
256837788f25SDaniel P. Berrange return 0;
256937788f25SDaniel P. Berrange}
257037788f25SDaniel P. BerrangeEOF
257137788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
257237788f25SDaniel P. Berrange            gcrypt_kdf=yes
257337788f25SDaniel P. Berrange        fi
25741f923c70SLongpeng(Mike)
25751f923c70SLongpeng(Mike)        cat > $TMPC << EOF
25761f923c70SLongpeng(Mike)#include <gcrypt.h>
25771f923c70SLongpeng(Mike)int main(void) {
25781f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
25791f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
25801f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
25811f923c70SLongpeng(Mike)  return 0;
25821f923c70SLongpeng(Mike)}
25831f923c70SLongpeng(Mike)EOF
25841f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
25851f923c70SLongpeng(Mike)            gcrypt_hmac=yes
25861f923c70SLongpeng(Mike)        fi
258762893b67SDaniel P. Berrange    else
258891bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
258962893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
259091bfcdb0SDaniel P. Berrange        else
259191bfcdb0SDaniel P. Berrange            gcrypt="no"
259291bfcdb0SDaniel P. Berrange        fi
259362893b67SDaniel P. Berrange    fi
259462893b67SDaniel P. Berrangefi
259562893b67SDaniel P. Berrange
2596ddbb0d09SDaniel P. Berrange
259791bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2598ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
259989138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
260089138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
260189138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2602ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2603ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2604ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
260591bfcdb0SDaniel P. Berrange        nettle="yes"
2606fff2f982SDaniel P. Berrange
2607fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
26089e87a691SSteven Luo#include <stddef.h>
2609fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2610fff2f982SDaniel P. Berrangeint main(void) {
2611fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2612fff2f982SDaniel P. Berrange     return 0;
2613fff2f982SDaniel P. Berrange}
2614fff2f982SDaniel P. BerrangeEOF
2615fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2616fff2f982SDaniel P. Berrange            nettle_kdf=yes
2617fff2f982SDaniel P. Berrange        fi
2618ed754746SDaniel P. Berrange    else
261991bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2620ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
262191bfcdb0SDaniel P. Berrange        else
262291bfcdb0SDaniel P. Berrange            nettle="no"
2623ed754746SDaniel P. Berrange        fi
2624ed754746SDaniel P. Berrange    fi
262591bfcdb0SDaniel P. Berrangefi
262691bfcdb0SDaniel P. Berrange
262791bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
262891bfcdb0SDaniel P. Berrangethen
262991bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
263091bfcdb0SDaniel P. Berrangefi
2631ed754746SDaniel P. Berrange
26329a2fd434SDaniel P. Berrange##########################################
26339a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
26349a2fd434SDaniel P. Berrange
26359a2fd434SDaniel P. Berrangetasn1=yes
263690246037SDaniel P. Berrangetasn1_cflags=""
263790246037SDaniel P. Berrangetasn1_libs=""
26389a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
263989138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
264089138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
26419a2fd434SDaniel P. Berrangeelse
26429a2fd434SDaniel P. Berrange    tasn1=no
26439a2fd434SDaniel P. Berrangefi
26449a2fd434SDaniel P. Berrange
2645ed754746SDaniel P. Berrange
2646bbbf9bfbSStefan Weil##########################################
2647559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2648559607eaSDaniel P. Berrange
2649559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2650559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2651559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2652559607eaSDaniel P. Berrangefi
2653559607eaSDaniel P. Berrange
2654559607eaSDaniel P. Berrange##########################################
2655bbbf9bfbSStefan Weil# VTE probe
2656bbbf9bfbSStefan Weil
2657bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2658bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2659c6feff9eSCole Robinson      vteminversion="0.32.0"
2660c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2661c6feff9eSCole Robinson        vtepackage="vte-2.91"
2662c6feff9eSCole Robinson      else
2663528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2664c6feff9eSCole Robinson      fi
2665528de90aSDaniel P. Berrange    else
2666528de90aSDaniel P. Berrange      vtepackage="vte"
2667c6feff9eSCole Robinson      vteminversion="0.24.0"
2668528de90aSDaniel P. Berrange    fi
2669c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
267089138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
267189138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
267289138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2673bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2674bbbf9bfbSStefan Weil        vte="yes"
2675bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
26769e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2677c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
26789e04c683SStefan Weil        else
26799e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
26809e04c683SStefan Weil        fi
2681bbbf9bfbSStefan Weil    else
2682bbbf9bfbSStefan Weil        vte="no"
2683a4ccabcfSAnthony Liguori    fi
2684a4ccabcfSAnthony Liguorifi
2685a4ccabcfSAnthony Liguori
2686a4ccabcfSAnthony Liguori##########################################
268711d9f695Sbellard# SDL probe
268811d9f695Sbellard
26893ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
26903ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
269147c03744SDave Airlie
2692ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
26938f4ea9cdSGerd Hoffmann    if $pkg_config --exists "sdl2"; then
2694ee8466d0SCole Robinson        sdlabi=2.0
26958f4ea9cdSGerd Hoffmann    elif $pkg_config --exists "sdl"; then
2696ee8466d0SCole Robinson        sdlabi=1.2
26978f4ea9cdSGerd Hoffmann    else
26988f4ea9cdSGerd Hoffmann        sdlabi=2.0
2699ee8466d0SCole Robinson    fi
2700ee8466d0SCole Robinsonfi
2701ee8466d0SCole Robinson
270247c03744SDave Airlieif test $sdlabi = "2.0"; then
270347c03744SDave Airlie    sdl_config=$sdl2_config
270447c03744SDave Airlie    sdlname=sdl2
270547c03744SDave Airlie    sdlconfigname=sdl2_config
2706e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
270747c03744SDave Airlie    sdlname=sdl
270847c03744SDave Airlie    sdlconfigname=sdl_config
2709e07047cfSCole Robinsonelse
2710e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
27113ec87ffeSPaolo Bonzinifi
27123ec87ffeSPaolo Bonzini
271389138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
271447c03744SDave Airlie  sdl_config=$sdlconfigname
271547c03744SDave Airliefi
271647c03744SDave Airlie
271747c03744SDave Airlieif $pkg_config $sdlname --exists; then
271847c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
271989138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
27203ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
27213ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
272289138857SStefan Weil  sdlversion=$($sdlconfig --version)
2723a0dfd8a4SLoïc Minierelse
2724a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
27258f4ea9cdSGerd Hoffmann    feature_not_found "sdl" "Install SDL2-devel"
2726a0dfd8a4SLoïc Minier  fi
2727a0dfd8a4SLoïc Minier  sdl=no
27289316f803SPaolo Bonzinifi
272929e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
27303ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
27313ec87ffeSPaolo Bonzinifi
273211d9f695Sbellard
27339316f803SPaolo Bonzinisdl_too_old=no
2734c4198157SJuan Quintelaif test "$sdl" != "no" ; then
273511d9f695Sbellard  cat > $TMPC << EOF
273611d9f695Sbellard#include <SDL.h>
273711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
273811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
273911d9f695SbellardEOF
274089138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
274174f42e18STeLeMan  if test "$static" = "yes" ; then
27425f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
27435f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
27445f37e6d4SThomas Huth    else
274589138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
27465f37e6d4SThomas Huth    fi
274774f42e18STeLeMan  else
274889138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
274974f42e18STeLeMan  fi
275052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
275189138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
275211d9f695Sbellard      sdl_too_old=yes
275311d9f695Sbellard    else
275411d9f695Sbellard      sdl=yes
275511d9f695Sbellard    fi
27567c1f25b4Sbellard
275767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
27581ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
275967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
276089138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
276189138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
276211d9f695Sbellard      fi
276352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
27641ac88f28SJuan Quintela	:
27651ac88f28SJuan Quintela      else
27661ac88f28SJuan Quintela        sdl=no
27677c1f25b4Sbellard      fi
27687c1f25b4Sbellard    fi # static link
2769c4198157SJuan Quintela  else # sdl not found
2770c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
277121684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2772c4198157SJuan Quintela    fi
2773c4198157SJuan Quintela    sdl=no
27747c1f25b4Sbellard  fi # sdl compile test
2775fd677642Sthsfi
277611d9f695Sbellard
27775368a422Saliguoriif test "$sdl" = "yes" ; then
27785368a422Saliguori  cat > $TMPC <<EOF
27795368a422Saliguori#include <SDL.h>
27805368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
27815368a422Saliguori#include <X11/XKBlib.h>
27825368a422Saliguori#else
27835368a422Saliguori#error No x11 support
27845368a422Saliguori#endif
27855368a422Saliguoriint main(void) { return 0; }
27865368a422SaliguoriEOF
2787f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2788f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2789f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
27905368a422Saliguori  fi
27915368a422Saliguorifi
27925368a422Saliguori
27938f28f3fbSths##########################################
27942da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
27952da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
27962da776dbSMichael R. Hines  cat > $TMPC <<EOF
27972da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
27982da776dbSMichael R. Hinesint main(void) { return 0; }
27992da776dbSMichael R. HinesEOF
28002da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
28012da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28022da776dbSMichael R. Hines    rdma="yes"
28032da776dbSMichael R. Hines  else
28042da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28052da776dbSMichael R. Hines        error_exit \
28062da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28072da776dbSMichael R. Hines            " Your options:" \
28082da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28092da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28102da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28112da776dbSMichael R. Hines    fi
28122da776dbSMichael R. Hines    rdma="no"
28132da776dbSMichael R. Hines  fi
28142da776dbSMichael R. Hinesfi
28152da776dbSMichael R. Hines
281695c6bff3SBenoît Canet
281795c6bff3SBenoît Canet##########################################
28182f9606b3Saliguori# VNC SASL detection
2819821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
28202f9606b3Saliguori  cat > $TMPC <<EOF
28212f9606b3Saliguori#include <sasl/sasl.h>
28222f9606b3Saliguori#include <stdio.h>
28232f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
28242f9606b3SaliguoriEOF
28252f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
28262f9606b3Saliguori  vnc_sasl_cflags=""
28272f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
282852166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2829ea784e3bSJuan Quintela    vnc_sasl=yes
2830fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2831ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
28322f9606b3Saliguori  else
2833ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
283421684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2835ea784e3bSJuan Quintela    fi
2836ea784e3bSJuan Quintela    vnc_sasl=no
28372f9606b3Saliguori  fi
28382f9606b3Saliguorifi
28392f9606b3Saliguori
28402f9606b3Saliguori##########################################
28412f6f5c7aSCorentin Chary# VNC JPEG detection
2842821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
28432f6f5c7aSCorentin Charycat > $TMPC <<EOF
28442f6f5c7aSCorentin Chary#include <stdio.h>
28452f6f5c7aSCorentin Chary#include <jpeglib.h>
28462f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
28472f6f5c7aSCorentin CharyEOF
28482f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
28492f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
28502f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
28512f6f5c7aSCorentin Chary    vnc_jpeg=yes
28522f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2853ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
28542f6f5c7aSCorentin Chary  else
28552f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
285621684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
28572f6f5c7aSCorentin Chary    fi
28582f6f5c7aSCorentin Chary    vnc_jpeg=no
28592f6f5c7aSCorentin Chary  fi
28602f6f5c7aSCorentin Charyfi
28612f6f5c7aSCorentin Chary
28622f6f5c7aSCorentin Chary##########################################
2863efe556adSCorentin Chary# VNC PNG detection
2864821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2865efe556adSCorentin Charycat > $TMPC <<EOF
2866efe556adSCorentin Chary//#include <stdio.h>
2867efe556adSCorentin Chary#include <png.h>
2868832ce9c2SScott Wood#include <stddef.h>
2869efe556adSCorentin Charyint main(void) {
2870efe556adSCorentin Chary    png_structp png_ptr;
2871efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
28727edc3fedSPeter Maydell    return png_ptr != 0;
2873efe556adSCorentin Chary}
2874efe556adSCorentin CharyEOF
287565d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
287689138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
287789138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
28789af8025eSBrad  else
2879efe556adSCorentin Chary    vnc_png_cflags=""
2880efe556adSCorentin Chary    vnc_png_libs="-lpng"
28819af8025eSBrad  fi
2882efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2883efe556adSCorentin Chary    vnc_png=yes
2884efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
28859af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2886efe556adSCorentin Chary  else
2887efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
288821684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2889efe556adSCorentin Chary    fi
2890efe556adSCorentin Chary    vnc_png=no
2891efe556adSCorentin Chary  fi
2892efe556adSCorentin Charyfi
2893efe556adSCorentin Chary
2894efe556adSCorentin Chary##########################################
289576655d6dSaliguori# fnmatch() probe, used for ACL routines
289676655d6dSaliguorifnmatch="no"
289776655d6dSaliguoricat > $TMPC << EOF
289876655d6dSaliguori#include <fnmatch.h>
289976655d6dSaliguoriint main(void)
290076655d6dSaliguori{
290176655d6dSaliguori    fnmatch("foo", "foo", 0);
290276655d6dSaliguori    return 0;
290376655d6dSaliguori}
290476655d6dSaliguoriEOF
290552166aa0SJuan Quintelaif compile_prog "" "" ; then
290676655d6dSaliguori   fnmatch="yes"
290776655d6dSaliguorifi
290876655d6dSaliguori
290976655d6dSaliguori##########################################
2910c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2911dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2912dce512deSChristoph Hellwig  cat > $TMPC << EOF
2913ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2914dce512deSChristoph Hellwig#include <xfs/xfs.h>
2915dce512deSChristoph Hellwigint main(void)
2916dce512deSChristoph Hellwig{
2917dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2918dce512deSChristoph Hellwig    return 0;
2919dce512deSChristoph Hellwig}
2920dce512deSChristoph HellwigEOF
2921dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2922dce512deSChristoph Hellwig    xfs="yes"
2923dce512deSChristoph Hellwig  else
2924dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
292521684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2926dce512deSChristoph Hellwig    fi
2927dce512deSChristoph Hellwig    xfs=no
2928dce512deSChristoph Hellwig  fi
2929dce512deSChristoph Hellwigfi
2930dce512deSChristoph Hellwig
2931dce512deSChristoph Hellwig##########################################
29328a16d273Sths# vde libraries probe
2933dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29344baae0acSJuan Quintela  vde_libs="-lvdeplug"
29358a16d273Sths  cat > $TMPC << EOF
29368a16d273Sths#include <libvdeplug.h>
29374a7f0e06Spbrookint main(void)
29384a7f0e06Spbrook{
29394a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2940fea08e08SPeter Maydell    char s[] = "";
2941fea08e08SPeter Maydell    vde_open(s, s, &a);
29424a7f0e06Spbrook    return 0;
29434a7f0e06Spbrook}
29448a16d273SthsEOF
294552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29464baae0acSJuan Quintela    vde=yes
2947dfb278bdSJuan Quintela  else
2948dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
294921684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2950dfb278bdSJuan Quintela    fi
2951dfb278bdSJuan Quintela    vde=no
29528a16d273Sths  fi
29538a16d273Sthsfi
29548a16d273Sths
29558a16d273Sths##########################################
29560a985b37SVincenzo Maffione# netmap support probe
29570a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29580a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29590a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29600a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29610a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
296258952137SVincenzo Maffioneif test "$netmap" != "no" ; then
296358952137SVincenzo Maffione  cat > $TMPC << EOF
296458952137SVincenzo Maffione#include <inttypes.h>
296558952137SVincenzo Maffione#include <net/if.h>
296658952137SVincenzo Maffione#include <net/netmap.h>
296758952137SVincenzo Maffione#include <net/netmap_user.h>
29680a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29690a985b37SVincenzo Maffione#error
29700a985b37SVincenzo Maffione#endif
297158952137SVincenzo Maffioneint main(void) { return 0; }
297258952137SVincenzo MaffioneEOF
297358952137SVincenzo Maffione  if compile_prog "" "" ; then
297458952137SVincenzo Maffione    netmap=yes
297558952137SVincenzo Maffione  else
297658952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
297758952137SVincenzo Maffione      feature_not_found "netmap"
297858952137SVincenzo Maffione    fi
297958952137SVincenzo Maffione    netmap=no
298058952137SVincenzo Maffione  fi
298158952137SVincenzo Maffionefi
298258952137SVincenzo Maffione
298358952137SVincenzo Maffione##########################################
298447e98658SCorey Bryant# libcap-ng library probe
298547e98658SCorey Bryantif test "$cap_ng" != "no" ; then
298647e98658SCorey Bryant  cap_libs="-lcap-ng"
298747e98658SCorey Bryant  cat > $TMPC << EOF
298847e98658SCorey Bryant#include <cap-ng.h>
298947e98658SCorey Bryantint main(void)
299047e98658SCorey Bryant{
299147e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
299247e98658SCorey Bryant    return 0;
299347e98658SCorey Bryant}
299447e98658SCorey BryantEOF
299547e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
299647e98658SCorey Bryant    cap_ng=yes
299747e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
299847e98658SCorey Bryant  else
299947e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
300021684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
300147e98658SCorey Bryant    fi
300247e98658SCorey Bryant    cap_ng=no
300347e98658SCorey Bryant  fi
300447e98658SCorey Bryantfi
300547e98658SCorey Bryant
300647e98658SCorey Bryant##########################################
3007c2de5c91Smalc# Sound support libraries probe
30088f28f3fbSths
3009c2de5c91Smalcaudio_drv_probe()
3010c2de5c91Smalc{
3011c2de5c91Smalc    drv=$1
3012c2de5c91Smalc    hdr=$2
3013c2de5c91Smalc    lib=$3
3014c2de5c91Smalc    exp=$4
3015c2de5c91Smalc    cfl=$5
30168f28f3fbSths        cat > $TMPC << EOF
3017c2de5c91Smalc#include <$hdr>
3018c2de5c91Smalcint main(void) { $exp }
30198f28f3fbSthsEOF
302052166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
30218f28f3fbSths        :
30228f28f3fbSths    else
302376ad07a4SPeter Maydell        error_exit "$drv check failed" \
302476ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
30258f28f3fbSths    fi
3026c2de5c91Smalc}
3027c2de5c91Smalc
302889138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3029c2de5c91Smalcfor drv in $audio_drv_list; do
3030c2de5c91Smalc    case $drv in
3031c2de5c91Smalc    alsa)
3032c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3033e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3034b1149911SFam Zheng    alsa_libs="-lasound"
3035c2de5c91Smalc    ;;
3036c2de5c91Smalc
3037b8e59f18Smalc    pa)
3038e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3039e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3040b1149911SFam Zheng    pulse_libs="-lpulse"
304167f86e8eSJuan Quintela    audio_pt_int="yes"
3042b8e59f18Smalc    ;;
3043b8e59f18Smalc
3044373967b2SGerd Hoffmann    sdl)
3045373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3046373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3047373967b2SGerd Hoffmann    fi
3048373967b2SGerd Hoffmann    ;;
3049373967b2SGerd Hoffmann
3050997e690aSJuan Quintela    coreaudio)
3051b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3052997e690aSJuan Quintela    ;;
3053997e690aSJuan Quintela
3054a4bf6780SJuan Quintela    dsound)
3055b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3056d5631638Smalc      audio_win_int="yes"
3057a4bf6780SJuan Quintela    ;;
3058a4bf6780SJuan Quintela
3059a4bf6780SJuan Quintela    oss)
3060b1149911SFam Zheng      oss_libs="$oss_lib"
3061a4bf6780SJuan Quintela    ;;
3062a4bf6780SJuan Quintela
3063373967b2SGerd Hoffmann    wav)
3064373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
30652f6a1ab0Sblueswir1    ;;
30662f6a1ab0Sblueswir1
3067e4c63a6aSmalc    *)
30681c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
306976ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
307076ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3071e4c63a6aSmalc    }
3072e4c63a6aSmalc    ;;
3073c2de5c91Smalc    esac
3074c2de5c91Smalcdone
30758f28f3fbSths
30764d3b6f6eSbalrog##########################################
30772e4d9fb1Saurel32# BrlAPI probe
30782e4d9fb1Saurel32
30794ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3080eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
30812e4d9fb1Saurel32  cat > $TMPC << EOF
30822e4d9fb1Saurel32#include <brlapi.h>
3083832ce9c2SScott Wood#include <stddef.h>
30842e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
30852e4d9fb1Saurel32EOF
308652166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
30872e4d9fb1Saurel32    brlapi=yes
30884ffcedb6SJuan Quintela  else
30894ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
309021684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
30914ffcedb6SJuan Quintela    fi
30924ffcedb6SJuan Quintela    brlapi=no
3093eb82284fSJuan Quintela  fi
3094eb82284fSJuan Quintelafi
30952e4d9fb1Saurel32
30962e4d9fb1Saurel32##########################################
30974d3b6f6eSbalrog# curses probe
3098a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3099e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
31008ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
31018ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3102e095e2f3SStefan Weil  else
31037c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
31048ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3105e095e2f3SStefan Weil  fi
3106c584a6d0SJuan Quintela  curses_found=no
31074d3b6f6eSbalrog  cat > $TMPC << EOF
31088ddc5bf9SSamuel Thibault#include <locale.h>
31094d3b6f6eSbalrog#include <curses.h>
31108ddc5bf9SSamuel Thibault#include <wchar.h>
3111ef9a2524SStefan Weilint main(void) {
31128ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
31138ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3114ef9a2524SStefan Weil  resize_term(0, 0);
31158ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
31168ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
31177c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3118271f37abSKamil Rytarowski  return 0;
3119ef9a2524SStefan Weil}
31204d3b6f6eSbalrogEOF
3121ecbe251fSVadim Evard  IFS=:
31228ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3123b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3124b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
31257c703002SSamuel Thibault    IFS=:
31268ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3127ecbe251fSVadim Evard      unset IFS
31288ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3129c584a6d0SJuan Quintela        curses_found=yes
31308ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
31314f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
31324f78ef9aSJuan Quintela        break
31334d3b6f6eSbalrog      fi
31344f78ef9aSJuan Quintela    done
31357c703002SSamuel Thibault    if test "$curses_found" = yes ; then
31367c703002SSamuel Thibault      break
31377c703002SSamuel Thibault    fi
31388ddc5bf9SSamuel Thibault  done
3139ecbe251fSVadim Evard  unset IFS
3140c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3141c584a6d0SJuan Quintela    curses=yes
3142c584a6d0SJuan Quintela  else
3143c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
314421684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3145c584a6d0SJuan Quintela    fi
3146c584a6d0SJuan Quintela    curses=no
3147c584a6d0SJuan Quintela  fi
31484f78ef9aSJuan Quintelafi
31494d3b6f6eSbalrog
3150414f0dabSblueswir1##########################################
3151769ce76dSAlexander Graf# curl probe
3152a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
315365d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3154a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
31554e2b0658SPaolo Bonzini  else
31564e2b0658SPaolo Bonzini    curlconfig=curl-config
31574e2b0658SPaolo Bonzini  fi
3158769ce76dSAlexander Graf  cat > $TMPC << EOF
3159769ce76dSAlexander Graf#include <curl/curl.h>
31600b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3161769ce76dSAlexander GrafEOF
316289138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
316389138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3164b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3165769ce76dSAlexander Graf    curl=yes
3166788c8196SJuan Quintela  else
3167788c8196SJuan Quintela    if test "$curl" = "yes" ; then
316821684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3169788c8196SJuan Quintela    fi
3170788c8196SJuan Quintela    curl=no
3171769ce76dSAlexander Graf  fi
3172769ce76dSAlexander Graffi # test "$curl"
3173769ce76dSAlexander Graf
3174769ce76dSAlexander Graf##########################################
3175fb599c9aSbalrog# bluez support probe
3176a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3177e820e3f4Sbalrog  cat > $TMPC << EOF
3178e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3179e820e3f4Sbalrogint main(void) { return bt_error(0); }
3180e820e3f4SbalrogEOF
318189138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
318289138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
318352166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3184a20a6f46SJuan Quintela    bluez=yes
3185e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3186e820e3f4Sbalrog  else
3187a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
318821684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3189a20a6f46SJuan Quintela    fi
3190e820e3f4Sbalrog    bluez="no"
3191e820e3f4Sbalrog  fi
3192fb599c9aSbalrogfi
3193fb599c9aSbalrog
3194fb599c9aSbalrog##########################################
3195e18df141SAnthony Liguori# glib support probe
3196a52d28afSPaolo Bonzini
3197ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3198ad04d8cbSPeter Maydell    glib_req_ver=2.30
3199ad04d8cbSPeter Maydellelse
3200f40685c6SJohn Snow    glib_req_ver=2.22
3201ad04d8cbSPeter Maydellfi
3202aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3203aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3204aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3205aa0d1f44SPaolo Bonzinifi
3206e26110cfSFam Zheng
32074eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
32084eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
32094eaf7202SSameeh Jubran
32104eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
32114eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
32124eaf7202SSameeh Jubranfi
32134eaf7202SSameeh Jubran
3214aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3215e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
321689138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
321789138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
32184a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
321914015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3220957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3221e18df141SAnthony Liguori    else
3222e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3223e26110cfSFam Zheng    fi
3224e26110cfSFam Zhengdone
3225e26110cfSFam Zheng
3226977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3227977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3228977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3229977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3230977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3231977a82abSDaniel P. Berrange#include <glib.h>
3232977a82abSDaniel P. Berrange#include <unistd.h>
3233977a82abSDaniel P. Berrange
3234977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3235977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3236977a82abSDaniel P. Berrange
3237977a82abSDaniel P. Berrangeint main(void) {
3238977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3239977a82abSDaniel P. Berrange   return 0;
3240977a82abSDaniel P. Berrange}
3241977a82abSDaniel P. BerrangeEOF
3242977a82abSDaniel P. Berrange
32435919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3244977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3245977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3246977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3247977a82abSDaniel P. Berrange	       "build target"
3248977a82abSDaniel P. Berrangefi
3249977a82abSDaniel P. Berrange
32509d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
32519d41401bSMichael S. Tsirkinglib_subprocess=yes
3252a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
32539d41401bSMichael S. Tsirkin    glib_subprocess=no
32549d41401bSMichael S. Tsirkinfi
32559d41401bSMichael S. Tsirkin
3256bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3257bbbf2e04SJohn Snowcat > $TMPC << EOF
3258bbbf2e04SJohn Snow#include <glib.h>
3259bbbf2e04SJohn Snowint main(void) { return 0; }
3260bbbf2e04SJohn SnowEOF
3261bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3262bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3263bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3264bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3265bbbf2e04SJohn Snow    fi
3266bbbf2e04SJohn Snowfi
3267bbbf2e04SJohn Snow
3268e26110cfSFam Zheng##########################################
3269e26110cfSFam Zheng# SHA command probe for modules
3270e26110cfSFam Zhengif test "$modules" = yes; then
3271e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3272e26110cfSFam Zheng    for c in $shacmd_probe; do
32738ccefb91SFam Zheng        if has $c; then
3274e26110cfSFam Zheng            shacmd="$c"
3275e26110cfSFam Zheng            break
3276e26110cfSFam Zheng        fi
3277e26110cfSFam Zheng    done
3278e26110cfSFam Zheng    if test "$shacmd" = ""; then
3279e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3280e26110cfSFam Zheng    fi
3281e18df141SAnthony Liguorifi
3282e18df141SAnthony Liguori
3283e18df141SAnthony Liguori##########################################
3284e2134eb9SGerd Hoffmann# pixman support probe
3285e2134eb9SGerd Hoffmann
328674880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
328774880fe2SRobert Schiele  pixman_cflags=
328874880fe2SRobert Schiele  pixman_libs=
328935c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
329089138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
329189138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3292e2134eb9SGerd Hoffmannelse
3293c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3294c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3295e2134eb9SGerd Hoffmannfi
3296e2134eb9SGerd Hoffmann
3297e2134eb9SGerd Hoffmann##########################################
329817bff52bSM. Mohan Kumar# libcap probe
329917bff52bSM. Mohan Kumar
330017bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
330117bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
330217bff52bSM. Mohan Kumar#include <stdio.h>
330317bff52bSM. Mohan Kumar#include <sys/capability.h>
3304cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
330517bff52bSM. Mohan KumarEOF
330617bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
330717bff52bSM. Mohan Kumar    cap=yes
330817bff52bSM. Mohan Kumar  else
330917bff52bSM. Mohan Kumar    cap=no
331017bff52bSM. Mohan Kumar  fi
331117bff52bSM. Mohan Kumarfi
331217bff52bSM. Mohan Kumar
331317bff52bSM. Mohan Kumar##########################################
3314e5d355d1Saliguori# pthread probe
33154b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
33163c529d93Saliguori
3317e5d355d1Saliguoripthread=no
3318414f0dabSblueswir1cat > $TMPC << EOF
33193c529d93Saliguori#include <pthread.h>
33207a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
33217a42bbe4SStefan Weilint main(void) {
33227a42bbe4SStefan Weil  pthread_t thread;
33237a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
33247a42bbe4SStefan Weil  return 0;
33257a42bbe4SStefan Weil}
3326414f0dabSblueswir1EOF
3327bd00d539SAndreas Färberif compile_prog "" "" ; then
3328bd00d539SAndreas Färber  pthread=yes
3329bd00d539SAndreas Färberelse
3330de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
333152166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3332e5d355d1Saliguori      pthread=yes
3333e3c56761SPeter Portante      found=no
3334e3c56761SPeter Portante      for lib_entry in $LIBS; do
3335e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3336e3c56761SPeter Portante          found=yes
3337e3c56761SPeter Portante          break
3338e3c56761SPeter Portante        fi
3339e3c56761SPeter Portante      done
3340e3c56761SPeter Portante      if test "$found" = "no"; then
33415572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3342e3c56761SPeter Portante      fi
3343409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3344de65fe0fSSebastian Herbszt      break
3345414f0dabSblueswir1    fi
3346de65fe0fSSebastian Herbszt  done
3347bd00d539SAndreas Färberfi
3348414f0dabSblueswir1
33494617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
335076ad07a4SPeter Maydell  error_exit "pthread check failed" \
335176ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3352e5d355d1Saliguorifi
3353e5d355d1Saliguori
33545c312079SDr. David Alan Gilbert# check for pthread_setname_np
33555c312079SDr. David Alan Gilbertpthread_setname_np=no
33565c312079SDr. David Alan Gilbertcat > $TMPC << EOF
33575c312079SDr. David Alan Gilbert#include <pthread.h>
33585c312079SDr. David Alan Gilbert
33595c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
33605c312079SDr. David Alan Gilbertint main(void)
33615c312079SDr. David Alan Gilbert{
33625c312079SDr. David Alan Gilbert    pthread_t thread;
33635c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
33645c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
33655c312079SDr. David Alan Gilbert    return 0;
33665c312079SDr. David Alan Gilbert}
33675c312079SDr. David Alan GilbertEOF
33685c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
33695c312079SDr. David Alan Gilbert  pthread_setname_np=yes
33705c312079SDr. David Alan Gilbertfi
33715c312079SDr. David Alan Gilbert
3372bf9298b9Saliguori##########################################
3373f27aaf4bSChristian Brunner# rbd probe
3374f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3375f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3376f27aaf4bSChristian Brunner#include <stdio.h>
3377ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3378f27aaf4bSChristian Brunnerint main(void) {
3379ad32e9c0SJosh Durgin    rados_t cluster;
3380ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3381f27aaf4bSChristian Brunner    return 0;
3382f27aaf4bSChristian Brunner}
3383f27aaf4bSChristian BrunnerEOF
3384ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3385f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3386f27aaf4bSChristian Brunner    rbd=yes
3387f27aaf4bSChristian Brunner  else
3388f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
338921684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3390f27aaf4bSChristian Brunner    fi
3391f27aaf4bSChristian Brunner    rbd=no
3392f27aaf4bSChristian Brunner  fi
3393f27aaf4bSChristian Brunnerfi
3394f27aaf4bSChristian Brunner
3395f27aaf4bSChristian Brunner##########################################
33960a12ec87SRichard W.M. Jones# libssh2 probe
33974fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
33980a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
339965d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
340089138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
340189138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
34020a12ec87SRichard W.M. Jones    libssh2=yes
34030a12ec87SRichard W.M. Jones  else
34040a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
34054fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
34060a12ec87SRichard W.M. Jones    fi
34070a12ec87SRichard W.M. Jones    libssh2=no
34080a12ec87SRichard W.M. Jones  fi
34090a12ec87SRichard W.M. Jonesfi
34100a12ec87SRichard W.M. Jones
34110a12ec87SRichard W.M. Jones##########################################
34129a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
34139a2d462eSRichard W.M. Jones
34149a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
34159a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
34169a2d462eSRichard W.M. Jones#include <stdio.h>
34179a2d462eSRichard W.M. Jones#include <libssh2.h>
34189a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
34199a2d462eSRichard W.M. Jonesint main(void) {
34209a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
34219a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
34229a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
34239a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
34249a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
34259a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
34269a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
34279a2d462eSRichard W.M. Jones    return 0;
34289a2d462eSRichard W.M. Jones}
34299a2d462eSRichard W.M. JonesEOF
34309a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
34319a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
34329a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
34339a2d462eSRichard W.M. Jones  fi
34349a2d462eSRichard W.M. Jonesfi
34359a2d462eSRichard W.M. Jones
34369a2d462eSRichard W.M. Jones##########################################
34375c6c3a6cSChristoph Hellwig# linux-aio probe
34385c6c3a6cSChristoph Hellwig
34395c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
34405c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
34415c6c3a6cSChristoph Hellwig#include <libaio.h>
34425c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3443832ce9c2SScott Wood#include <stddef.h>
34445c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
34455c6c3a6cSChristoph HellwigEOF
34465c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
34475c6c3a6cSChristoph Hellwig    linux_aio=yes
34485c6c3a6cSChristoph Hellwig  else
34495c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
345021684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
34515c6c3a6cSChristoph Hellwig    fi
34523cfcae3cSLuiz Capitulino    linux_aio=no
34535c6c3a6cSChristoph Hellwig  fi
34545c6c3a6cSChristoph Hellwigfi
34555c6c3a6cSChristoph Hellwig
34565c6c3a6cSChristoph Hellwig##########################################
34573b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
34583b8acc11SPaolo Bonzini
34593b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
34603b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
34613b8acc11SPaolo Bonzinielse
34623b8acc11SPaolo Bonzini  tpm_passthrough=no
34633b8acc11SPaolo Bonzinifi
34643b8acc11SPaolo Bonzini
34653b8acc11SPaolo Bonzini##########################################
3466758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3467758e8e38SVenkateswararao Jujjuri (JV)
3468758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3469758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3470758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3471758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3472f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3473f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3474f2338fb4SPavel Borzenkov#else
34754f26f2b6SAvi Kivity#include <sys/xattr.h>
3476f2338fb4SPavel Borzenkov#endif
3477758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3478758e8e38SVenkateswararao Jujjuri (JV)EOF
34794f26f2b6SAvi Kivity  if compile_prog "" "" ; then
34804f26f2b6SAvi Kivity    attr=yes
34814f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3482f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3483758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3484758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
34854f26f2b6SAvi Kivity    libattr=yes
3486758e8e38SVenkateswararao Jujjuri (JV)  else
3487758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
348821684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3489758e8e38SVenkateswararao Jujjuri (JV)    fi
3490758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3491758e8e38SVenkateswararao Jujjuri (JV)  fi
3492758e8e38SVenkateswararao Jujjuri (JV)fi
3493758e8e38SVenkateswararao Jujjuri (JV)
3494758e8e38SVenkateswararao Jujjuri (JV)##########################################
3495bf9298b9Saliguori# iovec probe
3496bf9298b9Saliguoricat > $TMPC <<EOF
3497db34f0b3Sblueswir1#include <sys/types.h>
3498bf9298b9Saliguori#include <sys/uio.h>
3499db34f0b3Sblueswir1#include <unistd.h>
3500f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3501bf9298b9SaliguoriEOF
3502bf9298b9Saliguoriiovec=no
350352166aa0SJuan Quintelaif compile_prog "" "" ; then
3504bf9298b9Saliguori  iovec=yes
3505bf9298b9Saliguorifi
3506bf9298b9Saliguori
3507f652e6afSaurel32##########################################
3508ceb42de8Saliguori# preadv probe
3509ceb42de8Saliguoricat > $TMPC <<EOF
3510ceb42de8Saliguori#include <sys/types.h>
3511ceb42de8Saliguori#include <sys/uio.h>
3512ceb42de8Saliguori#include <unistd.h>
3513c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3514ceb42de8SaliguoriEOF
3515ceb42de8Saliguoripreadv=no
351652166aa0SJuan Quintelaif compile_prog "" "" ; then
3517ceb42de8Saliguori  preadv=yes
3518ceb42de8Saliguorifi
3519ceb42de8Saliguori
3520ceb42de8Saliguori##########################################
3521f652e6afSaurel32# fdt probe
3522e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3523e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3524e169e1e1SPeter Maydellfdt_required=no
3525e169e1e1SPeter Maydellfor target in $target_list; do
3526e169e1e1SPeter Maydell  case $target in
3527df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3528e169e1e1SPeter Maydell      fdt_required=yes
3529e169e1e1SPeter Maydell    ;;
3530e169e1e1SPeter Maydell  esac
3531e169e1e1SPeter Maydelldone
3532e169e1e1SPeter Maydell
3533e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3534e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3535e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3536e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3537e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3538e169e1e1SPeter Maydell  fi
3539e169e1e1SPeter Maydell  fdt=yes
3540e169e1e1SPeter Maydellfi
3541e169e1e1SPeter Maydell
35422df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3543b41af4baSJuan Quintela  fdt_libs="-lfdt"
354496ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
35456e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3546f652e6afSaurel32  cat > $TMPC << EOF
354731ce0adbSThomas Huth#include <libfdt.h>
354896ce6545SPeter Crosthwaite#include <libfdt_env.h>
35496e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3550f652e6afSaurel32EOF
355152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3552a540f158SPeter Crosthwaite    # system DTC is good - use it
3553f652e6afSaurel32    fdt=yes
3554a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
3555a540f158SPeter Crosthwaite    # have submodule DTC - use it
3556a540f158SPeter Crosthwaite    fdt=yes
3557a540f158SPeter Crosthwaite    dtc_internal="yes"
3558a540f158SPeter Crosthwaite    mkdir -p dtc
3559cab00a5aSMichael S. Tsirkin    if [ "$pwd_is_source_path" != "y" ] ; then
3560a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3561a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
35622df87df7SJuan Quintela    fi
3563a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3564a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3565a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
3566a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
35676e85fce0SPaul Burton    error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
35683f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
3569a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
3570a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
3571a540f158SPeter Crosthwaite  else
3572a540f158SPeter Crosthwaite    # don't have and don't want
3573de3a354aSMichael Walle    fdt_libs=
35742df87df7SJuan Quintela    fdt=no
3575f652e6afSaurel32  fi
3576f652e6afSaurel32fi
3577f652e6afSaurel32
3578a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3579a540f158SPeter Crosthwaite
358020ff075bSMichael Walle##########################################
3581fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3582b1546f32SGerd Hoffmann
3583da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3584014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3585fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3586f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3587f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3588da076ffeSGerd Hoffmann    opengl=yes
3589925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3590925a0400SGerd Hoffmann        gtk_gl="yes"
3591925a0400SGerd Hoffmann    fi
3592cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
359320ff075bSMichael Walle  else
3594da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3595dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
359620ff075bSMichael Walle    fi
3597f676c67eSJeremy White    opengl_cflags=""
3598da076ffeSGerd Hoffmann    opengl_libs=""
3599da076ffeSGerd Hoffmann    opengl=no
360020ff075bSMichael Walle  fi
360120ff075bSMichael Wallefi
360220ff075bSMichael Walle
3603014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3604014cb152SGerd Hoffmann  cat > $TMPC << EOF
3605014cb152SGerd Hoffmann#include <epoxy/egl.h>
3606014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3607014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3608014cb152SGerd Hoffmann#endif
3609014cb152SGerd Hoffmannint main(void) { return 0; }
3610014cb152SGerd HoffmannEOF
3611014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3612014cb152SGerd Hoffmann    opengl_dmabuf=yes
3613014cb152SGerd Hoffmann  fi
3614014cb152SGerd Hoffmannfi
3615c9a12e75SChrysostomos Nanakos
3616c9a12e75SChrysostomos Nanakos
3617eb100396SBharata B Rao##########################################
3618eb100396SBharata B Rao# glusterfs probe
3619eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
362065d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3621e01bee08SBharata B Rao    glusterfs="yes"
362289138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
362389138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3624d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3625d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3626d85fa9ebSJeff Cody    fi
362765d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
36280c14fb47SBharata B Rao      glusterfs_discard="yes"
36290c14fb47SBharata B Rao    fi
36307c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3631df3a429aSNiels de Vos      glusterfs_fallocate="yes"
36327c815372SBharata B Rao      glusterfs_zerofill="yes"
36337c815372SBharata B Rao    fi
3634eb100396SBharata B Rao  else
3635eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
36368efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
36378efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3638eb100396SBharata B Rao    fi
3639e01bee08SBharata B Rao    glusterfs="no"
3640eb100396SBharata B Rao  fi
3641eb100396SBharata B Raofi
3642eb100396SBharata B Rao
364339386ac7Saurel32# Check for inotify functions when we are building linux-user
36443b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36453b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36463b3f24adSaurel32# don't provide them even if kernel supports them.
36473b3f24adSaurel32#
36483b3f24adSaurel32inotify=no
36493b3f24adSaurel32cat > $TMPC << EOF
36503b3f24adSaurel32#include <sys/inotify.h>
36513b3f24adSaurel32
36523b3f24adSaurel32int
36533b3f24adSaurel32main(void)
36543b3f24adSaurel32{
36553b3f24adSaurel32	/* try to start inotify */
36568690e420Saurel32	return inotify_init();
36573b3f24adSaurel32}
36583b3f24adSaurel32EOF
365952166aa0SJuan Quintelaif compile_prog "" "" ; then
36603b3f24adSaurel32  inotify=yes
36613b3f24adSaurel32fi
36623b3f24adSaurel32
3663c05c7a73SRiku Voipioinotify1=no
3664c05c7a73SRiku Voipiocat > $TMPC << EOF
3665c05c7a73SRiku Voipio#include <sys/inotify.h>
3666c05c7a73SRiku Voipio
3667c05c7a73SRiku Voipioint
3668c05c7a73SRiku Voipiomain(void)
3669c05c7a73SRiku Voipio{
3670c05c7a73SRiku Voipio    /* try to start inotify */
3671c05c7a73SRiku Voipio    return inotify_init1(0);
3672c05c7a73SRiku Voipio}
3673c05c7a73SRiku VoipioEOF
3674c05c7a73SRiku Voipioif compile_prog "" "" ; then
3675c05c7a73SRiku Voipio  inotify1=yes
3676c05c7a73SRiku Voipiofi
3677c05c7a73SRiku Voipio
3678099d6b0fSRiku Voipio# check if pipe2 is there
3679099d6b0fSRiku Voipiopipe2=no
3680099d6b0fSRiku Voipiocat > $TMPC << EOF
3681099d6b0fSRiku Voipio#include <unistd.h>
3682099d6b0fSRiku Voipio#include <fcntl.h>
3683099d6b0fSRiku Voipio
3684099d6b0fSRiku Voipioint main(void)
3685099d6b0fSRiku Voipio{
3686099d6b0fSRiku Voipio    int pipefd[2];
36879bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3688099d6b0fSRiku Voipio}
3689099d6b0fSRiku VoipioEOF
369052166aa0SJuan Quintelaif compile_prog "" "" ; then
3691099d6b0fSRiku Voipio  pipe2=yes
3692099d6b0fSRiku Voipiofi
3693099d6b0fSRiku Voipio
369440ff6d7eSKevin Wolf# check if accept4 is there
369540ff6d7eSKevin Wolfaccept4=no
369640ff6d7eSKevin Wolfcat > $TMPC << EOF
369740ff6d7eSKevin Wolf#include <sys/socket.h>
369840ff6d7eSKevin Wolf#include <stddef.h>
369940ff6d7eSKevin Wolf
370040ff6d7eSKevin Wolfint main(void)
370140ff6d7eSKevin Wolf{
370240ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
370340ff6d7eSKevin Wolf    return 0;
370440ff6d7eSKevin Wolf}
370540ff6d7eSKevin WolfEOF
370640ff6d7eSKevin Wolfif compile_prog "" "" ; then
370740ff6d7eSKevin Wolf  accept4=yes
370840ff6d7eSKevin Wolffi
370940ff6d7eSKevin Wolf
37103ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
37113ce34dfbSvibisreenivasansplice=no
37123ce34dfbSvibisreenivasancat > $TMPC << EOF
37133ce34dfbSvibisreenivasan#include <unistd.h>
37143ce34dfbSvibisreenivasan#include <fcntl.h>
37153ce34dfbSvibisreenivasan#include <limits.h>
37163ce34dfbSvibisreenivasan
37173ce34dfbSvibisreenivasanint main(void)
37183ce34dfbSvibisreenivasan{
371966ea0f22SStefan Weil    int len, fd = 0;
37203ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
37213ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
37223ce34dfbSvibisreenivasan    return 0;
37233ce34dfbSvibisreenivasan}
37243ce34dfbSvibisreenivasanEOF
372552166aa0SJuan Quintelaif compile_prog "" "" ; then
37263ce34dfbSvibisreenivasan  splice=yes
37273ce34dfbSvibisreenivasanfi
37283ce34dfbSvibisreenivasan
3729dcc38d1cSMarcelo Tosatti##########################################
3730a99d57bbSWanlong Gao# libnuma probe
3731a99d57bbSWanlong Gao
3732a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3733a99d57bbSWanlong Gao  cat > $TMPC << EOF
3734a99d57bbSWanlong Gao#include <numa.h>
3735a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3736a99d57bbSWanlong GaoEOF
3737a99d57bbSWanlong Gao
3738a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3739a99d57bbSWanlong Gao    numa=yes
3740a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3741a99d57bbSWanlong Gao  else
3742a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3743a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3744a99d57bbSWanlong Gao    fi
3745a99d57bbSWanlong Gao    numa=no
3746a99d57bbSWanlong Gao  fi
3747a99d57bbSWanlong Gaofi
3748a99d57bbSWanlong Gao
37497b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37507b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37517b01cb97SAlexandre Derumier    exit 1
37527b01cb97SAlexandre Derumierfi
37537b01cb97SAlexandre Derumier
3754a99d57bbSWanlong Gao##########################################
37552847b469SFam Zheng# tcmalloc probe
37562847b469SFam Zheng
37572847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
37582847b469SFam Zheng  cat > $TMPC << EOF
37592847b469SFam Zheng#include <stdlib.h>
37602847b469SFam Zhengint main(void) { malloc(1); return 0; }
37612847b469SFam ZhengEOF
37622847b469SFam Zheng
37632847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
37642847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
37652847b469SFam Zheng  else
37662847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
37672847b469SFam Zheng  fi
37682847b469SFam Zhengfi
37692847b469SFam Zheng
37702847b469SFam Zheng##########################################
37717b01cb97SAlexandre Derumier# jemalloc probe
37727b01cb97SAlexandre Derumier
37737b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
37747b01cb97SAlexandre Derumier  cat > $TMPC << EOF
37757b01cb97SAlexandre Derumier#include <stdlib.h>
37767b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
37777b01cb97SAlexandre DerumierEOF
37787b01cb97SAlexandre Derumier
37797b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
37807b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
37817b01cb97SAlexandre Derumier  else
37827b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
37837b01cb97SAlexandre Derumier  fi
37847b01cb97SAlexandre Derumierfi
37857b01cb97SAlexandre Derumier
37867b01cb97SAlexandre Derumier##########################################
3787dcc38d1cSMarcelo Tosatti# signalfd probe
3788dcc38d1cSMarcelo Tosattisignalfd="no"
3789dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3790dcc38d1cSMarcelo Tosatti#include <unistd.h>
3791dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3792dcc38d1cSMarcelo Tosatti#include <signal.h>
3793dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3794dcc38d1cSMarcelo TosattiEOF
3795dcc38d1cSMarcelo Tosatti
3796dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3797dcc38d1cSMarcelo Tosatti  signalfd=yes
3798dcc38d1cSMarcelo Tosattifi
3799dcc38d1cSMarcelo Tosatti
3800c2882b96SRiku Voipio# check if eventfd is supported
3801c2882b96SRiku Voipioeventfd=no
3802c2882b96SRiku Voipiocat > $TMPC << EOF
3803c2882b96SRiku Voipio#include <sys/eventfd.h>
3804c2882b96SRiku Voipio
3805c2882b96SRiku Voipioint main(void)
3806c2882b96SRiku Voipio{
380755cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3808c2882b96SRiku Voipio}
3809c2882b96SRiku VoipioEOF
3810c2882b96SRiku Voipioif compile_prog "" "" ; then
3811c2882b96SRiku Voipio  eventfd=yes
3812c2882b96SRiku Voipiofi
3813c2882b96SRiku Voipio
3814751bcc39SMarc-André Lureau# check if memfd is supported
3815751bcc39SMarc-André Lureaumemfd=no
3816751bcc39SMarc-André Lureaucat > $TMPC << EOF
3817751bcc39SMarc-André Lureau#include <sys/memfd.h>
3818751bcc39SMarc-André Lureau
3819751bcc39SMarc-André Lureauint main(void)
3820751bcc39SMarc-André Lureau{
3821751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3822751bcc39SMarc-André Lureau}
3823751bcc39SMarc-André LureauEOF
3824751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3825751bcc39SMarc-André Lureau  memfd=yes
3826751bcc39SMarc-André Lureaufi
3827751bcc39SMarc-André Lureau
3828751bcc39SMarc-André Lureau
3829751bcc39SMarc-André Lureau
3830d0927938SUlrich Hecht# check for fallocate
3831d0927938SUlrich Hechtfallocate=no
3832d0927938SUlrich Hechtcat > $TMPC << EOF
3833d0927938SUlrich Hecht#include <fcntl.h>
3834d0927938SUlrich Hecht
3835d0927938SUlrich Hechtint main(void)
3836d0927938SUlrich Hecht{
3837d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3838d0927938SUlrich Hecht    return 0;
3839d0927938SUlrich Hecht}
3840d0927938SUlrich HechtEOF
38418fb03151SPeter Maydellif compile_prog "" "" ; then
3842d0927938SUlrich Hecht  fallocate=yes
3843d0927938SUlrich Hechtfi
3844d0927938SUlrich Hecht
38453d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38463d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38473d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38483d4fa43eSKusanagi Kouichi#include <fcntl.h>
38493d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38503d4fa43eSKusanagi Kouichi
38513d4fa43eSKusanagi Kouichiint main(void)
38523d4fa43eSKusanagi Kouichi{
38533d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38543d4fa43eSKusanagi Kouichi    return 0;
38553d4fa43eSKusanagi Kouichi}
38563d4fa43eSKusanagi KouichiEOF
38573d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38583d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38593d4fa43eSKusanagi Kouichifi
38603d4fa43eSKusanagi Kouichi
3861b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3862b953f075SDenis V. Lunevfallocate_zero_range=no
3863b953f075SDenis V. Lunevcat > $TMPC << EOF
3864b953f075SDenis V. Lunev#include <fcntl.h>
3865b953f075SDenis V. Lunev#include <linux/falloc.h>
3866b953f075SDenis V. Lunev
3867b953f075SDenis V. Lunevint main(void)
3868b953f075SDenis V. Lunev{
3869b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3870b953f075SDenis V. Lunev    return 0;
3871b953f075SDenis V. Lunev}
3872b953f075SDenis V. LunevEOF
3873b953f075SDenis V. Lunevif compile_prog "" "" ; then
3874b953f075SDenis V. Lunev  fallocate_zero_range=yes
3875b953f075SDenis V. Lunevfi
3876b953f075SDenis V. Lunev
3877ed911435SKevin Wolf# check for posix_fallocate
3878ed911435SKevin Wolfposix_fallocate=no
3879ed911435SKevin Wolfcat > $TMPC << EOF
3880ed911435SKevin Wolf#include <fcntl.h>
3881ed911435SKevin Wolf
3882ed911435SKevin Wolfint main(void)
3883ed911435SKevin Wolf{
3884ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3885ed911435SKevin Wolf    return 0;
3886ed911435SKevin Wolf}
3887ed911435SKevin WolfEOF
3888ed911435SKevin Wolfif compile_prog "" "" ; then
3889ed911435SKevin Wolf    posix_fallocate=yes
3890ed911435SKevin Wolffi
3891ed911435SKevin Wolf
3892c727f47dSPeter Maydell# check for sync_file_range
3893c727f47dSPeter Maydellsync_file_range=no
3894c727f47dSPeter Maydellcat > $TMPC << EOF
3895c727f47dSPeter Maydell#include <fcntl.h>
3896c727f47dSPeter Maydell
3897c727f47dSPeter Maydellint main(void)
3898c727f47dSPeter Maydell{
3899c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3900c727f47dSPeter Maydell    return 0;
3901c727f47dSPeter Maydell}
3902c727f47dSPeter MaydellEOF
39038fb03151SPeter Maydellif compile_prog "" "" ; then
3904c727f47dSPeter Maydell  sync_file_range=yes
3905c727f47dSPeter Maydellfi
3906c727f47dSPeter Maydell
3907dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3908dace20dcSPeter Maydellfiemap=no
3909dace20dcSPeter Maydellcat > $TMPC << EOF
3910dace20dcSPeter Maydell#include <sys/ioctl.h>
3911dace20dcSPeter Maydell#include <linux/fs.h>
3912dace20dcSPeter Maydell#include <linux/fiemap.h>
3913dace20dcSPeter Maydell
3914dace20dcSPeter Maydellint main(void)
3915dace20dcSPeter Maydell{
3916dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3917dace20dcSPeter Maydell    return 0;
3918dace20dcSPeter Maydell}
3919dace20dcSPeter MaydellEOF
39208fb03151SPeter Maydellif compile_prog "" "" ; then
3921dace20dcSPeter Maydell  fiemap=yes
3922dace20dcSPeter Maydellfi
3923dace20dcSPeter Maydell
3924d0927938SUlrich Hecht# check for dup3
3925d0927938SUlrich Hechtdup3=no
3926d0927938SUlrich Hechtcat > $TMPC << EOF
3927d0927938SUlrich Hecht#include <unistd.h>
3928d0927938SUlrich Hecht
3929d0927938SUlrich Hechtint main(void)
3930d0927938SUlrich Hecht{
3931d0927938SUlrich Hecht    dup3(0, 0, 0);
3932d0927938SUlrich Hecht    return 0;
3933d0927938SUlrich Hecht}
3934d0927938SUlrich HechtEOF
393578f5d726SJan Kiszkaif compile_prog "" "" ; then
3936d0927938SUlrich Hecht  dup3=yes
3937d0927938SUlrich Hechtfi
3938d0927938SUlrich Hecht
39394e0c6529SAlex Bligh# check for ppoll support
39404e0c6529SAlex Blighppoll=no
39414e0c6529SAlex Blighcat > $TMPC << EOF
39424e0c6529SAlex Bligh#include <poll.h>
39434e0c6529SAlex Bligh
39444e0c6529SAlex Blighint main(void)
39454e0c6529SAlex Bligh{
39464e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39474e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39484e0c6529SAlex Bligh    return 0;
39494e0c6529SAlex Bligh}
39504e0c6529SAlex BlighEOF
39514e0c6529SAlex Blighif compile_prog "" "" ; then
39524e0c6529SAlex Bligh  ppoll=yes
39534e0c6529SAlex Blighfi
39544e0c6529SAlex Bligh
3955cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3956cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3957cd758dd0SAlex Blighcat > $TMPC << EOF
3958cd758dd0SAlex Bligh#include <sys/prctl.h>
3959cd758dd0SAlex Bligh
3960cd758dd0SAlex Blighint main(void)
3961cd758dd0SAlex Bligh{
3962cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3963cd758dd0SAlex Bligh    return 0;
3964cd758dd0SAlex Bligh}
3965cd758dd0SAlex BlighEOF
3966cd758dd0SAlex Blighif compile_prog "" "" ; then
3967cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3968cd758dd0SAlex Blighfi
3969cd758dd0SAlex Bligh
39703b6edd16SPeter Maydell# check for epoll support
39713b6edd16SPeter Maydellepoll=no
39723b6edd16SPeter Maydellcat > $TMPC << EOF
39733b6edd16SPeter Maydell#include <sys/epoll.h>
39743b6edd16SPeter Maydell
39753b6edd16SPeter Maydellint main(void)
39763b6edd16SPeter Maydell{
39773b6edd16SPeter Maydell    epoll_create(0);
39783b6edd16SPeter Maydell    return 0;
39793b6edd16SPeter Maydell}
39803b6edd16SPeter MaydellEOF
39818fb03151SPeter Maydellif compile_prog "" "" ; then
39823b6edd16SPeter Maydell  epoll=yes
39833b6edd16SPeter Maydellfi
39843b6edd16SPeter Maydell
3985227f0214SPeter Maydell# epoll_create1 is a later addition
3986227f0214SPeter Maydell# so we must check separately for its presence
39873b6edd16SPeter Maydellepoll_create1=no
39883b6edd16SPeter Maydellcat > $TMPC << EOF
39893b6edd16SPeter Maydell#include <sys/epoll.h>
39903b6edd16SPeter Maydell
39913b6edd16SPeter Maydellint main(void)
39923b6edd16SPeter Maydell{
399319e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
399419e83f6bSPeter Maydell     * a function being called. This is necessary so that on
399519e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
399619e83f6bSPeter Maydell     * the library but not declared in the header file we will
399719e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
399819e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
399919e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
400019e83f6bSPeter Maydell     */
4001c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
40023b6edd16SPeter Maydell}
40033b6edd16SPeter MaydellEOF
40048fb03151SPeter Maydellif compile_prog "" "" ; then
40053b6edd16SPeter Maydell  epoll_create1=yes
40063b6edd16SPeter Maydellfi
40073b6edd16SPeter Maydell
4008a8fd1abaSPeter Maydell# check for sendfile support
4009a8fd1abaSPeter Maydellsendfile=no
4010a8fd1abaSPeter Maydellcat > $TMPC << EOF
4011a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4012a8fd1abaSPeter Maydell
4013a8fd1abaSPeter Maydellint main(void)
4014a8fd1abaSPeter Maydell{
4015a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4016a8fd1abaSPeter Maydell}
4017a8fd1abaSPeter MaydellEOF
4018a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4019a8fd1abaSPeter Maydell  sendfile=yes
4020a8fd1abaSPeter Maydellfi
4021a8fd1abaSPeter Maydell
402251834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
402351834341SRiku Voipiotimerfd=no
402451834341SRiku Voipiocat > $TMPC << EOF
402551834341SRiku Voipio#include <sys/timerfd.h>
402651834341SRiku Voipio
402751834341SRiku Voipioint main(void)
402851834341SRiku Voipio{
402951834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
403051834341SRiku Voipio}
403151834341SRiku VoipioEOF
403251834341SRiku Voipioif compile_prog "" "" ; then
403351834341SRiku Voipio  timerfd=yes
403451834341SRiku Voipiofi
403551834341SRiku Voipio
40369af5c906SRiku Voipio# check for setns and unshare support
40379af5c906SRiku Voipiosetns=no
40389af5c906SRiku Voipiocat > $TMPC << EOF
40399af5c906SRiku Voipio#include <sched.h>
40409af5c906SRiku Voipio
40419af5c906SRiku Voipioint main(void)
40429af5c906SRiku Voipio{
40439af5c906SRiku Voipio    int ret;
40449af5c906SRiku Voipio    ret = setns(0, 0);
40459af5c906SRiku Voipio    ret = unshare(0);
40469af5c906SRiku Voipio    return ret;
40479af5c906SRiku Voipio}
40489af5c906SRiku VoipioEOF
40499af5c906SRiku Voipioif compile_prog "" "" ; then
40509af5c906SRiku Voipio  setns=yes
40519af5c906SRiku Voipiofi
40529af5c906SRiku Voipio
405338860a03SAleksandar Markovic# clock_adjtime probe
405438860a03SAleksandar Markovicclock_adjtime=no
405538860a03SAleksandar Markoviccat > $TMPC <<EOF
405638860a03SAleksandar Markovic#include <time.h>
405738860a03SAleksandar Markovic
405838860a03SAleksandar Markovicint main(void)
405938860a03SAleksandar Markovic{
406038860a03SAleksandar Markovic    return clock_adjtime(0, 0);
406138860a03SAleksandar Markovic}
406238860a03SAleksandar MarkovicEOF
406338860a03SAleksandar Markovicclock_adjtime=no
406438860a03SAleksandar Markovicif compile_prog "" "" ; then
406538860a03SAleksandar Markovic  clock_adjtime=yes
406638860a03SAleksandar Markovicfi
406738860a03SAleksandar Markovic
40685a03cd00SAleksandar Markovic# syncfs probe
40695a03cd00SAleksandar Markovicsyncfs=no
40705a03cd00SAleksandar Markoviccat > $TMPC <<EOF
40715a03cd00SAleksandar Markovic#include <unistd.h>
40725a03cd00SAleksandar Markovic
40735a03cd00SAleksandar Markovicint main(void)
40745a03cd00SAleksandar Markovic{
40755a03cd00SAleksandar Markovic    return syncfs(0);
40765a03cd00SAleksandar Markovic}
40775a03cd00SAleksandar MarkovicEOF
40785a03cd00SAleksandar Markovicsyncfs=no
40795a03cd00SAleksandar Markovicif compile_prog "" "" ; then
40805a03cd00SAleksandar Markovic  syncfs=yes
40815a03cd00SAleksandar Markovicfi
40825a03cd00SAleksandar Markovic
4083cc8ae6deSpbrook# Check if tools are available to build documentation.
4084a25dba17SJuan Quintelaif test "$docs" != "no" ; then
408501668d98SStefan Weil  if has makeinfo && has pod2man; then
4086a25dba17SJuan Quintela    docs=yes
408783a3ab8bSJuan Quintela  else
4088a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
408921684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
409083a3ab8bSJuan Quintela    fi
4091a25dba17SJuan Quintela    docs=no
409283a3ab8bSJuan Quintela  fi
4093cc8ae6deSpbrookfi
4094cc8ae6deSpbrook
4095f514f41cSStefan Weil# Search for bswap_32 function
40966ae9a1f4SJuan Quintelabyteswap_h=no
40976ae9a1f4SJuan Quintelacat > $TMPC << EOF
40986ae9a1f4SJuan Quintela#include <byteswap.h>
40996ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
41006ae9a1f4SJuan QuintelaEOF
410152166aa0SJuan Quintelaif compile_prog "" "" ; then
41026ae9a1f4SJuan Quintela  byteswap_h=yes
41036ae9a1f4SJuan Quintelafi
41046ae9a1f4SJuan Quintela
410575f13596SStefan Weil# Search for bswap32 function
41066ae9a1f4SJuan Quintelabswap_h=no
41076ae9a1f4SJuan Quintelacat > $TMPC << EOF
41086ae9a1f4SJuan Quintela#include <sys/endian.h>
41096ae9a1f4SJuan Quintela#include <sys/types.h>
41106ae9a1f4SJuan Quintela#include <machine/bswap.h>
41116ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
41126ae9a1f4SJuan QuintelaEOF
411352166aa0SJuan Quintelaif compile_prog "" "" ; then
41146ae9a1f4SJuan Quintela  bswap_h=yes
41156ae9a1f4SJuan Quintelafi
41166ae9a1f4SJuan Quintela
4117da93a1fdSaliguori##########################################
4118e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4119c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4120e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
41213c33ea96SPaolo Bonzini    libiscsi="yes"
4122ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4123ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4124c589b249SRonnie Sahlberg  else
4125c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4126e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4127c589b249SRonnie Sahlberg    fi
4128c589b249SRonnie Sahlberg    libiscsi="no"
4129c589b249SRonnie Sahlberg  fi
4130c589b249SRonnie Sahlbergfi
4131c589b249SRonnie Sahlberg
4132c589b249SRonnie Sahlberg##########################################
41338bacde8dSNatanael Copa# Do we need libm
41348bacde8dSNatanael Copacat > $TMPC << EOF
41358bacde8dSNatanael Copa#include <math.h>
4136f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
41378bacde8dSNatanael CopaEOF
41388bacde8dSNatanael Copaif compile_prog "" "" ; then
41398bacde8dSNatanael Copa  :
41408bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
41418bacde8dSNatanael Copa  LIBS="-lm $LIBS"
41428bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
41438bacde8dSNatanael Copaelse
414476ad07a4SPeter Maydell  error_exit "libm check failed"
41458bacde8dSNatanael Copafi
41468bacde8dSNatanael Copa
41478bacde8dSNatanael Copa##########################################
4148da93a1fdSaliguori# Do we need librt
41498bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
41508bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
41518bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
41528bacde8dSNatanael Copa# function in addition.
4153da93a1fdSaliguoricat > $TMPC <<EOF
4154da93a1fdSaliguori#include <signal.h>
4155da93a1fdSaliguori#include <time.h>
41568bacde8dSNatanael Copaint main(void) {
41578bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
41588bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
41598bacde8dSNatanael Copa}
4160da93a1fdSaliguoriEOF
4161da93a1fdSaliguori
416252166aa0SJuan Quintelaif compile_prog "" "" ; then
416307ffa4bdSJuan Quintela  :
41648bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
416518e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
416618e588b1SRick Liu  LIBS="$LIBS -lrt"
416718e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4168da93a1fdSaliguorifi
4169da93a1fdSaliguori
417031ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
417178723752SPeter Maydell        "$haiku" != "yes" ; then
41726362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
41736362a53fSJuan Quintelafi
41746362a53fSJuan Quintela
4175de5071c5SBlue Swirl##########################################
4176cd4ec0b4SGerd Hoffmann# spice probe
4177cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4178cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4179cd4ec0b4SGerd Hoffmann#include <spice.h>
4180cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4181cd4ec0b4SGerd HoffmannEOF
4182710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4183710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
418465d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
418565d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4186cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4187cd4ec0b4SGerd Hoffmann    spice="yes"
4188cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4189cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
41902e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
41912e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4192cd4ec0b4SGerd Hoffmann  else
4193cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
41948efc9363SHu Tao      feature_not_found "spice" \
41958efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4196cd4ec0b4SGerd Hoffmann    fi
4197cd4ec0b4SGerd Hoffmann    spice="no"
4198cd4ec0b4SGerd Hoffmann  fi
4199cd4ec0b4SGerd Hoffmannfi
4200cd4ec0b4SGerd Hoffmann
42017b02f544SMarc-André Lureau# check for smartcard support
4202111a38b0SRobert Relyeasmartcard_cflags=""
42037b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
42047b02f544SMarc-André Lureau    if $pkg_config libcacard; then
42057b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
42067b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
42077b02f544SMarc-André Lureau        smartcard="yes"
4208111a38b0SRobert Relyea    else
42097b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
42107b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4211111a38b0SRobert Relyea        fi
42127b02f544SMarc-André Lureau        smartcard="no"
4213111a38b0SRobert Relyea    fi
4214111a38b0SRobert Relyeafi
4215111a38b0SRobert Relyea
42162b2325ffSGerd Hoffmann# check for libusb
42172b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
421865d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
42192b2325ffSGerd Hoffmann        libusb="yes"
4220ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4221ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
42222b2325ffSGerd Hoffmann    else
42232b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
42248efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
42252b2325ffSGerd Hoffmann        fi
42262b2325ffSGerd Hoffmann        libusb="no"
42272b2325ffSGerd Hoffmann    fi
42282b2325ffSGerd Hoffmannfi
42292b2325ffSGerd Hoffmann
423069354a83SHans de Goede# check for usbredirparser for usb network redirection support
423169354a83SHans de Goedeif test "$usb_redir" != "no" ; then
423265d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
423369354a83SHans de Goede        usb_redir="yes"
4234ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4235ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
423669354a83SHans de Goede    else
423769354a83SHans de Goede        if test "$usb_redir" = "yes"; then
423821684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
423969354a83SHans de Goede        fi
424069354a83SHans de Goede        usb_redir="no"
424169354a83SHans de Goede    fi
424269354a83SHans de Goedefi
424369354a83SHans de Goede
4244cd4ec0b4SGerd Hoffmann##########################################
4245d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4246d9840e25STomoki Sekiyama
4247d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4248d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4249690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4250d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4251d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4252690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4253d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4254d9840e25STomoki Sekiyama	  ;;
4255690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4256d9840e25STomoki Sekiyama  esac
4257d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4258d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4259d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4260d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4261d9840e25STomoki SekiyamaEOF
4262d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4263d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4264d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4265315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4266f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4267d9840e25STomoki Sekiyama  else
4268d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4269d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4270d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4271d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4272d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4273d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4274d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4275d9840e25STomoki Sekiyama    fi
4276d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4277d9840e25STomoki Sekiyama  fi
4278d9840e25STomoki Sekiyamafi
4279d9840e25STomoki Sekiyama
4280d9840e25STomoki Sekiyama##########################################
4281d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4282d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4283d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4284d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4285d9840e25STomoki Sekiyama
4286d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4287d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4288d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4289d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4290d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4291d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4292d9840e25STomoki Sekiyama    else
4293d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4294d9840e25STomoki Sekiyama    fi
4295d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4296d9840e25STomoki Sekiyama    win_sdk=""
4297d9840e25STomoki Sekiyama  fi
4298d9840e25STomoki Sekiyamafi
4299d9840e25STomoki Sekiyama
4300d9840e25STomoki Sekiyama##########################################
430150cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
430250cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
430350cbebb9SMichael Roth  cat > $TMPC << EOF
430450cbebb9SMichael Roth#include <windows.h>
430550cbebb9SMichael Roth#include <ntddscsi.h>
430650cbebb9SMichael Rothint main(void) {
430750cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
430850cbebb9SMichael Roth#error Missing required ioctl definitions
430950cbebb9SMichael Roth#endif
431050cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
431150cbebb9SMichael Roth  return addr.Lun;
431250cbebb9SMichael Roth}
431350cbebb9SMichael RothEOF
431450cbebb9SMichael Roth  if compile_prog "" "" ; then
431550cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4316c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
431750cbebb9SMichael Roth  fi
431850cbebb9SMichael Rothfi
431950cbebb9SMichael Roth
432050cbebb9SMichael Roth##########################################
43219d9e1521SGerd Hoffmann# virgl renderer probe
43229d9e1521SGerd Hoffmann
43239d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
43249d9e1521SGerd Hoffmann  cat > $TMPC << EOF
43259d9e1521SGerd Hoffmann#include <virglrenderer.h>
43269d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
43279d9e1521SGerd HoffmannEOF
43289d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
43299d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
43309d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
43319d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
43329d9e1521SGerd Hoffmann    virglrenderer="yes"
43339d9e1521SGerd Hoffmann  else
43349d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
43359d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
43369d9e1521SGerd Hoffmann    fi
43379d9e1521SGerd Hoffmann    virglrenderer="no"
43389d9e1521SGerd Hoffmann  fi
43399d9e1521SGerd Hoffmannfi
43409d9e1521SGerd Hoffmann
43419d9e1521SGerd Hoffmann##########################################
43425f6b9e8fSBlue Swirl# check if we have fdatasync
43435f6b9e8fSBlue Swirl
43445f6b9e8fSBlue Swirlfdatasync=no
43455f6b9e8fSBlue Swirlcat > $TMPC << EOF
43465f6b9e8fSBlue Swirl#include <unistd.h>
4347d1722a27SAlexandre Raymondint main(void) {
4348d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4349d1722a27SAlexandre Raymondreturn fdatasync(0);
4350d1722a27SAlexandre Raymond#else
4351e172fe11SStefan Weil#error Not supported
4352d1722a27SAlexandre Raymond#endif
4353d1722a27SAlexandre Raymond}
43545f6b9e8fSBlue SwirlEOF
43555f6b9e8fSBlue Swirlif compile_prog "" "" ; then
43565f6b9e8fSBlue Swirl    fdatasync=yes
43575f6b9e8fSBlue Swirlfi
43585f6b9e8fSBlue Swirl
435994a420b1SStefan Hajnoczi##########################################
4360e78815a5SAndreas Färber# check if we have madvise
4361e78815a5SAndreas Färber
4362e78815a5SAndreas Färbermadvise=no
4363e78815a5SAndreas Färbercat > $TMPC << EOF
4364e78815a5SAndreas Färber#include <sys/types.h>
4365e78815a5SAndreas Färber#include <sys/mman.h>
4366832ce9c2SScott Wood#include <stddef.h>
4367e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4368e78815a5SAndreas FärberEOF
4369e78815a5SAndreas Färberif compile_prog "" "" ; then
4370e78815a5SAndreas Färber    madvise=yes
4371e78815a5SAndreas Färberfi
4372e78815a5SAndreas Färber
4373e78815a5SAndreas Färber##########################################
4374e78815a5SAndreas Färber# check if we have posix_madvise
4375e78815a5SAndreas Färber
4376e78815a5SAndreas Färberposix_madvise=no
4377e78815a5SAndreas Färbercat > $TMPC << EOF
4378e78815a5SAndreas Färber#include <sys/mman.h>
4379832ce9c2SScott Wood#include <stddef.h>
4380e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4381e78815a5SAndreas FärberEOF
4382e78815a5SAndreas Färberif compile_prog "" "" ; then
4383e78815a5SAndreas Färber    posix_madvise=yes
4384e78815a5SAndreas Färberfi
4385e78815a5SAndreas Färber
4386e78815a5SAndreas Färber##########################################
43870a852417SPaul Durrant# check if we have posix_syslog
43880a852417SPaul Durrant
43890a852417SPaul Durrantposix_syslog=no
43900a852417SPaul Durrantcat > $TMPC << EOF
43910a852417SPaul Durrant#include <syslog.h>
43920a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
43930a852417SPaul DurrantEOF
43940a852417SPaul Durrantif compile_prog "" "" ; then
43950a852417SPaul Durrant    posix_syslog=yes
43960a852417SPaul Durrantfi
43970a852417SPaul Durrant
43980a852417SPaul Durrant##########################################
439994a420b1SStefan Hajnoczi# check if trace backend exists
440094a420b1SStefan Hajnoczi
44015b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
440294a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
44035b808275SLluís Vilanova  error_exit "invalid trace backends" \
44045b808275SLluís Vilanova      "Please choose supported trace backends."
440594a420b1SStefan Hajnoczifi
440694a420b1SStefan Hajnoczi
44077e24e92aSStefan Hajnoczi##########################################
44087e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
44095b808275SLluís Vilanovaif have_backend "ust"; then
44107e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4411bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
44127e24e92aSStefan Hajnocziint main(void) { return 0; }
44137e24e92aSStefan HajnocziEOF
4414c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4415bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
441689138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
44177e24e92aSStefan Hajnoczi    else
4418c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4419bf15f63cSMohamad Gebai    fi
4420bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
442189138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4422bf15f63cSMohamad Gebai    else
4423bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4424bf15f63cSMohamad Gebai    fi
4425bf15f63cSMohamad Gebai
4426bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4427bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4428bf15f63cSMohamad Gebai  else
4429bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44307e24e92aSStefan Hajnoczi  fi
44317e24e92aSStefan Hajnoczifi
4432b3d08c02SDaniel P. Berrange
4433b3d08c02SDaniel P. Berrange##########################################
4434b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44355b808275SLluís Vilanovaif have_backend "dtrace"; then
4436b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
443776ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4438b3d08c02SDaniel P. Berrange  fi
4439c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4440c276b17dSDaniel P. Berrange  if has 'stap' ; then
4441c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4442c276b17dSDaniel P. Berrange  fi
4443b3d08c02SDaniel P. Berrangefi
4444b3d08c02SDaniel P. Berrange
44457e24e92aSStefan Hajnoczi##########################################
4446519175a2SAlex Barcelo# check and set a backend for coroutine
4447d0e2fce5SAneesh Kumar K.V
44487c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
444933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
445033c53c54SDaniel P. Berrange# specific one.
44517c2acc70SPeter Maydell
44527c2acc70SPeter Maydellucontext_works=no
4453d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4454d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4455d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4456cdf84806SPeter Maydell#ifdef __stub_makecontext
4457cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4458cdf84806SPeter Maydell#endif
445975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4460d0e2fce5SAneesh Kumar K.VEOF
4461d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
44627c2acc70SPeter Maydell    ucontext_works=yes
4463d0e2fce5SAneesh Kumar K.V  fi
4464519175a2SAlex Barcelofi
44657c2acc70SPeter Maydell
44667c2acc70SPeter Maydellif test "$coroutine" = ""; then
44677c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
44687c2acc70SPeter Maydell    coroutine=win32
44697c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
44707c2acc70SPeter Maydell    coroutine=ucontext
4471519175a2SAlex Barcelo  else
44727c2acc70SPeter Maydell    coroutine=sigaltstack
44737c2acc70SPeter Maydell  fi
44747c2acc70SPeter Maydellelse
44757c2acc70SPeter Maydell  case $coroutine in
44767c2acc70SPeter Maydell  windows)
44777c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
44787c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
44797c2acc70SPeter Maydell    fi
44807c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
44817c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
44827c2acc70SPeter Maydell    coroutine=win32
44837c2acc70SPeter Maydell    ;;
44847c2acc70SPeter Maydell  ucontext)
44857c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
44867c2acc70SPeter Maydell      feature_not_found "ucontext"
44877c2acc70SPeter Maydell    fi
44887c2acc70SPeter Maydell    ;;
448933c53c54SDaniel P. Berrange  sigaltstack)
44907c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
44917c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
44927c2acc70SPeter Maydell    fi
44937c2acc70SPeter Maydell    ;;
44947c2acc70SPeter Maydell  *)
449576ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
44967c2acc70SPeter Maydell    ;;
44977c2acc70SPeter Maydell  esac
4498d0e2fce5SAneesh Kumar K.Vfi
4499d0e2fce5SAneesh Kumar K.V
450070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
450170c60c08SStefan Hajnoczi  coroutine_pool=yes
450270c60c08SStefan Hajnoczifi
450370c60c08SStefan Hajnoczi
45047d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
45057d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
45067d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
45077d992e4dSPeter Lieven  fi
45087d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
45097d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
45107d992e4dSPeter Lieven    coroutine_pool=no
45117d992e4dSPeter Lieven  fi
45127d992e4dSPeter Lievenfi
45137d992e4dSPeter Lieven
45147d992e4dSPeter Lieven
4515d0e2fce5SAneesh Kumar K.V##########################################
4516d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4517d2042378SAneesh Kumar K.V
45184e1797f9SStefan Weilopen_by_handle_at=no
4519d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4520d2042378SAneesh Kumar K.V#include <fcntl.h>
4521acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4522acc55ba8SStefan Weil# error missing definition
4523acc55ba8SStefan Weil#else
452475cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4525acc55ba8SStefan Weil#endif
4526d2042378SAneesh Kumar K.VEOF
4527d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4528d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4529d2042378SAneesh Kumar K.Vfi
4530d2042378SAneesh Kumar K.V
4531e06a765eSHarsh Prateek Bora########################################
4532e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4533e06a765eSHarsh Prateek Bora
4534e06a765eSHarsh Prateek Boralinux_magic_h=no
4535e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4536e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4537e06a765eSHarsh Prateek Boraint main(void) {
453875cafad7SStefan Weil  return 0;
4539e06a765eSHarsh Prateek Bora}
4540e06a765eSHarsh Prateek BoraEOF
4541e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4542e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4543e06a765eSHarsh Prateek Borafi
4544e06a765eSHarsh Prateek Bora
45458ab1bf12SLuiz Capitulino########################################
4546c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4547c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4548c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4549c95e3080SKevin Wolf# only a warning.
4550c95e3080SKevin Wolf#
4551c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4552c95e3080SKevin Wolf# the build doesn't fail anyway.
4553c95e3080SKevin Wolf
455406d71fa1SPeter Maydellpragma_disable_unused_but_set=no
455506d71fa1SPeter Maydellcat > $TMPC << EOF
4556e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
455706d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4558c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4559e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4560c95e3080SKevin Wolf
456106d71fa1SPeter Maydellint main(void) {
456206d71fa1SPeter Maydell    return 0;
456306d71fa1SPeter Maydell}
456406d71fa1SPeter MaydellEOF
456506d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4566cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4567c95e3080SKevin Wolfelse
4568c95e3080SKevin Wolf    werror=no
456906d71fa1SPeter Maydellfi
457006d71fa1SPeter Maydell
457106d71fa1SPeter Maydell########################################
4572541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
45733f4349dcSKevin Wolf
45743f4349dcSKevin Wolfvalgrind_h=no
45753f4349dcSKevin Wolfcat > $TMPC << EOF
45763f4349dcSKevin Wolf#include <valgrind/valgrind.h>
45773f4349dcSKevin Wolfint main(void) {
45783f4349dcSKevin Wolf  return 0;
45793f4349dcSKevin Wolf}
45803f4349dcSKevin WolfEOF
45813f4349dcSKevin Wolfif compile_prog "" "" ; then
45823f4349dcSKevin Wolf    valgrind_h=yes
45833f4349dcSKevin Wolffi
45843f4349dcSKevin Wolf
45853f4349dcSKevin Wolf########################################
45868ab1bf12SLuiz Capitulino# check if environ is declared
45878ab1bf12SLuiz Capitulino
45888ab1bf12SLuiz Capitulinohas_environ=no
45898ab1bf12SLuiz Capitulinocat > $TMPC << EOF
45908ab1bf12SLuiz Capitulino#include <unistd.h>
45918ab1bf12SLuiz Capitulinoint main(void) {
4592c075a723SBlue Swirl    environ = 0;
45938ab1bf12SLuiz Capitulino    return 0;
45948ab1bf12SLuiz Capitulino}
45958ab1bf12SLuiz CapitulinoEOF
45968ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
45978ab1bf12SLuiz Capitulino    has_environ=yes
45988ab1bf12SLuiz Capitulinofi
45998ab1bf12SLuiz Capitulino
460076a347e1SRichard Henderson########################################
460176a347e1SRichard Henderson# check if cpuid.h is usable.
460276a347e1SRichard Henderson
460376a347e1SRichard Hendersoncat > $TMPC << EOF
460476a347e1SRichard Henderson#include <cpuid.h>
460576a347e1SRichard Hendersonint main(void) {
4606774d566cSPeter Maydell    unsigned a, b, c, d;
4607774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4608774d566cSPeter Maydell
4609774d566cSPeter Maydell    if (max >= 1) {
4610774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4611774d566cSPeter Maydell    }
4612774d566cSPeter Maydell
4613774d566cSPeter Maydell    if (max >= 7) {
4614774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4615774d566cSPeter Maydell    }
4616774d566cSPeter Maydell
461776a347e1SRichard Henderson    return 0;
461876a347e1SRichard Henderson}
461976a347e1SRichard HendersonEOF
462076a347e1SRichard Hendersonif compile_prog "" "" ; then
462176a347e1SRichard Henderson    cpuid_h=yes
462276a347e1SRichard Hendersonfi
462376a347e1SRichard Henderson
46245dd89908SRichard Henderson##########################################
46255dd89908SRichard Henderson# avx2 optimization requirement check
46265dd89908SRichard Henderson#
46275dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
46285dd89908SRichard Henderson# since we won't be able to select the new routines.
46295dd89908SRichard Henderson
46305dd89908SRichard Hendersonif test $cpuid_h = yes; then
46315dd89908SRichard Henderson  cat > $TMPC << EOF
46325dd89908SRichard Henderson#pragma GCC push_options
46335dd89908SRichard Henderson#pragma GCC target("avx2")
46345dd89908SRichard Henderson#include <cpuid.h>
46355dd89908SRichard Henderson#include <immintrin.h>
46365dd89908SRichard Hendersonstatic int bar(void *a) {
46375dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
46385dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
46395dd89908SRichard Henderson}
46405dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
46415dd89908SRichard HendersonEOF
46425dd89908SRichard Henderson  if compile_object "" ; then
46435dd89908SRichard Henderson    avx2_opt="yes"
46445dd89908SRichard Henderson  fi
46455dd89908SRichard Hendersonfi
46465dd89908SRichard Henderson
4647f540166bSRichard Henderson########################################
4648f540166bSRichard Henderson# check if __[u]int128_t is usable.
4649f540166bSRichard Henderson
4650f540166bSRichard Hendersonint128=no
4651f540166bSRichard Hendersoncat > $TMPC << EOF
4652a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4653a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4654a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4655a00f66abSStefan Weil# endif
4656a00f66abSStefan Weil#endif
4657f540166bSRichard Henderson__int128_t a;
4658f540166bSRichard Henderson__uint128_t b;
4659f540166bSRichard Hendersonint main (void) {
4660f540166bSRichard Henderson  a = a + b;
4661f540166bSRichard Henderson  b = a * b;
4662464e3671SPeter Maydell  a = a * a;
4663f540166bSRichard Henderson  return 0;
4664f540166bSRichard Henderson}
4665f540166bSRichard HendersonEOF
4666f540166bSRichard Hendersonif compile_prog "" "" ; then
4667f540166bSRichard Henderson    int128=yes
4668f540166bSRichard Hendersonfi
466976a347e1SRichard Henderson
46707ebee43eSRichard Henderson#########################################
46717ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
46727ebee43eSRichard Henderson
46737ebee43eSRichard Hendersonatomic128=no
46747ebee43eSRichard Hendersonif test "$int128" = "yes"; then
46757ebee43eSRichard Henderson  cat > $TMPC << EOF
46767ebee43eSRichard Hendersonint main(void)
46777ebee43eSRichard Henderson{
46787ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
46797ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
46807ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
46817ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
46827ebee43eSRichard Henderson  return 0;
46837ebee43eSRichard Henderson}
46847ebee43eSRichard HendersonEOF
46857ebee43eSRichard Henderson  if compile_prog "" "" ; then
46867ebee43eSRichard Henderson    atomic128=yes
46877ebee43eSRichard Henderson  fi
46887ebee43eSRichard Hendersonfi
46897ebee43eSRichard Henderson
4690df79b996SRichard Henderson#########################################
4691df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4692df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4693df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4694df79b996SRichard Henderson
4695df79b996SRichard Hendersoncat > $TMPC << EOF
4696df79b996SRichard Henderson#include <stdint.h>
4697df79b996SRichard Hendersonint main(void)
4698df79b996SRichard Henderson{
4699df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4700df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4701df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4702df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4703df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4704df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4705df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4706df79b996SRichard Henderson#else
4707df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4708df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4709df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4710df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4711df79b996SRichard Henderson#endif
4712df79b996SRichard Henderson  return 0;
4713df79b996SRichard Henderson}
4714df79b996SRichard HendersonEOF
4715df79b996SRichard Hendersonif compile_prog "" "" ; then
4716df79b996SRichard Henderson  atomic64=yes
4717df79b996SRichard Hendersonfi
4718df79b996SRichard Henderson
47191e6e9acaSRichard Henderson########################################
47201e6e9acaSRichard Henderson# check if getauxval is available.
47211e6e9acaSRichard Henderson
47221e6e9acaSRichard Hendersongetauxval=no
47231e6e9acaSRichard Hendersoncat > $TMPC << EOF
47241e6e9acaSRichard Henderson#include <sys/auxv.h>
47251e6e9acaSRichard Hendersonint main(void) {
47261e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
47271e6e9acaSRichard Henderson}
47281e6e9acaSRichard HendersonEOF
47291e6e9acaSRichard Hendersonif compile_prog "" "" ; then
47301e6e9acaSRichard Henderson    getauxval=yes
47311e6e9acaSRichard Hendersonfi
47321e6e9acaSRichard Henderson
4733fd0e6053SJohn Snow########################################
4734fd0e6053SJohn Snow# check if ccache is interfering with
4735fd0e6053SJohn Snow# semantic analysis of macros
4736fd0e6053SJohn Snow
47375e4dfd3dSJohn Snowunset CCACHE_CPP2
4738fd0e6053SJohn Snowccache_cpp2=no
4739fd0e6053SJohn Snowcat > $TMPC << EOF
4740fd0e6053SJohn Snowstatic const int Z = 1;
4741fd0e6053SJohn Snow#define fn() ({ Z; })
4742fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4743fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4744fd0e6053SJohn Snow#define ID(X) (X)
4745fd0e6053SJohn Snowint main(int argc, char *argv[])
4746fd0e6053SJohn Snow{
4747fd0e6053SJohn Snow    int x = 0, y = 0;
4748fd0e6053SJohn Snow    x = ID(x);
4749fd0e6053SJohn Snow    x = fn();
4750fd0e6053SJohn Snow    fn();
4751fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4752fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4753fd0e6053SJohn Snow    return 0;
4754fd0e6053SJohn Snow}
4755fd0e6053SJohn SnowEOF
4756fd0e6053SJohn Snow
4757fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4758fd0e6053SJohn Snow    ccache_cpp2=yes
4759fd0e6053SJohn Snowfi
4760fd0e6053SJohn Snow
4761b553a042SJohn Snow#################################################
4762b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4763b553a042SJohn Snow
4764b553a042SJohn Snowif test "$fortify_source" != "no"; then
4765b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4766b553a042SJohn Snow    fortify_source="no";
4767e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4768cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4769b553a042SJohn Snow    fortify_source="no";
4770b553a042SJohn Snow  else
4771b553a042SJohn Snow    fortify_source="yes"
4772b553a042SJohn Snow  fi
4773b553a042SJohn Snowfi
4774b553a042SJohn Snow
4775d2042378SAneesh Kumar K.V##########################################
4776277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4777277abf15SJan Vesely
4778277abf15SJan Veselyhave_fsxattr=no
4779277abf15SJan Veselycat > $TMPC << EOF
4780277abf15SJan Vesely#include <linux/fs.h>
4781277abf15SJan Veselystruct fsxattr foo;
4782277abf15SJan Veselyint main(void) {
4783277abf15SJan Vesely  return 0;
4784277abf15SJan Vesely}
4785277abf15SJan VeselyEOF
4786277abf15SJan Veselyif compile_prog "" "" ; then
4787277abf15SJan Vesely    have_fsxattr=yes
4788277abf15SJan Veselyfi
4789277abf15SJan Vesely
4790b66e10e4SPeter Maydell##########################################
4791b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4792575b22b1SLaurent Vivierhave_rtnetlink=no
4793575b22b1SLaurent Viviercat > $TMPC << EOF
4794575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4795575b22b1SLaurent Vivierint main(void) {
4796575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4797575b22b1SLaurent Vivier}
4798575b22b1SLaurent VivierEOF
4799575b22b1SLaurent Vivierif compile_prog "" "" ; then
4800575b22b1SLaurent Vivier    have_rtnetlink=yes
4801575b22b1SLaurent Vivierfi
4802575b22b1SLaurent Vivier
48036a02c806SStefan Hajnoczi##########################################
48046a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
48056a02c806SStefan Hajnoczihave_af_vsock=no
48066a02c806SStefan Hajnoczicat > $TMPC << EOF
48076a02c806SStefan Hajnoczi#include <errno.h>
48086a02c806SStefan Hajnoczi#include <sys/types.h>
48096a02c806SStefan Hajnoczi#include <sys/socket.h>
48106a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
48116a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
48126a02c806SStefan Hajnoczi#endif
48136a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
48146a02c806SStefan Hajnocziint main(void) {
48156a02c806SStefan Hajnoczi    int sock, ret;
48166a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
48176a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
48186a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
48196a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
48206a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
48216a02c806SStefan Hajnoczi        return 0;
48226a02c806SStefan Hajnoczi    }
48236a02c806SStefan Hajnoczi    return -1;
48246a02c806SStefan Hajnoczi}
48256a02c806SStefan HajnocziEOF
48266a02c806SStefan Hajnocziif compile_prog "" "" ; then
48276a02c806SStefan Hajnoczi    have_af_vsock=yes
48286a02c806SStefan Hajnoczifi
48296a02c806SStefan Hajnoczi
4830f0d92b56SLongpeng(Mike)##########################################
4831f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
4832f0d92b56SLongpeng(Mike)hava_afalg=no
4833f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
4834f0d92b56SLongpeng(Mike)#include <errno.h>
4835f0d92b56SLongpeng(Mike)#include <sys/types.h>
4836f0d92b56SLongpeng(Mike)#include <sys/socket.h>
4837f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
4838f0d92b56SLongpeng(Mike)int main(void) {
4839f0d92b56SLongpeng(Mike)    int sock;
4840f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
4841f0d92b56SLongpeng(Mike)    return sock;
4842f0d92b56SLongpeng(Mike)}
4843f0d92b56SLongpeng(Mike)EOF
4844f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4845f0d92b56SLongpeng(Mike)    have_afalg=yes
4846f0d92b56SLongpeng(Mike)fi
4847f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4848f0d92b56SLongpeng(Mike)then
4849f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4850f0d92b56SLongpeng(Mike)    then
4851f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4852f0d92b56SLongpeng(Mike)    fi
4853f0d92b56SLongpeng(Mike)fi
4854f0d92b56SLongpeng(Mike)
4855f0d92b56SLongpeng(Mike)
48566969ec6cSJames Clarke#################################################
48576969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
48586969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
48596969ec6cSJames Clarke# given. It does no harm to give it on other
48606969ec6cSJames Clarke# platforms too.
48616969ec6cSJames Clarke
48626969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
48636969ec6cSJames Clarke#       contains -Wmissing-prototypes
48646969ec6cSJames Clarkecat > $TMPC << EOF
48656969ec6cSJames Clarkeextern int foo(void);
48666969ec6cSJames Clarkeint foo(void) { return 0; }
48676969ec6cSJames ClarkeEOF
48686969ec6cSJames Clarkeif ! compile_object ""; then
48696969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
48706969ec6cSJames Clarkefi
48717ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
48727ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
48737ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
48747ecf44a5SPaolo Bonzini    break
48757ecf44a5SPaolo Bonzini  fi
48767ecf44a5SPaolo Bonzinidone
48777ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
48787ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
48796969ec6cSJames Clarkefi
48806969ec6cSJames Clarke
4881277abf15SJan Vesely##########################################
48824d04351fSChristopher Covington# check for sysmacros.h
48834d04351fSChristopher Covington
48844d04351fSChristopher Covingtonhave_sysmacros=no
48854d04351fSChristopher Covingtoncat > $TMPC << EOF
48864d04351fSChristopher Covington#include <sys/sysmacros.h>
48874d04351fSChristopher Covingtonint main(void) {
48884d04351fSChristopher Covington    return makedev(0, 0);
48894d04351fSChristopher Covington}
48904d04351fSChristopher CovingtonEOF
48914d04351fSChristopher Covingtonif compile_prog "" "" ; then
48924d04351fSChristopher Covington    have_sysmacros=yes
48934d04351fSChristopher Covingtonfi
48944d04351fSChristopher Covington
48954d04351fSChristopher Covington##########################################
4896da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
4897da92c3ffSAshish Mittal# Check if libvxhs is installed
4898da92c3ffSAshish Mittal
4899da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
4900da92c3ffSAshish Mittal  cat > $TMPC <<EOF
4901da92c3ffSAshish Mittal#include <stdint.h>
4902da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
4903da92c3ffSAshish Mittal
4904da92c3ffSAshish Mittalvoid *vxhs_callback;
4905da92c3ffSAshish Mittal
4906da92c3ffSAshish Mittalint main(void) {
4907da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
4908da92c3ffSAshish Mittal    return 0;
4909da92c3ffSAshish Mittal}
4910da92c3ffSAshish MittalEOF
4911da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
4912da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
4913da92c3ffSAshish Mittal    vxhs=yes
4914da92c3ffSAshish Mittal  else
4915da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
4916da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
4917da92c3ffSAshish Mittal    fi
4918da92c3ffSAshish Mittal    vxhs=no
4919da92c3ffSAshish Mittal  fi
4920da92c3ffSAshish Mittalfi
4921da92c3ffSAshish Mittal
4922da92c3ffSAshish Mittal##########################################
492349e00a18SAndreas Grapentin# check for _Static_assert()
492449e00a18SAndreas Grapentin
492549e00a18SAndreas Grapentinhave_static_assert=no
492649e00a18SAndreas Grapentincat > $TMPC << EOF
492749e00a18SAndreas Grapentin_Static_assert(1, "success");
492849e00a18SAndreas Grapentinint main(void) {
492949e00a18SAndreas Grapentin    return 0;
493049e00a18SAndreas Grapentin}
493149e00a18SAndreas GrapentinEOF
493249e00a18SAndreas Grapentinif compile_prog "" "" ; then
493349e00a18SAndreas Grapentin    have_static_assert=yes
493449e00a18SAndreas Grapentinfi
493549e00a18SAndreas Grapentin
493649e00a18SAndreas Grapentin##########################################
4937e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
4938e674605fSTomáš Golembiovský
4939e674605fSTomáš Golembiovskýhave_utmpx=no
4940e674605fSTomáš Golembiovskýcat > $TMPC << EOF
4941e674605fSTomáš Golembiovský#include <utmpx.h>
4942e674605fSTomáš Golembiovskýstruct utmpx user_info;
4943e674605fSTomáš Golembiovskýint main(void) {
4944e674605fSTomáš Golembiovský    return 0;
4945e674605fSTomáš Golembiovský}
4946e674605fSTomáš GolembiovskýEOF
4947e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
4948e674605fSTomáš Golembiovský    have_utmpx=yes
4949e674605fSTomáš Golembiovskýfi
4950e674605fSTomáš Golembiovský
4951e674605fSTomáš Golembiovský##########################################
4952e86ecd4bSJuan Quintela# End of CC checks
4953e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4954e86ecd4bSJuan Quintela
49551d728c39SBlue Swirlif test "$gcov" = "yes" ; then
49561d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
49571d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4958b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4959e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4960ce278618SPeter Maydellelif test "$debug" = "no"; then
4961ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
4962e86ecd4bSJuan Quintelafi
4963a316e378SJuan Quintela
49646542aa9cSPeter Lieven##########################################
49656542aa9cSPeter Lieven# Do we have libnfs
49666542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
4967b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
49686542aa9cSPeter Lieven    libnfs="yes"
49696542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
49706542aa9cSPeter Lieven  else
49716542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
49728efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
49736542aa9cSPeter Lieven    fi
49746542aa9cSPeter Lieven    libnfs="no"
49756542aa9cSPeter Lieven  fi
49766542aa9cSPeter Lievenfi
49771d728c39SBlue Swirl
49786ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
49796ca026cbSPeter Maydellif test "$werror" = "yes"; then
49806ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
49816ca026cbSPeter Maydellfi
49826ca026cbSPeter Maydell
4983e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
4984e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
49851156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
4986e86ecd4bSJuan Quintela    fi
4987e86ecd4bSJuan Quintelafi
4988e86ecd4bSJuan Quintela
498994dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
499094dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
499194dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
499294dd53c5SGerd Hoffmannelse
499394dd53c5SGerd Hoffmann    POD2MAN="pod2man"
499494dd53c5SGerd Hoffmannfi
499594dd53c5SGerd Hoffmann
4996952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4997952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4998952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
4999e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5000952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5001952afb71SBlue Swirl        fi
5002952afb71SBlue Swirl    done
5003952afb71SBlue Swirlfi
5004952afb71SBlue Swirl
500510ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5006e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5007528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5008834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
50095a67135aSbellard
5010e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5011e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5012e0580342SKamil Rytarowski  ivshmem=yes
5013e0580342SKamil Rytarowskifi
5014e0580342SKamil Rytarowski
50154b1c11fdSDaniel P. Berrangetools=""
50164b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5017ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
50184b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
50194b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5020b1449edbSKamil Rytarowski  fi
5021b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5022a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
50234b1c11fdSDaniel P. Berrange  fi
50244b1c11fdSDaniel P. Berrangefi
50254b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5026983eef5aSMeador Inge  if test "$virtfs" != no ; then
5027be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
5028983eef5aSMeador Inge      virtfs=yes
502917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5030983eef5aSMeador Inge    else
5031983eef5aSMeador Inge      if test "$virtfs" = yes; then
50323f3b5388SStefan Weil        error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
5033983eef5aSMeador Inge      fi
503417500370SAndreas Färber      virtfs=no
5035983eef5aSMeador Inge    fi
503617bff52bSM. Mohan Kumar  fi
5037d138cee9SMichael Rothfi
50389d6bc27bSMichael Roth
50399d6bc27bSMichael Roth# Probe for guest agent support/options
50409d6bc27bSMichael Roth
5041e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5042b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5043fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5044e8ef31a3SMichael Tokarev      guest_agent=yes
5045e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5046e8ef31a3SMichael Tokarev      guest_agent=no
5047e8ef31a3SMichael Tokarev  else
5048e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5049ca35f780SPaolo Bonzini  fi
50504b1c11fdSDaniel P. Berrangefi
5051ca35f780SPaolo Bonzini
50529d6bc27bSMichael Roth# Guest agent Window MSI  package
50539d6bc27bSMichael Roth
50549d6bc27bSMichael Rothif test "$guest_agent" != yes; then
50559d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
50569d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
50579d6bc27bSMichael Roth  fi
50589d6bc27bSMichael Roth  guest_agent_msi=no
50599d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
50609d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50619d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
50629d6bc27bSMichael Roth  fi
50639d6bc27bSMichael Roth  guest_agent_msi=no
50649d6bc27bSMichael Rothelif ! has wixl; then
50659d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50669d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
50679d6bc27bSMichael Roth  fi
50689d6bc27bSMichael Roth  guest_agent_msi=no
50691a34904eSMichael Rothelse
50701a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
50711a34904eSMichael Roth  # disabled explicitly
50721a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
50731a34904eSMichael Roth    guest_agent_msi=yes
50741a34904eSMichael Roth  fi
50759d6bc27bSMichael Rothfi
50769d6bc27bSMichael Roth
50771a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
50789d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
50799d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
50809d6bc27bSMichael Roth  fi
50819d6bc27bSMichael Roth
50829d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
50839d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
50849d6bc27bSMichael Roth  fi
50859d6bc27bSMichael Roth
50869d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
50879d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
50889d6bc27bSMichael Roth  fi
50899d6bc27bSMichael Roth
50909d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
509189138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
50929d6bc27bSMichael Roth  fi
50939d6bc27bSMichael Roth
509489138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
50959d6bc27bSMichael Roth
50969d6bc27bSMichael Roth  case "$cpu" in
50979d6bc27bSMichael Roth  x86_64)
50989d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
50999d6bc27bSMichael Roth    ;;
51009d6bc27bSMichael Roth  i386)
51019d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
51029d6bc27bSMichael Roth    ;;
51039d6bc27bSMichael Roth  *)
51049d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
51059d6bc27bSMichael Roth    ;;
51069d6bc27bSMichael Roth  esac
51079d6bc27bSMichael Rothfi
51089d6bc27bSMichael Roth
5109ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5110ca35f780SPaolo Bonziniroms=
5111ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5112ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5113ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5114e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5115e57218b6SPeter Maydell    # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5116e57218b6SPeter Maydell    # variant; and Windows uses i386pe.
5117e57218b6SPeter Maydell    for emu in elf_i386 elf_i386_fbsd i386pe; do
5118e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5119e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5120ca35f780SPaolo Bonzini            roms="optionrom"
5121e57218b6SPeter Maydell            break
5122e57218b6SPeter Maydell        fi
5123e57218b6SPeter Maydell    done
5124ca35f780SPaolo Bonzinifi
5125d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
512639ac8455SDavid Gibson  roms="$roms spapr-rtas"
512739ac8455SDavid Gibsonfi
5128ca35f780SPaolo Bonzini
51299933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
51309933c305SChristian Borntraeger  roms="$roms s390-ccw"
51319933c305SChristian Borntraegerfi
51329933c305SChristian Borntraeger
5133964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
513492fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5135964c6fa1SRichard Henderson  textseg_addr=
5136964c6fa1SRichard Henderson  case "$cpu" in
5137479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5138479eb121SRichard Henderson      # ??? Rationale for choosing this address
5139964c6fa1SRichard Henderson      textseg_addr=0x60000000
5140964c6fa1SRichard Henderson      ;;
5141964c6fa1SRichard Henderson    mips)
5142479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5143479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5144479eb121SRichard Henderson      textseg_addr=0x60000000
5145964c6fa1SRichard Henderson      ;;
5146964c6fa1SRichard Henderson  esac
5147964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5148964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5149964c6fa1SRichard Henderson    int main(void) { return 0; }
5150964c6fa1SRichard HendersonEOF
5151964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5152964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5153964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5154964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5155964c6fa1SRichard Henderson      # at least.
515692fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
515792fe2ba8SPeter Maydell        error_exit \
515892fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
515992fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
516092fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
516192fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
516292fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
516392fe2ba8SPeter Maydell            "--disable-user option to configure."
516492fe2ba8SPeter Maydell      fi
516592fe2ba8SPeter Maydell
5166964c6fa1SRichard Henderson      $ld --verbose | sed \
5167964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5168964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5169964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5170964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5171964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5172964c6fa1SRichard Henderson    fi
5173964c6fa1SRichard Henderson  fi
5174964c6fa1SRichard Hendersonfi
5175964c6fa1SRichard Henderson
517611cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
517711cde1c8SBruno 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.
517811cde1c8SBruno Dominguezif has $cxx; then
517911cde1c8SBruno Dominguez    cat > $TMPC <<EOF
518011cde1c8SBruno Dominguezint c_function(void);
518111cde1c8SBruno Dominguezint main(void) { return c_function(); }
518211cde1c8SBruno DominguezEOF
518311cde1c8SBruno Dominguez
518411cde1c8SBruno Dominguez    compile_object
518511cde1c8SBruno Dominguez
518611cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
518711cde1c8SBruno Dominguezextern "C" {
518811cde1c8SBruno Dominguez   int c_function(void);
518911cde1c8SBruno Dominguez}
519011cde1c8SBruno Dominguezint c_function(void) { return 42; }
519111cde1c8SBruno DominguezEOF
519211cde1c8SBruno Dominguez
519311cde1c8SBruno Dominguez    update_cxxflags
519411cde1c8SBruno Dominguez
519511cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
519611cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
519711cde1c8SBruno Dominguez        :
519811cde1c8SBruno Dominguez    else
519911cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
520011cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
520111cde1c8SBruno Dominguez        cxx=
520211cde1c8SBruno Dominguez    fi
520311cde1c8SBruno Dominguezelse
520411cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
520511cde1c8SBruno Dominguez    cxx=
520611cde1c8SBruno Dominguezfi
520711cde1c8SBruno Dominguez
520802d34f62SCole Robinsonecho_version() {
520902d34f62SCole Robinson    if test "$1" = "yes" ; then
521002d34f62SCole Robinson        echo "($2)"
521102d34f62SCole Robinson    fi
521202d34f62SCole Robinson}
521302d34f62SCole Robinson
521450e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
521550e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
521650e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
52175ca9388aSGerd Hoffmann
52187d13299dSbellardecho "Install prefix    $prefix"
521989138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
522089138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
522189138857SStefan Weilecho "library directory $(eval echo $libdir)"
522289138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
522389138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
522489138857SStefan Weilecho "include directory $(eval echo $includedir)"
522589138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
522611d9f695Sbellardif test "$mingw32" = "no" ; then
522789138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
522889138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
522943ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
52305a699bbbSLaszlo Ersekelse
52315a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5232d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
523311d9f695Sbellardfi
52345a67135aSbellardecho "Source path       $source_path"
52357d13299dSbellardecho "C compiler        $cc"
523683469015Sbellardecho "Host C compiler   $host_cc"
523783f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
52383c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
523945d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
52400c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5241a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
52420c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
52437d13299dSbellardecho "make              $make"
52446a882643Spbrookecho "install           $install"
5245c886edfbSBlue Swirlecho "python            $python"
5246e2d8830eSBradif test "$slirp" = "yes" ; then
5247e2d8830eSBrad    echo "smbd              $smbd"
5248e2d8830eSBradfi
524917969268SFam Zhengecho "module support    $modules"
5250a98fd896Sbellardecho "host CPU          $cpu"
5251de83cd02Sbellardecho "host big endian   $bigendian"
525297a847bcSbellardecho "target list       $target_list"
52537d13299dSbellardecho "gprof enabled     $gprof"
525403b4fe7dSaliguoriecho "sparse enabled    $sparse"
52551625af87Saliguoriecho "strip binaries    $strip_opt"
525605c2a3e7Sbellardecho "profiler          $profiler"
525743ce4dfeSbellardecho "static build      $static"
52585b0753e0Sbellardif test "$darwin" = "yes" ; then
52595b0753e0Sbellard    echo "Cocoa support     $cocoa"
52605b0753e0Sbellardfi
526189138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
526289138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5263925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
526489138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5265a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5266ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5267b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
526891bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
526937788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
527089138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5271fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
52729a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
52734d3b6f6eSbalrogecho "curses support    $curses"
52749d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5275769ce76dSAlexander Grafecho "curl support      $curl"
527667b915a5Sbellardecho "mingw32 support   $mingw32"
52770c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5278b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5279b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5280983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5281821601eaSJes Sorensenecho "VNC support       $vnc"
5282821601eaSJes Sorensenif test "$vnc" = "yes" ; then
52832f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
52842f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5285efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5286821601eaSJes Sorensenfi
52873142255cSblueswir1if test -n "$sparc_cpu"; then
52883142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
52893142255cSblueswir1fi
5290e37630caSaliguoriecho "xen support       $xen"
52913996e85cSPaul Durrantif test "$xen" = "yes" ; then
52923996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
529364a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
52943996e85cSPaul Durrantfi
52952e4d9fb1Saurel32echo "brlapi support    $brlapi"
5296a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5297a25dba17SJuan Quintelaecho "Documentation     $docs"
529840d6444eSAvi Kivityecho "PIE               $pie"
52998a16d273Sthsecho "vde support       $vde"
530058952137SVincenzo Maffioneecho "netmap support    $netmap"
53015c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5302758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
530377755340Sthsecho "Install blobs     $blobs"
5304b31a0277SJuan Quintelaecho "KVM support       $kvm"
5305b0cb0a66SVincent Palatinecho "HAX support       $hax"
5306b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5307b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5308b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
53099195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5310b3f6ea7eSPaolo Bonzinifi
5311b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5312f652e6afSaurel32echo "fdt support       $fdt"
5313ceb42de8Saliguoriecho "preadv support    $preadv"
53145f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5315e78815a5SAndreas Färberecho "madvise           $madvise"
5316e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
531747e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5318d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
53195e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5320fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5321e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
53225b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5323713572a7SMarc-André Lureauif have_backend "simple"; then
53249410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5325e00e36fbSStefan Weilfi
532689138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5327f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5328dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
53297b02f544SMarc-André Lureauecho "smartcard support $smartcard"
53302b2325ffSGerd Hoffmannecho "libusb            $libusb"
533169354a83SHans de Goedeecho "usb net redir     $usb_redir"
5332da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5333014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5334c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
53356542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5336d138cee9SMichael Rothecho "build guest agent $guest_agent"
5337d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
533850cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
53394c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5340f794573eSEduardo Otuboecho "seccomp support   $seccomp"
53417c2acc70SPeter Maydellecho "coroutine backend $coroutine"
534270c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
53437d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5344f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5345eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
53461d728c39SBlue Swirlecho "gcov              $gcov_tool"
53471d728c39SBlue Swirlecho "gcov enabled      $gcov"
5348ab214c29SStefan Bergerecho "TPM support       $tpm"
53490a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
53503b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
53513556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5352ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5353607dacd0Sqiaonuohanecho "lzo support       $lzo"
5354607dacd0Sqiaonuohanecho "snappy support    $snappy"
53556b383c08SPeter Wuecho "bzip2 support     $bzip2"
5356a99d57bbSWanlong Gaoecho "NUMA host support $numa"
53572847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
53587b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
535999f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5360a6b1d4c0SChanglong Xieecho "replication support $replication"
5361da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
536267b915a5Sbellard
53631ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
536424b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5365e8cd23deSbellardfi
536697a847bcSbellard
5367898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5368898be3e0SPeter Maydell    echo
5369898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5370898be3e0SPeter Maydell    echo
5371898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5372898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5373898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5374898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5375898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5376898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5377898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5378898be3e0SPeter Maydellfi
5379898be3e0SPeter Maydell
5380898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5381898be3e0SPeter Maydell    echo
5382898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5383898be3e0SPeter Maydell    echo
5384c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5385c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5386898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5387898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5388898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5389898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5390898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5391898be3e0SPeter Maydellfi
5392898be3e0SPeter Maydell
539398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
539497a847bcSbellard
5395dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5396dbd99ae3SStefan Weil
539798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
539898ec69acSJuan Quintelaecho >> $config_host_mak
539998ec69acSJuan Quintela
5400e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
540199d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
540299d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
54033aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
54048bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
54050f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
540699d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
540799d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
540822d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
54099afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
54109afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5411e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
54125a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5413785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
54145a699bbbSLaszlo Ersekfi
5415f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5416f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
541711cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5418f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5419834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5420f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5421804edf29SJuan Quintela
542298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5423727e5283SPaolo Bonzini
5424f8393946Saurel32if test "$debug_tcg" = "yes" ; then
54252358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5426f8393946Saurel32fi
54271625af87Saliguoriif test "$strip_opt" = "yes" ; then
542852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
54291625af87Saliguorifi
54307d13299dSbellardif test "$bigendian" = "yes" ; then
5431e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
543297a847bcSbellardfi
543367b915a5Sbellardif test "$mingw32" = "yes" ; then
543498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
543589138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
54369fe6de94SBlue Swirl  version_major=${rc_version%%.*}
54379fe6de94SBlue Swirl  rc_version=${rc_version#*.}
54389fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
54399fe6de94SBlue Swirl  rc_version=${rc_version#*.}
54409fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
54419fe6de94SBlue Swirl  version_micro=0
54429fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
54439fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5444d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5445d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5446f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5447d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5448d9840e25STomoki Sekiyama  fi
544950cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
545050cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
545150cbebb9SMichael Roth  fi
54521a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
54539dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
54549dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
54559dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
54569dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
54579dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
54589dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
54599dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
54609dacf32dSYossi Hindin  fi
5461210fa556Spbrookelse
546235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5463210fa556Spbrookfi
5464128ab2ffSblueswir1
5465dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5466dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5467dffcb71cSMark McLoughlinfi
5468dffcb71cSMark McLoughlin
546983fb7adfSbellardif test "$darwin" = "yes" ; then
547098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
547183fb7adfSbellardfi
5472b29fe3edSmalc
5473ec530c81Sbellardif test "$solaris" = "yes" ; then
547498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5475ec530c81Sbellardfi
5476179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5477179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5478179cf400SAndreas Färberfi
547997a847bcSbellardif test "$static" = "yes" ; then
548098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
548197a847bcSbellardfi
54821ba16968SStefan Weilif test "$profiler" = "yes" ; then
54832358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
548405c2a3e7Sbellardfi
5485c20709aaSbellardif test "$slirp" = "yes" ; then
548698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5487e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5488c20709aaSbellardfi
54898a16d273Sthsif test "$vde" = "yes" ; then
549098ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5491e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
54928a16d273Sthsfi
549358952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
549458952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
549558952137SVincenzo Maffionefi
5496015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5497015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5498015a33bdSGongleifi
549947e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
550047e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
550147e98658SCorey Bryantfi
55022358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
55030c58ac1cSmalcfor drv in $audio_drv_list; do
550489138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
550598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
55060c58ac1cSmalcdone
5507b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5508b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5509b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5510b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5511b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
551267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
551367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
551467f86e8eSJuan Quintelafi
5515d5631638Smalcif test "$audio_win_int" = "yes" ; then
5516d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5517d5631638Smalcfi
5518b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5519b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5520821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5521821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5522821601eaSJes Sorensenfi
55232f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
552498ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
55252f9606b3Saliguorifi
5526821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
55272f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
55282f6f5c7aSCorentin Charyfi
5529821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5530efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5531efe556adSCorentin Charyfi
553276655d6dSaliguoriif test "$fnmatch" = "yes" ; then
55332358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
553476655d6dSaliguorifi
5535dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5536dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5537dce512deSChristoph Hellwigfi
553889138857SStefan Weilqemu_version=$(head $source_path/VERSION)
553998ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
55402358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
554198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
554298ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5543a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
554498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5545cc8ae6deSpbrookfi
554617969268SFam Zhengif test "$modules" = "yes"; then
5547e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5548e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
554989138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
555017969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
555117969268SFam Zhengfi
55521ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
555398ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5554a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
55558ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
55568ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
555749ecc3faSbellardfi
555849ecc3faSbellardif test "$cocoa" = "yes" ; then
555998ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
556049ecc3faSbellardfi
55614d3b6f6eSbalrogif test "$curses" = "yes" ; then
556298ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5563ab4e5602SJan Kiszkafi
5564099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
55652358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5566099d6b0fSRiku Voipiofi
556740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
556840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
556940ff6d7eSKevin Wolffi
55703ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
55712358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
55723ce34dfbSvibisreenivasanfi
5573c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5574c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5575c2882b96SRiku Voipiofi
5576751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5577751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5578751bcc39SMarc-André Lureaufi
5579d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5580d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5581d0927938SUlrich Hechtfi
55823d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
55833d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
55843d4fa43eSKusanagi Kouichifi
5585b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5586b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5587b953f075SDenis V. Lunevfi
5588ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5589ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5590ed911435SKevin Wolffi
5591c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5592c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5593c727f47dSPeter Maydellfi
5594dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5595dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5596dace20dcSPeter Maydellfi
5597d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5598d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5599d0927938SUlrich Hechtfi
56004e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
56014e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
56024e0c6529SAlex Blighfi
5603cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5604cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5605cd758dd0SAlex Blighfi
56063b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
56073b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
56083b6edd16SPeter Maydellfi
56093b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
56103b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
56113b6edd16SPeter Maydellfi
5612a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5613a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5614a8fd1abaSPeter Maydellfi
561551834341SRiku Voipioif test "$timerfd" = "yes" ; then
561651834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
561751834341SRiku Voipiofi
56189af5c906SRiku Voipioif test "$setns" = "yes" ; then
56199af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
56209af5c906SRiku Voipiofi
562138860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
562238860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
562338860a03SAleksandar Markovicfi
56245a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
56255a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
56265a03cd00SAleksandar Markovicfi
56273b3f24adSaurel32if test "$inotify" = "yes" ; then
56282358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
56293b3f24adSaurel32fi
5630c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5631c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5632c05c7a73SRiku Voipiofi
56336ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
56346ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
56356ae9a1f4SJuan Quintelafi
56366ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
56376ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
56386ae9a1f4SJuan Quintelafi
5639769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5640d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5641b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
56426ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5643769ce76dSAlexander Graffi
56442e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
564598ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
56468eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
56472e4d9fb1Saurel32fi
5648fb599c9aSbalrogif test "$bluez" = "yes" ; then
564998ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5650ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5651fb599c9aSbalrogfi
5652d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
56539d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
56549d41401bSMichael S. Tsirkinfi
5655a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5656a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5657a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5658a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5659014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5660925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5661925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5662925a0400SGerd Hoffmann  fi
5663bbbf9bfbSStefan Weilfi
5664a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5665ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5666ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5667ddbb0d09SDaniel P. Berrangefi
5668b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5669b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5670b917da4cSDaniel P. Berrangefi
567191bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
567291bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
56731f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
56741f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
56751f923c70SLongpeng(Mike)  fi
567637788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
567737788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
567837788f25SDaniel P. Berrange  fi
567962893b67SDaniel P. Berrangefi
568091bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
568191bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5682becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5683fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5684fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5685fff2f982SDaniel P. Berrange  fi
5686ed754746SDaniel P. Berrangefi
56879a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
56889a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
56899a2fd434SDaniel P. Berrangefi
5690559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5691559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5692559607eaSDaniel P. Berrangefi
56936b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
56946b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
56956b39b063SEric Blakefi
5696277abf15SJan Vesely
5697277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5698277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5699277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5700277abf15SJan Vesely# if this macro is set.
5701277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5702277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5703277abf15SJan Veselyfi
5704bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5705bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5706a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5707a4ccabcfSAnthony Liguorifi
57089d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
57099d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
57109d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
57119d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
57129d9e1521SGerd Hoffmannfi
5713e37630caSaliguoriif test "$xen" = "yes" ; then
57146dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5715d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
571664a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
571764a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
571864a7ad6fSIan Campbell  fi
5719e37630caSaliguorifi
57205c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
57215c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
57225c6c3a6cSChristoph Hellwigfi
5723758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5724758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5725758e8e38SVenkateswararao Jujjuri (JV)fi
57264f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
57274f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
57284f26f2b6SAvi Kivityfi
5729983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5730758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5731758e8e38SVenkateswararao Jujjuri (JV)fi
57325e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
57335e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
57345e9be92dSNicholas Bellingerfi
5735e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
573603ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
573703ce5744SNikolay Nikolaevfi
5738fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5739fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5740fc0b9b0eSStefan Hajnoczifi
5741e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5742e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5743e6a74868SMarc-André Lureaufi
574477755340Sthsif test "$blobs" = "yes" ; then
574598ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
574677755340Sthsfi
5747bf9298b9Saliguoriif test "$iovec" = "yes" ; then
57482358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5749bf9298b9Saliguorifi
5750ceb42de8Saliguoriif test "$preadv" = "yes" ; then
57512358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5752ceb42de8Saliguorifi
5753f652e6afSaurel32if test "$fdt" = "yes" ; then
57543f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5755f652e6afSaurel32fi
5756dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5757dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5758dcc38d1cSMarcelo Tosattifi
5759b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
5760b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
57619195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
57629195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
57639195b2c2SStefan Weil  fi
5764b3f6ea7eSPaolo Bonzinifi
57655f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
57665f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
57675f6b9e8fSBlue Swirlfi
5768e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5769e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5770e78815a5SAndreas Färberfi
5771e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5772e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5773e78815a5SAndreas Färberfi
577497a847bcSbellard
5775cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5776cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5777cd4ec0b4SGerd Hoffmannfi
5778cd4ec0b4SGerd Hoffmann
57797b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
57807b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
57817b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
57827b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
5783111a38b0SRobert Relyeafi
5784111a38b0SRobert Relyea
57852b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
57862b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5787b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
5788b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
57892b2325ffSGerd Hoffmannfi
57902b2325ffSGerd Hoffmann
579169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
579269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5793cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
5794cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
579569354a83SHans de Goedefi
579669354a83SHans de Goede
5797da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5798da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5799da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5800014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5801014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5802014cb152SGerd Hoffmann  fi
580320ff075bSMichael Wallefi
580420ff075bSMichael Walle
580599f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
580699f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
580799f2dbd3SLiang Lifi
580899f2dbd3SLiang Li
5809607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5810607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5811607dacd0Sqiaonuohanfi
5812607dacd0Sqiaonuohan
5813607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5814607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5815607dacd0Sqiaonuohanfi
5816607dacd0Sqiaonuohan
58176b383c08SPeter Wuif test "$bzip2" = "yes" ; then
58186b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
58196b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
58206b383c08SPeter Wufi
58216b383c08SPeter Wu
5822c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5823d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
58246ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
58256ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5826c589b249SRonnie Sahlbergfi
5827c589b249SRonnie Sahlberg
58286542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
58294be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
58304be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
58316542aa9cSPeter Lievenfi
58326542aa9cSPeter Lieven
5833f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5834f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5835c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
5836c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
5837f794573eSEduardo Otubofi
5838f794573eSEduardo Otubo
583983fb7adfSbellard# XXX: suppress that
58407d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
58412358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
58427d3505c5Sbellardfi
58437d3505c5Sbellard
58444d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
58454d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
58464d9310f4SDaniel P. Berrangefi
58473556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
58483556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
58493556c233SPaolo Bonzinifi
5850f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5851d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
58526ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
58536ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5854f27aaf4bSChristian Brunnerfi
585520ff6c80SAnthony Liguori
58567c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
585770c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
585870c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
585970c60c08SStefan Hajnoczielse
586070c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
586170c60c08SStefan Hajnoczifi
5862d0e2fce5SAneesh Kumar K.V
58637d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
58647d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
58657d992e4dSPeter Lievenfi
58667d992e4dSPeter Lieven
5867f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5868f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5869f0d92b56SLongpeng(Mike)fi
5870f0d92b56SLongpeng(Mike)
5871d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5872d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5873d2042378SAneesh Kumar K.Vfi
5874d2042378SAneesh Kumar K.V
5875e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5876e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5877e06a765eSHarsh Prateek Borafi
5878e06a765eSHarsh Prateek Bora
5879cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5880cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
588106d71fa1SPeter Maydellfi
588206d71fa1SPeter Maydell
58833f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
58843f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
58853f4349dcSKevin Wolffi
58863f4349dcSKevin Wolf
58878ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
58888ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
58898ab1bf12SLuiz Capitulinofi
58908ab1bf12SLuiz Capitulino
589176a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
589276a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
589376a347e1SRichard Hendersonfi
589476a347e1SRichard Henderson
5895f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5896f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5897f540166bSRichard Hendersonfi
5898f540166bSRichard Henderson
58997ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
59007ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
59017ebee43eSRichard Hendersonfi
59027ebee43eSRichard Henderson
5903df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5904df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5905df79b996SRichard Hendersonfi
5906df79b996SRichard Henderson
59071e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
59081e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
59091e6e9acaSRichard Hendersonfi
59101e6e9acaSRichard Henderson
5911eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5912d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
59136ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
59146ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5915eb100396SBharata B Raofi
5916eb100396SBharata B Rao
5917d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5918d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5919d85fa9ebSJeff Codyfi
5920d85fa9ebSJeff Cody
59210c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
59220c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
59230c14fb47SBharata B Raofi
59240c14fb47SBharata B Rao
5925df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
5926df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
5927df3a429aSNiels de Vosfi
5928df3a429aSNiels de Vos
59297c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
59307c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
59317c815372SBharata B Raofi
59327c815372SBharata B Rao
59330a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
5934d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
59356ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
59366ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
59370a12ec87SRichard W.M. Jonesfi
59380a12ec87SRichard W.M. Jones
5939ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5940ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5941ed1701c6SDr. David Alan Gilbertfi
5942ed1701c6SDr. David Alan Gilbert
59433b8acc11SPaolo Bonzini# TPM passthrough support?
59443b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
59453b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
59463b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
59473b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
59483b8acc11SPaolo Bonzini  fi
59493b8acc11SPaolo Bonzinifi
59503b8acc11SPaolo Bonzini
59515b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
59525b808275SLluís Vilanovaif have_backend "nop"; then
59536d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
595422890ab5SPrerna Saxenafi
59555b808275SLluís Vilanovaif have_backend "simple"; then
59566d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
59576d8a764eSLluís  # Set the appropriate trace file.
5958953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
59599410b56cSPrerna Saxenafi
5960ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5961ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
59626d8a764eSLluísfi
59635b808275SLluís Vilanovaif have_backend "ust"; then
59646d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
59656d8a764eSLluísfi
59665b808275SLluís Vilanovaif have_backend "dtrace"; then
59676d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
59686d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
59696d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
59706d8a764eSLluís  fi
5971c276b17dSDaniel P. Berrangefi
59725b808275SLluís Vilanovaif have_backend "ftrace"; then
5973781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5974781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5975781e9545SEiichi Tsukata  else
597621684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5977781e9545SEiichi Tsukata  fi
5978781e9545SEiichi Tsukatafi
59790a852417SPaul Durrantif have_backend "syslog"; then
59800a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
59810a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
59820a852417SPaul Durrant  else
59830a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
59840a852417SPaul Durrant  fi
59850a852417SPaul Durrantfi
59869410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
59879410b56cSPrerna Saxena
59882da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
59892da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
5990*392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
59912da776dbSMichael R. Hinesfi
59922da776dbSMichael R. Hines
5993575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5994575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5995575b22b1SLaurent Vivierfi
5996575b22b1SLaurent Vivier
5997a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
5998a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
5999a6b1d4c0SChanglong Xiefi
6000a6b1d4c0SChanglong Xie
60016a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
60026a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
60036a02c806SStefan Hajnoczifi
60046a02c806SStefan Hajnoczi
60054d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
60064d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
60074d04351fSChristopher Covingtonfi
60084d04351fSChristopher Covington
600949e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
601049e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
601149e00a18SAndreas Grapentinfi
601249e00a18SAndreas Grapentin
6013e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6014e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6015e674605fSTomáš Golembiovskýfi
6016e674605fSTomáš Golembiovský
6017e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6018e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6019e0580342SKamil Rytarowskifi
6020e0580342SKamil Rytarowski
60215c312079SDr. David Alan Gilbert# Hold two types of flag:
60225c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
60235c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
60245c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
60255c312079SDr. David Alan Gilbert#                                     platform
60265c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
60275c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
60285c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
60295c312079SDr. David Alan Gilbertfi
60305c312079SDr. David Alan Gilbert
6031da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6032da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6033da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6034da92c3ffSAshish Mittalfi
6035da92c3ffSAshish Mittal
60365b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
60375b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
60385b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
60395b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
60405b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
60415b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6042c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
60435b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
604440d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
604540d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
60465b5e3037SPaolo Bonzinielse
60475b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
60485b5e3037SPaolo Bonzinifi
60495b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
60505b5e3037SPaolo Bonzini
605198ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
605298ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6053804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6054804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
60551901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
60561901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
60571901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
605821655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6059c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6060804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6061a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6062a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6063a31a8642SMichael S. Tsirkinfi
60642b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6065804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
606683f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
60673c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6068804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
606945d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6070cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
60715f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
60723dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6073804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6074804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
60754852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
60769fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6077e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
607846eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6079a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
608011cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6081f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6082e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6083e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
608480fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
60852944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6086e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6087e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6088e39f0062SPaolo Bonzinifi
608942da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
609042da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
609142da6041SGerd Hoffmannelse
609242da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
609342da6041SGerd Hoffmannfi
6094e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
609546eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
60966969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6097e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
609873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
60993e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6100409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6101804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
610217969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
610317969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6104957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
610590246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
610690246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
610794dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6108cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
61091d728c39SBlue Swirlif test "$gcov" = "yes" ; then
61101d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
61111d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
61121d728c39SBlue Swirlfi
6113804edf29SJuan Quintela
61146efd7517SPeter Maydell# use included Linux headers
61156efd7517SPeter Maydellif test "$linux" = "yes" ; then
6116a307beb6SAndreas Färber  mkdir -p linux-headers
61176efd7517SPeter Maydell  case "$cpu" in
6118c72b26ecSRichard Henderson  i386|x86_64|x32)
611908312a63SPeter Maydell    linux_arch=x86
61206efd7517SPeter Maydell    ;;
61216efd7517SPeter Maydell  ppcemb|ppc|ppc64)
612208312a63SPeter Maydell    linux_arch=powerpc
61236efd7517SPeter Maydell    ;;
61246efd7517SPeter Maydell  s390x)
612508312a63SPeter Maydell    linux_arch=s390
612608312a63SPeter Maydell    ;;
61271f080313SClaudio Fontana  aarch64)
61281f080313SClaudio Fontana    linux_arch=arm64
61291f080313SClaudio Fontana    ;;
6130222e7d11SSanjay Lal  mips64)
6131222e7d11SSanjay Lal    linux_arch=mips
6132222e7d11SSanjay Lal    ;;
613308312a63SPeter Maydell  *)
613408312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
613508312a63SPeter Maydell    linux_arch="$cpu"
61366efd7517SPeter Maydell    ;;
61376efd7517SPeter Maydell  esac
613808312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
613908312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
614008312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
614108312a63SPeter Maydell    fi
61426efd7517SPeter Maydellfi
61436efd7517SPeter Maydell
614497a847bcSbellardfor target in $target_list; do
614597a847bcSbellardtarget_dir="$target"
614625be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
614789138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
614897a847bcSbellardtarget_bigendian="no"
61491f3d3c8fSJuan Quintela
6150c1799a84SPaolo Bonzinicase "$target_name" in
61514a09d0bbSRichard Henderson  armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6152ea2d6a39SJuan Quintela  target_bigendian=yes
6153ea2d6a39SJuan Quintela  ;;
6154ea2d6a39SJuan Quintelaesac
615597a847bcSbellardtarget_softmmu="no"
6156997344f3Sbellardtarget_user_only="no"
6157831b7825Sthstarget_linux_user="no"
615884778508Sblueswir1target_bsd_user="no"
61599e407a85Spbrookcase "$target" in
6160c1799a84SPaolo Bonzini  ${target_name}-softmmu)
61619e407a85Spbrook    target_softmmu="yes"
61629e407a85Spbrook    ;;
6163c1799a84SPaolo Bonzini  ${target_name}-linux-user)
61649e407a85Spbrook    target_user_only="yes"
61659e407a85Spbrook    target_linux_user="yes"
61669e407a85Spbrook    ;;
6167c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
616884778508Sblueswir1    target_user_only="yes"
616984778508Sblueswir1    target_bsd_user="yes"
617084778508Sblueswir1    ;;
61719e407a85Spbrook  *)
617276ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
61739e407a85Spbrook    exit 1
61749e407a85Spbrook    ;;
61759e407a85Spbrookesac
6176831b7825Sths
617797a847bcSbellardmkdir -p $target_dir
617825be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
617997a847bcSbellard
6180e5fe0c52Spbrookbflt="no"
6181ca759f9eSAlex Bennéemttcg="no"
618289138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
618356aebc89Spbrookgdb_xml_files=""
61847ba1e619Saliguori
6185c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
61866acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6187e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6188e73aae67SJuan Quintela
6189c1799a84SPaolo Bonzinicase "$target_name" in
61902408a527Saurel32  i386)
6191b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
61922408a527Saurel32  ;;
61932408a527Saurel32  x86_64)
61946acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6195b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
61962408a527Saurel32  ;;
61972408a527Saurel32  alpha)
61985ee4f3c2SRichard Henderson    mttcg="yes"
61992408a527Saurel32  ;;
62002408a527Saurel32  arm|armeb)
6201b498c8a0SJuan Quintela    TARGET_ARCH=arm
6202e5fe0c52Spbrook    bflt="yes"
6203ca759f9eSAlex Bennée    mttcg="yes"
620456aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62052408a527Saurel32  ;;
62066a49fa95SAlexander Graf  aarch64)
62076a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
62086a49fa95SAlexander Graf    bflt="yes"
6209ca759f9eSAlex Bennée    mttcg="yes"
62108f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62116a49fa95SAlexander Graf  ;;
62122408a527Saurel32  cris)
62132408a527Saurel32  ;;
621461766fe9SRichard Henderson  hppa)
621561766fe9SRichard Henderson  ;;
6216613a22c9SMichael Walle  lm32)
6217613a22c9SMichael Walle  ;;
62182408a527Saurel32  m68k)
62190938cda5Saurel32    bflt="yes"
62205a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
62212408a527Saurel32  ;;
6222877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6223877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
622472b675caSEdgar E. Iglesias    bflt="yes"
622572b675caSEdgar E. Iglesias  ;;
62262408a527Saurel32  mips|mipsel)
6227b498c8a0SJuan Quintela    TARGET_ARCH=mips
622825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
62292408a527Saurel32  ;;
62302408a527Saurel32  mipsn32|mipsn32el)
6231597e2cecSRichard Henderson    TARGET_ARCH=mips64
62326acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
623325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6234597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
62352408a527Saurel32  ;;
62362408a527Saurel32  mips64|mips64el)
6237b498c8a0SJuan Quintela    TARGET_ARCH=mips64
62386acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
623925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
62402408a527Saurel32  ;;
6241d15a9c23SAnthony Green  moxie)
6242d15a9c23SAnthony Green  ;;
6243e671711cSMarek Vasut  nios2)
6244e671711cSMarek Vasut  ;;
62454a09d0bbSRichard Henderson  or1k)
6246e67db06eSJia Liu    TARGET_ARCH=openrisc
6247e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6248e67db06eSJia Liu  ;;
62492408a527Saurel32  ppc)
6250c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
62512408a527Saurel32  ;;
62522408a527Saurel32  ppcemb)
62536acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6254e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6255c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
62562408a527Saurel32  ;;
62572408a527Saurel32  ppc64)
62586acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6259e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6260f0b0685dSNikunj A Dadhania    mttcg=yes
62611438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62622408a527Saurel32  ;;
62639c35126cSDoug Kwan  ppc64le)
62649c35126cSDoug Kwan    TARGET_ARCH=ppc64
62659c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
62669c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6267f0b0685dSNikunj A Dadhania    mttcg=yes
62681438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62699c35126cSDoug Kwan  ;;
62702408a527Saurel32  ppc64abi32)
6271b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
62726acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6273e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
627425be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62751438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62762408a527Saurel32  ;;
62772408a527Saurel32  sh4|sh4eb)
6278b498c8a0SJuan Quintela    TARGET_ARCH=sh4
62794dbed897Spbrook    bflt="yes"
62802408a527Saurel32  ;;
62812408a527Saurel32  sparc)
62822408a527Saurel32  ;;
62832408a527Saurel32  sparc64)
62846acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
62852408a527Saurel32  ;;
62862408a527Saurel32  sparc32plus)
6287b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
62886acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6289e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
629025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62912408a527Saurel32  ;;
629224e804ecSAlexander Graf  s390x)
629386158a2aSChristian 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"
629424e804ecSAlexander Graf  ;;
6295444e06b1SChen Gang  tilegx)
6296444e06b1SChen Gang  ;;
62975ecaa4edSPeter Crosthwaite  tricore)
62985ecaa4edSPeter Crosthwaite  ;;
6299d2fbca94SGuan Xuetao  unicore32)
6300d2fbca94SGuan Xuetao  ;;
6301cfa550c6SMax Filippov  xtensa|xtensaeb)
6302cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6303cfa550c6SMax Filippov  ;;
63042408a527Saurel32  *)
630576ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
63062408a527Saurel32  ;;
63072408a527Saurel32esac
63085e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
63095e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
63105e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
63115e8861a0SPaolo Bonzinifi
63125e8861a0SPaolo Bonzini
63135e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
63145e8861a0SPaolo Bonzini
631599afc91dSDaniel P. Berrangeupper() {
631699afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
631799afc91dSDaniel P. Berrange}
631899afc91dSDaniel P. Berrange
631989138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
632025be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6321c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
632225be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6323e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6324e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6325e6e91b9cSJuan Quintelafi
632625be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6327adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6328adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6329adfc3e91SStacey Sonfi
63303b6b7550SPaolo Bonzini
63313b6b7550SPaolo Bonziniif supported_xen_target $target; then
633225be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6333eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6334eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6335eb6fda0fSAnthony PERARD    fi
6336432d268cSJun Nakajimafi
63373b6b7550SPaolo Bonziniif supported_kvm_target $target; then
633825be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
63391ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6340d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6341e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
6342e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6343e6a74868SMarc-André Lureau        fi
6344d5970055SMichael S. Tsirkin    fi
6345c59249f9SJuan Quintelafi
63463b6b7550SPaolo Bonziniif supported_hax_target $target; then
6347b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6348b0cb0a66SVincent Palatinfi
6349de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
635025be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
635197a847bcSbellardfi
635297a847bcSbellardif test "$target_softmmu" = "yes" ; then
635325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6354ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6355ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6356ca759f9eSAlex Bennée  fi
6357de83cd02Sbellardfi
6358997344f3Sbellardif test "$target_user_only" = "yes" ; then
635925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6360a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6361997344f3Sbellardfi
6362831b7825Sthsif test "$target_linux_user" = "yes" ; then
636325be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6364831b7825Sthsfi
636556aebc89Spbrooklist=""
636656aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
636756aebc89Spbrook  for x in $gdb_xml_files; do
636856aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
636956aebc89Spbrook  done
637025be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
63713d0f1517SJuan Quintelafi
6372de83cd02Sbellard
6373e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
637425be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6375e5fe0c52Spbrookfi
637684778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
637725be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
637884778508Sblueswir1fi
63795b0753e0Sbellard
63804afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6381fa282484SJuan Quintela
63824afddb55SJuan Quintelacflags=""
6383fa282484SJuan Quintelaldflags=""
63849b8e111fSJuan Quintela
6385c765fcacSPeter Crosthwaitedisas_config() {
6386c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6387c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6388c765fcacSPeter Crosthwaite}
6389c765fcacSPeter Crosthwaite
639064656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
639164656024SJuan Quintela  case "$i" in
639264656024SJuan Quintela  alpha)
6393c765fcacSPeter Crosthwaite    disas_config "ALPHA"
639464656024SJuan Quintela  ;;
639582295d8aSRichard Henderson  aarch64)
639682295d8aSRichard Henderson    if test -n "${cxx}"; then
6397c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
639882295d8aSRichard Henderson    fi
639982295d8aSRichard Henderson  ;;
640064656024SJuan Quintela  arm)
6401c765fcacSPeter Crosthwaite    disas_config "ARM"
6402999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6403c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6404999b53ecSClaudio Fontana    fi
640564656024SJuan Quintela  ;;
640664656024SJuan Quintela  cris)
6407c765fcacSPeter Crosthwaite    disas_config "CRIS"
640864656024SJuan Quintela  ;;
6409429b31a2SRichard Henderson  hppa)
6410429b31a2SRichard Henderson    disas_config "HPPA"
6411429b31a2SRichard Henderson  ;;
6412c72b26ecSRichard Henderson  i386|x86_64|x32)
6413c765fcacSPeter Crosthwaite    disas_config "I386"
641464656024SJuan Quintela  ;;
641579368f49SMichael Walle  lm32)
6416c765fcacSPeter Crosthwaite    disas_config "LM32"
641779368f49SMichael Walle  ;;
641864656024SJuan Quintela  m68k)
6419c765fcacSPeter Crosthwaite    disas_config "M68K"
642064656024SJuan Quintela  ;;
6421877fdc12SEdgar E. Iglesias  microblaze*)
6422c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
642364656024SJuan Quintela  ;;
642464656024SJuan Quintela  mips*)
6425c765fcacSPeter Crosthwaite    disas_config "MIPS"
642664656024SJuan Quintela  ;;
6427d15a9c23SAnthony Green  moxie*)
6428c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6429d15a9c23SAnthony Green  ;;
6430e671711cSMarek Vasut  nios2)
6431e671711cSMarek Vasut    disas_config "NIOS2"
6432e671711cSMarek Vasut  ;;
64334a09d0bbSRichard Henderson  or1k)
6434c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6435e67db06eSJia Liu  ;;
643664656024SJuan Quintela  ppc*)
6437c765fcacSPeter Crosthwaite    disas_config "PPC"
643864656024SJuan Quintela  ;;
643924e804ecSAlexander Graf  s390*)
6440c765fcacSPeter Crosthwaite    disas_config "S390"
644164656024SJuan Quintela  ;;
644264656024SJuan Quintela  sh4)
6443c765fcacSPeter Crosthwaite    disas_config "SH4"
644464656024SJuan Quintela  ;;
644564656024SJuan Quintela  sparc*)
6446c765fcacSPeter Crosthwaite    disas_config "SPARC"
644764656024SJuan Quintela  ;;
6448cfa550c6SMax Filippov  xtensa*)
6449c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6450cfa550c6SMax Filippov  ;;
645164656024SJuan Quintela  esac
645264656024SJuan Quinteladone
64539195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6454c765fcacSPeter Crosthwaite  disas_config "TCI"
64559195b2c2SStefan Weilfi
645664656024SJuan Quintela
64576ee7126fSJuan Quintelacase "$ARCH" in
64586ee7126fSJuan Quintelaalpha)
64596ee7126fSJuan Quintela  # Ensure there's only a single GP
64606ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
64616ee7126fSJuan Quintela;;
64626ee7126fSJuan Quintelaesac
64636ee7126fSJuan Quintela
6464d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
646525be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6466d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6467d02c1db3SJuan Quintela    cflags="-p $cflags"
6468d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6469d02c1db3SJuan Quintela  fi
6470d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6471d02c1db3SJuan Quintela    ldflags="-p $ldflags"
647225be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6473d02c1db3SJuan Quintela  fi
6474d02c1db3SJuan Quintelafi
6475d02c1db3SJuan Quintela
64769b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6477964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6478fa282484SJuan Quintelafi
6479fa282484SJuan Quintela
6480e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
6481e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
6482e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
6483e9a3591fSChristian Borntraeger# header if
6484e9a3591fSChristian Borntraeger#  - we build on s390x
6485e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
6486e9a3591fSChristian Borntraeger#  - KVM is enabled
6487e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
6488e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6489e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
6490e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
6491e9a3591fSChristian Borntraeger    fi
6492e9a3591fSChristian Borntraegerfi
6493e9a3591fSChristian Borntraeger
649425be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
649525be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6496fa282484SJuan Quintela
649797a847bcSbellarddone # for target in $targets
64987d13299dSbellard
6499a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6500a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6501a540f158SPeter Crosthwaitefi
6502a540f158SPeter Crosthwaite
6503a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6504a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6505a99d57bbSWanlong Gaofi
6506a99d57bbSWanlong Gao
6507fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6508fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6509fd0e6053SJohn Snowfi
6510fd0e6053SJohn Snow
6511d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6512f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6513d59157eaSPaolo BonziniDIRS="$DIRS docs docs/interop fsdev"
65149933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
65152d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
65162dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6517c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6518c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6519aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6520ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6521446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
65229933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
65232d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
65244652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
65253a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6526753d11f2SRichard Hendersonfor bios_file in \
6527753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6528225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
65295acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6530753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6531753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6532e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6533753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
65344e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6535753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6536753d11f2SRichard Hendersondo
653789138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
65387ea78b74SJan Kiszkadone
653989138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6540c2304b52SMarcel Apfelbaumdo
654189138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6542c2304b52SMarcel Apfelbaumdone
6543d1807a4fSPaolo Bonzinimkdir -p $DIRS
65447d13299dSbellardfor f in $FILES ; do
6545cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6546f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6547f9245e10SPeter Maydell    fi
65487d13299dSbellarddone
65491ad2134fSPaul Brook
6550c34ebfdcSAnthony Liguori# temporary config to build submodules
65512d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6552c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
655337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6554c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6555cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
65565f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6557c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6558c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
65593dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6560c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6561a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6562c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
6563c34ebfdcSAnthony Liguoridone
6564c34ebfdcSAnthony Liguori
6565fe31017fSMarc-André Lureau# set up tests data directory
6566fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6567fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6568fe31017fSMarc-André Lureaufi
6569fe31017fSMarc-André Lureau
657076c7560aSMax Reitz# set up qemu-iotests in this build directory
657176c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
657276c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
657376c7560aSMax Reitz
657476c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
657576c7560aSMax Reitzecho >> "$iotests_common_env"
657676c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
657776c7560aSMax Reitz
657876c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
657976c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
658076c7560aSMax Reitzfi
658176c7560aSMax Reitz
6582dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6583dc655404SMichael S. Tsirkincat <<EOD >config.status
6584dc655404SMichael S. Tsirkin#!/bin/sh
6585dc655404SMichael S. Tsirkin# Generated by configure.
6586dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6587dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6588dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6589dc655404SMichael S. TsirkinEOD
6590dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6591dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6592cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6593dc655404SMichael S. Tsirkinchmod +x config.status
6594dc655404SMichael S. Tsirkin
65958cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6596