xref: /openbmc/qemu/configure (revision 35c4e86c)
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        ;;
20283e684455SMichael Strosaker    ppc|ppc64)
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
203889138857SStefan Weil        libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
203989138857SStefan Weil        QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags 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
27910705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
27925368a422Saliguorifi
27935368a422Saliguori
27948f28f3fbSths##########################################
27952da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
27962da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
27972da776dbSMichael R. Hines  cat > $TMPC <<EOF
27982da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
27992da776dbSMichael R. Hinesint main(void) { return 0; }
28002da776dbSMichael R. HinesEOF
28012da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
28022da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28032da776dbSMichael R. Hines    rdma="yes"
28042da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
28052da776dbSMichael R. Hines  else
28062da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28072da776dbSMichael R. Hines        error_exit \
28082da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28092da776dbSMichael R. Hines            " Your options:" \
28102da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28112da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28122da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28132da776dbSMichael R. Hines    fi
28142da776dbSMichael R. Hines    rdma="no"
28152da776dbSMichael R. Hines  fi
28162da776dbSMichael R. Hinesfi
28172da776dbSMichael R. Hines
281895c6bff3SBenoît Canet
281995c6bff3SBenoît Canet##########################################
28202f9606b3Saliguori# VNC SASL detection
2821821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
28222f9606b3Saliguori  cat > $TMPC <<EOF
28232f9606b3Saliguori#include <sasl/sasl.h>
28242f9606b3Saliguori#include <stdio.h>
28252f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
28262f9606b3SaliguoriEOF
28272f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
28282f9606b3Saliguori  vnc_sasl_cflags=""
28292f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
283052166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2831ea784e3bSJuan Quintela    vnc_sasl=yes
2832fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2833ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
28342f9606b3Saliguori  else
2835ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
283621684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2837ea784e3bSJuan Quintela    fi
2838ea784e3bSJuan Quintela    vnc_sasl=no
28392f9606b3Saliguori  fi
28402f9606b3Saliguorifi
28412f9606b3Saliguori
28422f9606b3Saliguori##########################################
28432f6f5c7aSCorentin Chary# VNC JPEG detection
2844821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
28452f6f5c7aSCorentin Charycat > $TMPC <<EOF
28462f6f5c7aSCorentin Chary#include <stdio.h>
28472f6f5c7aSCorentin Chary#include <jpeglib.h>
28482f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
28492f6f5c7aSCorentin CharyEOF
28502f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
28512f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
28522f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
28532f6f5c7aSCorentin Chary    vnc_jpeg=yes
28542f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2855ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
28562f6f5c7aSCorentin Chary  else
28572f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
285821684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
28592f6f5c7aSCorentin Chary    fi
28602f6f5c7aSCorentin Chary    vnc_jpeg=no
28612f6f5c7aSCorentin Chary  fi
28622f6f5c7aSCorentin Charyfi
28632f6f5c7aSCorentin Chary
28642f6f5c7aSCorentin Chary##########################################
2865efe556adSCorentin Chary# VNC PNG detection
2866821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2867efe556adSCorentin Charycat > $TMPC <<EOF
2868efe556adSCorentin Chary//#include <stdio.h>
2869efe556adSCorentin Chary#include <png.h>
2870832ce9c2SScott Wood#include <stddef.h>
2871efe556adSCorentin Charyint main(void) {
2872efe556adSCorentin Chary    png_structp png_ptr;
2873efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
28747edc3fedSPeter Maydell    return png_ptr != 0;
2875efe556adSCorentin Chary}
2876efe556adSCorentin CharyEOF
287765d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
287889138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
287989138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
28809af8025eSBrad  else
2881efe556adSCorentin Chary    vnc_png_cflags=""
2882efe556adSCorentin Chary    vnc_png_libs="-lpng"
28839af8025eSBrad  fi
2884efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2885efe556adSCorentin Chary    vnc_png=yes
2886efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
28879af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2888efe556adSCorentin Chary  else
2889efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
289021684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2891efe556adSCorentin Chary    fi
2892efe556adSCorentin Chary    vnc_png=no
2893efe556adSCorentin Chary  fi
2894efe556adSCorentin Charyfi
2895efe556adSCorentin Chary
2896efe556adSCorentin Chary##########################################
289776655d6dSaliguori# fnmatch() probe, used for ACL routines
289876655d6dSaliguorifnmatch="no"
289976655d6dSaliguoricat > $TMPC << EOF
290076655d6dSaliguori#include <fnmatch.h>
290176655d6dSaliguoriint main(void)
290276655d6dSaliguori{
290376655d6dSaliguori    fnmatch("foo", "foo", 0);
290476655d6dSaliguori    return 0;
290576655d6dSaliguori}
290676655d6dSaliguoriEOF
290752166aa0SJuan Quintelaif compile_prog "" "" ; then
290876655d6dSaliguori   fnmatch="yes"
290976655d6dSaliguorifi
291076655d6dSaliguori
291176655d6dSaliguori##########################################
2912c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2913dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2914dce512deSChristoph Hellwig  cat > $TMPC << EOF
2915ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2916dce512deSChristoph Hellwig#include <xfs/xfs.h>
2917dce512deSChristoph Hellwigint main(void)
2918dce512deSChristoph Hellwig{
2919dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2920dce512deSChristoph Hellwig    return 0;
2921dce512deSChristoph Hellwig}
2922dce512deSChristoph HellwigEOF
2923dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2924dce512deSChristoph Hellwig    xfs="yes"
2925dce512deSChristoph Hellwig  else
2926dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
292721684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2928dce512deSChristoph Hellwig    fi
2929dce512deSChristoph Hellwig    xfs=no
2930dce512deSChristoph Hellwig  fi
2931dce512deSChristoph Hellwigfi
2932dce512deSChristoph Hellwig
2933dce512deSChristoph Hellwig##########################################
29348a16d273Sths# vde libraries probe
2935dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29364baae0acSJuan Quintela  vde_libs="-lvdeplug"
29378a16d273Sths  cat > $TMPC << EOF
29388a16d273Sths#include <libvdeplug.h>
29394a7f0e06Spbrookint main(void)
29404a7f0e06Spbrook{
29414a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2942fea08e08SPeter Maydell    char s[] = "";
2943fea08e08SPeter Maydell    vde_open(s, s, &a);
29444a7f0e06Spbrook    return 0;
29454a7f0e06Spbrook}
29468a16d273SthsEOF
294752166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29484baae0acSJuan Quintela    vde=yes
29498e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
29508e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2951dfb278bdSJuan Quintela  else
2952dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
295321684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2954dfb278bdSJuan Quintela    fi
2955dfb278bdSJuan Quintela    vde=no
29568a16d273Sths  fi
29578a16d273Sthsfi
29588a16d273Sths
29598a16d273Sths##########################################
29600a985b37SVincenzo Maffione# netmap support probe
29610a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29620a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29630a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29640a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29650a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
296658952137SVincenzo Maffioneif test "$netmap" != "no" ; then
296758952137SVincenzo Maffione  cat > $TMPC << EOF
296858952137SVincenzo Maffione#include <inttypes.h>
296958952137SVincenzo Maffione#include <net/if.h>
297058952137SVincenzo Maffione#include <net/netmap.h>
297158952137SVincenzo Maffione#include <net/netmap_user.h>
29720a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29730a985b37SVincenzo Maffione#error
29740a985b37SVincenzo Maffione#endif
297558952137SVincenzo Maffioneint main(void) { return 0; }
297658952137SVincenzo MaffioneEOF
297758952137SVincenzo Maffione  if compile_prog "" "" ; then
297858952137SVincenzo Maffione    netmap=yes
297958952137SVincenzo Maffione  else
298058952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
298158952137SVincenzo Maffione      feature_not_found "netmap"
298258952137SVincenzo Maffione    fi
298358952137SVincenzo Maffione    netmap=no
298458952137SVincenzo Maffione  fi
298558952137SVincenzo Maffionefi
298658952137SVincenzo Maffione
298758952137SVincenzo Maffione##########################################
298847e98658SCorey Bryant# libcap-ng library probe
298947e98658SCorey Bryantif test "$cap_ng" != "no" ; then
299047e98658SCorey Bryant  cap_libs="-lcap-ng"
299147e98658SCorey Bryant  cat > $TMPC << EOF
299247e98658SCorey Bryant#include <cap-ng.h>
299347e98658SCorey Bryantint main(void)
299447e98658SCorey Bryant{
299547e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
299647e98658SCorey Bryant    return 0;
299747e98658SCorey Bryant}
299847e98658SCorey BryantEOF
299947e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
300047e98658SCorey Bryant    cap_ng=yes
300147e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
300247e98658SCorey Bryant  else
300347e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
300421684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
300547e98658SCorey Bryant    fi
300647e98658SCorey Bryant    cap_ng=no
300747e98658SCorey Bryant  fi
300847e98658SCorey Bryantfi
300947e98658SCorey Bryant
301047e98658SCorey Bryant##########################################
3011c2de5c91Smalc# Sound support libraries probe
30128f28f3fbSths
3013c2de5c91Smalcaudio_drv_probe()
3014c2de5c91Smalc{
3015c2de5c91Smalc    drv=$1
3016c2de5c91Smalc    hdr=$2
3017c2de5c91Smalc    lib=$3
3018c2de5c91Smalc    exp=$4
3019c2de5c91Smalc    cfl=$5
30208f28f3fbSths        cat > $TMPC << EOF
3021c2de5c91Smalc#include <$hdr>
3022c2de5c91Smalcint main(void) { $exp }
30238f28f3fbSthsEOF
302452166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
30258f28f3fbSths        :
30268f28f3fbSths    else
302776ad07a4SPeter Maydell        error_exit "$drv check failed" \
302876ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
30298f28f3fbSths    fi
3030c2de5c91Smalc}
3031c2de5c91Smalc
303289138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3033c2de5c91Smalcfor drv in $audio_drv_list; do
3034c2de5c91Smalc    case $drv in
3035c2de5c91Smalc    alsa)
3036c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3037e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3038a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
3039c2de5c91Smalc    ;;
3040c2de5c91Smalc
3041b8e59f18Smalc    pa)
3042e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3043e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3044a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
304567f86e8eSJuan Quintela    audio_pt_int="yes"
3046b8e59f18Smalc    ;;
3047b8e59f18Smalc
3048373967b2SGerd Hoffmann    sdl)
3049373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3050373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3051373967b2SGerd Hoffmann    fi
3052373967b2SGerd Hoffmann    ;;
3053373967b2SGerd Hoffmann
3054997e690aSJuan Quintela    coreaudio)
3055997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
3056997e690aSJuan Quintela    ;;
3057997e690aSJuan Quintela
3058a4bf6780SJuan Quintela    dsound)
3059a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
3060d5631638Smalc      audio_win_int="yes"
3061a4bf6780SJuan Quintela    ;;
3062a4bf6780SJuan Quintela
3063a4bf6780SJuan Quintela    oss)
3064a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
3065a4bf6780SJuan Quintela    ;;
3066a4bf6780SJuan Quintela
3067373967b2SGerd Hoffmann    wav)
3068373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
30692f6a1ab0Sblueswir1    ;;
30702f6a1ab0Sblueswir1
3071e4c63a6aSmalc    *)
30721c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
307376ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
307476ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3075e4c63a6aSmalc    }
3076e4c63a6aSmalc    ;;
3077c2de5c91Smalc    esac
3078c2de5c91Smalcdone
30798f28f3fbSths
30804d3b6f6eSbalrog##########################################
30812e4d9fb1Saurel32# BrlAPI probe
30822e4d9fb1Saurel32
30834ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3084eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
30852e4d9fb1Saurel32  cat > $TMPC << EOF
30862e4d9fb1Saurel32#include <brlapi.h>
3087832ce9c2SScott Wood#include <stddef.h>
30882e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
30892e4d9fb1Saurel32EOF
309052166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
30912e4d9fb1Saurel32    brlapi=yes
3092264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
30934ffcedb6SJuan Quintela  else
30944ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
309521684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
30964ffcedb6SJuan Quintela    fi
30974ffcedb6SJuan Quintela    brlapi=no
3098eb82284fSJuan Quintela  fi
3099eb82284fSJuan Quintelafi
31002e4d9fb1Saurel32
31012e4d9fb1Saurel32##########################################
31024d3b6f6eSbalrog# curses probe
3103a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3104e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
31058ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
31068ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3107e095e2f3SStefan Weil  else
31087c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
31098ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3110e095e2f3SStefan Weil  fi
3111c584a6d0SJuan Quintela  curses_found=no
31124d3b6f6eSbalrog  cat > $TMPC << EOF
31138ddc5bf9SSamuel Thibault#include <locale.h>
31144d3b6f6eSbalrog#include <curses.h>
31158ddc5bf9SSamuel Thibault#include <wchar.h>
3116ef9a2524SStefan Weilint main(void) {
31178ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
31188ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3119ef9a2524SStefan Weil  resize_term(0, 0);
31208ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
31218ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
31227c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3123271f37abSKamil Rytarowski  return 0;
3124ef9a2524SStefan Weil}
31254d3b6f6eSbalrogEOF
3126ecbe251fSVadim Evard  IFS=:
31278ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3128b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3129b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
31307c703002SSamuel Thibault    IFS=:
31318ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3132ecbe251fSVadim Evard      unset IFS
31338ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3134c584a6d0SJuan Quintela        curses_found=yes
31358ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
31364f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
31374f78ef9aSJuan Quintela        break
31384d3b6f6eSbalrog      fi
31394f78ef9aSJuan Quintela    done
31407c703002SSamuel Thibault    if test "$curses_found" = yes ; then
31417c703002SSamuel Thibault      break
31427c703002SSamuel Thibault    fi
31438ddc5bf9SSamuel Thibault  done
3144ecbe251fSVadim Evard  unset IFS
3145c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3146c584a6d0SJuan Quintela    curses=yes
3147c584a6d0SJuan Quintela  else
3148c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
314921684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3150c584a6d0SJuan Quintela    fi
3151c584a6d0SJuan Quintela    curses=no
3152c584a6d0SJuan Quintela  fi
31534f78ef9aSJuan Quintelafi
31544d3b6f6eSbalrog
3155414f0dabSblueswir1##########################################
3156769ce76dSAlexander Graf# curl probe
3157a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
315865d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3159a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
31604e2b0658SPaolo Bonzini  else
31614e2b0658SPaolo Bonzini    curlconfig=curl-config
31624e2b0658SPaolo Bonzini  fi
3163769ce76dSAlexander Graf  cat > $TMPC << EOF
3164769ce76dSAlexander Graf#include <curl/curl.h>
31650b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3166769ce76dSAlexander GrafEOF
316789138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
316889138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3169b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3170769ce76dSAlexander Graf    curl=yes
3171788c8196SJuan Quintela  else
3172788c8196SJuan Quintela    if test "$curl" = "yes" ; then
317321684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3174788c8196SJuan Quintela    fi
3175788c8196SJuan Quintela    curl=no
3176769ce76dSAlexander Graf  fi
3177769ce76dSAlexander Graffi # test "$curl"
3178769ce76dSAlexander Graf
3179769ce76dSAlexander Graf##########################################
3180fb599c9aSbalrog# bluez support probe
3181a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3182e820e3f4Sbalrog  cat > $TMPC << EOF
3183e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3184e820e3f4Sbalrogint main(void) { return bt_error(0); }
3185e820e3f4SbalrogEOF
318689138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
318789138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
318852166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3189a20a6f46SJuan Quintela    bluez=yes
3190e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3191e820e3f4Sbalrog  else
3192a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
319321684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3194a20a6f46SJuan Quintela    fi
3195e820e3f4Sbalrog    bluez="no"
3196e820e3f4Sbalrog  fi
3197fb599c9aSbalrogfi
3198fb599c9aSbalrog
3199fb599c9aSbalrog##########################################
3200e18df141SAnthony Liguori# glib support probe
3201a52d28afSPaolo Bonzini
3202ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3203ad04d8cbSPeter Maydell    glib_req_ver=2.30
3204ad04d8cbSPeter Maydellelse
3205f40685c6SJohn Snow    glib_req_ver=2.22
3206ad04d8cbSPeter Maydellfi
3207aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3208aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3209aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3210aa0d1f44SPaolo Bonzinifi
3211e26110cfSFam Zheng
32124eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
32134eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
32144eaf7202SSameeh Jubran
32154eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
32164eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
32174eaf7202SSameeh Jubranfi
32184eaf7202SSameeh Jubran
3219aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3220e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
322189138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
322289138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
32234a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
322414015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3225957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3226e18df141SAnthony Liguori    else
3227e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3228e26110cfSFam Zheng    fi
3229e26110cfSFam Zhengdone
3230e26110cfSFam Zheng
3231977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3232977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3233977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3234977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3235977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3236977a82abSDaniel P. Berrange#include <glib.h>
3237977a82abSDaniel P. Berrange#include <unistd.h>
3238977a82abSDaniel P. Berrange
3239977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3240977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3241977a82abSDaniel P. Berrange
3242977a82abSDaniel P. Berrangeint main(void) {
3243977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3244977a82abSDaniel P. Berrange   return 0;
3245977a82abSDaniel P. Berrange}
3246977a82abSDaniel P. BerrangeEOF
3247977a82abSDaniel P. Berrange
32485919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3249977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3250977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3251977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3252977a82abSDaniel P. Berrange	       "build target"
3253977a82abSDaniel P. Berrangefi
3254977a82abSDaniel P. Berrange
32559d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
32569d41401bSMichael S. Tsirkinglib_subprocess=yes
3257a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
32589d41401bSMichael S. Tsirkin    glib_subprocess=no
32599d41401bSMichael S. Tsirkinfi
32609d41401bSMichael S. Tsirkin
3261bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3262bbbf2e04SJohn Snowcat > $TMPC << EOF
3263bbbf2e04SJohn Snow#include <glib.h>
3264bbbf2e04SJohn Snowint main(void) { return 0; }
3265bbbf2e04SJohn SnowEOF
3266bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3267bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3268bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3269bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3270bbbf2e04SJohn Snow    fi
3271bbbf2e04SJohn Snowfi
3272bbbf2e04SJohn Snow
3273e26110cfSFam Zheng##########################################
3274e26110cfSFam Zheng# SHA command probe for modules
3275e26110cfSFam Zhengif test "$modules" = yes; then
3276e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3277e26110cfSFam Zheng    for c in $shacmd_probe; do
32788ccefb91SFam Zheng        if has $c; then
3279e26110cfSFam Zheng            shacmd="$c"
3280e26110cfSFam Zheng            break
3281e26110cfSFam Zheng        fi
3282e26110cfSFam Zheng    done
3283e26110cfSFam Zheng    if test "$shacmd" = ""; then
3284e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3285e26110cfSFam Zheng    fi
3286e18df141SAnthony Liguorifi
3287e18df141SAnthony Liguori
3288e18df141SAnthony Liguori##########################################
3289e2134eb9SGerd Hoffmann# pixman support probe
3290e2134eb9SGerd Hoffmann
329174880fe2SRobert Schieleif test "$want_tools" = "no" -a "$softmmu" = "no"; then
329274880fe2SRobert Schiele  pixman_cflags=
329374880fe2SRobert Schiele  pixman_libs=
3294*35c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
329589138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
329689138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3297e2134eb9SGerd Hoffmannelse
3298c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
3299c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
3300e2134eb9SGerd Hoffmannfi
3301e2134eb9SGerd Hoffmann
3302e2134eb9SGerd Hoffmann##########################################
330317bff52bSM. Mohan Kumar# libcap probe
330417bff52bSM. Mohan Kumar
330517bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
330617bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
330717bff52bSM. Mohan Kumar#include <stdio.h>
330817bff52bSM. Mohan Kumar#include <sys/capability.h>
3309cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
331017bff52bSM. Mohan KumarEOF
331117bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
331217bff52bSM. Mohan Kumar    cap=yes
331317bff52bSM. Mohan Kumar  else
331417bff52bSM. Mohan Kumar    cap=no
331517bff52bSM. Mohan Kumar  fi
331617bff52bSM. Mohan Kumarfi
331717bff52bSM. Mohan Kumar
331817bff52bSM. Mohan Kumar##########################################
3319e5d355d1Saliguori# pthread probe
33204b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
33213c529d93Saliguori
3322e5d355d1Saliguoripthread=no
3323414f0dabSblueswir1cat > $TMPC << EOF
33243c529d93Saliguori#include <pthread.h>
33257a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
33267a42bbe4SStefan Weilint main(void) {
33277a42bbe4SStefan Weil  pthread_t thread;
33287a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
33297a42bbe4SStefan Weil  return 0;
33307a42bbe4SStefan Weil}
3331414f0dabSblueswir1EOF
3332bd00d539SAndreas Färberif compile_prog "" "" ; then
3333bd00d539SAndreas Färber  pthread=yes
3334bd00d539SAndreas Färberelse
3335de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
333652166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3337e5d355d1Saliguori      pthread=yes
3338e3c56761SPeter Portante      found=no
3339e3c56761SPeter Portante      for lib_entry in $LIBS; do
3340e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3341e3c56761SPeter Portante          found=yes
3342e3c56761SPeter Portante          break
3343e3c56761SPeter Portante        fi
3344e3c56761SPeter Portante      done
3345e3c56761SPeter Portante      if test "$found" = "no"; then
33465572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3347e3c56761SPeter Portante      fi
3348409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3349de65fe0fSSebastian Herbszt      break
3350414f0dabSblueswir1    fi
3351de65fe0fSSebastian Herbszt  done
3352bd00d539SAndreas Färberfi
3353414f0dabSblueswir1
33544617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
335576ad07a4SPeter Maydell  error_exit "pthread check failed" \
335676ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3357e5d355d1Saliguorifi
3358e5d355d1Saliguori
33595c312079SDr. David Alan Gilbert# check for pthread_setname_np
33605c312079SDr. David Alan Gilbertpthread_setname_np=no
33615c312079SDr. David Alan Gilbertcat > $TMPC << EOF
33625c312079SDr. David Alan Gilbert#include <pthread.h>
33635c312079SDr. David Alan Gilbert
33645c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
33655c312079SDr. David Alan Gilbertint main(void)
33665c312079SDr. David Alan Gilbert{
33675c312079SDr. David Alan Gilbert    pthread_t thread;
33685c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
33695c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
33705c312079SDr. David Alan Gilbert    return 0;
33715c312079SDr. David Alan Gilbert}
33725c312079SDr. David Alan GilbertEOF
33735c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
33745c312079SDr. David Alan Gilbert  pthread_setname_np=yes
33755c312079SDr. David Alan Gilbertfi
33765c312079SDr. David Alan Gilbert
3377bf9298b9Saliguori##########################################
3378f27aaf4bSChristian Brunner# rbd probe
3379f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3380f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3381f27aaf4bSChristian Brunner#include <stdio.h>
3382ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3383f27aaf4bSChristian Brunnerint main(void) {
3384ad32e9c0SJosh Durgin    rados_t cluster;
3385ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3386f27aaf4bSChristian Brunner    return 0;
3387f27aaf4bSChristian Brunner}
3388f27aaf4bSChristian BrunnerEOF
3389ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3390f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3391f27aaf4bSChristian Brunner    rbd=yes
3392f27aaf4bSChristian Brunner  else
3393f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
339421684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3395f27aaf4bSChristian Brunner    fi
3396f27aaf4bSChristian Brunner    rbd=no
3397f27aaf4bSChristian Brunner  fi
3398f27aaf4bSChristian Brunnerfi
3399f27aaf4bSChristian Brunner
3400f27aaf4bSChristian Brunner##########################################
34010a12ec87SRichard W.M. Jones# libssh2 probe
34024fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
34030a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
340465d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
340589138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
340689138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
34070a12ec87SRichard W.M. Jones    libssh2=yes
34080a12ec87SRichard W.M. Jones  else
34090a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
34104fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
34110a12ec87SRichard W.M. Jones    fi
34120a12ec87SRichard W.M. Jones    libssh2=no
34130a12ec87SRichard W.M. Jones  fi
34140a12ec87SRichard W.M. Jonesfi
34150a12ec87SRichard W.M. Jones
34160a12ec87SRichard W.M. Jones##########################################
34179a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
34189a2d462eSRichard W.M. Jones
34199a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
34209a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
34219a2d462eSRichard W.M. Jones#include <stdio.h>
34229a2d462eSRichard W.M. Jones#include <libssh2.h>
34239a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
34249a2d462eSRichard W.M. Jonesint main(void) {
34259a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
34269a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
34279a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
34289a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
34299a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
34309a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
34319a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
34329a2d462eSRichard W.M. Jones    return 0;
34339a2d462eSRichard W.M. Jones}
34349a2d462eSRichard W.M. JonesEOF
34359a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
34369a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
34379a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
34389a2d462eSRichard W.M. Jones  fi
34399a2d462eSRichard W.M. Jonesfi
34409a2d462eSRichard W.M. Jones
34419a2d462eSRichard W.M. Jones##########################################
34425c6c3a6cSChristoph Hellwig# linux-aio probe
34435c6c3a6cSChristoph Hellwig
34445c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
34455c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
34465c6c3a6cSChristoph Hellwig#include <libaio.h>
34475c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3448832ce9c2SScott Wood#include <stddef.h>
34495c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
34505c6c3a6cSChristoph HellwigEOF
34515c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
34525c6c3a6cSChristoph Hellwig    linux_aio=yes
34535c6c3a6cSChristoph Hellwig  else
34545c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
345521684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
34565c6c3a6cSChristoph Hellwig    fi
34573cfcae3cSLuiz Capitulino    linux_aio=no
34585c6c3a6cSChristoph Hellwig  fi
34595c6c3a6cSChristoph Hellwigfi
34605c6c3a6cSChristoph Hellwig
34615c6c3a6cSChristoph Hellwig##########################################
34623b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
34633b8acc11SPaolo Bonzini
34643b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
34653b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
34663b8acc11SPaolo Bonzinielse
34673b8acc11SPaolo Bonzini  tpm_passthrough=no
34683b8acc11SPaolo Bonzinifi
34693b8acc11SPaolo Bonzini
34703b8acc11SPaolo Bonzini##########################################
3471758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3472758e8e38SVenkateswararao Jujjuri (JV)
3473758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3474758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3475758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3476758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3477f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3478f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3479f2338fb4SPavel Borzenkov#else
34804f26f2b6SAvi Kivity#include <sys/xattr.h>
3481f2338fb4SPavel Borzenkov#endif
3482758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3483758e8e38SVenkateswararao Jujjuri (JV)EOF
34844f26f2b6SAvi Kivity  if compile_prog "" "" ; then
34854f26f2b6SAvi Kivity    attr=yes
34864f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3487f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3488758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3489758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
34904f26f2b6SAvi Kivity    libattr=yes
3491758e8e38SVenkateswararao Jujjuri (JV)  else
3492758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
349321684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3494758e8e38SVenkateswararao Jujjuri (JV)    fi
3495758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3496758e8e38SVenkateswararao Jujjuri (JV)  fi
3497758e8e38SVenkateswararao Jujjuri (JV)fi
3498758e8e38SVenkateswararao Jujjuri (JV)
3499758e8e38SVenkateswararao Jujjuri (JV)##########################################
3500bf9298b9Saliguori# iovec probe
3501bf9298b9Saliguoricat > $TMPC <<EOF
3502db34f0b3Sblueswir1#include <sys/types.h>
3503bf9298b9Saliguori#include <sys/uio.h>
3504db34f0b3Sblueswir1#include <unistd.h>
3505f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3506bf9298b9SaliguoriEOF
3507bf9298b9Saliguoriiovec=no
350852166aa0SJuan Quintelaif compile_prog "" "" ; then
3509bf9298b9Saliguori  iovec=yes
3510bf9298b9Saliguorifi
3511bf9298b9Saliguori
3512f652e6afSaurel32##########################################
3513ceb42de8Saliguori# preadv probe
3514ceb42de8Saliguoricat > $TMPC <<EOF
3515ceb42de8Saliguori#include <sys/types.h>
3516ceb42de8Saliguori#include <sys/uio.h>
3517ceb42de8Saliguori#include <unistd.h>
3518c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3519ceb42de8SaliguoriEOF
3520ceb42de8Saliguoripreadv=no
352152166aa0SJuan Quintelaif compile_prog "" "" ; then
3522ceb42de8Saliguori  preadv=yes
3523ceb42de8Saliguorifi
3524ceb42de8Saliguori
3525ceb42de8Saliguori##########################################
3526f652e6afSaurel32# fdt probe
3527e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3528e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3529e169e1e1SPeter Maydellfdt_required=no
3530e169e1e1SPeter Maydellfor target in $target_list; do
3531e169e1e1SPeter Maydell  case $target in
3532df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3533e169e1e1SPeter Maydell      fdt_required=yes
3534e169e1e1SPeter Maydell    ;;
3535e169e1e1SPeter Maydell  esac
3536e169e1e1SPeter Maydelldone
3537e169e1e1SPeter Maydell
3538e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3539e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3540e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3541e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3542e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3543e169e1e1SPeter Maydell  fi
3544e169e1e1SPeter Maydell  fdt=yes
3545e169e1e1SPeter Maydellfi
3546e169e1e1SPeter Maydell
35472df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3548b41af4baSJuan Quintela  fdt_libs="-lfdt"
354996ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
35506e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3551f652e6afSaurel32  cat > $TMPC << EOF
355231ce0adbSThomas Huth#include <libfdt.h>
355396ce6545SPeter Crosthwaite#include <libfdt_env.h>
35546e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3555f652e6afSaurel32EOF
355652166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3557a540f158SPeter Crosthwaite    # system DTC is good - use it
3558f652e6afSaurel32    fdt=yes
3559a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
3560a540f158SPeter Crosthwaite    # have submodule DTC - use it
3561a540f158SPeter Crosthwaite    fdt=yes
3562a540f158SPeter Crosthwaite    dtc_internal="yes"
3563a540f158SPeter Crosthwaite    mkdir -p dtc
3564cab00a5aSMichael S. Tsirkin    if [ "$pwd_is_source_path" != "y" ] ; then
3565a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3566a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
35672df87df7SJuan Quintela    fi
3568a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3569a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3570a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
3571a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
35726e85fce0SPaul Burton    error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
35733f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
3574a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
3575a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
3576a540f158SPeter Crosthwaite  else
3577a540f158SPeter Crosthwaite    # don't have and don't want
3578de3a354aSMichael Walle    fdt_libs=
35792df87df7SJuan Quintela    fdt=no
3580f652e6afSaurel32  fi
3581f652e6afSaurel32fi
3582f652e6afSaurel32
3583a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3584a540f158SPeter Crosthwaite
358520ff075bSMichael Walle##########################################
3586fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3587b1546f32SGerd Hoffmann
3588da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3589014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3590fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3591f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3592f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3593da076ffeSGerd Hoffmann    opengl=yes
3594925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3595925a0400SGerd Hoffmann        gtk_gl="yes"
3596925a0400SGerd Hoffmann    fi
3597cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
359820ff075bSMichael Walle  else
3599da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3600dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
360120ff075bSMichael Walle    fi
3602f676c67eSJeremy White    opengl_cflags=""
3603da076ffeSGerd Hoffmann    opengl_libs=""
3604da076ffeSGerd Hoffmann    opengl=no
360520ff075bSMichael Walle  fi
360620ff075bSMichael Wallefi
360720ff075bSMichael Walle
3608014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3609014cb152SGerd Hoffmann  cat > $TMPC << EOF
3610014cb152SGerd Hoffmann#include <epoxy/egl.h>
3611014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3612014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3613014cb152SGerd Hoffmann#endif
3614014cb152SGerd Hoffmannint main(void) { return 0; }
3615014cb152SGerd HoffmannEOF
3616014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3617014cb152SGerd Hoffmann    opengl_dmabuf=yes
3618014cb152SGerd Hoffmann  fi
3619014cb152SGerd Hoffmannfi
3620c9a12e75SChrysostomos Nanakos
3621c9a12e75SChrysostomos Nanakos
3622eb100396SBharata B Rao##########################################
3623eb100396SBharata B Rao# glusterfs probe
3624eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
362565d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3626e01bee08SBharata B Rao    glusterfs="yes"
362789138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
362889138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3629d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3630d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3631d85fa9ebSJeff Cody    fi
363265d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
36330c14fb47SBharata B Rao      glusterfs_discard="yes"
36340c14fb47SBharata B Rao    fi
36357c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3636df3a429aSNiels de Vos      glusterfs_fallocate="yes"
36377c815372SBharata B Rao      glusterfs_zerofill="yes"
36387c815372SBharata B Rao    fi
3639eb100396SBharata B Rao  else
3640eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
36418efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
36428efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3643eb100396SBharata B Rao    fi
3644e01bee08SBharata B Rao    glusterfs="no"
3645eb100396SBharata B Rao  fi
3646eb100396SBharata B Raofi
3647eb100396SBharata B Rao
364839386ac7Saurel32# Check for inotify functions when we are building linux-user
36493b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36503b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36513b3f24adSaurel32# don't provide them even if kernel supports them.
36523b3f24adSaurel32#
36533b3f24adSaurel32inotify=no
36543b3f24adSaurel32cat > $TMPC << EOF
36553b3f24adSaurel32#include <sys/inotify.h>
36563b3f24adSaurel32
36573b3f24adSaurel32int
36583b3f24adSaurel32main(void)
36593b3f24adSaurel32{
36603b3f24adSaurel32	/* try to start inotify */
36618690e420Saurel32	return inotify_init();
36623b3f24adSaurel32}
36633b3f24adSaurel32EOF
366452166aa0SJuan Quintelaif compile_prog "" "" ; then
36653b3f24adSaurel32  inotify=yes
36663b3f24adSaurel32fi
36673b3f24adSaurel32
3668c05c7a73SRiku Voipioinotify1=no
3669c05c7a73SRiku Voipiocat > $TMPC << EOF
3670c05c7a73SRiku Voipio#include <sys/inotify.h>
3671c05c7a73SRiku Voipio
3672c05c7a73SRiku Voipioint
3673c05c7a73SRiku Voipiomain(void)
3674c05c7a73SRiku Voipio{
3675c05c7a73SRiku Voipio    /* try to start inotify */
3676c05c7a73SRiku Voipio    return inotify_init1(0);
3677c05c7a73SRiku Voipio}
3678c05c7a73SRiku VoipioEOF
3679c05c7a73SRiku Voipioif compile_prog "" "" ; then
3680c05c7a73SRiku Voipio  inotify1=yes
3681c05c7a73SRiku Voipiofi
3682c05c7a73SRiku Voipio
3683099d6b0fSRiku Voipio# check if pipe2 is there
3684099d6b0fSRiku Voipiopipe2=no
3685099d6b0fSRiku Voipiocat > $TMPC << EOF
3686099d6b0fSRiku Voipio#include <unistd.h>
3687099d6b0fSRiku Voipio#include <fcntl.h>
3688099d6b0fSRiku Voipio
3689099d6b0fSRiku Voipioint main(void)
3690099d6b0fSRiku Voipio{
3691099d6b0fSRiku Voipio    int pipefd[2];
36929bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3693099d6b0fSRiku Voipio}
3694099d6b0fSRiku VoipioEOF
369552166aa0SJuan Quintelaif compile_prog "" "" ; then
3696099d6b0fSRiku Voipio  pipe2=yes
3697099d6b0fSRiku Voipiofi
3698099d6b0fSRiku Voipio
369940ff6d7eSKevin Wolf# check if accept4 is there
370040ff6d7eSKevin Wolfaccept4=no
370140ff6d7eSKevin Wolfcat > $TMPC << EOF
370240ff6d7eSKevin Wolf#include <sys/socket.h>
370340ff6d7eSKevin Wolf#include <stddef.h>
370440ff6d7eSKevin Wolf
370540ff6d7eSKevin Wolfint main(void)
370640ff6d7eSKevin Wolf{
370740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
370840ff6d7eSKevin Wolf    return 0;
370940ff6d7eSKevin Wolf}
371040ff6d7eSKevin WolfEOF
371140ff6d7eSKevin Wolfif compile_prog "" "" ; then
371240ff6d7eSKevin Wolf  accept4=yes
371340ff6d7eSKevin Wolffi
371440ff6d7eSKevin Wolf
37153ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
37163ce34dfbSvibisreenivasansplice=no
37173ce34dfbSvibisreenivasancat > $TMPC << EOF
37183ce34dfbSvibisreenivasan#include <unistd.h>
37193ce34dfbSvibisreenivasan#include <fcntl.h>
37203ce34dfbSvibisreenivasan#include <limits.h>
37213ce34dfbSvibisreenivasan
37223ce34dfbSvibisreenivasanint main(void)
37233ce34dfbSvibisreenivasan{
372466ea0f22SStefan Weil    int len, fd = 0;
37253ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
37263ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
37273ce34dfbSvibisreenivasan    return 0;
37283ce34dfbSvibisreenivasan}
37293ce34dfbSvibisreenivasanEOF
373052166aa0SJuan Quintelaif compile_prog "" "" ; then
37313ce34dfbSvibisreenivasan  splice=yes
37323ce34dfbSvibisreenivasanfi
37333ce34dfbSvibisreenivasan
3734dcc38d1cSMarcelo Tosatti##########################################
3735a99d57bbSWanlong Gao# libnuma probe
3736a99d57bbSWanlong Gao
3737a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3738a99d57bbSWanlong Gao  cat > $TMPC << EOF
3739a99d57bbSWanlong Gao#include <numa.h>
3740a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3741a99d57bbSWanlong GaoEOF
3742a99d57bbSWanlong Gao
3743a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3744a99d57bbSWanlong Gao    numa=yes
3745a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3746a99d57bbSWanlong Gao  else
3747a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3748a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3749a99d57bbSWanlong Gao    fi
3750a99d57bbSWanlong Gao    numa=no
3751a99d57bbSWanlong Gao  fi
3752a99d57bbSWanlong Gaofi
3753a99d57bbSWanlong Gao
37547b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37557b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37567b01cb97SAlexandre Derumier    exit 1
37577b01cb97SAlexandre Derumierfi
37587b01cb97SAlexandre Derumier
3759a99d57bbSWanlong Gao##########################################
37602847b469SFam Zheng# tcmalloc probe
37612847b469SFam Zheng
37622847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
37632847b469SFam Zheng  cat > $TMPC << EOF
37642847b469SFam Zheng#include <stdlib.h>
37652847b469SFam Zhengint main(void) { malloc(1); return 0; }
37662847b469SFam ZhengEOF
37672847b469SFam Zheng
37682847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
37692847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
37702847b469SFam Zheng  else
37712847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
37722847b469SFam Zheng  fi
37732847b469SFam Zhengfi
37742847b469SFam Zheng
37752847b469SFam Zheng##########################################
37767b01cb97SAlexandre Derumier# jemalloc probe
37777b01cb97SAlexandre Derumier
37787b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
37797b01cb97SAlexandre Derumier  cat > $TMPC << EOF
37807b01cb97SAlexandre Derumier#include <stdlib.h>
37817b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
37827b01cb97SAlexandre DerumierEOF
37837b01cb97SAlexandre Derumier
37847b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
37857b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
37867b01cb97SAlexandre Derumier  else
37877b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
37887b01cb97SAlexandre Derumier  fi
37897b01cb97SAlexandre Derumierfi
37907b01cb97SAlexandre Derumier
37917b01cb97SAlexandre Derumier##########################################
3792dcc38d1cSMarcelo Tosatti# signalfd probe
3793dcc38d1cSMarcelo Tosattisignalfd="no"
3794dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3795dcc38d1cSMarcelo Tosatti#include <unistd.h>
3796dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3797dcc38d1cSMarcelo Tosatti#include <signal.h>
3798dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3799dcc38d1cSMarcelo TosattiEOF
3800dcc38d1cSMarcelo Tosatti
3801dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3802dcc38d1cSMarcelo Tosatti  signalfd=yes
3803dcc38d1cSMarcelo Tosattifi
3804dcc38d1cSMarcelo Tosatti
3805c2882b96SRiku Voipio# check if eventfd is supported
3806c2882b96SRiku Voipioeventfd=no
3807c2882b96SRiku Voipiocat > $TMPC << EOF
3808c2882b96SRiku Voipio#include <sys/eventfd.h>
3809c2882b96SRiku Voipio
3810c2882b96SRiku Voipioint main(void)
3811c2882b96SRiku Voipio{
381255cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3813c2882b96SRiku Voipio}
3814c2882b96SRiku VoipioEOF
3815c2882b96SRiku Voipioif compile_prog "" "" ; then
3816c2882b96SRiku Voipio  eventfd=yes
3817c2882b96SRiku Voipiofi
3818c2882b96SRiku Voipio
3819751bcc39SMarc-André Lureau# check if memfd is supported
3820751bcc39SMarc-André Lureaumemfd=no
3821751bcc39SMarc-André Lureaucat > $TMPC << EOF
3822751bcc39SMarc-André Lureau#include <sys/memfd.h>
3823751bcc39SMarc-André Lureau
3824751bcc39SMarc-André Lureauint main(void)
3825751bcc39SMarc-André Lureau{
3826751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3827751bcc39SMarc-André Lureau}
3828751bcc39SMarc-André LureauEOF
3829751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3830751bcc39SMarc-André Lureau  memfd=yes
3831751bcc39SMarc-André Lureaufi
3832751bcc39SMarc-André Lureau
3833751bcc39SMarc-André Lureau
3834751bcc39SMarc-André Lureau
3835d0927938SUlrich Hecht# check for fallocate
3836d0927938SUlrich Hechtfallocate=no
3837d0927938SUlrich Hechtcat > $TMPC << EOF
3838d0927938SUlrich Hecht#include <fcntl.h>
3839d0927938SUlrich Hecht
3840d0927938SUlrich Hechtint main(void)
3841d0927938SUlrich Hecht{
3842d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3843d0927938SUlrich Hecht    return 0;
3844d0927938SUlrich Hecht}
3845d0927938SUlrich HechtEOF
38468fb03151SPeter Maydellif compile_prog "" "" ; then
3847d0927938SUlrich Hecht  fallocate=yes
3848d0927938SUlrich Hechtfi
3849d0927938SUlrich Hecht
38503d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38513d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38523d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38533d4fa43eSKusanagi Kouichi#include <fcntl.h>
38543d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38553d4fa43eSKusanagi Kouichi
38563d4fa43eSKusanagi Kouichiint main(void)
38573d4fa43eSKusanagi Kouichi{
38583d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38593d4fa43eSKusanagi Kouichi    return 0;
38603d4fa43eSKusanagi Kouichi}
38613d4fa43eSKusanagi KouichiEOF
38623d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38633d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38643d4fa43eSKusanagi Kouichifi
38653d4fa43eSKusanagi Kouichi
3866b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3867b953f075SDenis V. Lunevfallocate_zero_range=no
3868b953f075SDenis V. Lunevcat > $TMPC << EOF
3869b953f075SDenis V. Lunev#include <fcntl.h>
3870b953f075SDenis V. Lunev#include <linux/falloc.h>
3871b953f075SDenis V. Lunev
3872b953f075SDenis V. Lunevint main(void)
3873b953f075SDenis V. Lunev{
3874b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3875b953f075SDenis V. Lunev    return 0;
3876b953f075SDenis V. Lunev}
3877b953f075SDenis V. LunevEOF
3878b953f075SDenis V. Lunevif compile_prog "" "" ; then
3879b953f075SDenis V. Lunev  fallocate_zero_range=yes
3880b953f075SDenis V. Lunevfi
3881b953f075SDenis V. Lunev
3882ed911435SKevin Wolf# check for posix_fallocate
3883ed911435SKevin Wolfposix_fallocate=no
3884ed911435SKevin Wolfcat > $TMPC << EOF
3885ed911435SKevin Wolf#include <fcntl.h>
3886ed911435SKevin Wolf
3887ed911435SKevin Wolfint main(void)
3888ed911435SKevin Wolf{
3889ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3890ed911435SKevin Wolf    return 0;
3891ed911435SKevin Wolf}
3892ed911435SKevin WolfEOF
3893ed911435SKevin Wolfif compile_prog "" "" ; then
3894ed911435SKevin Wolf    posix_fallocate=yes
3895ed911435SKevin Wolffi
3896ed911435SKevin Wolf
3897c727f47dSPeter Maydell# check for sync_file_range
3898c727f47dSPeter Maydellsync_file_range=no
3899c727f47dSPeter Maydellcat > $TMPC << EOF
3900c727f47dSPeter Maydell#include <fcntl.h>
3901c727f47dSPeter Maydell
3902c727f47dSPeter Maydellint main(void)
3903c727f47dSPeter Maydell{
3904c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3905c727f47dSPeter Maydell    return 0;
3906c727f47dSPeter Maydell}
3907c727f47dSPeter MaydellEOF
39088fb03151SPeter Maydellif compile_prog "" "" ; then
3909c727f47dSPeter Maydell  sync_file_range=yes
3910c727f47dSPeter Maydellfi
3911c727f47dSPeter Maydell
3912dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3913dace20dcSPeter Maydellfiemap=no
3914dace20dcSPeter Maydellcat > $TMPC << EOF
3915dace20dcSPeter Maydell#include <sys/ioctl.h>
3916dace20dcSPeter Maydell#include <linux/fs.h>
3917dace20dcSPeter Maydell#include <linux/fiemap.h>
3918dace20dcSPeter Maydell
3919dace20dcSPeter Maydellint main(void)
3920dace20dcSPeter Maydell{
3921dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3922dace20dcSPeter Maydell    return 0;
3923dace20dcSPeter Maydell}
3924dace20dcSPeter MaydellEOF
39258fb03151SPeter Maydellif compile_prog "" "" ; then
3926dace20dcSPeter Maydell  fiemap=yes
3927dace20dcSPeter Maydellfi
3928dace20dcSPeter Maydell
3929d0927938SUlrich Hecht# check for dup3
3930d0927938SUlrich Hechtdup3=no
3931d0927938SUlrich Hechtcat > $TMPC << EOF
3932d0927938SUlrich Hecht#include <unistd.h>
3933d0927938SUlrich Hecht
3934d0927938SUlrich Hechtint main(void)
3935d0927938SUlrich Hecht{
3936d0927938SUlrich Hecht    dup3(0, 0, 0);
3937d0927938SUlrich Hecht    return 0;
3938d0927938SUlrich Hecht}
3939d0927938SUlrich HechtEOF
394078f5d726SJan Kiszkaif compile_prog "" "" ; then
3941d0927938SUlrich Hecht  dup3=yes
3942d0927938SUlrich Hechtfi
3943d0927938SUlrich Hecht
39444e0c6529SAlex Bligh# check for ppoll support
39454e0c6529SAlex Blighppoll=no
39464e0c6529SAlex Blighcat > $TMPC << EOF
39474e0c6529SAlex Bligh#include <poll.h>
39484e0c6529SAlex Bligh
39494e0c6529SAlex Blighint main(void)
39504e0c6529SAlex Bligh{
39514e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39524e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39534e0c6529SAlex Bligh    return 0;
39544e0c6529SAlex Bligh}
39554e0c6529SAlex BlighEOF
39564e0c6529SAlex Blighif compile_prog "" "" ; then
39574e0c6529SAlex Bligh  ppoll=yes
39584e0c6529SAlex Blighfi
39594e0c6529SAlex Bligh
3960cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3961cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3962cd758dd0SAlex Blighcat > $TMPC << EOF
3963cd758dd0SAlex Bligh#include <sys/prctl.h>
3964cd758dd0SAlex Bligh
3965cd758dd0SAlex Blighint main(void)
3966cd758dd0SAlex Bligh{
3967cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3968cd758dd0SAlex Bligh    return 0;
3969cd758dd0SAlex Bligh}
3970cd758dd0SAlex BlighEOF
3971cd758dd0SAlex Blighif compile_prog "" "" ; then
3972cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3973cd758dd0SAlex Blighfi
3974cd758dd0SAlex Bligh
39753b6edd16SPeter Maydell# check for epoll support
39763b6edd16SPeter Maydellepoll=no
39773b6edd16SPeter Maydellcat > $TMPC << EOF
39783b6edd16SPeter Maydell#include <sys/epoll.h>
39793b6edd16SPeter Maydell
39803b6edd16SPeter Maydellint main(void)
39813b6edd16SPeter Maydell{
39823b6edd16SPeter Maydell    epoll_create(0);
39833b6edd16SPeter Maydell    return 0;
39843b6edd16SPeter Maydell}
39853b6edd16SPeter MaydellEOF
39868fb03151SPeter Maydellif compile_prog "" "" ; then
39873b6edd16SPeter Maydell  epoll=yes
39883b6edd16SPeter Maydellfi
39893b6edd16SPeter Maydell
3990227f0214SPeter Maydell# epoll_create1 is a later addition
3991227f0214SPeter Maydell# so we must check separately for its presence
39923b6edd16SPeter Maydellepoll_create1=no
39933b6edd16SPeter Maydellcat > $TMPC << EOF
39943b6edd16SPeter Maydell#include <sys/epoll.h>
39953b6edd16SPeter Maydell
39963b6edd16SPeter Maydellint main(void)
39973b6edd16SPeter Maydell{
399819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
399919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
400019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
400119e83f6bSPeter Maydell     * the library but not declared in the header file we will
400219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
400319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
400419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
400519e83f6bSPeter Maydell     */
4006c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
40073b6edd16SPeter Maydell}
40083b6edd16SPeter MaydellEOF
40098fb03151SPeter Maydellif compile_prog "" "" ; then
40103b6edd16SPeter Maydell  epoll_create1=yes
40113b6edd16SPeter Maydellfi
40123b6edd16SPeter Maydell
4013a8fd1abaSPeter Maydell# check for sendfile support
4014a8fd1abaSPeter Maydellsendfile=no
4015a8fd1abaSPeter Maydellcat > $TMPC << EOF
4016a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4017a8fd1abaSPeter Maydell
4018a8fd1abaSPeter Maydellint main(void)
4019a8fd1abaSPeter Maydell{
4020a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4021a8fd1abaSPeter Maydell}
4022a8fd1abaSPeter MaydellEOF
4023a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4024a8fd1abaSPeter Maydell  sendfile=yes
4025a8fd1abaSPeter Maydellfi
4026a8fd1abaSPeter Maydell
402751834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
402851834341SRiku Voipiotimerfd=no
402951834341SRiku Voipiocat > $TMPC << EOF
403051834341SRiku Voipio#include <sys/timerfd.h>
403151834341SRiku Voipio
403251834341SRiku Voipioint main(void)
403351834341SRiku Voipio{
403451834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
403551834341SRiku Voipio}
403651834341SRiku VoipioEOF
403751834341SRiku Voipioif compile_prog "" "" ; then
403851834341SRiku Voipio  timerfd=yes
403951834341SRiku Voipiofi
404051834341SRiku Voipio
40419af5c906SRiku Voipio# check for setns and unshare support
40429af5c906SRiku Voipiosetns=no
40439af5c906SRiku Voipiocat > $TMPC << EOF
40449af5c906SRiku Voipio#include <sched.h>
40459af5c906SRiku Voipio
40469af5c906SRiku Voipioint main(void)
40479af5c906SRiku Voipio{
40489af5c906SRiku Voipio    int ret;
40499af5c906SRiku Voipio    ret = setns(0, 0);
40509af5c906SRiku Voipio    ret = unshare(0);
40519af5c906SRiku Voipio    return ret;
40529af5c906SRiku Voipio}
40539af5c906SRiku VoipioEOF
40549af5c906SRiku Voipioif compile_prog "" "" ; then
40559af5c906SRiku Voipio  setns=yes
40569af5c906SRiku Voipiofi
40579af5c906SRiku Voipio
405838860a03SAleksandar Markovic# clock_adjtime probe
405938860a03SAleksandar Markovicclock_adjtime=no
406038860a03SAleksandar Markoviccat > $TMPC <<EOF
406138860a03SAleksandar Markovic#include <time.h>
406238860a03SAleksandar Markovic
406338860a03SAleksandar Markovicint main(void)
406438860a03SAleksandar Markovic{
406538860a03SAleksandar Markovic    return clock_adjtime(0, 0);
406638860a03SAleksandar Markovic}
406738860a03SAleksandar MarkovicEOF
406838860a03SAleksandar Markovicclock_adjtime=no
406938860a03SAleksandar Markovicif compile_prog "" "" ; then
407038860a03SAleksandar Markovic  clock_adjtime=yes
407138860a03SAleksandar Markovicfi
407238860a03SAleksandar Markovic
40735a03cd00SAleksandar Markovic# syncfs probe
40745a03cd00SAleksandar Markovicsyncfs=no
40755a03cd00SAleksandar Markoviccat > $TMPC <<EOF
40765a03cd00SAleksandar Markovic#include <unistd.h>
40775a03cd00SAleksandar Markovic
40785a03cd00SAleksandar Markovicint main(void)
40795a03cd00SAleksandar Markovic{
40805a03cd00SAleksandar Markovic    return syncfs(0);
40815a03cd00SAleksandar Markovic}
40825a03cd00SAleksandar MarkovicEOF
40835a03cd00SAleksandar Markovicsyncfs=no
40845a03cd00SAleksandar Markovicif compile_prog "" "" ; then
40855a03cd00SAleksandar Markovic  syncfs=yes
40865a03cd00SAleksandar Markovicfi
40875a03cd00SAleksandar Markovic
4088cc8ae6deSpbrook# Check if tools are available to build documentation.
4089a25dba17SJuan Quintelaif test "$docs" != "no" ; then
409001668d98SStefan Weil  if has makeinfo && has pod2man; then
4091a25dba17SJuan Quintela    docs=yes
409283a3ab8bSJuan Quintela  else
4093a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
409421684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
409583a3ab8bSJuan Quintela    fi
4096a25dba17SJuan Quintela    docs=no
409783a3ab8bSJuan Quintela  fi
4098cc8ae6deSpbrookfi
4099cc8ae6deSpbrook
4100f514f41cSStefan Weil# Search for bswap_32 function
41016ae9a1f4SJuan Quintelabyteswap_h=no
41026ae9a1f4SJuan Quintelacat > $TMPC << EOF
41036ae9a1f4SJuan Quintela#include <byteswap.h>
41046ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
41056ae9a1f4SJuan QuintelaEOF
410652166aa0SJuan Quintelaif compile_prog "" "" ; then
41076ae9a1f4SJuan Quintela  byteswap_h=yes
41086ae9a1f4SJuan Quintelafi
41096ae9a1f4SJuan Quintela
411075f13596SStefan Weil# Search for bswap32 function
41116ae9a1f4SJuan Quintelabswap_h=no
41126ae9a1f4SJuan Quintelacat > $TMPC << EOF
41136ae9a1f4SJuan Quintela#include <sys/endian.h>
41146ae9a1f4SJuan Quintela#include <sys/types.h>
41156ae9a1f4SJuan Quintela#include <machine/bswap.h>
41166ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
41176ae9a1f4SJuan QuintelaEOF
411852166aa0SJuan Quintelaif compile_prog "" "" ; then
41196ae9a1f4SJuan Quintela  bswap_h=yes
41206ae9a1f4SJuan Quintelafi
41216ae9a1f4SJuan Quintela
4122da93a1fdSaliguori##########################################
4123e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4124c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4125e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
41263c33ea96SPaolo Bonzini    libiscsi="yes"
4127ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4128ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4129c589b249SRonnie Sahlberg  else
4130c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4131e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4132c589b249SRonnie Sahlberg    fi
4133c589b249SRonnie Sahlberg    libiscsi="no"
4134c589b249SRonnie Sahlberg  fi
4135c589b249SRonnie Sahlbergfi
4136c589b249SRonnie Sahlberg
4137c589b249SRonnie Sahlberg##########################################
41388bacde8dSNatanael Copa# Do we need libm
41398bacde8dSNatanael Copacat > $TMPC << EOF
41408bacde8dSNatanael Copa#include <math.h>
4141f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
41428bacde8dSNatanael CopaEOF
41438bacde8dSNatanael Copaif compile_prog "" "" ; then
41448bacde8dSNatanael Copa  :
41458bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
41468bacde8dSNatanael Copa  LIBS="-lm $LIBS"
41478bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
41488bacde8dSNatanael Copaelse
414976ad07a4SPeter Maydell  error_exit "libm check failed"
41508bacde8dSNatanael Copafi
41518bacde8dSNatanael Copa
41528bacde8dSNatanael Copa##########################################
4153da93a1fdSaliguori# Do we need librt
41548bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
41558bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
41568bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
41578bacde8dSNatanael Copa# function in addition.
4158da93a1fdSaliguoricat > $TMPC <<EOF
4159da93a1fdSaliguori#include <signal.h>
4160da93a1fdSaliguori#include <time.h>
41618bacde8dSNatanael Copaint main(void) {
41628bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
41638bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
41648bacde8dSNatanael Copa}
4165da93a1fdSaliguoriEOF
4166da93a1fdSaliguori
416752166aa0SJuan Quintelaif compile_prog "" "" ; then
416807ffa4bdSJuan Quintela  :
41698bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
417018e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
417118e588b1SRick Liu  LIBS="$LIBS -lrt"
417218e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4173da93a1fdSaliguorifi
4174da93a1fdSaliguori
417531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
417678723752SPeter Maydell        "$haiku" != "yes" ; then
41776362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
41786362a53fSJuan Quintelafi
41796362a53fSJuan Quintela
4180de5071c5SBlue Swirl##########################################
4181cd4ec0b4SGerd Hoffmann# spice probe
4182cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4183cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4184cd4ec0b4SGerd Hoffmann#include <spice.h>
4185cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4186cd4ec0b4SGerd HoffmannEOF
4187710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4188710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
418965d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
419065d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4191cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4192cd4ec0b4SGerd Hoffmann    spice="yes"
4193cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4194cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
41952e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
41962e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4197cd4ec0b4SGerd Hoffmann  else
4198cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
41998efc9363SHu Tao      feature_not_found "spice" \
42008efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4201cd4ec0b4SGerd Hoffmann    fi
4202cd4ec0b4SGerd Hoffmann    spice="no"
4203cd4ec0b4SGerd Hoffmann  fi
4204cd4ec0b4SGerd Hoffmannfi
4205cd4ec0b4SGerd Hoffmann
42067b02f544SMarc-André Lureau# check for smartcard support
4207111a38b0SRobert Relyeasmartcard_cflags=""
42087b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
42097b02f544SMarc-André Lureau    if $pkg_config libcacard; then
42107b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
42117b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
42127b02f544SMarc-André Lureau        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
42137b02f544SMarc-André Lureau        libs_softmmu="$libs_softmmu $libcacard_libs"
42147b02f544SMarc-André Lureau        smartcard="yes"
4215111a38b0SRobert Relyea    else
42167b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
42177b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4218111a38b0SRobert Relyea        fi
42197b02f544SMarc-André Lureau        smartcard="no"
4220111a38b0SRobert Relyea    fi
4221111a38b0SRobert Relyeafi
4222111a38b0SRobert Relyea
42232b2325ffSGerd Hoffmann# check for libusb
42242b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
422565d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
42262b2325ffSGerd Hoffmann        libusb="yes"
4227ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4228ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
42292b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
42302b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
42312b2325ffSGerd Hoffmann    else
42322b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
42338efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
42342b2325ffSGerd Hoffmann        fi
42352b2325ffSGerd Hoffmann        libusb="no"
42362b2325ffSGerd Hoffmann    fi
42372b2325ffSGerd Hoffmannfi
42382b2325ffSGerd Hoffmann
423969354a83SHans de Goede# check for usbredirparser for usb network redirection support
424069354a83SHans de Goedeif test "$usb_redir" != "no" ; then
424165d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
424269354a83SHans de Goede        usb_redir="yes"
4243ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4244ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
424569354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
424656ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
424769354a83SHans de Goede    else
424869354a83SHans de Goede        if test "$usb_redir" = "yes"; then
424921684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
425069354a83SHans de Goede        fi
425169354a83SHans de Goede        usb_redir="no"
425269354a83SHans de Goede    fi
425369354a83SHans de Goedefi
425469354a83SHans de Goede
4255cd4ec0b4SGerd Hoffmann##########################################
4256d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4257d9840e25STomoki Sekiyama
4258d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4259d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4260690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4261d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4262d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4263690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4264d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4265d9840e25STomoki Sekiyama	  ;;
4266690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4267d9840e25STomoki Sekiyama  esac
4268d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4269d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4270d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4271d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4272d9840e25STomoki SekiyamaEOF
4273d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4274d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4275d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4276315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4277f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4278d9840e25STomoki Sekiyama  else
4279d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4280d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4281d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4282d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4283d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4284d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4285d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4286d9840e25STomoki Sekiyama    fi
4287d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4288d9840e25STomoki Sekiyama  fi
4289d9840e25STomoki Sekiyamafi
4290d9840e25STomoki Sekiyama
4291d9840e25STomoki Sekiyama##########################################
4292d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4293d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4294d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4295d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4296d9840e25STomoki Sekiyama
4297d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4298d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4299d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4300d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4301d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4302d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4303d9840e25STomoki Sekiyama    else
4304d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4305d9840e25STomoki Sekiyama    fi
4306d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4307d9840e25STomoki Sekiyama    win_sdk=""
4308d9840e25STomoki Sekiyama  fi
4309d9840e25STomoki Sekiyamafi
4310d9840e25STomoki Sekiyama
4311d9840e25STomoki Sekiyama##########################################
431250cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
431350cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
431450cbebb9SMichael Roth  cat > $TMPC << EOF
431550cbebb9SMichael Roth#include <windows.h>
431650cbebb9SMichael Roth#include <ntddscsi.h>
431750cbebb9SMichael Rothint main(void) {
431850cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
431950cbebb9SMichael Roth#error Missing required ioctl definitions
432050cbebb9SMichael Roth#endif
432150cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
432250cbebb9SMichael Roth  return addr.Lun;
432350cbebb9SMichael Roth}
432450cbebb9SMichael RothEOF
432550cbebb9SMichael Roth  if compile_prog "" "" ; then
432650cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4327c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
432850cbebb9SMichael Roth  fi
432950cbebb9SMichael Rothfi
433050cbebb9SMichael Roth
433150cbebb9SMichael Roth##########################################
43329d9e1521SGerd Hoffmann# virgl renderer probe
43339d9e1521SGerd Hoffmann
43349d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
43359d9e1521SGerd Hoffmann  cat > $TMPC << EOF
43369d9e1521SGerd Hoffmann#include <virglrenderer.h>
43379d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
43389d9e1521SGerd HoffmannEOF
43399d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
43409d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
43419d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
43429d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
43439d9e1521SGerd Hoffmann    virglrenderer="yes"
43449d9e1521SGerd Hoffmann  else
43459d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
43469d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
43479d9e1521SGerd Hoffmann    fi
43489d9e1521SGerd Hoffmann    virglrenderer="no"
43499d9e1521SGerd Hoffmann  fi
43509d9e1521SGerd Hoffmannfi
43519d9e1521SGerd Hoffmann
43529d9e1521SGerd Hoffmann##########################################
43535f6b9e8fSBlue Swirl# check if we have fdatasync
43545f6b9e8fSBlue Swirl
43555f6b9e8fSBlue Swirlfdatasync=no
43565f6b9e8fSBlue Swirlcat > $TMPC << EOF
43575f6b9e8fSBlue Swirl#include <unistd.h>
4358d1722a27SAlexandre Raymondint main(void) {
4359d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4360d1722a27SAlexandre Raymondreturn fdatasync(0);
4361d1722a27SAlexandre Raymond#else
4362e172fe11SStefan Weil#error Not supported
4363d1722a27SAlexandre Raymond#endif
4364d1722a27SAlexandre Raymond}
43655f6b9e8fSBlue SwirlEOF
43665f6b9e8fSBlue Swirlif compile_prog "" "" ; then
43675f6b9e8fSBlue Swirl    fdatasync=yes
43685f6b9e8fSBlue Swirlfi
43695f6b9e8fSBlue Swirl
437094a420b1SStefan Hajnoczi##########################################
4371e78815a5SAndreas Färber# check if we have madvise
4372e78815a5SAndreas Färber
4373e78815a5SAndreas Färbermadvise=no
4374e78815a5SAndreas Färbercat > $TMPC << EOF
4375e78815a5SAndreas Färber#include <sys/types.h>
4376e78815a5SAndreas Färber#include <sys/mman.h>
4377832ce9c2SScott Wood#include <stddef.h>
4378e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4379e78815a5SAndreas FärberEOF
4380e78815a5SAndreas Färberif compile_prog "" "" ; then
4381e78815a5SAndreas Färber    madvise=yes
4382e78815a5SAndreas Färberfi
4383e78815a5SAndreas Färber
4384e78815a5SAndreas Färber##########################################
4385e78815a5SAndreas Färber# check if we have posix_madvise
4386e78815a5SAndreas Färber
4387e78815a5SAndreas Färberposix_madvise=no
4388e78815a5SAndreas Färbercat > $TMPC << EOF
4389e78815a5SAndreas Färber#include <sys/mman.h>
4390832ce9c2SScott Wood#include <stddef.h>
4391e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4392e78815a5SAndreas FärberEOF
4393e78815a5SAndreas Färberif compile_prog "" "" ; then
4394e78815a5SAndreas Färber    posix_madvise=yes
4395e78815a5SAndreas Färberfi
4396e78815a5SAndreas Färber
4397e78815a5SAndreas Färber##########################################
43980a852417SPaul Durrant# check if we have posix_syslog
43990a852417SPaul Durrant
44000a852417SPaul Durrantposix_syslog=no
44010a852417SPaul Durrantcat > $TMPC << EOF
44020a852417SPaul Durrant#include <syslog.h>
44030a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
44040a852417SPaul DurrantEOF
44050a852417SPaul Durrantif compile_prog "" "" ; then
44060a852417SPaul Durrant    posix_syslog=yes
44070a852417SPaul Durrantfi
44080a852417SPaul Durrant
44090a852417SPaul Durrant##########################################
441094a420b1SStefan Hajnoczi# check if trace backend exists
441194a420b1SStefan Hajnoczi
44125b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
441394a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
44145b808275SLluís Vilanova  error_exit "invalid trace backends" \
44155b808275SLluís Vilanova      "Please choose supported trace backends."
441694a420b1SStefan Hajnoczifi
441794a420b1SStefan Hajnoczi
44187e24e92aSStefan Hajnoczi##########################################
44197e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
44205b808275SLluís Vilanovaif have_backend "ust"; then
44217e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4422bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
44237e24e92aSStefan Hajnocziint main(void) { return 0; }
44247e24e92aSStefan HajnocziEOF
4425c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4426bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
442789138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
44287e24e92aSStefan Hajnoczi    else
4429c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4430bf15f63cSMohamad Gebai    fi
4431bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
443289138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4433bf15f63cSMohamad Gebai    else
4434bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4435bf15f63cSMohamad Gebai    fi
4436bf15f63cSMohamad Gebai
4437bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4438bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4439bf15f63cSMohamad Gebai  else
4440bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44417e24e92aSStefan Hajnoczi  fi
44427e24e92aSStefan Hajnoczifi
4443b3d08c02SDaniel P. Berrange
4444b3d08c02SDaniel P. Berrange##########################################
4445b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44465b808275SLluís Vilanovaif have_backend "dtrace"; then
4447b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
444876ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4449b3d08c02SDaniel P. Berrange  fi
4450c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4451c276b17dSDaniel P. Berrange  if has 'stap' ; then
4452c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4453c276b17dSDaniel P. Berrange  fi
4454b3d08c02SDaniel P. Berrangefi
4455b3d08c02SDaniel P. Berrange
44567e24e92aSStefan Hajnoczi##########################################
4457519175a2SAlex Barcelo# check and set a backend for coroutine
4458d0e2fce5SAneesh Kumar K.V
44597c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
446033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
446133c53c54SDaniel P. Berrange# specific one.
44627c2acc70SPeter Maydell
44637c2acc70SPeter Maydellucontext_works=no
4464d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4465d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4466d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4467cdf84806SPeter Maydell#ifdef __stub_makecontext
4468cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4469cdf84806SPeter Maydell#endif
447075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4471d0e2fce5SAneesh Kumar K.VEOF
4472d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
44737c2acc70SPeter Maydell    ucontext_works=yes
4474d0e2fce5SAneesh Kumar K.V  fi
4475519175a2SAlex Barcelofi
44767c2acc70SPeter Maydell
44777c2acc70SPeter Maydellif test "$coroutine" = ""; then
44787c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
44797c2acc70SPeter Maydell    coroutine=win32
44807c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
44817c2acc70SPeter Maydell    coroutine=ucontext
4482519175a2SAlex Barcelo  else
44837c2acc70SPeter Maydell    coroutine=sigaltstack
44847c2acc70SPeter Maydell  fi
44857c2acc70SPeter Maydellelse
44867c2acc70SPeter Maydell  case $coroutine in
44877c2acc70SPeter Maydell  windows)
44887c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
44897c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
44907c2acc70SPeter Maydell    fi
44917c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
44927c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
44937c2acc70SPeter Maydell    coroutine=win32
44947c2acc70SPeter Maydell    ;;
44957c2acc70SPeter Maydell  ucontext)
44967c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
44977c2acc70SPeter Maydell      feature_not_found "ucontext"
44987c2acc70SPeter Maydell    fi
44997c2acc70SPeter Maydell    ;;
450033c53c54SDaniel P. Berrange  sigaltstack)
45017c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
45027c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
45037c2acc70SPeter Maydell    fi
45047c2acc70SPeter Maydell    ;;
45057c2acc70SPeter Maydell  *)
450676ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
45077c2acc70SPeter Maydell    ;;
45087c2acc70SPeter Maydell  esac
4509d0e2fce5SAneesh Kumar K.Vfi
4510d0e2fce5SAneesh Kumar K.V
451170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
451270c60c08SStefan Hajnoczi  coroutine_pool=yes
451370c60c08SStefan Hajnoczifi
451470c60c08SStefan Hajnoczi
45157d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
45167d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
45177d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
45187d992e4dSPeter Lieven  fi
45197d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
45207d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
45217d992e4dSPeter Lieven    coroutine_pool=no
45227d992e4dSPeter Lieven  fi
45237d992e4dSPeter Lievenfi
45247d992e4dSPeter Lieven
45257d992e4dSPeter Lieven
4526d0e2fce5SAneesh Kumar K.V##########################################
4527d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4528d2042378SAneesh Kumar K.V
45294e1797f9SStefan Weilopen_by_handle_at=no
4530d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4531d2042378SAneesh Kumar K.V#include <fcntl.h>
4532acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4533acc55ba8SStefan Weil# error missing definition
4534acc55ba8SStefan Weil#else
453575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4536acc55ba8SStefan Weil#endif
4537d2042378SAneesh Kumar K.VEOF
4538d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4539d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4540d2042378SAneesh Kumar K.Vfi
4541d2042378SAneesh Kumar K.V
4542e06a765eSHarsh Prateek Bora########################################
4543e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4544e06a765eSHarsh Prateek Bora
4545e06a765eSHarsh Prateek Boralinux_magic_h=no
4546e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4547e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4548e06a765eSHarsh Prateek Boraint main(void) {
454975cafad7SStefan Weil  return 0;
4550e06a765eSHarsh Prateek Bora}
4551e06a765eSHarsh Prateek BoraEOF
4552e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4553e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4554e06a765eSHarsh Prateek Borafi
4555e06a765eSHarsh Prateek Bora
45568ab1bf12SLuiz Capitulino########################################
4557c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4558c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4559c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4560c95e3080SKevin Wolf# only a warning.
4561c95e3080SKevin Wolf#
4562c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4563c95e3080SKevin Wolf# the build doesn't fail anyway.
4564c95e3080SKevin Wolf
456506d71fa1SPeter Maydellpragma_disable_unused_but_set=no
456606d71fa1SPeter Maydellcat > $TMPC << EOF
4567e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
456806d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4569c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4570e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4571c95e3080SKevin Wolf
457206d71fa1SPeter Maydellint main(void) {
457306d71fa1SPeter Maydell    return 0;
457406d71fa1SPeter Maydell}
457506d71fa1SPeter MaydellEOF
457606d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4577cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4578c95e3080SKevin Wolfelse
4579c95e3080SKevin Wolf    werror=no
458006d71fa1SPeter Maydellfi
458106d71fa1SPeter Maydell
458206d71fa1SPeter Maydell########################################
4583541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
45843f4349dcSKevin Wolf
45853f4349dcSKevin Wolfvalgrind_h=no
45863f4349dcSKevin Wolfcat > $TMPC << EOF
45873f4349dcSKevin Wolf#include <valgrind/valgrind.h>
45883f4349dcSKevin Wolfint main(void) {
45893f4349dcSKevin Wolf  return 0;
45903f4349dcSKevin Wolf}
45913f4349dcSKevin WolfEOF
45923f4349dcSKevin Wolfif compile_prog "" "" ; then
45933f4349dcSKevin Wolf    valgrind_h=yes
45943f4349dcSKevin Wolffi
45953f4349dcSKevin Wolf
45963f4349dcSKevin Wolf########################################
45978ab1bf12SLuiz Capitulino# check if environ is declared
45988ab1bf12SLuiz Capitulino
45998ab1bf12SLuiz Capitulinohas_environ=no
46008ab1bf12SLuiz Capitulinocat > $TMPC << EOF
46018ab1bf12SLuiz Capitulino#include <unistd.h>
46028ab1bf12SLuiz Capitulinoint main(void) {
4603c075a723SBlue Swirl    environ = 0;
46048ab1bf12SLuiz Capitulino    return 0;
46058ab1bf12SLuiz Capitulino}
46068ab1bf12SLuiz CapitulinoEOF
46078ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
46088ab1bf12SLuiz Capitulino    has_environ=yes
46098ab1bf12SLuiz Capitulinofi
46108ab1bf12SLuiz Capitulino
461176a347e1SRichard Henderson########################################
461276a347e1SRichard Henderson# check if cpuid.h is usable.
461376a347e1SRichard Henderson
461476a347e1SRichard Hendersoncat > $TMPC << EOF
461576a347e1SRichard Henderson#include <cpuid.h>
461676a347e1SRichard Hendersonint main(void) {
4617774d566cSPeter Maydell    unsigned a, b, c, d;
4618774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4619774d566cSPeter Maydell
4620774d566cSPeter Maydell    if (max >= 1) {
4621774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4622774d566cSPeter Maydell    }
4623774d566cSPeter Maydell
4624774d566cSPeter Maydell    if (max >= 7) {
4625774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4626774d566cSPeter Maydell    }
4627774d566cSPeter Maydell
462876a347e1SRichard Henderson    return 0;
462976a347e1SRichard Henderson}
463076a347e1SRichard HendersonEOF
463176a347e1SRichard Hendersonif compile_prog "" "" ; then
463276a347e1SRichard Henderson    cpuid_h=yes
463376a347e1SRichard Hendersonfi
463476a347e1SRichard Henderson
46355dd89908SRichard Henderson##########################################
46365dd89908SRichard Henderson# avx2 optimization requirement check
46375dd89908SRichard Henderson#
46385dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
46395dd89908SRichard Henderson# since we won't be able to select the new routines.
46405dd89908SRichard Henderson
46415dd89908SRichard Hendersonif test $cpuid_h = yes; then
46425dd89908SRichard Henderson  cat > $TMPC << EOF
46435dd89908SRichard Henderson#pragma GCC push_options
46445dd89908SRichard Henderson#pragma GCC target("avx2")
46455dd89908SRichard Henderson#include <cpuid.h>
46465dd89908SRichard Henderson#include <immintrin.h>
46475dd89908SRichard Hendersonstatic int bar(void *a) {
46485dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
46495dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
46505dd89908SRichard Henderson}
46515dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
46525dd89908SRichard HendersonEOF
46535dd89908SRichard Henderson  if compile_object "" ; then
46545dd89908SRichard Henderson    avx2_opt="yes"
46555dd89908SRichard Henderson  fi
46565dd89908SRichard Hendersonfi
46575dd89908SRichard Henderson
4658f540166bSRichard Henderson########################################
4659f540166bSRichard Henderson# check if __[u]int128_t is usable.
4660f540166bSRichard Henderson
4661f540166bSRichard Hendersonint128=no
4662f540166bSRichard Hendersoncat > $TMPC << EOF
4663a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4664a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4665a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4666a00f66abSStefan Weil# endif
4667a00f66abSStefan Weil#endif
4668f540166bSRichard Henderson__int128_t a;
4669f540166bSRichard Henderson__uint128_t b;
4670f540166bSRichard Hendersonint main (void) {
4671f540166bSRichard Henderson  a = a + b;
4672f540166bSRichard Henderson  b = a * b;
4673464e3671SPeter Maydell  a = a * a;
4674f540166bSRichard Henderson  return 0;
4675f540166bSRichard Henderson}
4676f540166bSRichard HendersonEOF
4677f540166bSRichard Hendersonif compile_prog "" "" ; then
4678f540166bSRichard Henderson    int128=yes
4679f540166bSRichard Hendersonfi
468076a347e1SRichard Henderson
46817ebee43eSRichard Henderson#########################################
46827ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
46837ebee43eSRichard Henderson
46847ebee43eSRichard Hendersonatomic128=no
46857ebee43eSRichard Hendersonif test "$int128" = "yes"; then
46867ebee43eSRichard Henderson  cat > $TMPC << EOF
46877ebee43eSRichard Hendersonint main(void)
46887ebee43eSRichard Henderson{
46897ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
46907ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
46917ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
46927ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
46937ebee43eSRichard Henderson  return 0;
46947ebee43eSRichard Henderson}
46957ebee43eSRichard HendersonEOF
46967ebee43eSRichard Henderson  if compile_prog "" "" ; then
46977ebee43eSRichard Henderson    atomic128=yes
46987ebee43eSRichard Henderson  fi
46997ebee43eSRichard Hendersonfi
47007ebee43eSRichard Henderson
4701df79b996SRichard Henderson#########################################
4702df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4703df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4704df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4705df79b996SRichard Henderson
4706df79b996SRichard Hendersoncat > $TMPC << EOF
4707df79b996SRichard Henderson#include <stdint.h>
4708df79b996SRichard Hendersonint main(void)
4709df79b996SRichard Henderson{
4710df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4711df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4712df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4713df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4714df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4715df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4716df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4717df79b996SRichard Henderson#else
4718df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4719df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4720df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4721df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4722df79b996SRichard Henderson#endif
4723df79b996SRichard Henderson  return 0;
4724df79b996SRichard Henderson}
4725df79b996SRichard HendersonEOF
4726df79b996SRichard Hendersonif compile_prog "" "" ; then
4727df79b996SRichard Henderson  atomic64=yes
4728df79b996SRichard Hendersonfi
4729df79b996SRichard Henderson
47301e6e9acaSRichard Henderson########################################
47311e6e9acaSRichard Henderson# check if getauxval is available.
47321e6e9acaSRichard Henderson
47331e6e9acaSRichard Hendersongetauxval=no
47341e6e9acaSRichard Hendersoncat > $TMPC << EOF
47351e6e9acaSRichard Henderson#include <sys/auxv.h>
47361e6e9acaSRichard Hendersonint main(void) {
47371e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
47381e6e9acaSRichard Henderson}
47391e6e9acaSRichard HendersonEOF
47401e6e9acaSRichard Hendersonif compile_prog "" "" ; then
47411e6e9acaSRichard Henderson    getauxval=yes
47421e6e9acaSRichard Hendersonfi
47431e6e9acaSRichard Henderson
4744fd0e6053SJohn Snow########################################
4745fd0e6053SJohn Snow# check if ccache is interfering with
4746fd0e6053SJohn Snow# semantic analysis of macros
4747fd0e6053SJohn Snow
47485e4dfd3dSJohn Snowunset CCACHE_CPP2
4749fd0e6053SJohn Snowccache_cpp2=no
4750fd0e6053SJohn Snowcat > $TMPC << EOF
4751fd0e6053SJohn Snowstatic const int Z = 1;
4752fd0e6053SJohn Snow#define fn() ({ Z; })
4753fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4754fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4755fd0e6053SJohn Snow#define ID(X) (X)
4756fd0e6053SJohn Snowint main(int argc, char *argv[])
4757fd0e6053SJohn Snow{
4758fd0e6053SJohn Snow    int x = 0, y = 0;
4759fd0e6053SJohn Snow    x = ID(x);
4760fd0e6053SJohn Snow    x = fn();
4761fd0e6053SJohn Snow    fn();
4762fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4763fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4764fd0e6053SJohn Snow    return 0;
4765fd0e6053SJohn Snow}
4766fd0e6053SJohn SnowEOF
4767fd0e6053SJohn Snow
4768fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4769fd0e6053SJohn Snow    ccache_cpp2=yes
4770fd0e6053SJohn Snowfi
4771fd0e6053SJohn Snow
4772b553a042SJohn Snow#################################################
4773b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4774b553a042SJohn Snow
4775b553a042SJohn Snowif test "$fortify_source" != "no"; then
4776b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4777b553a042SJohn Snow    fortify_source="no";
4778e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4779cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4780b553a042SJohn Snow    fortify_source="no";
4781b553a042SJohn Snow  else
4782b553a042SJohn Snow    fortify_source="yes"
4783b553a042SJohn Snow  fi
4784b553a042SJohn Snowfi
4785b553a042SJohn Snow
4786d2042378SAneesh Kumar K.V##########################################
4787277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4788277abf15SJan Vesely
4789277abf15SJan Veselyhave_fsxattr=no
4790277abf15SJan Veselycat > $TMPC << EOF
4791277abf15SJan Vesely#include <linux/fs.h>
4792277abf15SJan Veselystruct fsxattr foo;
4793277abf15SJan Veselyint main(void) {
4794277abf15SJan Vesely  return 0;
4795277abf15SJan Vesely}
4796277abf15SJan VeselyEOF
4797277abf15SJan Veselyif compile_prog "" "" ; then
4798277abf15SJan Vesely    have_fsxattr=yes
4799277abf15SJan Veselyfi
4800277abf15SJan Vesely
4801b66e10e4SPeter Maydell##########################################
4802b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4803575b22b1SLaurent Vivierhave_rtnetlink=no
4804575b22b1SLaurent Viviercat > $TMPC << EOF
4805575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4806575b22b1SLaurent Vivierint main(void) {
4807575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4808575b22b1SLaurent Vivier}
4809575b22b1SLaurent VivierEOF
4810575b22b1SLaurent Vivierif compile_prog "" "" ; then
4811575b22b1SLaurent Vivier    have_rtnetlink=yes
4812575b22b1SLaurent Vivierfi
4813575b22b1SLaurent Vivier
48146a02c806SStefan Hajnoczi##########################################
48156a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
48166a02c806SStefan Hajnoczihave_af_vsock=no
48176a02c806SStefan Hajnoczicat > $TMPC << EOF
48186a02c806SStefan Hajnoczi#include <errno.h>
48196a02c806SStefan Hajnoczi#include <sys/types.h>
48206a02c806SStefan Hajnoczi#include <sys/socket.h>
48216a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
48226a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
48236a02c806SStefan Hajnoczi#endif
48246a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
48256a02c806SStefan Hajnocziint main(void) {
48266a02c806SStefan Hajnoczi    int sock, ret;
48276a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
48286a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
48296a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
48306a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
48316a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
48326a02c806SStefan Hajnoczi        return 0;
48336a02c806SStefan Hajnoczi    }
48346a02c806SStefan Hajnoczi    return -1;
48356a02c806SStefan Hajnoczi}
48366a02c806SStefan HajnocziEOF
48376a02c806SStefan Hajnocziif compile_prog "" "" ; then
48386a02c806SStefan Hajnoczi    have_af_vsock=yes
48396a02c806SStefan Hajnoczifi
48406a02c806SStefan Hajnoczi
4841f0d92b56SLongpeng(Mike)##########################################
4842f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
4843f0d92b56SLongpeng(Mike)hava_afalg=no
4844f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
4845f0d92b56SLongpeng(Mike)#include <errno.h>
4846f0d92b56SLongpeng(Mike)#include <sys/types.h>
4847f0d92b56SLongpeng(Mike)#include <sys/socket.h>
4848f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
4849f0d92b56SLongpeng(Mike)int main(void) {
4850f0d92b56SLongpeng(Mike)    int sock;
4851f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
4852f0d92b56SLongpeng(Mike)    return sock;
4853f0d92b56SLongpeng(Mike)}
4854f0d92b56SLongpeng(Mike)EOF
4855f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4856f0d92b56SLongpeng(Mike)    have_afalg=yes
4857f0d92b56SLongpeng(Mike)fi
4858f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4859f0d92b56SLongpeng(Mike)then
4860f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4861f0d92b56SLongpeng(Mike)    then
4862f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4863f0d92b56SLongpeng(Mike)    fi
4864f0d92b56SLongpeng(Mike)fi
4865f0d92b56SLongpeng(Mike)
4866f0d92b56SLongpeng(Mike)
48676969ec6cSJames Clarke#################################################
48686969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
48696969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
48706969ec6cSJames Clarke# given. It does no harm to give it on other
48716969ec6cSJames Clarke# platforms too.
48726969ec6cSJames Clarke
48736969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
48746969ec6cSJames Clarke#       contains -Wmissing-prototypes
48756969ec6cSJames Clarkecat > $TMPC << EOF
48766969ec6cSJames Clarkeextern int foo(void);
48776969ec6cSJames Clarkeint foo(void) { return 0; }
48786969ec6cSJames ClarkeEOF
48796969ec6cSJames Clarkeif ! compile_object ""; then
48806969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
48816969ec6cSJames Clarkefi
48827ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
48837ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
48847ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
48857ecf44a5SPaolo Bonzini    break
48867ecf44a5SPaolo Bonzini  fi
48877ecf44a5SPaolo Bonzinidone
48887ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
48897ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
48906969ec6cSJames Clarkefi
48916969ec6cSJames Clarke
4892277abf15SJan Vesely##########################################
48934d04351fSChristopher Covington# check for sysmacros.h
48944d04351fSChristopher Covington
48954d04351fSChristopher Covingtonhave_sysmacros=no
48964d04351fSChristopher Covingtoncat > $TMPC << EOF
48974d04351fSChristopher Covington#include <sys/sysmacros.h>
48984d04351fSChristopher Covingtonint main(void) {
48994d04351fSChristopher Covington    return makedev(0, 0);
49004d04351fSChristopher Covington}
49014d04351fSChristopher CovingtonEOF
49024d04351fSChristopher Covingtonif compile_prog "" "" ; then
49034d04351fSChristopher Covington    have_sysmacros=yes
49044d04351fSChristopher Covingtonfi
49054d04351fSChristopher Covington
49064d04351fSChristopher Covington##########################################
4907da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
4908da92c3ffSAshish Mittal# Check if libvxhs is installed
4909da92c3ffSAshish Mittal
4910da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
4911da92c3ffSAshish Mittal  cat > $TMPC <<EOF
4912da92c3ffSAshish Mittal#include <stdint.h>
4913da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
4914da92c3ffSAshish Mittal
4915da92c3ffSAshish Mittalvoid *vxhs_callback;
4916da92c3ffSAshish Mittal
4917da92c3ffSAshish Mittalint main(void) {
4918da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
4919da92c3ffSAshish Mittal    return 0;
4920da92c3ffSAshish Mittal}
4921da92c3ffSAshish MittalEOF
4922da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
4923da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
4924da92c3ffSAshish Mittal    vxhs=yes
4925da92c3ffSAshish Mittal  else
4926da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
4927da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
4928da92c3ffSAshish Mittal    fi
4929da92c3ffSAshish Mittal    vxhs=no
4930da92c3ffSAshish Mittal  fi
4931da92c3ffSAshish Mittalfi
4932da92c3ffSAshish Mittal
4933da92c3ffSAshish Mittal##########################################
493449e00a18SAndreas Grapentin# check for _Static_assert()
493549e00a18SAndreas Grapentin
493649e00a18SAndreas Grapentinhave_static_assert=no
493749e00a18SAndreas Grapentincat > $TMPC << EOF
493849e00a18SAndreas Grapentin_Static_assert(1, "success");
493949e00a18SAndreas Grapentinint main(void) {
494049e00a18SAndreas Grapentin    return 0;
494149e00a18SAndreas Grapentin}
494249e00a18SAndreas GrapentinEOF
494349e00a18SAndreas Grapentinif compile_prog "" "" ; then
494449e00a18SAndreas Grapentin    have_static_assert=yes
494549e00a18SAndreas Grapentinfi
494649e00a18SAndreas Grapentin
494749e00a18SAndreas Grapentin##########################################
4948e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
4949e674605fSTomáš Golembiovský
4950e674605fSTomáš Golembiovskýhave_utmpx=no
4951e674605fSTomáš Golembiovskýcat > $TMPC << EOF
4952e674605fSTomáš Golembiovský#include <utmpx.h>
4953e674605fSTomáš Golembiovskýstruct utmpx user_info;
4954e674605fSTomáš Golembiovskýint main(void) {
4955e674605fSTomáš Golembiovský    return 0;
4956e674605fSTomáš Golembiovský}
4957e674605fSTomáš GolembiovskýEOF
4958e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
4959e674605fSTomáš Golembiovský    have_utmpx=yes
4960e674605fSTomáš Golembiovskýfi
4961e674605fSTomáš Golembiovský
4962e674605fSTomáš Golembiovský##########################################
4963e86ecd4bSJuan Quintela# End of CC checks
4964e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4965e86ecd4bSJuan Quintela
49661d728c39SBlue Swirlif test "$gcov" = "yes" ; then
49671d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
49681d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4969b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4970e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4971ce278618SPeter Maydellelif test "$debug" = "no"; then
4972ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
4973e86ecd4bSJuan Quintelafi
4974a316e378SJuan Quintela
49756542aa9cSPeter Lieven##########################################
49766542aa9cSPeter Lieven# Do we have libnfs
49776542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
4978b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
49796542aa9cSPeter Lieven    libnfs="yes"
49806542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
49816542aa9cSPeter Lieven  else
49826542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
49838efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
49846542aa9cSPeter Lieven    fi
49856542aa9cSPeter Lieven    libnfs="no"
49866542aa9cSPeter Lieven  fi
49876542aa9cSPeter Lievenfi
49881d728c39SBlue Swirl
49896ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
49906ca026cbSPeter Maydellif test "$werror" = "yes"; then
49916ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
49926ca026cbSPeter Maydellfi
49936ca026cbSPeter Maydell
4994e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
4995e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
49961156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
4997e86ecd4bSJuan Quintela    fi
4998e86ecd4bSJuan Quintelafi
4999e86ecd4bSJuan Quintela
500094dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
500194dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
500294dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
500394dd53c5SGerd Hoffmannelse
500494dd53c5SGerd Hoffmann    POD2MAN="pod2man"
500594dd53c5SGerd Hoffmannfi
500694dd53c5SGerd Hoffmann
5007952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5008952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5009952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
5010e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5011952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
5012952afb71SBlue Swirl        fi
5013952afb71SBlue Swirl    done
5014952afb71SBlue Swirlfi
5015952afb71SBlue Swirl
501610ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
5017e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
5018528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
5019834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
50205a67135aSbellard
5021e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5022e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5023e0580342SKamil Rytarowski  ivshmem=yes
5024e0580342SKamil Rytarowskifi
5025e0580342SKamil Rytarowski
50264b1c11fdSDaniel P. Berrangetools=""
50274b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
5028ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
50294b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
50304b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
5031b1449edbSKamil Rytarowski  fi
5032b1449edbSKamil Rytarowski  if [ "$ivshmem" = "yes" ]; then
5033a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
50344b1c11fdSDaniel P. Berrange  fi
50354b1c11fdSDaniel P. Berrangefi
50364b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5037983eef5aSMeador Inge  if test "$virtfs" != no ; then
5038be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
5039983eef5aSMeador Inge      virtfs=yes
504017bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5041983eef5aSMeador Inge    else
5042983eef5aSMeador Inge      if test "$virtfs" = yes; then
50433f3b5388SStefan Weil        error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
5044983eef5aSMeador Inge      fi
504517500370SAndreas Färber      virtfs=no
5046983eef5aSMeador Inge    fi
504717bff52bSM. Mohan Kumar  fi
5048d138cee9SMichael Rothfi
50499d6bc27bSMichael Roth
50509d6bc27bSMichael Roth# Probe for guest agent support/options
50519d6bc27bSMichael Roth
5052e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5053b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5054fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5055e8ef31a3SMichael Tokarev      guest_agent=yes
5056e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5057e8ef31a3SMichael Tokarev      guest_agent=no
5058e8ef31a3SMichael Tokarev  else
5059e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5060ca35f780SPaolo Bonzini  fi
50614b1c11fdSDaniel P. Berrangefi
5062ca35f780SPaolo Bonzini
50639d6bc27bSMichael Roth# Guest agent Window MSI  package
50649d6bc27bSMichael Roth
50659d6bc27bSMichael Rothif test "$guest_agent" != yes; then
50669d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
50679d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
50689d6bc27bSMichael Roth  fi
50699d6bc27bSMichael Roth  guest_agent_msi=no
50709d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
50719d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50729d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
50739d6bc27bSMichael Roth  fi
50749d6bc27bSMichael Roth  guest_agent_msi=no
50759d6bc27bSMichael Rothelif ! has wixl; then
50769d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50779d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
50789d6bc27bSMichael Roth  fi
50799d6bc27bSMichael Roth  guest_agent_msi=no
50801a34904eSMichael Rothelse
50811a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
50821a34904eSMichael Roth  # disabled explicitly
50831a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
50841a34904eSMichael Roth    guest_agent_msi=yes
50851a34904eSMichael Roth  fi
50869d6bc27bSMichael Rothfi
50879d6bc27bSMichael Roth
50881a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
50899d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
50909d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
50919d6bc27bSMichael Roth  fi
50929d6bc27bSMichael Roth
50939d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
50949d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
50959d6bc27bSMichael Roth  fi
50969d6bc27bSMichael Roth
50979d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
50989d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
50999d6bc27bSMichael Roth  fi
51009d6bc27bSMichael Roth
51019d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
510289138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
51039d6bc27bSMichael Roth  fi
51049d6bc27bSMichael Roth
510589138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
51069d6bc27bSMichael Roth
51079d6bc27bSMichael Roth  case "$cpu" in
51089d6bc27bSMichael Roth  x86_64)
51099d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
51109d6bc27bSMichael Roth    ;;
51119d6bc27bSMichael Roth  i386)
51129d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
51139d6bc27bSMichael Roth    ;;
51149d6bc27bSMichael Roth  *)
51159d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
51169d6bc27bSMichael Roth    ;;
51179d6bc27bSMichael Roth  esac
51189d6bc27bSMichael Rothfi
51199d6bc27bSMichael Roth
5120ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5121ca35f780SPaolo Bonziniroms=
5122ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5123ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5124ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5125e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5126e57218b6SPeter Maydell    # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5127e57218b6SPeter Maydell    # variant; and Windows uses i386pe.
5128e57218b6SPeter Maydell    for emu in elf_i386 elf_i386_fbsd i386pe; do
5129e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5130e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5131ca35f780SPaolo Bonzini            roms="optionrom"
5132e57218b6SPeter Maydell            break
5133e57218b6SPeter Maydell        fi
5134e57218b6SPeter Maydell    done
5135ca35f780SPaolo Bonzinifi
5136d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
513739ac8455SDavid Gibson  roms="$roms spapr-rtas"
513839ac8455SDavid Gibsonfi
5139ca35f780SPaolo Bonzini
51409933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
51419933c305SChristian Borntraeger  roms="$roms s390-ccw"
51429933c305SChristian Borntraegerfi
51439933c305SChristian Borntraeger
5144964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
514592fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5146964c6fa1SRichard Henderson  textseg_addr=
5147964c6fa1SRichard Henderson  case "$cpu" in
5148479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5149479eb121SRichard Henderson      # ??? Rationale for choosing this address
5150964c6fa1SRichard Henderson      textseg_addr=0x60000000
5151964c6fa1SRichard Henderson      ;;
5152964c6fa1SRichard Henderson    mips)
5153479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5154479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5155479eb121SRichard Henderson      textseg_addr=0x60000000
5156964c6fa1SRichard Henderson      ;;
5157964c6fa1SRichard Henderson  esac
5158964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5159964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5160964c6fa1SRichard Henderson    int main(void) { return 0; }
5161964c6fa1SRichard HendersonEOF
5162964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5163964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5164964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5165964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5166964c6fa1SRichard Henderson      # at least.
516792fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
516892fe2ba8SPeter Maydell        error_exit \
516992fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
517092fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
517192fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
517292fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
517392fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
517492fe2ba8SPeter Maydell            "--disable-user option to configure."
517592fe2ba8SPeter Maydell      fi
517692fe2ba8SPeter Maydell
5177964c6fa1SRichard Henderson      $ld --verbose | sed \
5178964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5179964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5180964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5181964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5182964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5183964c6fa1SRichard Henderson    fi
5184964c6fa1SRichard Henderson  fi
5185964c6fa1SRichard Hendersonfi
5186964c6fa1SRichard Henderson
518711cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
518811cde1c8SBruno 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.
518911cde1c8SBruno Dominguezif has $cxx; then
519011cde1c8SBruno Dominguez    cat > $TMPC <<EOF
519111cde1c8SBruno Dominguezint c_function(void);
519211cde1c8SBruno Dominguezint main(void) { return c_function(); }
519311cde1c8SBruno DominguezEOF
519411cde1c8SBruno Dominguez
519511cde1c8SBruno Dominguez    compile_object
519611cde1c8SBruno Dominguez
519711cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
519811cde1c8SBruno Dominguezextern "C" {
519911cde1c8SBruno Dominguez   int c_function(void);
520011cde1c8SBruno Dominguez}
520111cde1c8SBruno Dominguezint c_function(void) { return 42; }
520211cde1c8SBruno DominguezEOF
520311cde1c8SBruno Dominguez
520411cde1c8SBruno Dominguez    update_cxxflags
520511cde1c8SBruno Dominguez
520611cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
520711cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
520811cde1c8SBruno Dominguez        :
520911cde1c8SBruno Dominguez    else
521011cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
521111cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
521211cde1c8SBruno Dominguez        cxx=
521311cde1c8SBruno Dominguez    fi
521411cde1c8SBruno Dominguezelse
521511cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
521611cde1c8SBruno Dominguez    cxx=
521711cde1c8SBruno Dominguezfi
521811cde1c8SBruno Dominguez
521902d34f62SCole Robinsonecho_version() {
522002d34f62SCole Robinson    if test "$1" = "yes" ; then
522102d34f62SCole Robinson        echo "($2)"
522202d34f62SCole Robinson    fi
522302d34f62SCole Robinson}
522402d34f62SCole Robinson
522550e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
522650e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
522750e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
52285ca9388aSGerd Hoffmann
52297d13299dSbellardecho "Install prefix    $prefix"
523089138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
523189138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
523289138857SStefan Weilecho "library directory $(eval echo $libdir)"
523389138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
523489138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
523589138857SStefan Weilecho "include directory $(eval echo $includedir)"
523689138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
523711d9f695Sbellardif test "$mingw32" = "no" ; then
523889138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
523989138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
524043ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
52415a699bbbSLaszlo Ersekelse
52425a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5243d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
524411d9f695Sbellardfi
52455a67135aSbellardecho "Source path       $source_path"
52467d13299dSbellardecho "C compiler        $cc"
524783469015Sbellardecho "Host C compiler   $host_cc"
524883f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
52493c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
525045d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
52510c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5252a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
52530c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
52547d13299dSbellardecho "make              $make"
52556a882643Spbrookecho "install           $install"
5256c886edfbSBlue Swirlecho "python            $python"
5257e2d8830eSBradif test "$slirp" = "yes" ; then
5258e2d8830eSBrad    echo "smbd              $smbd"
5259e2d8830eSBradfi
526017969268SFam Zhengecho "module support    $modules"
5261a98fd896Sbellardecho "host CPU          $cpu"
5262de83cd02Sbellardecho "host big endian   $bigendian"
526397a847bcSbellardecho "target list       $target_list"
52647d13299dSbellardecho "gprof enabled     $gprof"
526503b4fe7dSaliguoriecho "sparse enabled    $sparse"
52661625af87Saliguoriecho "strip binaries    $strip_opt"
526705c2a3e7Sbellardecho "profiler          $profiler"
526843ce4dfeSbellardecho "static build      $static"
52695b0753e0Sbellardif test "$darwin" = "yes" ; then
52705b0753e0Sbellard    echo "Cocoa support     $cocoa"
52715b0753e0Sbellardfi
527289138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
527389138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5274925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
527589138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5276a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5277ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5278b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
527991bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
528037788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
528189138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5282fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
52839a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
52844d3b6f6eSbalrogecho "curses support    $curses"
52859d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5286769ce76dSAlexander Grafecho "curl support      $curl"
528767b915a5Sbellardecho "mingw32 support   $mingw32"
52880c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5289b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5290b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5291983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5292821601eaSJes Sorensenecho "VNC support       $vnc"
5293821601eaSJes Sorensenif test "$vnc" = "yes" ; then
52942f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
52952f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5296efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5297821601eaSJes Sorensenfi
52983142255cSblueswir1if test -n "$sparc_cpu"; then
52993142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
53003142255cSblueswir1fi
5301e37630caSaliguoriecho "xen support       $xen"
53023996e85cSPaul Durrantif test "$xen" = "yes" ; then
53033996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
530464a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
53053996e85cSPaul Durrantfi
53062e4d9fb1Saurel32echo "brlapi support    $brlapi"
5307a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5308a25dba17SJuan Quintelaecho "Documentation     $docs"
530940d6444eSAvi Kivityecho "PIE               $pie"
53108a16d273Sthsecho "vde support       $vde"
531158952137SVincenzo Maffioneecho "netmap support    $netmap"
53125c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5313758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
531477755340Sthsecho "Install blobs     $blobs"
5315b31a0277SJuan Quintelaecho "KVM support       $kvm"
5316b0cb0a66SVincent Palatinecho "HAX support       $hax"
5317b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5318b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5319b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
53209195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5321b3f6ea7eSPaolo Bonzinifi
5322b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5323f652e6afSaurel32echo "fdt support       $fdt"
5324ceb42de8Saliguoriecho "preadv support    $preadv"
53255f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5326e78815a5SAndreas Färberecho "madvise           $madvise"
5327e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
532847e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5329d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
53305e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5331fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
5332e6a74868SMarc-André Lureauecho "vhost-user support $vhost_user"
53335b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5334713572a7SMarc-André Lureauif have_backend "simple"; then
53359410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5336e00e36fbSStefan Weilfi
533789138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5338f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5339dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
53407b02f544SMarc-André Lureauecho "smartcard support $smartcard"
53412b2325ffSGerd Hoffmannecho "libusb            $libusb"
534269354a83SHans de Goedeecho "usb net redir     $usb_redir"
5343da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5344014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5345c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
53466542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5347d138cee9SMichael Rothecho "build guest agent $guest_agent"
5348d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
534950cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
53504c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5351f794573eSEduardo Otuboecho "seccomp support   $seccomp"
53527c2acc70SPeter Maydellecho "coroutine backend $coroutine"
535370c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
53547d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5355f0d92b56SLongpeng(Mike)echo "crypto afalg      $crypto_afalg"
5356eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
53571d728c39SBlue Swirlecho "gcov              $gcov_tool"
53581d728c39SBlue Swirlecho "gcov enabled      $gcov"
5359ab214c29SStefan Bergerecho "TPM support       $tpm"
53600a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
53613b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
53623556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5363ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5364607dacd0Sqiaonuohanecho "lzo support       $lzo"
5365607dacd0Sqiaonuohanecho "snappy support    $snappy"
53666b383c08SPeter Wuecho "bzip2 support     $bzip2"
5367a99d57bbSWanlong Gaoecho "NUMA host support $numa"
53682847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
53697b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
537099f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5371a6b1d4c0SChanglong Xieecho "replication support $replication"
5372da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
537367b915a5Sbellard
53741ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
537524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5376e8cd23deSbellardfi
537797a847bcSbellard
5378898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5379898be3e0SPeter Maydell    echo
5380898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5381898be3e0SPeter Maydell    echo
5382898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5383898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5384898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5385898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5386898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5387898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5388898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5389898be3e0SPeter Maydellfi
5390898be3e0SPeter Maydell
5391898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5392898be3e0SPeter Maydell    echo
5393898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5394898be3e0SPeter Maydell    echo
5395c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5396c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5397898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5398898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5399898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5400898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5401898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5402898be3e0SPeter Maydellfi
5403898be3e0SPeter Maydell
540498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
540597a847bcSbellard
5406dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5407dbd99ae3SStefan Weil
540898ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
540998ec69acSJuan Quintelaecho >> $config_host_mak
541098ec69acSJuan Quintela
5411e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
541299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
541399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
54143aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
54158bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
54160f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
541799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
541899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
541922d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
54209afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
54219afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5422e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
54235a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5424785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
54255a699bbbSLaszlo Ersekfi
5426f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5427f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
542811cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5429f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5430834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5431f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5432804edf29SJuan Quintela
543398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5434727e5283SPaolo Bonzini
5435f8393946Saurel32if test "$debug_tcg" = "yes" ; then
54362358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5437f8393946Saurel32fi
54381625af87Saliguoriif test "$strip_opt" = "yes" ; then
543952ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
54401625af87Saliguorifi
54417d13299dSbellardif test "$bigendian" = "yes" ; then
5442e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
544397a847bcSbellardfi
544467b915a5Sbellardif test "$mingw32" = "yes" ; then
544598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
544689138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
54479fe6de94SBlue Swirl  version_major=${rc_version%%.*}
54489fe6de94SBlue Swirl  rc_version=${rc_version#*.}
54499fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
54509fe6de94SBlue Swirl  rc_version=${rc_version#*.}
54519fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
54529fe6de94SBlue Swirl  version_micro=0
54539fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
54549fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5455d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5456d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5457f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5458d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5459d9840e25STomoki Sekiyama  fi
546050cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
546150cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
546250cbebb9SMichael Roth  fi
54631a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
54649dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
54659dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
54669dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
54679dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
54689dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
54699dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
54709dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
54719dacf32dSYossi Hindin  fi
5472210fa556Spbrookelse
547335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5474210fa556Spbrookfi
5475128ab2ffSblueswir1
5476dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5477dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5478dffcb71cSMark McLoughlinfi
5479dffcb71cSMark McLoughlin
548083fb7adfSbellardif test "$darwin" = "yes" ; then
548198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
548283fb7adfSbellardfi
5483b29fe3edSmalc
5484ec530c81Sbellardif test "$solaris" = "yes" ; then
548598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5486ec530c81Sbellardfi
5487179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5488179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5489179cf400SAndreas Färberfi
549097a847bcSbellardif test "$static" = "yes" ; then
549198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
549297a847bcSbellardfi
54931ba16968SStefan Weilif test "$profiler" = "yes" ; then
54942358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
549505c2a3e7Sbellardfi
5496c20709aaSbellardif test "$slirp" = "yes" ; then
549798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5498e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5499c20709aaSbellardfi
55008a16d273Sthsif test "$vde" = "yes" ; then
550198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
55028a16d273Sthsfi
550358952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
550458952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
550558952137SVincenzo Maffionefi
5506015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5507015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5508015a33bdSGongleifi
550947e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
551047e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
551147e98658SCorey Bryantfi
55122358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
55130c58ac1cSmalcfor drv in $audio_drv_list; do
551489138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
551598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
55160c58ac1cSmalcdone
551767f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
551867f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
551967f86e8eSJuan Quintelafi
5520d5631638Smalcif test "$audio_win_int" = "yes" ; then
5521d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5522d5631638Smalcfi
5523b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5524b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5525821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5526821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5527821601eaSJes Sorensenfi
55282f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
552998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
55302f9606b3Saliguorifi
5531821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
55322f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
55332f6f5c7aSCorentin Charyfi
5534821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5535efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5536efe556adSCorentin Charyfi
553776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
55382358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
553976655d6dSaliguorifi
5540dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5541dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5542dce512deSChristoph Hellwigfi
554389138857SStefan Weilqemu_version=$(head $source_path/VERSION)
554498ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
55452358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
554698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
554798ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5548a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
554998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5550cc8ae6deSpbrookfi
555117969268SFam Zhengif test "$modules" = "yes"; then
5552e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5553e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
555489138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
555517969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
555617969268SFam Zhengfi
55571ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
555898ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5559a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
55608ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
556149ecc3faSbellardfi
556249ecc3faSbellardif test "$cocoa" = "yes" ; then
556398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
556449ecc3faSbellardfi
55654d3b6f6eSbalrogif test "$curses" = "yes" ; then
556698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5567ab4e5602SJan Kiszkafi
5568099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
55692358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5570099d6b0fSRiku Voipiofi
557140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
557240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
557340ff6d7eSKevin Wolffi
55743ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
55752358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
55763ce34dfbSvibisreenivasanfi
5577c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5578c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5579c2882b96SRiku Voipiofi
5580751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5581751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5582751bcc39SMarc-André Lureaufi
5583d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5584d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5585d0927938SUlrich Hechtfi
55863d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
55873d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
55883d4fa43eSKusanagi Kouichifi
5589b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5590b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5591b953f075SDenis V. Lunevfi
5592ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5593ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5594ed911435SKevin Wolffi
5595c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5596c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5597c727f47dSPeter Maydellfi
5598dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5599dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5600dace20dcSPeter Maydellfi
5601d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5602d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5603d0927938SUlrich Hechtfi
56044e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
56054e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
56064e0c6529SAlex Blighfi
5607cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5608cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5609cd758dd0SAlex Blighfi
56103b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
56113b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
56123b6edd16SPeter Maydellfi
56133b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
56143b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
56153b6edd16SPeter Maydellfi
5616a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5617a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5618a8fd1abaSPeter Maydellfi
561951834341SRiku Voipioif test "$timerfd" = "yes" ; then
562051834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
562151834341SRiku Voipiofi
56229af5c906SRiku Voipioif test "$setns" = "yes" ; then
56239af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
56249af5c906SRiku Voipiofi
562538860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
562638860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
562738860a03SAleksandar Markovicfi
56285a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
56295a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
56305a03cd00SAleksandar Markovicfi
56313b3f24adSaurel32if test "$inotify" = "yes" ; then
56322358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
56333b3f24adSaurel32fi
5634c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5635c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5636c05c7a73SRiku Voipiofi
56376ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
56386ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
56396ae9a1f4SJuan Quintelafi
56406ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
56416ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
56426ae9a1f4SJuan Quintelafi
5643769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5644d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5645b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
56466ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5647769ce76dSAlexander Graffi
56482e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
564998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
56502e4d9fb1Saurel32fi
5651fb599c9aSbalrogif test "$bluez" = "yes" ; then
565298ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5653ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5654fb599c9aSbalrogfi
5655d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
56569d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
56579d41401bSMichael S. Tsirkinfi
5658a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5659a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5660a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5661a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5662014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5663925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5664925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5665925a0400SGerd Hoffmann  fi
5666bbbf9bfbSStefan Weilfi
5667a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5668ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5669ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5670ddbb0d09SDaniel P. Berrangefi
5671b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5672b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5673b917da4cSDaniel P. Berrangefi
567491bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
567591bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
56761f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
56771f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
56781f923c70SLongpeng(Mike)  fi
567937788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
568037788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
568137788f25SDaniel P. Berrange  fi
568262893b67SDaniel P. Berrangefi
568391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
568491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5685becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5686fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5687fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5688fff2f982SDaniel P. Berrange  fi
5689ed754746SDaniel P. Berrangefi
56909a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
56919a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
56929a2fd434SDaniel P. Berrangefi
5693559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5694559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5695559607eaSDaniel P. Berrangefi
56966b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
56976b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
56986b39b063SEric Blakefi
5699277abf15SJan Vesely
5700277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5701277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5702277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5703277abf15SJan Vesely# if this macro is set.
5704277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5705277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5706277abf15SJan Veselyfi
5707bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5708bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5709a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5710a4ccabcfSAnthony Liguorifi
57119d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
57129d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
57139d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
57149d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
57159d9e1521SGerd Hoffmannfi
5716e37630caSaliguoriif test "$xen" = "yes" ; then
57176dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5718d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
571964a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
572064a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
572164a7ad6fSIan Campbell  fi
5722e37630caSaliguorifi
57235c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
57245c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
57255c6c3a6cSChristoph Hellwigfi
5726758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5727758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5728758e8e38SVenkateswararao Jujjuri (JV)fi
57294f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
57304f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
57314f26f2b6SAvi Kivityfi
5732983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5733758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5734758e8e38SVenkateswararao Jujjuri (JV)fi
57355e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
57365e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
57375e9be92dSNicholas Bellingerfi
5738e6a74868SMarc-André Lureauif test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
573903ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
574003ce5744SNikolay Nikolaevfi
5741fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5742fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5743fc0b9b0eSStefan Hajnoczifi
5744e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5745e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5746e6a74868SMarc-André Lureaufi
574777755340Sthsif test "$blobs" = "yes" ; then
574898ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
574977755340Sthsfi
5750bf9298b9Saliguoriif test "$iovec" = "yes" ; then
57512358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5752bf9298b9Saliguorifi
5753ceb42de8Saliguoriif test "$preadv" = "yes" ; then
57542358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5755ceb42de8Saliguorifi
5756f652e6afSaurel32if test "$fdt" = "yes" ; then
57573f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5758f652e6afSaurel32fi
5759dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5760dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5761dcc38d1cSMarcelo Tosattifi
5762b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
5763b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
57649195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
57659195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
57669195b2c2SStefan Weil  fi
5767b3f6ea7eSPaolo Bonzinifi
57685f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
57695f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
57705f6b9e8fSBlue Swirlfi
5771e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5772e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5773e78815a5SAndreas Färberfi
5774e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5775e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5776e78815a5SAndreas Färberfi
577797a847bcSbellard
5778cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5779cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5780cd4ec0b4SGerd Hoffmannfi
5781cd4ec0b4SGerd Hoffmann
57827b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
57837b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5784111a38b0SRobert Relyeafi
5785111a38b0SRobert Relyea
57862b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
57872b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
57882b2325ffSGerd Hoffmannfi
57892b2325ffSGerd Hoffmann
579069354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
579169354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
579269354a83SHans de Goedefi
579369354a83SHans de Goede
5794da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5795da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5796da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5797014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5798014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5799014cb152SGerd Hoffmann  fi
580020ff075bSMichael Wallefi
580120ff075bSMichael Walle
580299f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
580399f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
580499f2dbd3SLiang Lifi
580599f2dbd3SLiang Li
5806607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5807607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5808607dacd0Sqiaonuohanfi
5809607dacd0Sqiaonuohan
5810607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5811607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5812607dacd0Sqiaonuohanfi
5813607dacd0Sqiaonuohan
58146b383c08SPeter Wuif test "$bzip2" = "yes" ; then
58156b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
58166b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
58176b383c08SPeter Wufi
58186b383c08SPeter Wu
5819c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5820d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
58216ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
58226ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5823c589b249SRonnie Sahlbergfi
5824c589b249SRonnie Sahlberg
58256542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
58264be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
58274be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
58286542aa9cSPeter Lievenfi
58296542aa9cSPeter Lieven
5830f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5831f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5832f794573eSEduardo Otubofi
5833f794573eSEduardo Otubo
583483fb7adfSbellard# XXX: suppress that
58357d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
58362358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
58377d3505c5Sbellardfi
58387d3505c5Sbellard
58394d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
58404d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
58414d9310f4SDaniel P. Berrangefi
58423556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
58433556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
58443556c233SPaolo Bonzinifi
5845f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5846d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
58476ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
58486ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5849f27aaf4bSChristian Brunnerfi
585020ff6c80SAnthony Liguori
58517c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
585270c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
585370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
585470c60c08SStefan Hajnoczielse
585570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
585670c60c08SStefan Hajnoczifi
5857d0e2fce5SAneesh Kumar K.V
58587d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
58597d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
58607d992e4dSPeter Lievenfi
58617d992e4dSPeter Lieven
5862f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5863f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5864f0d92b56SLongpeng(Mike)fi
5865f0d92b56SLongpeng(Mike)
5866d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5867d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5868d2042378SAneesh Kumar K.Vfi
5869d2042378SAneesh Kumar K.V
5870e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5871e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5872e06a765eSHarsh Prateek Borafi
5873e06a765eSHarsh Prateek Bora
5874cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5875cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
587606d71fa1SPeter Maydellfi
587706d71fa1SPeter Maydell
58783f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
58793f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
58803f4349dcSKevin Wolffi
58813f4349dcSKevin Wolf
58828ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
58838ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
58848ab1bf12SLuiz Capitulinofi
58858ab1bf12SLuiz Capitulino
588676a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
588776a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
588876a347e1SRichard Hendersonfi
588976a347e1SRichard Henderson
5890f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5891f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5892f540166bSRichard Hendersonfi
5893f540166bSRichard Henderson
58947ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
58957ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
58967ebee43eSRichard Hendersonfi
58977ebee43eSRichard Henderson
5898df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5899df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5900df79b996SRichard Hendersonfi
5901df79b996SRichard Henderson
59021e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
59031e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
59041e6e9acaSRichard Hendersonfi
59051e6e9acaSRichard Henderson
5906eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5907d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
59086ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
59096ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5910eb100396SBharata B Raofi
5911eb100396SBharata B Rao
5912d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5913d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5914d85fa9ebSJeff Codyfi
5915d85fa9ebSJeff Cody
59160c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
59170c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
59180c14fb47SBharata B Raofi
59190c14fb47SBharata B Rao
5920df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
5921df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
5922df3a429aSNiels de Vosfi
5923df3a429aSNiels de Vos
59247c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
59257c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
59267c815372SBharata B Raofi
59277c815372SBharata B Rao
59280a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
5929d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
59306ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
59316ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
59320a12ec87SRichard W.M. Jonesfi
59330a12ec87SRichard W.M. Jones
5934ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5935ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5936ed1701c6SDr. David Alan Gilbertfi
5937ed1701c6SDr. David Alan Gilbert
593868063649Sblueswir1# USB host support
5939b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
59402b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
5941b5613fdcSGerd Hoffmannelse
594298ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
5943b5613fdcSGerd Hoffmannfi
594468063649Sblueswir1
59453b8acc11SPaolo Bonzini# TPM passthrough support?
59463b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
59473b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
59483b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
59493b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
59503b8acc11SPaolo Bonzini  fi
59513b8acc11SPaolo Bonzinifi
59523b8acc11SPaolo Bonzini
59535b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
59545b808275SLluís Vilanovaif have_backend "nop"; then
59556d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
595622890ab5SPrerna Saxenafi
59575b808275SLluís Vilanovaif have_backend "simple"; then
59586d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
59596d8a764eSLluís  # Set the appropriate trace file.
5960953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
59619410b56cSPrerna Saxenafi
5962ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5963ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
59646d8a764eSLluísfi
59655b808275SLluís Vilanovaif have_backend "ust"; then
59666d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
59676d8a764eSLluísfi
59685b808275SLluís Vilanovaif have_backend "dtrace"; then
59696d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
59706d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
59716d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
59726d8a764eSLluís  fi
5973c276b17dSDaniel P. Berrangefi
59745b808275SLluís Vilanovaif have_backend "ftrace"; then
5975781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5976781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5977781e9545SEiichi Tsukata  else
597821684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5979781e9545SEiichi Tsukata  fi
5980781e9545SEiichi Tsukatafi
59810a852417SPaul Durrantif have_backend "syslog"; then
59820a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
59830a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
59840a852417SPaul Durrant  else
59850a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
59860a852417SPaul Durrant  fi
59870a852417SPaul Durrantfi
59889410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
59899410b56cSPrerna Saxena
59902da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
59912da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
59922da776dbSMichael R. Hinesfi
59932da776dbSMichael R. Hines
5994575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5995575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5996575b22b1SLaurent Vivierfi
5997575b22b1SLaurent Vivier
5998a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
5999a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6000a6b1d4c0SChanglong Xiefi
6001a6b1d4c0SChanglong Xie
60026a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
60036a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
60046a02c806SStefan Hajnoczifi
60056a02c806SStefan Hajnoczi
60064d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
60074d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
60084d04351fSChristopher Covingtonfi
60094d04351fSChristopher Covington
601049e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
601149e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
601249e00a18SAndreas Grapentinfi
601349e00a18SAndreas Grapentin
6014e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6015e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6016e674605fSTomáš Golembiovskýfi
6017e674605fSTomáš Golembiovský
6018e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6019e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6020e0580342SKamil Rytarowskifi
6021e0580342SKamil Rytarowski
60225c312079SDr. David Alan Gilbert# Hold two types of flag:
60235c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
60245c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
60255c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
60265c312079SDr. David Alan Gilbert#                                     platform
60275c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
60285c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
60295c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
60305c312079SDr. David Alan Gilbertfi
60315c312079SDr. David Alan Gilbert
6032da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
6033da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
6034da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6035da92c3ffSAshish Mittalfi
6036da92c3ffSAshish Mittal
60375b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
60385b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
60395b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
60405b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
60415b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
60425b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6043c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
60445b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
604540d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
604640d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
60475b5e3037SPaolo Bonzinielse
60485b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
60495b5e3037SPaolo Bonzinifi
60505b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
60515b5e3037SPaolo Bonzini
605298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
605398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6054804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6055804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
60561901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
60571901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
60581901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
605921655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6060c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6061804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6062a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6063a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6064a31a8642SMichael S. Tsirkinfi
60652b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6066804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
606783f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
60683c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6069804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
607045d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6071cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
60725f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
60733dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6074804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6075804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
60764852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
60779fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6078e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
607946eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6080a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
608111cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6082f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6083e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6084e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
608580fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
60862944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6087e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6088e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6089e39f0062SPaolo Bonzinifi
609042da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
609142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
609242da6041SGerd Hoffmannelse
609342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
609442da6041SGerd Hoffmannfi
6095e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
609646eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
60976969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6098e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
609973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
61003e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6101409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6102804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
610317969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
610417969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6105957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
610690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
610790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
610894dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6109cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
61101d728c39SBlue Swirlif test "$gcov" = "yes" ; then
61111d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
61121d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
61131d728c39SBlue Swirlfi
6114804edf29SJuan Quintela
61156efd7517SPeter Maydell# use included Linux headers
61166efd7517SPeter Maydellif test "$linux" = "yes" ; then
6117a307beb6SAndreas Färber  mkdir -p linux-headers
61186efd7517SPeter Maydell  case "$cpu" in
6119c72b26ecSRichard Henderson  i386|x86_64|x32)
612008312a63SPeter Maydell    linux_arch=x86
61216efd7517SPeter Maydell    ;;
61226efd7517SPeter Maydell  ppcemb|ppc|ppc64)
612308312a63SPeter Maydell    linux_arch=powerpc
61246efd7517SPeter Maydell    ;;
61256efd7517SPeter Maydell  s390x)
612608312a63SPeter Maydell    linux_arch=s390
612708312a63SPeter Maydell    ;;
61281f080313SClaudio Fontana  aarch64)
61291f080313SClaudio Fontana    linux_arch=arm64
61301f080313SClaudio Fontana    ;;
6131222e7d11SSanjay Lal  mips64)
6132222e7d11SSanjay Lal    linux_arch=mips
6133222e7d11SSanjay Lal    ;;
613408312a63SPeter Maydell  *)
613508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
613608312a63SPeter Maydell    linux_arch="$cpu"
61376efd7517SPeter Maydell    ;;
61386efd7517SPeter Maydell  esac
613908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
614008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
614108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
614208312a63SPeter Maydell    fi
61436efd7517SPeter Maydellfi
61446efd7517SPeter Maydell
614597a847bcSbellardfor target in $target_list; do
614697a847bcSbellardtarget_dir="$target"
614725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
614889138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
614997a847bcSbellardtarget_bigendian="no"
61501f3d3c8fSJuan Quintela
6151c1799a84SPaolo Bonzinicase "$target_name" in
61524a09d0bbSRichard Henderson  armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6153ea2d6a39SJuan Quintela  target_bigendian=yes
6154ea2d6a39SJuan Quintela  ;;
6155ea2d6a39SJuan Quintelaesac
615697a847bcSbellardtarget_softmmu="no"
6157997344f3Sbellardtarget_user_only="no"
6158831b7825Sthstarget_linux_user="no"
615984778508Sblueswir1target_bsd_user="no"
61609e407a85Spbrookcase "$target" in
6161c1799a84SPaolo Bonzini  ${target_name}-softmmu)
61629e407a85Spbrook    target_softmmu="yes"
61639e407a85Spbrook    ;;
6164c1799a84SPaolo Bonzini  ${target_name}-linux-user)
61659e407a85Spbrook    target_user_only="yes"
61669e407a85Spbrook    target_linux_user="yes"
61679e407a85Spbrook    ;;
6168c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
616984778508Sblueswir1    target_user_only="yes"
617084778508Sblueswir1    target_bsd_user="yes"
617184778508Sblueswir1    ;;
61729e407a85Spbrook  *)
617376ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
61749e407a85Spbrook    exit 1
61759e407a85Spbrook    ;;
61769e407a85Spbrookesac
6177831b7825Sths
617897a847bcSbellardmkdir -p $target_dir
617925be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
618097a847bcSbellard
6181e5fe0c52Spbrookbflt="no"
6182ca759f9eSAlex Bennéemttcg="no"
618389138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
618456aebc89Spbrookgdb_xml_files=""
61857ba1e619Saliguori
6186c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
61876acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6188e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6189e73aae67SJuan Quintela
6190c1799a84SPaolo Bonzinicase "$target_name" in
61912408a527Saurel32  i386)
6192b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
61932408a527Saurel32  ;;
61942408a527Saurel32  x86_64)
61956acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6196b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
61972408a527Saurel32  ;;
61982408a527Saurel32  alpha)
61995ee4f3c2SRichard Henderson    mttcg="yes"
62002408a527Saurel32  ;;
62012408a527Saurel32  arm|armeb)
6202b498c8a0SJuan Quintela    TARGET_ARCH=arm
6203e5fe0c52Spbrook    bflt="yes"
6204ca759f9eSAlex Bennée    mttcg="yes"
620556aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62062408a527Saurel32  ;;
62076a49fa95SAlexander Graf  aarch64)
62086a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
62096a49fa95SAlexander Graf    bflt="yes"
6210ca759f9eSAlex Bennée    mttcg="yes"
62118f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
62126a49fa95SAlexander Graf  ;;
62132408a527Saurel32  cris)
62142408a527Saurel32  ;;
621561766fe9SRichard Henderson  hppa)
621661766fe9SRichard Henderson  ;;
6217613a22c9SMichael Walle  lm32)
6218613a22c9SMichael Walle  ;;
62192408a527Saurel32  m68k)
62200938cda5Saurel32    bflt="yes"
62215a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
62222408a527Saurel32  ;;
6223877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6224877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
622572b675caSEdgar E. Iglesias    bflt="yes"
622672b675caSEdgar E. Iglesias  ;;
62272408a527Saurel32  mips|mipsel)
6228b498c8a0SJuan Quintela    TARGET_ARCH=mips
622925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
62302408a527Saurel32  ;;
62312408a527Saurel32  mipsn32|mipsn32el)
6232597e2cecSRichard Henderson    TARGET_ARCH=mips64
62336acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
623425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6235597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
62362408a527Saurel32  ;;
62372408a527Saurel32  mips64|mips64el)
6238b498c8a0SJuan Quintela    TARGET_ARCH=mips64
62396acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
624025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
62412408a527Saurel32  ;;
6242d15a9c23SAnthony Green  moxie)
6243d15a9c23SAnthony Green  ;;
6244e671711cSMarek Vasut  nios2)
6245e671711cSMarek Vasut  ;;
62464a09d0bbSRichard Henderson  or1k)
6247e67db06eSJia Liu    TARGET_ARCH=openrisc
6248e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6249e67db06eSJia Liu  ;;
62502408a527Saurel32  ppc)
6251c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
62522408a527Saurel32  ;;
62532408a527Saurel32  ppcemb)
62546acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6255e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6256c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
62572408a527Saurel32  ;;
62582408a527Saurel32  ppc64)
62596acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6260e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6261f0b0685dSNikunj A Dadhania    mttcg=yes
62621438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62632408a527Saurel32  ;;
62649c35126cSDoug Kwan  ppc64le)
62659c35126cSDoug Kwan    TARGET_ARCH=ppc64
62669c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
62679c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6268f0b0685dSNikunj A Dadhania    mttcg=yes
62691438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62709c35126cSDoug Kwan  ;;
62712408a527Saurel32  ppc64abi32)
6272b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
62736acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6274e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
627525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62761438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62772408a527Saurel32  ;;
62782408a527Saurel32  sh4|sh4eb)
6279b498c8a0SJuan Quintela    TARGET_ARCH=sh4
62804dbed897Spbrook    bflt="yes"
62812408a527Saurel32  ;;
62822408a527Saurel32  sparc)
62832408a527Saurel32  ;;
62842408a527Saurel32  sparc64)
62856acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
62862408a527Saurel32  ;;
62872408a527Saurel32  sparc32plus)
6288b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
62896acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6290e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
629125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62922408a527Saurel32  ;;
629324e804ecSAlexander Graf  s390x)
629486158a2aSChristian 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"
629524e804ecSAlexander Graf  ;;
6296444e06b1SChen Gang  tilegx)
6297444e06b1SChen Gang  ;;
62985ecaa4edSPeter Crosthwaite  tricore)
62995ecaa4edSPeter Crosthwaite  ;;
6300d2fbca94SGuan Xuetao  unicore32)
6301d2fbca94SGuan Xuetao  ;;
6302cfa550c6SMax Filippov  xtensa|xtensaeb)
6303cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6304cfa550c6SMax Filippov  ;;
63052408a527Saurel32  *)
630676ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
63072408a527Saurel32  ;;
63082408a527Saurel32esac
63095e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
63105e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
63115e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
63125e8861a0SPaolo Bonzinifi
63135e8861a0SPaolo Bonzini
63145e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
63155e8861a0SPaolo Bonzini
631699afc91dSDaniel P. Berrangeupper() {
631799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
631899afc91dSDaniel P. Berrange}
631999afc91dSDaniel P. Berrange
632089138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
632125be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6322c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
632325be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6324e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6325e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6326e6e91b9cSJuan Quintelafi
632725be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6328adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6329adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6330adfc3e91SStacey Sonfi
63313b6b7550SPaolo Bonzini
63323b6b7550SPaolo Bonziniif supported_xen_target $target; then
633325be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6334eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6335eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6336eb6fda0fSAnthony PERARD    fi
6337432d268cSJun Nakajimafi
63383b6b7550SPaolo Bonziniif supported_kvm_target $target; then
633925be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
63401ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6341d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6342e6a74868SMarc-André Lureau        if test "$vhost_user" = "yes" ; then
6343e6a74868SMarc-André Lureau            echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6344e6a74868SMarc-André Lureau        fi
6345d5970055SMichael S. Tsirkin    fi
6346c59249f9SJuan Quintelafi
63473b6b7550SPaolo Bonziniif supported_hax_target $target; then
6348b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6349b0cb0a66SVincent Palatinfi
6350de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
635125be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
635297a847bcSbellardfi
635397a847bcSbellardif test "$target_softmmu" = "yes" ; then
635425be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6355ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6356ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6357ca759f9eSAlex Bennée  fi
6358de83cd02Sbellardfi
6359997344f3Sbellardif test "$target_user_only" = "yes" ; then
636025be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6361a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6362997344f3Sbellardfi
6363831b7825Sthsif test "$target_linux_user" = "yes" ; then
636425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6365831b7825Sthsfi
636656aebc89Spbrooklist=""
636756aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
636856aebc89Spbrook  for x in $gdb_xml_files; do
636956aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
637056aebc89Spbrook  done
637125be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
63723d0f1517SJuan Quintelafi
6373de83cd02Sbellard
6374e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
637525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6376e5fe0c52Spbrookfi
637784778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
637825be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
637984778508Sblueswir1fi
63805b0753e0Sbellard
63814afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6382fa282484SJuan Quintela
63834afddb55SJuan Quintelacflags=""
6384fa282484SJuan Quintelaldflags=""
63859b8e111fSJuan Quintela
6386c765fcacSPeter Crosthwaitedisas_config() {
6387c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6388c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6389c765fcacSPeter Crosthwaite}
6390c765fcacSPeter Crosthwaite
639164656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
639264656024SJuan Quintela  case "$i" in
639364656024SJuan Quintela  alpha)
6394c765fcacSPeter Crosthwaite    disas_config "ALPHA"
639564656024SJuan Quintela  ;;
639682295d8aSRichard Henderson  aarch64)
639782295d8aSRichard Henderson    if test -n "${cxx}"; then
6398c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
639982295d8aSRichard Henderson    fi
640082295d8aSRichard Henderson  ;;
640164656024SJuan Quintela  arm)
6402c765fcacSPeter Crosthwaite    disas_config "ARM"
6403999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6404c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6405999b53ecSClaudio Fontana    fi
640664656024SJuan Quintela  ;;
640764656024SJuan Quintela  cris)
6408c765fcacSPeter Crosthwaite    disas_config "CRIS"
640964656024SJuan Quintela  ;;
6410429b31a2SRichard Henderson  hppa)
6411429b31a2SRichard Henderson    disas_config "HPPA"
6412429b31a2SRichard Henderson  ;;
6413c72b26ecSRichard Henderson  i386|x86_64|x32)
6414c765fcacSPeter Crosthwaite    disas_config "I386"
641564656024SJuan Quintela  ;;
641679368f49SMichael Walle  lm32)
6417c765fcacSPeter Crosthwaite    disas_config "LM32"
641879368f49SMichael Walle  ;;
641964656024SJuan Quintela  m68k)
6420c765fcacSPeter Crosthwaite    disas_config "M68K"
642164656024SJuan Quintela  ;;
6422877fdc12SEdgar E. Iglesias  microblaze*)
6423c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
642464656024SJuan Quintela  ;;
642564656024SJuan Quintela  mips*)
6426c765fcacSPeter Crosthwaite    disas_config "MIPS"
642764656024SJuan Quintela  ;;
6428d15a9c23SAnthony Green  moxie*)
6429c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6430d15a9c23SAnthony Green  ;;
6431e671711cSMarek Vasut  nios2)
6432e671711cSMarek Vasut    disas_config "NIOS2"
6433e671711cSMarek Vasut  ;;
64344a09d0bbSRichard Henderson  or1k)
6435c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6436e67db06eSJia Liu  ;;
643764656024SJuan Quintela  ppc*)
6438c765fcacSPeter Crosthwaite    disas_config "PPC"
643964656024SJuan Quintela  ;;
644024e804ecSAlexander Graf  s390*)
6441c765fcacSPeter Crosthwaite    disas_config "S390"
644264656024SJuan Quintela  ;;
644364656024SJuan Quintela  sh4)
6444c765fcacSPeter Crosthwaite    disas_config "SH4"
644564656024SJuan Quintela  ;;
644664656024SJuan Quintela  sparc*)
6447c765fcacSPeter Crosthwaite    disas_config "SPARC"
644864656024SJuan Quintela  ;;
6449cfa550c6SMax Filippov  xtensa*)
6450c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6451cfa550c6SMax Filippov  ;;
645264656024SJuan Quintela  esac
645364656024SJuan Quinteladone
64549195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6455c765fcacSPeter Crosthwaite  disas_config "TCI"
64569195b2c2SStefan Weilfi
645764656024SJuan Quintela
64586ee7126fSJuan Quintelacase "$ARCH" in
64596ee7126fSJuan Quintelaalpha)
64606ee7126fSJuan Quintela  # Ensure there's only a single GP
64616ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
64626ee7126fSJuan Quintela;;
64636ee7126fSJuan Quintelaesac
64646ee7126fSJuan Quintela
6465d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
646625be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6467d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6468d02c1db3SJuan Quintela    cflags="-p $cflags"
6469d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6470d02c1db3SJuan Quintela  fi
6471d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6472d02c1db3SJuan Quintela    ldflags="-p $ldflags"
647325be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6474d02c1db3SJuan Quintela  fi
6475d02c1db3SJuan Quintelafi
6476d02c1db3SJuan Quintela
64779b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6478964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6479fa282484SJuan Quintelafi
6480fa282484SJuan Quintela
6481e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
6482e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
6483e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
6484e9a3591fSChristian Borntraeger# header if
6485e9a3591fSChristian Borntraeger#  - we build on s390x
6486e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
6487e9a3591fSChristian Borntraeger#  - KVM is enabled
6488e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
6489e9a3591fSChristian Borntraegerif test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes"  -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6490e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
6491e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
6492e9a3591fSChristian Borntraeger    fi
6493e9a3591fSChristian Borntraegerfi
6494e9a3591fSChristian Borntraeger
649525be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
649625be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6497fa282484SJuan Quintela
649897a847bcSbellarddone # for target in $targets
64997d13299dSbellard
6500a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6501a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6502a540f158SPeter Crosthwaitefi
6503a540f158SPeter Crosthwaite
6504a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6505a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6506a99d57bbSWanlong Gaofi
6507a99d57bbSWanlong Gao
6508fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6509fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6510fd0e6053SJohn Snowfi
6511fd0e6053SJohn Snow
6512d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6513f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6514d59157eaSPaolo BonziniDIRS="$DIRS docs docs/interop fsdev"
65159933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
65162d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
65172dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6518c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6519c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6520aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6521ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6522446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
65239933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
65242d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
65254652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
65263a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6527753d11f2SRichard Hendersonfor bios_file in \
6528753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6529225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
65305acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6531753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6532753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6533e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6534753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
65354e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6536753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6537753d11f2SRichard Hendersondo
653889138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
65397ea78b74SJan Kiszkadone
654089138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6541c2304b52SMarcel Apfelbaumdo
654289138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6543c2304b52SMarcel Apfelbaumdone
6544d1807a4fSPaolo Bonzinimkdir -p $DIRS
65457d13299dSbellardfor f in $FILES ; do
6546cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6547f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6548f9245e10SPeter Maydell    fi
65497d13299dSbellarddone
65501ad2134fSPaul Brook
6551c34ebfdcSAnthony Liguori# temporary config to build submodules
65522d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6553c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
655437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6555c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6556cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
65575f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6558c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6559c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
65603dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6561c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6562a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6563c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
6564c34ebfdcSAnthony Liguoridone
6565c34ebfdcSAnthony Liguori
6566fe31017fSMarc-André Lureau# set up tests data directory
6567fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6568fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6569fe31017fSMarc-André Lureaufi
6570fe31017fSMarc-André Lureau
657176c7560aSMax Reitz# set up qemu-iotests in this build directory
657276c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
657376c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
657476c7560aSMax Reitz
657576c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
657676c7560aSMax Reitzecho >> "$iotests_common_env"
657776c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
657876c7560aSMax Reitz
657976c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
658076c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
658176c7560aSMax Reitzfi
658276c7560aSMax Reitz
6583dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6584dc655404SMichael S. Tsirkincat <<EOD >config.status
6585dc655404SMichael S. Tsirkin#!/bin/sh
6586dc655404SMichael S. Tsirkin# Generated by configure.
6587dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6588dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6589dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6590dc655404SMichael S. TsirkinEOD
6591dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6592dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6593cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6594dc655404SMichael S. Tsirkinchmod +x config.status
6595dc655404SMichael S. Tsirkin
65968cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6597