xref: /openbmc/qemu/configure (revision e189091f)
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
2053b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
2063b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
2073b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | x86_64:i386 | x86_64: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
2437d13299dSbellard# default parameters
24489138857SStefan Weilsource_path=$(dirname "$0")
2452ff6b91eSJuan Quintelacpu=""
246a31a8642SMichael S. Tsirkiniasl="iasl"
2471e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
24843ce4dfeSbellardstatic="no"
2497d13299dSbellardcross_prefix=""
2500c58ac1cSmalcaudio_drv_list=""
251b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
252b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
253e49d021eSPeter Maydellhost_cc="cc"
25473da375eSJuan Quintelalibs_softmmu=""
2553e2e0e6bSJuan Quintelalibs_tools=""
25667f86e8eSJuan Quintelaaudio_pt_int=""
257d5631638Smalcaudio_win_int=""
2582b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
259957f1f99SMichael Rothlibs_qga=""
2605bc62e01SGerd Hoffmanndebug_info="yes"
26163678e17SSteven Noonanstack_protector=""
262ac0df51dSaliguori
263afb63ebdSStefan Weil# Don't accept a target_list environment variable.
264afb63ebdSStefan Weilunset target_list
265377529c0SPaolo Bonzini
266377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
267377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
268377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
269377529c0SPaolo Bonzini#              unless --disable-foo is given
270377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
271377529c0SPaolo Bonzini#              feature will searched for,
272377529c0SPaolo Bonzini#              if not found, configure exits with error
273377529c0SPaolo Bonzini#
274377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
275377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
276377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
277377529c0SPaolo Bonzini
278377529c0SPaolo Bonzinibluez=""
279377529c0SPaolo Bonzinibrlapi=""
280377529c0SPaolo Bonzinicurl=""
281377529c0SPaolo Bonzinicurses=""
282377529c0SPaolo Bonzinidocs=""
283377529c0SPaolo Bonzinifdt=""
28458952137SVincenzo Maffionenetmap="no"
285e2134eb9SGerd Hoffmannpixman=""
286377529c0SPaolo Bonzinisdl=""
287ee8466d0SCole Robinsonsdlabi=""
288983eef5aSMeador Ingevirtfs=""
289821601eaSJes Sorensenvnc="yes"
290377529c0SPaolo Bonzinisparse="no"
291377529c0SPaolo Bonzinivde=""
292377529c0SPaolo Bonzinivnc_sasl=""
293377529c0SPaolo Bonzinivnc_jpeg=""
294377529c0SPaolo Bonzinivnc_png=""
295377529c0SPaolo Bonzinixen=""
296d5b93ddfSAnthony PERARDxen_ctrl_version=""
29764a7ad6fSIan Campbellxen_pv_domain_build="no"
298eb6fda0fSAnthony PERARDxen_pci_passthrough=""
299377529c0SPaolo Bonzinilinux_aio=""
30047e98658SCorey Bryantcap_ng=""
301377529c0SPaolo Bonziniattr=""
3024f26f2b6SAvi Kivitylibattr=""
303377529c0SPaolo Bonzinixfs=""
304b3f6ea7eSPaolo Bonzinitcg="yes"
305377529c0SPaolo Bonzini
306d41a75a2SBradvhost_net="no"
3075e9be92dSNicholas Bellingervhost_scsi="no"
308fc0b9b0eSStefan Hajnoczivhost_vsock="no"
309d41a75a2SBradkvm="no"
310b0cb0a66SVincent Palatinhax="no"
3112da776dbSMichael R. Hinesrdma=""
312377529c0SPaolo Bonzinigprof="no"
313377529c0SPaolo Bonzinidebug_tcg="no"
314377529c0SPaolo Bonzinidebug="no"
315b553a042SJohn Snowfortify_source=""
316377529c0SPaolo Bonzinistrip_opt="yes"
3179195b2c2SStefan Weiltcg_interpreter="no"
318377529c0SPaolo Bonzinibigendian="no"
319377529c0SPaolo Bonzinimingw32="no"
3201d728c39SBlue Swirlgcov="no"
3211d728c39SBlue Swirlgcov_tool="gcov"
322377529c0SPaolo BonziniEXESUF=""
32317969268SFam ZhengDSOSUF=".so"
32417969268SFam ZhengLDFLAGS_SHARED="-shared"
32517969268SFam Zhengmodules="no"
326377529c0SPaolo Bonziniprefix="/usr/local"
327377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
328528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
329850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
330377529c0SPaolo Bonzinibindir="\${prefix}/bin"
3313aa5d2beSAlon Levylibdir="\${prefix}/lib"
3328bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
3330f94d6daSAlon Levyincludedir="\${prefix}/include"
334377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
335785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
336377529c0SPaolo Bonziniconfsuffix="/qemu"
337377529c0SPaolo Bonzinislirp="yes"
338377529c0SPaolo Bonzinioss_lib=""
339377529c0SPaolo Bonzinibsd="no"
340377529c0SPaolo Bonzinilinux="no"
341377529c0SPaolo Bonzinisolaris="no"
342377529c0SPaolo Bonziniprofiler="no"
343377529c0SPaolo Bonzinicocoa="no"
344377529c0SPaolo Bonzinisoftmmu="yes"
345377529c0SPaolo Bonzinilinux_user="no"
346377529c0SPaolo Bonzinibsd_user="no"
347377529c0SPaolo Bonziniaix="no"
348377529c0SPaolo Bonziniblobs="yes"
349377529c0SPaolo Bonzinipkgversion=""
35040d6444eSAvi Kivitypie=""
3513556c233SPaolo Bonziniqom_cast_debug="yes"
352baf86d6bSPaolo Bonzinitrace_backends="log"
353377529c0SPaolo Bonzinitrace_file="trace"
354377529c0SPaolo Bonzinispice=""
355377529c0SPaolo Bonzinirbd=""
3567b02f544SMarc-André Lureausmartcard=""
3572b2325ffSGerd Hoffmannlibusb=""
35869354a83SHans de Goedeusb_redir=""
359da076ffeSGerd Hoffmannopengl=""
360014cb152SGerd Hoffmannopengl_dmabuf="no"
36199f2dbd3SLiang Liavx2_opt="no"
3621ece9905SAlon Levyzlib="yes"
363b25c9dffSStefan Weillzo=""
364b25c9dffSStefan Weilsnappy=""
3656b383c08SPeter Wubzip2=""
366e8ef31a3SMichael Tokarevguest_agent=""
367d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
36850cbebb9SMichael Rothguest_agent_ntddscsi="no"
3699dacf32dSYossi Hindinguest_agent_msi=""
370d9840e25STomoki Sekiyamavss_win32_sdk=""
371d9840e25STomoki Sekiyamawin_sdk="no"
3724b1c11fdSDaniel P. Berrangewant_tools="yes"
373c589b249SRonnie Sahlberglibiscsi=""
3746542aa9cSPeter Lievenlibnfs=""
375519175a2SAlex Barcelocoroutine=""
37670c60c08SStefan Hajnoczicoroutine_pool=""
3777d992e4dSPeter Lievendebug_stack_usage="no"
378f794573eSEduardo Otuboseccomp=""
379eb100396SBharata B Raoglusterfs=""
380d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
3810c14fb47SBharata B Raoglusterfs_discard="no"
382df3a429aSNiels de Vosglusterfs_fallocate="no"
3837c815372SBharata B Raoglusterfs_zerofill="no"
384a4ccabcfSAnthony Liguorigtk=""
3859e04c683SStefan Weilgtkabi=""
386925a0400SGerd Hoffmanngtk_gl="no"
387a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
388ddbb0d09SDaniel P. Berrangegnutls=""
389b917da4cSDaniel P. Berrangegnutls_rnd=""
39091bfcdb0SDaniel P. Berrangenettle=""
391fff2f982SDaniel P. Berrangenettle_kdf="no"
39291bfcdb0SDaniel P. Berrangegcrypt=""
3931f923c70SLongpeng(Mike)gcrypt_hmac="no"
39437788f25SDaniel P. Berrangegcrypt_kdf="no"
395bbbf9bfbSStefan Weilvte=""
3969d9e1521SGerd Hoffmannvirglrenderer=""
397e91c793cSCole Robinsontpm="yes"
3980a12ec87SRichard W.M. Joneslibssh2=""
399ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
400a99d57bbSWanlong Gaonuma=""
4012847b469SFam Zhengtcmalloc="no"
4027b01cb97SAlexandre Derumierjemalloc="no"
403a6b1d4c0SChanglong Xiereplication="yes"
404da92c3ffSAshish Mittalvxhs=""
405377529c0SPaolo Bonzini
406898be3e0SPeter Maydellsupported_cpu="no"
407898be3e0SPeter Maydellsupported_os="no"
408fb59dabdSPeter Maydellbogus_os="no"
409898be3e0SPeter Maydell
410ac0df51dSaliguori# parse CC options first
411ac0df51dSaliguorifor opt do
41289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
413ac0df51dSaliguori  case "$opt" in
414ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
415ac0df51dSaliguori  ;;
4163d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
417ac0df51dSaliguori  ;;
41883f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
41983f73fceSTomoki Sekiyama  ;;
420ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
421ca4deeb1SPaolo Bonzini  ;;
4222ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4232ff6b91eSJuan Quintela  ;;
424de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
425f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
426e2a2ed06SJuan Quintela  ;;
42711cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
42811cde1c8SBruno Dominguez                      EXTRA_CXXFLAGS="$optarg"
42911cde1c8SBruno Dominguez  ;;
430a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
431f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
432e2a2ed06SJuan Quintela  ;;
4335bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4345bc62e01SGerd Hoffmann  ;;
4355bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4365bc62e01SGerd Hoffmann  ;;
437ac0df51dSaliguori  esac
438ac0df51dSaliguoridone
439ac0df51dSaliguori# OS specific
440ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
44193148aa5SStefan Weil# we can eliminate its usage altogether.
442ac0df51dSaliguori
443e49d021eSPeter Maydell# Preferred compiler:
444e49d021eSPeter Maydell#  ${CC} (if set)
445e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
446e49d021eSPeter Maydell#  system compiler
447e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
448e49d021eSPeter Maydell  cc="$host_cc"
449e49d021eSPeter Maydellelse
450b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
451e49d021eSPeter Maydellfi
452e49d021eSPeter Maydell
45383f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
45483f73fceSTomoki Sekiyama  cxx="c++"
45583f73fceSTomoki Sekiyamaelse
45683f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
45783f73fceSTomoki Sekiyamafi
45883f73fceSTomoki Sekiyama
459b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
460cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4615f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4623dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
463b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
464b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
4654852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
466b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
467b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
46817884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
46917884d7bSSergei Trofimovichquery_pkg_config() {
47017884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
47117884d7bSSergei Trofimovich}
47217884d7bSSergei Trofimovichpkg_config=query_pkg_config
473b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
47447c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
475ac0df51dSaliguori
47645d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
47745d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
47845d285abSPeter Maydell
479be17dc90SMichael S. Tsirkin# default flags for all hosts
4802d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
4812d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
4822d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
4832d31515bSPeter Maydell# provides these semantics.)
4842d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
485f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
486c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
487be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
488244f1441SYang ZhongQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
4895bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
4905bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
491be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
4925bc62e01SGerd Hoffmannfi
493be17dc90SMichael S. Tsirkin
494ca4deeb1SPaolo Bonzini# make source path absolute
49589138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
496ca4deeb1SPaolo Bonzini
497cab00a5aSMichael S. Tsirkin# running configure in the source tree?
498cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
499cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
500cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
501cab00a5aSMichael S. Tsirkinelse
502cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
503cab00a5aSMichael S. Tsirkinfi
504cab00a5aSMichael S. Tsirkin
505ac0df51dSaliguoricheck_define() {
506ac0df51dSaliguoricat > $TMPC <<EOF
507ac0df51dSaliguori#if !defined($1)
508fd786e1aSPeter Maydell#error $1 not defined
509ac0df51dSaliguori#endif
510ac0df51dSaliguoriint main(void) { return 0; }
511ac0df51dSaliguoriEOF
51252166aa0SJuan Quintela  compile_object
513ac0df51dSaliguori}
514ac0df51dSaliguori
515307119e7SGerd Hoffmanncheck_include() {
516307119e7SGerd Hoffmanncat > $TMPC <<EOF
517307119e7SGerd Hoffmann#include <$1>
518307119e7SGerd Hoffmannint main(void) { return 0; }
519307119e7SGerd HoffmannEOF
520307119e7SGerd Hoffmann  compile_object
521307119e7SGerd Hoffmann}
522307119e7SGerd Hoffmann
52393b25869SJohn Snowwrite_c_skeleton() {
52493b25869SJohn Snow    cat > $TMPC <<EOF
52593b25869SJohn Snowint main(void) { return 0; }
52693b25869SJohn SnowEOF
52793b25869SJohn Snow}
52893b25869SJohn Snow
529bbea4050SPeter Maydellif check_define __linux__ ; then
530bbea4050SPeter Maydell  targetos="Linux"
531bbea4050SPeter Maydellelif check_define _WIN32 ; then
532bbea4050SPeter Maydell  targetos='MINGW32'
533bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
534bbea4050SPeter Maydell  targetos='OpenBSD'
535bbea4050SPeter Maydellelif check_define __sun__ ; then
536bbea4050SPeter Maydell  targetos='SunOS'
537bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
538bbea4050SPeter Maydell  targetos='Haiku'
539bbea4050SPeter Maydellelse
54089138857SStefan Weil  targetos=$(uname -s)
541bbea4050SPeter Maydellfi
542bbea4050SPeter Maydell
543bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
544bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
545bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
546bbea4050SPeter Maydell# the correct CPU with the --cpu option.
547bbea4050SPeter Maydellcase $targetos in
548bbea4050SPeter MaydellDarwin)
549bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
550bbea4050SPeter Maydell  # run 64-bit userspace code.
551bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
552bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
553bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
554bbea4050SPeter Maydell    cpu="x86_64"
555bbea4050SPeter Maydell  fi
556bbea4050SPeter Maydell  ;;
557bbea4050SPeter MaydellSunOS)
55889138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
559bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
560bbea4050SPeter Maydell    cpu="x86_64"
561bbea4050SPeter Maydell  fi
562bbea4050SPeter Maydellesac
563bbea4050SPeter Maydell
5642ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
5652ff6b91eSJuan Quintela  # command line argument
5662ff6b91eSJuan Quintela  :
5672ff6b91eSJuan Quintelaelif check_define __i386__ ; then
568ac0df51dSaliguori  cpu="i386"
569ac0df51dSaliguorielif check_define __x86_64__ ; then
570c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
571c72b26ecSRichard Henderson    cpu="x32"
572c72b26ecSRichard Henderson  else
573ac0df51dSaliguori    cpu="x86_64"
574c72b26ecSRichard Henderson  fi
5753aa9bd6cSblueswir1elif check_define __sparc__ ; then
5763aa9bd6cSblueswir1  if check_define __arch64__ ; then
5773aa9bd6cSblueswir1    cpu="sparc64"
5783aa9bd6cSblueswir1  else
5793aa9bd6cSblueswir1    cpu="sparc"
5803aa9bd6cSblueswir1  fi
581fdf7ed96Smalcelif check_define _ARCH_PPC ; then
582fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
583fdf7ed96Smalc    cpu="ppc64"
584ac0df51dSaliguori  else
585fdf7ed96Smalc    cpu="ppc"
586fdf7ed96Smalc  fi
587afa05235SAurelien Jarnoelif check_define __mips__ ; then
588afa05235SAurelien Jarno  cpu="mips"
589477ba620SAurelien Jarnoelif check_define __ia64__ ; then
590477ba620SAurelien Jarno  cpu="ia64"
591d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
592d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
593d66ed0eaSAurelien Jarno    cpu="s390x"
594d66ed0eaSAurelien Jarno  else
595d66ed0eaSAurelien Jarno    cpu="s390"
596d66ed0eaSAurelien Jarno  fi
59721d89f84SPeter Maydellelif check_define __arm__ ; then
59821d89f84SPeter Maydell  cpu="arm"
5991f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6001f080313SClaudio Fontana  cpu="aarch64"
601fdf7ed96Smalcelse
60289138857SStefan Weil  cpu=$(uname -m)
603ac0df51dSaliguorifi
604ac0df51dSaliguori
605359bc95dSPeter MaydellARCH=
606359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
607359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6087d13299dSbellardcase "$cpu" in
6096499fd15SPeter Maydell  ppc|ppc64|s390|s390x|sparc64|x32)
610898be3e0SPeter Maydell    cpu="$cpu"
611898be3e0SPeter Maydell    supported_cpu="yes"
612898be3e0SPeter Maydell  ;;
6136499fd15SPeter Maydell  ia64)
614ea8f20f8SJuan Quintela    cpu="$cpu"
615ea8f20f8SJuan Quintela  ;;
6167d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
61797a847bcSbellard    cpu="i386"
618898be3e0SPeter Maydell    supported_cpu="yes"
6197d13299dSbellard  ;;
620aaa5fa14Saurel32  x86_64|amd64)
621aaa5fa14Saurel32    cpu="x86_64"
622898be3e0SPeter Maydell    supported_cpu="yes"
623aaa5fa14Saurel32  ;;
62421d89f84SPeter Maydell  armv*b|armv*l|arm)
62521d89f84SPeter Maydell    cpu="arm"
626898be3e0SPeter Maydell    supported_cpu="yes"
6277d13299dSbellard  ;;
6281f080313SClaudio Fontana  aarch64)
6291f080313SClaudio Fontana    cpu="aarch64"
630898be3e0SPeter Maydell    supported_cpu="yes"
6311f080313SClaudio Fontana  ;;
632afa05235SAurelien Jarno  mips*)
633afa05235SAurelien Jarno    cpu="mips"
634898be3e0SPeter Maydell    supported_cpu="yes"
635afa05235SAurelien Jarno  ;;
6363142255cSblueswir1  sparc|sun4[cdmuv])
637ae228531Sbellard    cpu="sparc"
6386499fd15SPeter Maydell    supported_cpu="yes"
639ae228531Sbellard  ;;
6407d13299dSbellard  *)
641359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
642359bc95dSPeter Maydell    ARCH=unknown
6437d13299dSbellard  ;;
6447d13299dSbellardesac
645359bc95dSPeter Maydellif test -z "$ARCH"; then
646359bc95dSPeter Maydell  ARCH="$cpu"
647359bc95dSPeter Maydellfi
648e2d52ad3SJuan Quintela
6497d13299dSbellard# OS specific
6500dbfc675SJuan Quintela
651adfc3e91SStacey Son# host *BSD for user mode
652adfc3e91SStacey SonHOST_VARIANT_DIR=""
653adfc3e91SStacey Son
6547d13299dSbellardcase $targetos in
65567b915a5SbellardMINGW32*)
65667b915a5Sbellard  mingw32="yes"
657b0cb0a66SVincent Palatin  hax="yes"
6583cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
659307119e7SGerd Hoffmann  if check_include dsound.h; then
6603cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
661307119e7SGerd Hoffmann  else
662307119e7SGerd Hoffmann    audio_drv_list=""
663307119e7SGerd Hoffmann  fi
664898be3e0SPeter Maydell  supported_os="yes"
66567b915a5Sbellard;;
6665c40d2bdSthsGNU/kFreeBSD)
667a167ba50SAurelien Jarno  bsd="yes"
6680c58ac1cSmalc  audio_drv_list="oss"
6690bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
6705c40d2bdSths;;
6717d3505c5SbellardFreeBSD)
6727d3505c5Sbellard  bsd="yes"
6730db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6740c58ac1cSmalc  audio_drv_list="oss"
6750bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
676f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
677f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
678a7764f15SEd Maste  # needed for kinfo_getproc
679a7764f15SEd Maste  libs_qga="-lutil $libs_qga"
68058952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
681adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
682898be3e0SPeter Maydell  supported_os="yes"
6837d3505c5Sbellard;;
684c5e97233Sblueswir1DragonFly)
685c5e97233Sblueswir1  bsd="yes"
6860db4a067SPaolo Bonzini  make="${MAKE-gmake}"
687c5e97233Sblueswir1  audio_drv_list="oss"
6880bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
689adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
690c5e97233Sblueswir1;;
6917d3505c5SbellardNetBSD)
6927d3505c5Sbellard  bsd="yes"
6930db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6940c58ac1cSmalc  audio_drv_list="oss"
6950bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
6968ef92a88Sblueswir1  oss_lib="-lossaudio"
697adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
6983c2bdbc1SKamil Rytarowski  supported_os="yes"
6997d3505c5Sbellard;;
7007d3505c5SbellardOpenBSD)
7017d3505c5Sbellard  bsd="yes"
7020db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7034f6ab397SBrad Smith  audio_drv_list="sdl"
7040bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
705adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
7067d3505c5Sbellard;;
70783fb7adfSbellardDarwin)
70883fb7adfSbellard  bsd="yes"
70983fb7adfSbellard  darwin="yes"
710b0cb0a66SVincent Palatin  hax="yes"
71117969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
7121b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
713a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
7140c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
7151b0f9cc2Saliguori  fi
716fd677642Sths  cocoa="yes"
7170c58ac1cSmalc  audio_drv_list="coreaudio"
71814382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
7190c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7207973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
721a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
722a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
723a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
724adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
725898be3e0SPeter Maydell  supported_os="yes"
72683fb7adfSbellard;;
727ec530c81SbellardSunOS)
728ec530c81Sbellard  solaris="yes"
7290db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7300db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
731fa58948dSBlue Swirl  ld="gld"
732e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7330475a5caSths  needs_libsunmath="no"
73489138857SStefan Weil  solarisrev=$(uname -r | cut -f2 -d.)
735c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
7360475a5caSths    if test "$solarisrev" -le 9 ; then
7370475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
7380475a5caSths        needs_libsunmath="yes"
739f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
740f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
741f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
7420475a5caSths      else
74376ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
74476ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
74576ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
74676ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
7470475a5caSths      fi
7480475a5caSths    fi
74986b2bd93Sths  fi
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;;
763b29fe3edSmalcAIX)
764b29fe3edSmalc  aix="yes"
7650db4a067SPaolo Bonzini  make="${MAKE-gmake}"
766b29fe3edSmalc;;
767179cf400SAndreas FärberHaiku)
768179cf400SAndreas Färber  haiku="yes"
769179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
770179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
771179cf400SAndreas Färber;;
772898be3e0SPeter MaydellLinux)
7730c58ac1cSmalc  audio_drv_list="oss"
7740bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7755327cf48Sbellard  linux="yes"
776831b7825Sths  linux_user="yes"
777af2be207SJan Kiszka  kvm="yes"
778af2be207SJan Kiszka  vhost_net="yes"
7795e9be92dSNicholas Bellinger  vhost_scsi="yes"
780fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
781a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
782898be3e0SPeter Maydell  supported_os="yes"
783898be3e0SPeter Maydell;;
784898be3e0SPeter Maydell*)
785fb59dabdSPeter Maydell  # This is a fatal error, but don't report it yet, because we
786fb59dabdSPeter Maydell  # might be going to just print the --help text, or it might
787fb59dabdSPeter Maydell  # be the result of a missing compiler.
788fb59dabdSPeter Maydell  bogus_os="yes"
789fb065187Sbellard;;
7907d13299dSbellardesac
7917d13299dSbellard
7927d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
793b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
79484778508Sblueswir1    bsd_user="yes"
7957d3505c5Sbellard  fi
79608de3949SAndreas Färberfi
7977d3505c5Sbellard
7980db4a067SPaolo Bonzini: ${make=${MAKE-make}}
7990db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
80052510f8bSStefan Weil: ${python=${PYTHON-python}}
801e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8020db4a067SPaolo Bonzini
8033c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8043c4a4d0dSPeter Maydellif has clang; then
8053c4a4d0dSPeter Maydell  objcc=clang
8063c4a4d0dSPeter Maydellelse
8073c4a4d0dSPeter Maydell  objcc="$cc"
8083c4a4d0dSPeter Maydellfi
8093c4a4d0dSPeter Maydell
8103457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8113457a3f8SJuan Quintela  EXESUF=".exe"
81217969268SFam Zheng  DSOSUF=".dll"
813a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
814e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
815e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
81678e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
81778e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
818f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
81993b25869SJohn Snow  write_c_skeleton;
820f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
821f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
822f7cf5d5bSStefan Weil  fi
823c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
824683035deSPaolo Bonzini  mandir="\${prefix}"
825528ae5b8SEduardo Habkost  datadir="\${prefix}"
826850da188SEduardo Habkost  qemu_docdir="\${prefix}"
827683035deSPaolo Bonzini  bindir="\${prefix}"
828683035deSPaolo Bonzini  sysconfdir="\${prefix}"
8295a699bbbSLaszlo Ersek  local_statedir=
830683035deSPaolo Bonzini  confsuffix=""
831161a56a9SVinzenz Feenstra  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -liphlpapi -lnetapi32 $libs_qga"
8323457a3f8SJuan Quintelafi
8333457a3f8SJuan Quintela
834487fefdbSAnthony Liguoriwerror=""
83585aa5189Sbellard
8367d13299dSbellardfor opt do
83789138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8387d13299dSbellard  case "$opt" in
8392efc3265Sbellard  --help|-h) show_help=yes
8402efc3265Sbellard  ;;
84199123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
84299123e13SMike Frysinger  ;;
843b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8447d13299dSbellard  ;;
845b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
84632ce6337Sbellard  ;;
847ca4deeb1SPaolo Bonzini  --source-path=*)
8487d13299dSbellard  ;;
849ac0df51dSaliguori  --cross-prefix=*)
8507d13299dSbellard  ;;
851ac0df51dSaliguori  --cc=*)
8527d13299dSbellard  ;;
853b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
85483469015Sbellard  ;;
85583f73fceSTomoki Sekiyama  --cxx=*)
85683f73fceSTomoki Sekiyama  ;;
857e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
858e007dbecSMichael S. Tsirkin  ;;
8593c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8603c4a4d0dSPeter Maydell  ;;
861b1a550a0Spbrook  --make=*) make="$optarg"
8627d13299dSbellard  ;;
8636a882643Spbrook  --install=*) install="$optarg"
8646a882643Spbrook  ;;
865c886edfbSBlue Swirl  --python=*) python="$optarg"
866c886edfbSBlue Swirl  ;;
8671d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
8681d728c39SBlue Swirl  ;;
869e2d8830eSBrad  --smbd=*) smbd="$optarg"
870e2d8830eSBrad  ;;
871e2a2ed06SJuan Quintela  --extra-cflags=*)
8727d13299dSbellard  ;;
87311cde1c8SBruno Dominguez  --extra-cxxflags=*)
87411cde1c8SBruno Dominguez  ;;
875e2a2ed06SJuan Quintela  --extra-ldflags=*)
8767d13299dSbellard  ;;
8775bc62e01SGerd Hoffmann  --enable-debug-info)
8785bc62e01SGerd Hoffmann  ;;
8795bc62e01SGerd Hoffmann  --disable-debug-info)
8805bc62e01SGerd Hoffmann  ;;
88117969268SFam Zheng  --enable-modules)
88217969268SFam Zheng      modules="yes"
88317969268SFam Zheng  ;;
8843aa88b31SStefan Hajnoczi  --disable-modules)
8853aa88b31SStefan Hajnoczi      modules="no"
8863aa88b31SStefan Hajnoczi  ;;
8872ff6b91eSJuan Quintela  --cpu=*)
8887d13299dSbellard  ;;
889b1a550a0Spbrook  --target-list=*) target_list="$optarg"
890de83cd02Sbellard  ;;
8915b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8925b808275SLluís Vilanova  ;;
8935b808275SLluís Vilanova  # XXX: backwards compatibility
8945b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
89594a420b1SStefan Hajnoczi  ;;
89674242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8979410b56cSPrerna Saxena  ;;
8987d13299dSbellard  --enable-gprof) gprof="yes"
8997d13299dSbellard  ;;
9001d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9011d728c39SBlue Swirl  ;;
90279427693SLoïc Minier  --static)
90379427693SLoïc Minier    static="yes"
90479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
90517884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
90643ce4dfeSbellard  ;;
9070b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9080b24e75fSPaolo Bonzini  ;;
9090b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9100b24e75fSPaolo Bonzini  ;;
9113aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9123aa5d2beSAlon Levy  ;;
9138bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9148bf188aaSMichael Tokarev  ;;
9150f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9160f94d6daSAlon Levy  ;;
917528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9180b24e75fSPaolo Bonzini  ;;
919023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
920023d3d67SEduardo Habkost  ;;
921850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
9220b24e75fSPaolo Bonzini  ;;
923ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
92407381cc1SAnthony Liguori  ;;
925785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
926785c23aeSLuiz Capitulino  ;;
927785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
928023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
929023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
930023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
931023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
932023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
933023ddd74SMax Filippov    # lots of directory switches by default.
934023ddd74SMax Filippov  ;;
935e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
936e2134eb9SGerd Hoffmann  ;;
937e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
938e2134eb9SGerd Hoffmann  ;;
93974880fe2SRobert Schiele  --without-pixman) pixman="none"
94074880fe2SRobert Schiele  ;;
94197a847bcSbellard  --disable-sdl) sdl="no"
94297a847bcSbellard  ;;
943c4198157SJuan Quintela  --enable-sdl) sdl="yes"
944c4198157SJuan Quintela  ;;
94547c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
94647c03744SDave Airlie  ;;
9473556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9483556c233SPaolo Bonzini  ;;
9493556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9503556c233SPaolo Bonzini  ;;
951983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
952983eef5aSMeador Inge  ;;
953983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
954983eef5aSMeador Inge  ;;
955821601eaSJes Sorensen  --disable-vnc) vnc="no"
956821601eaSJes Sorensen  ;;
957821601eaSJes Sorensen  --enable-vnc) vnc="yes"
958821601eaSJes Sorensen  ;;
9592f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
9602f6a1ab0Sblueswir1  ;;
9610c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9620c58ac1cSmalc  ;;
96389138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
964b64ec4e4SFam Zheng  ;;
96589138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
966eb852011SMarkus Armbruster  ;;
967f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
968f8393946Saurel32  ;;
969f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
970f8393946Saurel32  ;;
971f3d08ee6SPaul Brook  --enable-debug)
972f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
973f3d08ee6SPaul Brook      debug_tcg="yes"
974f3d08ee6SPaul Brook      debug="yes"
975f3d08ee6SPaul Brook      strip_opt="no"
976b553a042SJohn Snow      fortify_source="no"
977f3d08ee6SPaul Brook  ;;
97803b4fe7dSaliguori  --enable-sparse) sparse="yes"
97903b4fe7dSaliguori  ;;
98003b4fe7dSaliguori  --disable-sparse) sparse="no"
98103b4fe7dSaliguori  ;;
9821625af87Saliguori  --disable-strip) strip_opt="no"
9831625af87Saliguori  ;;
9842f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
9852f9606b3Saliguori  ;;
986ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
987ea784e3bSJuan Quintela  ;;
9882f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
9892f6f5c7aSCorentin Chary  ;;
9902f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
9912f6f5c7aSCorentin Chary  ;;
992efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
993efe556adSCorentin Chary  ;;
994efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
995efe556adSCorentin Chary  ;;
996443f1376Sbellard  --disable-slirp) slirp="no"
997c20709aaSbellard  ;;
998e0e6c8c0Saliguori  --disable-vde) vde="no"
9998a16d273Sths  ;;
1000dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1001dfb278bdSJuan Quintela  ;;
100258952137SVincenzo Maffione  --disable-netmap) netmap="no"
100358952137SVincenzo Maffione  ;;
100458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
100558952137SVincenzo Maffione  ;;
1006e37630caSaliguori  --disable-xen) xen="no"
1007e37630caSaliguori  ;;
1008fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1009fc321b4bSJuan Quintela  ;;
1010eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1011eb6fda0fSAnthony PERARD  ;;
1012eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1013eb6fda0fSAnthony PERARD  ;;
101464a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
101564a7ad6fSIan Campbell  ;;
101664a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
101764a7ad6fSIan Campbell  ;;
10182e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10192e4d9fb1Saurel32  ;;
10204ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10214ffcedb6SJuan Quintela  ;;
1022fb599c9aSbalrog  --disable-bluez) bluez="no"
1023fb599c9aSbalrog  ;;
1024a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
1025a20a6f46SJuan Quintela  ;;
10267ba1e619Saliguori  --disable-kvm) kvm="no"
10277ba1e619Saliguori  ;;
1028b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1029b31a0277SJuan Quintela  ;;
1030b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1031180fb750Szhanghailiang  ;;
1032b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1033180fb750Szhanghailiang  ;;
10349195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
10359195b2c2SStefan Weil  ;;
10369195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
10379195b2c2SStefan Weil  ;;
103847e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
103947e98658SCorey Bryant  ;;
104047e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
104147e98658SCorey Bryant  ;;
1042b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1043b3f6ea7eSPaolo Bonzini  ;;
1044b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1045b3f6ea7eSPaolo Bonzini  ;;
1046cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1047cd4ec0b4SGerd Hoffmann  ;;
1048cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1049cd4ec0b4SGerd Hoffmann  ;;
1050c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1051c589b249SRonnie Sahlberg  ;;
1052c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1053c589b249SRonnie Sahlberg  ;;
10546542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
10556542aa9cSPeter Lieven  ;;
10566542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
10576542aa9cSPeter Lieven  ;;
105805c2a3e7Sbellard  --enable-profiler) profiler="yes"
105905c2a3e7Sbellard  ;;
106014821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
106114821030SPavel Borzenkov  ;;
1062c2de5c91Smalc  --enable-cocoa)
1063c2de5c91Smalc      cocoa="yes" ;
106489138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
10655b0753e0Sbellard  ;;
1066cad25d69Spbrook  --disable-system) softmmu="no"
10670a8e90f4Spbrook  ;;
1068cad25d69Spbrook  --enable-system) softmmu="yes"
10690a8e90f4Spbrook  ;;
10700953a80fSZachary Amsden  --disable-user)
10710953a80fSZachary Amsden      linux_user="no" ;
10720953a80fSZachary Amsden      bsd_user="no" ;
10730953a80fSZachary Amsden  ;;
10740953a80fSZachary Amsden  --enable-user) ;;
1075831b7825Sths  --disable-linux-user) linux_user="no"
10760a8e90f4Spbrook  ;;
1077831b7825Sths  --enable-linux-user) linux_user="yes"
1078831b7825Sths  ;;
107984778508Sblueswir1  --disable-bsd-user) bsd_user="no"
108084778508Sblueswir1  ;;
108184778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
108284778508Sblueswir1  ;;
108340d6444eSAvi Kivity  --enable-pie) pie="yes"
108434005a00SKirill A. Shutemov  ;;
108540d6444eSAvi Kivity  --disable-pie) pie="no"
108634005a00SKirill A. Shutemov  ;;
108785aa5189Sbellard  --enable-werror) werror="yes"
108885aa5189Sbellard  ;;
108985aa5189Sbellard  --disable-werror) werror="no"
109085aa5189Sbellard  ;;
109163678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
109263678e17SSteven Noonan  ;;
109363678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
109463678e17SSteven Noonan  ;;
10954d3b6f6eSbalrog  --disable-curses) curses="no"
10964d3b6f6eSbalrog  ;;
1097c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1098c584a6d0SJuan Quintela  ;;
1099769ce76dSAlexander Graf  --disable-curl) curl="no"
1100769ce76dSAlexander Graf  ;;
1101788c8196SJuan Quintela  --enable-curl) curl="yes"
1102788c8196SJuan Quintela  ;;
11032df87df7SJuan Quintela  --disable-fdt) fdt="no"
11042df87df7SJuan Quintela  ;;
11052df87df7SJuan Quintela  --enable-fdt) fdt="yes"
11062df87df7SJuan Quintela  ;;
11075c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
11085c6c3a6cSChristoph Hellwig  ;;
11095c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
11105c6c3a6cSChristoph Hellwig  ;;
1111758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1112758e8e38SVenkateswararao Jujjuri (JV)  ;;
1113758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1114758e8e38SVenkateswararao Jujjuri (JV)  ;;
111577755340Sths  --disable-blobs) blobs="no"
111677755340Sths  ;;
11174a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
11184a19f1ecSpbrook  ;;
1119519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1120519175a2SAlex Barcelo  ;;
112170c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
112270c60c08SStefan Hajnoczi  ;;
112370c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
112470c60c08SStefan Hajnoczi  ;;
11257d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
11267d992e4dSPeter Lieven  ;;
1127a25dba17SJuan Quintela  --disable-docs) docs="no"
112870ec5dc0SAnthony Liguori  ;;
1129a25dba17SJuan Quintela  --enable-docs) docs="yes"
113083a3ab8bSJuan Quintela  ;;
1131d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1132d5970055SMichael S. Tsirkin  ;;
1133d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1134d5970055SMichael S. Tsirkin  ;;
11355e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
11365e9be92dSNicholas Bellinger  ;;
11375e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
11385e9be92dSNicholas Bellinger  ;;
1139fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1140fc0b9b0eSStefan Hajnoczi  ;;
1141fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1142fc0b9b0eSStefan Hajnoczi  ;;
1143da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
114420ff075bSMichael Walle  ;;
1145da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
114620ff075bSMichael Walle  ;;
1147f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1148f27aaf4bSChristian Brunner  ;;
1149f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1150f27aaf4bSChristian Brunner  ;;
11518c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
11528c84cf11SSergei Trofimovich  ;;
11538c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
11548c84cf11SSergei Trofimovich  ;;
11557b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1156111a38b0SRobert Relyea  ;;
11577b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1158111a38b0SRobert Relyea  ;;
11592b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
11602b2325ffSGerd Hoffmann  ;;
11612b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
11622b2325ffSGerd Hoffmann  ;;
116369354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
116469354a83SHans de Goede  ;;
116569354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
116669354a83SHans de Goede  ;;
11671ece9905SAlon Levy  --disable-zlib-test) zlib="no"
11681ece9905SAlon Levy  ;;
1169b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1170b25c9dffSStefan Weil  ;;
1171607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1172607dacd0Sqiaonuohan  ;;
1173b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1174b25c9dffSStefan Weil  ;;
1175607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1176607dacd0Sqiaonuohan  ;;
11776b383c08SPeter Wu  --disable-bzip2) bzip2="no"
11786b383c08SPeter Wu  ;;
11796b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
11806b383c08SPeter Wu  ;;
1181d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1182d138cee9SMichael Roth  ;;
1183d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1184d138cee9SMichael Roth  ;;
11859dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
11869dacf32dSYossi Hindin  ;;
11879dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
11889dacf32dSYossi Hindin  ;;
1189d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1190d9840e25STomoki Sekiyama  ;;
1191d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1192d9840e25STomoki Sekiyama  ;;
1193d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1194d9840e25STomoki Sekiyama  ;;
1195d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1196d9840e25STomoki Sekiyama  ;;
1197d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1198d9840e25STomoki Sekiyama  ;;
1199d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1200d9840e25STomoki Sekiyama  ;;
12014b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
12024b1c11fdSDaniel P. Berrange  ;;
12034b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
12044b1c11fdSDaniel P. Berrange  ;;
1205f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1206f794573eSEduardo Otubo  ;;
1207f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1208f794573eSEduardo Otubo  ;;
1209eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1210eb100396SBharata B Rao  ;;
1211eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1212eb100396SBharata B Rao  ;;
121352b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
121452b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1215583f6e7bSStefan Hajnoczi  ;;
1216cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1217cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1218cb6414dfSFam Zheng  ;;
1219315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1220315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1221315d3184SFam Zheng  ;;
1222a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1223a4ccabcfSAnthony Liguori  ;;
1224a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1225a4ccabcfSAnthony Liguori  ;;
1226a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1227a1c5e949SDaniel P. Berrange  ;;
1228ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1229ddbb0d09SDaniel P. Berrange  ;;
1230ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1231ddbb0d09SDaniel P. Berrange  ;;
123291bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
123391bfcdb0SDaniel P. Berrange  ;;
123491bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
123591bfcdb0SDaniel P. Berrange  ;;
123691bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
123791bfcdb0SDaniel P. Berrange  ;;
123891bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
123991bfcdb0SDaniel P. Berrange  ;;
12402da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
12412da776dbSMichael R. Hines  ;;
12422da776dbSMichael R. Hines  --disable-rdma) rdma="no"
12432da776dbSMichael R. Hines  ;;
1244528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1245528de90aSDaniel P. Berrange  ;;
1246bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1247bbbf9bfbSStefan Weil  ;;
1248bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1249bbbf9bfbSStefan Weil  ;;
12509d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
12519d9e1521SGerd Hoffmann  ;;
12529d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
12539d9e1521SGerd Hoffmann  ;;
1254e91c793cSCole Robinson  --disable-tpm) tpm="no"
1255e91c793cSCole Robinson  ;;
1256ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1257ab214c29SStefan Berger  ;;
12580a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
12590a12ec87SRichard W.M. Jones  ;;
12600a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
12610a12ec87SRichard W.M. Jones  ;;
1262ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1263ed1701c6SDr. David Alan Gilbert  ;;
1264ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1265ed1701c6SDr. David Alan Gilbert  ;;
1266a99d57bbSWanlong Gao  --disable-numa) numa="no"
1267a99d57bbSWanlong Gao  ;;
1268a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1269a99d57bbSWanlong Gao  ;;
12702847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
12712847b469SFam Zheng  ;;
12722847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
12732847b469SFam Zheng  ;;
12747b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
12757b01cb97SAlexandre Derumier  ;;
12767b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
12777b01cb97SAlexandre Derumier  ;;
1278a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1279a6b1d4c0SChanglong Xie  ;;
1280a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1281a6b1d4c0SChanglong Xie  ;;
1282da92c3ffSAshish Mittal  --disable-vxhs) vxhs="no"
1283da92c3ffSAshish Mittal  ;;
1284da92c3ffSAshish Mittal  --enable-vxhs) vxhs="yes"
1285da92c3ffSAshish Mittal  ;;
12862d2ad6d0SFam Zheng  *)
12872d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
12882d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
12892d2ad6d0SFam Zheng      exit 1
12907f1559c6Sbalrog  ;;
12917d13299dSbellard  esac
12927d13299dSbellarddone
12937d13299dSbellard
129440293e58Sbellardcase "$cpu" in
1295e3608d66SRichard Henderson    ppc)
1296e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1297e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1298e3608d66SRichard Henderson           ;;
1299e3608d66SRichard Henderson    ppc64)
1300e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1301e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1302e3608d66SRichard Henderson           ;;
13039b9c37c3SRichard Henderson    sparc)
1304f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1305f1079bb8SRichard Henderson           LDFLAGS="-m32 -mv8plus $LDFLAGS"
13063142255cSblueswir1           ;;
1307ed968ff1SJuan Quintela    sparc64)
130879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1309f1079bb8SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
13103142255cSblueswir1           ;;
131176d83bdeSths    s390)
1312061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
131328d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
131428d7cc49SRichard Henderson           ;;
131528d7cc49SRichard Henderson    s390x)
1316061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
131728d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
131876d83bdeSths           ;;
131940293e58Sbellard    i386)
132079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
13210c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
13222b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
132340293e58Sbellard           ;;
132440293e58Sbellard    x86_64)
13257ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
13267ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
13277ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
13287ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
13290c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
13302b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1331379f6698SPaul Brook           ;;
1332c72b26ecSRichard Henderson    x32)
1333c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1334c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1335c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1336c72b26ecSRichard Henderson           ;;
133730163d89SPeter Maydell    # No special flags required for other host CPUs
13383142255cSblueswir1esac
13393142255cSblueswir1
134079f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
134179f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
134279f3b12fSPeter Crosthwaite
1343affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1344affc88ccSPeter Maydell# support, even if we're using TCI.
1345affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1346affc88ccSPeter Maydell  bsd_user="no"
1347affc88ccSPeter Maydell  linux_user="no"
1348affc88ccSPeter Maydellfi
1349affc88ccSPeter Maydell
135060e0df25SPeter Maydelldefault_target_list=""
135160e0df25SPeter Maydell
13526e92f823SPeter Maydellmak_wilds=""
13536e92f823SPeter Maydell
135460e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
13556e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
135660e0df25SPeter Maydellfi
135760e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
13586e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
135960e0df25SPeter Maydellfi
136060e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
13616e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
136260e0df25SPeter Maydellfi
136360e0df25SPeter Maydell
13646e92f823SPeter Maydellfor config in $mak_wilds; do
13656e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
13666e92f823SPeter Maydelldone
13676e92f823SPeter Maydell
1368c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
136964a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1370c53eeaf7SStefan Hajnoczi
1371af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1372af5db58eSpbrookcat << EOF
1373af5db58eSpbrook
1374af5db58eSpbrookUsage: configure [options]
1375af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1376af5db58eSpbrook
137708fb77edSStefan WeilStandard options:
137808fb77edSStefan Weil  --help                   print this message
137908fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
138008fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
138108fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
138208fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
138308fb77edSStefan Weil$(echo Available targets: $default_target_list | \
138408fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
138508fb77edSStefan Weil
138608fb77edSStefan WeilAdvanced options (experts only):
138708fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
138808fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
138908fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
139008fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
139108fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
139208fb77edSStefan Weil                           build time
139308fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
139408fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
139508fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
139611cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
139708fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
139808fb77edSStefan Weil  --make=MAKE              use specified make [$make]
139908fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
140008fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
140108fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
140208fb77edSStefan Weil  --static                 enable static build [$static]
140308fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
140408fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
140508fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
140608fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
140708fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
140808fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
140908fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1410e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
141108fb77edSStefan Weil  --enable-debug           enable common debug build options
141208fb77edSStefan Weil  --disable-strip          disable stripping binaries
141308fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
141463678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
141508fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
141608fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
141708fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
141808fb77edSStefan Weil  --block-drv-rw-whitelist=L
141908fb77edSStefan Weil                           set block driver read-write whitelist
142008fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
142108fb77edSStefan Weil  --block-drv-ro-whitelist=L
142208fb77edSStefan Weil                           set block driver read-only whitelist
142308fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
14245b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1425c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
142608fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
142708fb77edSStefan Weil                           Default:trace-<pid>
1428c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1429c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1430c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1431c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
143208fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
143333c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
143408fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
143508fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1436c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1437c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1438c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1439a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1440c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1441c12d66aaSLin Ma  --enable-profiler        profiler support
1442c12d66aaSLin Ma  --enable-xen-pv-domain-build
1443c12d66aaSLin Ma                           xen pv domain builder
1444c12d66aaSLin Ma  --enable-debug-stack-usage
1445c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
1446c23f23b9SMichael Tokarev
1447c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1448c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1449c23f23b9SMichael Tokarev
1450c23f23b9SMichael Tokarev  system          all system emulation targets
1451c23f23b9SMichael Tokarev  user            supported user emulation targets
1452c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1453c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1454c23f23b9SMichael Tokarev  docs            build documentation
1455c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1456c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1457c23f23b9SMichael Tokarev  pie             Position Independent Executables
1458c23f23b9SMichael Tokarev  modules         modules support
1459c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1460c23f23b9SMichael Tokarev  debug-info      debugging information
1461c23f23b9SMichael Tokarev  sparse          sparse checker
1462c23f23b9SMichael Tokarev
1463ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
146491bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
146591bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1466c23f23b9SMichael Tokarev  sdl             SDL UI
1467c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1468c23f23b9SMichael Tokarev  gtk             gtk UI
1469c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1470c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1471c23f23b9SMichael Tokarev  curses          curses UI
1472c23f23b9SMichael Tokarev  vnc             VNC UI support
1473c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1474c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1475c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1476c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1477c23f23b9SMichael Tokarev  virtfs          VirtFS
1478c23f23b9SMichael Tokarev  xen             xen backend driver support
1479c23f23b9SMichael Tokarev  xen-pci-passthrough
1480c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1481c23f23b9SMichael Tokarev  curl            curl connectivity
1482c23f23b9SMichael Tokarev  fdt             fdt device tree
1483c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1484c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1485b0cb0a66SVincent Palatin  hax             HAX acceleration support
1486c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1487c23f23b9SMichael Tokarev  vde             support for vde network
1488c23f23b9SMichael Tokarev  netmap          support for netmap network
1489c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1490c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1491c23f23b9SMichael Tokarev  attr            attr and xattr support
1492c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1493c23f23b9SMichael Tokarev  spice           spice
1494c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1495c23f23b9SMichael Tokarev  libiscsi        iscsi support
1496c23f23b9SMichael Tokarev  libnfs          nfs support
14977b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1498c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1499ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1500c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1501c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1502c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1503c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1504c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1505c23f23b9SMichael Tokarev  seccomp         seccomp support
1506c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1507c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1508c23f23b9SMichael Tokarev  tpm             TPM support
1509c23f23b9SMichael Tokarev  libssh2         ssh block device support
1510c23f23b9SMichael Tokarev  numa            libnuma support
1511c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
15127b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1513a6b1d4c0SChanglong Xie  replication     replication support
1514c12d66aaSLin Ma  vhost-vsock     virtio sockets device support
1515c12d66aaSLin Ma  opengl          opengl support
1516c12d66aaSLin Ma  virglrenderer   virgl rendering support
1517c12d66aaSLin Ma  xfsctl          xfsctl support
1518c12d66aaSLin Ma  qom-cast-debug  cast debugging support
1519c12d66aaSLin Ma  tools           build qemu-io, qemu-nbd and qemu-image tools
1520da92c3ffSAshish Mittal  vxhs            Veritas HyperScale vDisk backend support
152108fb77edSStefan Weil
152208fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1523af5db58eSpbrookEOF
15242d2ad6d0SFam Zhengexit 0
1525af5db58eSpbrookfi
1526af5db58eSpbrook
1527c53eeaf7SStefan Hajnocziif ! has $python; then
1528c53eeaf7SStefan Hajnoczi  error_exit "Python not found. Use --python=/path/to/python"
1529c53eeaf7SStefan Hajnoczifi
1530c53eeaf7SStefan Hajnoczi
1531c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1532c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1533c53eeaf7SStefan Hajnocziif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1534c53eeaf7SStefan Hajnoczi  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1535c53eeaf7SStefan Hajnoczi      "Note that Python 3 or later is not yet supported." \
1536c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1537c53eeaf7SStefan Hajnoczifi
1538c53eeaf7SStefan Hajnoczi
1539c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1540c53eeaf7SStefan Hajnoczipython="$python -B"
1541c53eeaf7SStefan Hajnoczi
1542359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1543359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1544359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1545359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1546359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1547359bc95dSPeter Maydell    else
154876ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1549359bc95dSPeter Maydell    fi
1550359bc95dSPeter Maydellfi
1551359bc95dSPeter Maydell
15529c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
15539c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
15549c83ffd8SPeter Maydellif test -z "$werror" ; then
15559c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1556e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
15579c83ffd8SPeter Maydell        werror="yes"
15589c83ffd8SPeter Maydell    else
15599c83ffd8SPeter Maydell        werror="no"
15609c83ffd8SPeter Maydell    fi
15619c83ffd8SPeter Maydellfi
15629c83ffd8SPeter Maydell
15638d05095cSPaolo Bonzini# check that the C compiler works.
156493b25869SJohn Snowwrite_c_skeleton;
15658d05095cSPaolo Bonziniif compile_object ; then
15668d05095cSPaolo Bonzini  : C compiler works ok
15678d05095cSPaolo Bonzinielse
156876ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
15698d05095cSPaolo Bonzinifi
15700ef74c74SPeter Maydellif ! compile_prog ; then
15710ef74c74SPeter Maydell    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
15720ef74c74SPeter Maydellfi
15738d05095cSPaolo Bonzini
1574fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1575fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1576fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1577fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1578fb59dabdSPeter Maydell    # host OS we should stop now.
1579fb59dabdSPeter Maydell    error_exit "Unrecognized host OS $targetos"
1580fb59dabdSPeter Maydellfi
1581fb59dabdSPeter Maydell
15828d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
15838d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1584ac7568bdSDaniel P. Berrangegcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1585435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1586c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
158771429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
15886ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
15896ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
15906ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
15916ca026cbSPeter Maydell# so it's too error prone.
159293b25869SJohn Snow
159393b25869SJohn Snowcc_has_warning_flag() {
159493b25869SJohn Snow    write_c_skeleton;
159593b25869SJohn Snow
1596a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1597a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1598a1d29d6cSPeter Maydell    # warning options).
159993b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
160093b25869SJohn Snow    compile_prog "-Werror $optflag" ""
160193b25869SJohn Snow}
160293b25869SJohn Snow
160393b25869SJohn Snowfor flag in $gcc_flags; do
160493b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16058d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16068d05095cSPaolo Bonzini    fi
16078d05095cSPaolo Bonzinidone
16088d05095cSPaolo Bonzini
160963678e17SSteven Noonanif test "$stack_protector" != "no"; then
1610fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1611fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1612fccd35a0SRodrigo Rebello{
1613fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1614fccd35a0SRodrigo Rebello    while (*c) {
1615fccd35a0SRodrigo Rebello        *p++ = *c++;
1616fccd35a0SRodrigo Rebello    }
1617fccd35a0SRodrigo Rebello    return 0;
1618fccd35a0SRodrigo Rebello}
1619fccd35a0SRodrigo RebelloEOF
162063678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16213b463a3fSMiroslav Rezanina  sp_on=0
162263678e17SSteven Noonan  for flag in $gcc_flags; do
1623590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1624590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1625590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1626590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
162763678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16283b463a3fSMiroslav Rezanina      sp_on=1
162963678e17SSteven Noonan      break
163063678e17SSteven Noonan    fi
163163678e17SSteven Noonan  done
16323b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
16333b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
16343b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
16353b463a3fSMiroslav Rezanina    fi
16363b463a3fSMiroslav Rezanina  fi
163737746c5eSMarc-André Lureaufi
163837746c5eSMarc-André Lureau
1639cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1640cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1641cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1642cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1643cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1644cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1645cbdd1999SPaolo Bonziniint main(void) { return 0; }
1646cbdd1999SPaolo Bonzini#else
1647cbdd1999SPaolo Bonzini#error No bug in this compiler.
1648cbdd1999SPaolo Bonzini#endif
1649cbdd1999SPaolo BonziniEOF
1650cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1651cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1652cbdd1999SPaolo Bonzinifi
1653cbdd1999SPaolo Bonzini
165440d6444eSAvi Kivityif test "$static" = "yes" ; then
1655aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1656aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1657aa0d1f44SPaolo Bonzini  fi
165840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
165976ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
166040d6444eSAvi Kivity  else
166140d6444eSAvi Kivity    pie="no"
166240d6444eSAvi Kivity  fi
166340d6444eSAvi Kivityfi
166440d6444eSAvi Kivity
1665768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1666768b7855SEmilio G. Cota  cat > $TMPC << EOF
1667768b7855SEmilio G. Cotastatic __thread int tls_var;
1668768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1669768b7855SEmilio G. CotaEOF
1670768b7855SEmilio G. Cota
1671768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1672768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1673768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1674768b7855SEmilio G. Cotafi
1675768b7855SEmilio G. Cota
167640d6444eSAvi Kivityif test "$pie" = ""; then
167740d6444eSAvi Kivity  case "$cpu-$targetos" in
1678c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
167940d6444eSAvi Kivity      ;;
168040d6444eSAvi Kivity    *)
168140d6444eSAvi Kivity      pie="no"
168240d6444eSAvi Kivity      ;;
168340d6444eSAvi Kivity  esac
168440d6444eSAvi Kivityfi
168540d6444eSAvi Kivity
168640d6444eSAvi Kivityif test "$pie" != "no" ; then
168740d6444eSAvi Kivity  cat > $TMPC << EOF
168821d4a791SAvi Kivity
168921d4a791SAvi Kivity#ifdef __linux__
169021d4a791SAvi Kivity#  define THREAD __thread
169121d4a791SAvi Kivity#else
169221d4a791SAvi Kivity#  define THREAD
169321d4a791SAvi Kivity#endif
169421d4a791SAvi Kivity
169521d4a791SAvi Kivitystatic THREAD int tls_var;
169621d4a791SAvi Kivity
169721d4a791SAvi Kivityint main(void) { return tls_var; }
169821d4a791SAvi Kivity
169940d6444eSAvi KivityEOF
170040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
170140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
170240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
170340d6444eSAvi Kivity    pie="yes"
170440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
170540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
170640d6444eSAvi Kivity    fi
170740d6444eSAvi Kivity  else
170840d6444eSAvi Kivity    if test "$pie" = "yes"; then
170976ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
171040d6444eSAvi Kivity    else
171140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
171240d6444eSAvi Kivity      pie="no"
171340d6444eSAvi Kivity    fi
171440d6444eSAvi Kivity  fi
171546eef33bSBrad
1716e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
171746eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
171846eef33bSBrad    LDFLAGS_NOPIE="-nopie"
171946eef33bSBrad  fi
172040d6444eSAvi Kivityfi
172140d6444eSAvi Kivity
172209dada40SPaolo Bonzini##########################################
172309dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
172409dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
172509dada40SPaolo Bonzini# specification is necessary
172609dada40SPaolo Bonzini
172709dada40SPaolo Bonziniif test "$cpu" = "i386"; then
172809dada40SPaolo Bonzini  cat > $TMPC << EOF
172909dada40SPaolo Bonzinistatic int sfaa(int *ptr)
173009dada40SPaolo Bonzini{
173109dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
173209dada40SPaolo Bonzini}
173309dada40SPaolo Bonzini
173409dada40SPaolo Bonziniint main(void)
173509dada40SPaolo Bonzini{
173609dada40SPaolo Bonzini  int val = 42;
17371405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
173809dada40SPaolo Bonzini  sfaa(&val);
173909dada40SPaolo Bonzini  return val;
174009dada40SPaolo Bonzini}
174109dada40SPaolo BonziniEOF
174209dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
174309dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
174409dada40SPaolo Bonzini  fi
174509dada40SPaolo Bonzinifi
174609dada40SPaolo Bonzini
174709dada40SPaolo Bonzini#########################################
1748ec530c81Sbellard# Solaris specific configure tool chain decisions
174909dada40SPaolo Bonzini
1750ec530c81Sbellardif test "$solaris" = "yes" ; then
17516792aa11SLoïc Minier  if has $install; then
17526792aa11SLoïc Minier    :
17536792aa11SLoïc Minier  else
175476ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
175576ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
175676ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1757ec530c81Sbellard  fi
175889138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
175976ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
176076ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
176176ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1762ec530c81Sbellard  fi
17636792aa11SLoïc Minier  if has ar; then
17646792aa11SLoïc Minier    :
17656792aa11SLoïc Minier  else
1766ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
176776ad07a4SPeter Maydell      error_exit "No path includes ar" \
176876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1769ec530c81Sbellard    fi
177076ad07a4SPeter Maydell    error_exit "No path includes ar"
1771ec530c81Sbellard  fi
1772ec530c81Sbellardfi
1773ec530c81Sbellard
1774afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1775d880a3baSPaolo Bonzini    for target in $default_target_list; do
1776d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
1777d880a3baSPaolo Bonzini            target_list="$target_list $target"
1778d880a3baSPaolo Bonzini    done
1779d880a3baSPaolo Bonzini    target_list="${target_list# }"
1780121afa9eSAnthony Liguorielse
178189138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1782d880a3baSPaolo Bonzini    for target in $target_list; do
178325b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
178425b48338SPeter Maydell        # friendly error message than if we let it fall through.
178525b48338SPeter Maydell        case " $default_target_list " in
178625b48338SPeter Maydell            *" $target "*)
178725b48338SPeter Maydell                ;;
178825b48338SPeter Maydell            *)
178925b48338SPeter Maydell                error_exit "Unknown target name '$target'"
179025b48338SPeter Maydell                ;;
179125b48338SPeter Maydell        esac
1792d880a3baSPaolo Bonzini        supported_target $target || exit 1
179325b48338SPeter Maydell    done
1794d880a3baSPaolo Bonzinifi
179525b48338SPeter Maydell
1796f55fe278SPaolo Bonzini# see if system emulation was really requested
1797f55fe278SPaolo Bonzinicase " $target_list " in
1798f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1799f55fe278SPaolo Bonzini  ;;
1800f55fe278SPaolo Bonzini  *) softmmu=no
1801f55fe278SPaolo Bonzini  ;;
1802f55fe278SPaolo Bonziniesac
18035327cf48Sbellard
1804249247c9SJuan Quintelafeature_not_found() {
1805249247c9SJuan Quintela  feature=$1
180621684af0SStewart Smith  remedy=$2
1807249247c9SJuan Quintela
180876ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
180921684af0SStewart Smith      "configure was not able to find it." \
181021684af0SStewart Smith      "$remedy"
1811249247c9SJuan Quintela}
1812249247c9SJuan Quintela
18137d13299dSbellard# ---
18147d13299dSbellard# big/little endian test
18157d13299dSbellardcat > $TMPC << EOF
181661cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
181761cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
181861cc919fSMike Frysingerextern int foo(short *, short *);
181961cc919fSMike Frysingerint main(int argc, char *argv[]) {
182061cc919fSMike Frysinger    return foo(big_endian, little_endian);
18217d13299dSbellard}
18227d13299dSbellardEOF
18237d13299dSbellard
182461cc919fSMike Frysingerif compile_object ; then
182561cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
182661cc919fSMike Frysinger        bigendian="yes"
182761cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
182861cc919fSMike Frysinger        bigendian="no"
18297d13299dSbellard    else
18307d13299dSbellard        echo big/little test failed
18317d13299dSbellard    fi
18327d13299dSbellardelse
183361cc919fSMike Frysinger    echo big/little test failed
18347d13299dSbellardfi
18357d13299dSbellard
1836b0a47e79SJuan Quintela##########################################
1837a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1838a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1839a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1840a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1841a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1842a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1843a30878e7SPeter Maydell    fi
1844a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1845a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1846a30878e7SPeter Maydell    fi
1847a30878e7SPeter Maydell    gtk=no
1848a30878e7SPeter Maydell    sdl=no
1849a30878e7SPeter Maydellfi
1850a30878e7SPeter Maydell
18516b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
18526b39b063SEric Blakecat > $TMPC << EOF
18536b39b063SEric Blake#include <stdint.h>
18546b39b063SEric Blake#include <stdio.h>
18556b39b063SEric Blakeint main(int argc, char *argv[]) {
18566b39b063SEric Blake    return printf("%zu", SIZE_MAX);
18576b39b063SEric Blake}
18586b39b063SEric BlakeEOF
18596b39b063SEric Blakehave_broken_size_max=no
18606b39b063SEric Blakeif ! compile_object -Werror ; then
18616b39b063SEric Blake    have_broken_size_max=yes
18626b39b063SEric Blakefi
18636b39b063SEric Blake
1864a30878e7SPeter Maydell##########################################
1865015a33bdSGonglei# L2TPV3 probe
1866015a33bdSGonglei
1867015a33bdSGongleicat > $TMPC <<EOF
1868015a33bdSGonglei#include <sys/socket.h>
1869bff6cb72SMichael Tokarev#include <linux/ip.h>
1870015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1871015a33bdSGongleiEOF
1872015a33bdSGongleiif compile_prog "" "" ; then
1873015a33bdSGonglei  l2tpv3=yes
1874015a33bdSGongleielse
1875015a33bdSGonglei  l2tpv3=no
1876015a33bdSGongleifi
1877015a33bdSGonglei
1878015a33bdSGonglei##########################################
18794d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
18804d9310f4SDaniel P. Berrange
18814d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
18824d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
18834d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
18844d9310f4SDaniel P. Berrange    #
18854d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
18864d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
18874d9310f4SDaniel P. Berrange    #
18884d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
18894d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
18904d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
18914d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
18924d9310f4SDaniel P. Berrange    # that for you.
18934d9310f4SDaniel P. Berrange    #
18944d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
18954d9310f4SDaniel P. Berrange    # are not in fact redundant.
18964d9310f4SDaniel P. Berrangecat > $TMPC << EOF
18974d9310f4SDaniel P. Berrange#include <unistd.h>
18984d9310f4SDaniel P. Berrange#include <time.h>
18994d9310f4SDaniel P. Berrange#undef localtime_r
19004d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
19014d9310f4SDaniel P. BerrangeEOF
19024d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
19034d9310f4SDaniel P. Berrange        localtime_r="yes"
19044d9310f4SDaniel P. Berrange    else
19054d9310f4SDaniel P. Berrange        localtime_r="no"
19064d9310f4SDaniel P. Berrange    fi
19074d9310f4SDaniel P. Berrangefi
19084d9310f4SDaniel P. Berrange
19094d9310f4SDaniel P. Berrange##########################################
1910779ab5e3SStefan Weil# pkg-config probe
1911779ab5e3SStefan Weil
1912779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
191376ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1914779ab5e3SStefan Weilfi
1915779ab5e3SStefan Weil
1916779ab5e3SStefan Weil##########################################
1917b0a47e79SJuan Quintela# NPTL probe
1918b0a47e79SJuan Quintela
191924cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1920bd0c5661Spbrook  cat > $TMPC <<EOF
1921bd0c5661Spbrook#include <sched.h>
192230813ceaSpbrook#include <linux/futex.h>
1923182eacc0SStefan Weilint main(void) {
1924bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1925bd0c5661Spbrook#error bork
1926bd0c5661Spbrook#endif
1927182eacc0SStefan Weil  return 0;
1928bd0c5661Spbrook}
1929bd0c5661SpbrookEOF
193024cb36a6SPeter Maydell  if ! compile_object ; then
193121684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1932b0a47e79SJuan Quintela  fi
1933bd0c5661Spbrookfi
1934bd0c5661Spbrook
193511d9f695Sbellard##########################################
193699f2dbd3SLiang Li# avx2 optimization requirement check
193799f2dbd3SLiang Li
193899f2dbd3SLiang Licat > $TMPC << EOF
19394fb8320aSDr. David Alan Gilbert#pragma GCC push_options
19404fb8320aSDr. David Alan Gilbert#pragma GCC target("avx2")
19414fb8320aSDr. David Alan Gilbert#include <cpuid.h>
19424fb8320aSDr. David Alan Gilbert#include <immintrin.h>
19434fb8320aSDr. David Alan Gilbertstatic int bar(void *a) {
19445e33a872SRichard Henderson    __m256i x = *(__m256i *)a;
19455e33a872SRichard Henderson    return _mm256_testz_si256(x, x);
19464fb8320aSDr. David Alan Gilbert}
19475e33a872SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
194899f2dbd3SLiang LiEOF
19494fb8320aSDr. David Alan Gilbertif compile_object "" ; then
195099f2dbd3SLiang Li  avx2_opt="yes"
195199f2dbd3SLiang Lifi
195299f2dbd3SLiang Li
195399f2dbd3SLiang Li#########################################
1954ac62922eSbalrog# zlib check
1955ac62922eSbalrog
19561ece9905SAlon Levyif test "$zlib" != "no" ; then
1957ac62922eSbalrog    cat > $TMPC << EOF
1958ac62922eSbalrog#include <zlib.h>
1959ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1960ac62922eSbalrogEOF
196152166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1962ac62922eSbalrog        :
1963ac62922eSbalrog    else
196476ad07a4SPeter Maydell        error_exit "zlib check failed" \
196576ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1966ac62922eSbalrog    fi
19671ece9905SAlon Levyfi
1968eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1969ac62922eSbalrog
1970ac62922eSbalrog##########################################
1971607dacd0Sqiaonuohan# lzo check
1972607dacd0Sqiaonuohan
1973607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1974607dacd0Sqiaonuohan    cat > $TMPC << EOF
1975607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1976607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1977607dacd0SqiaonuohanEOF
1978607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1979607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
1980b25c9dffSStefan Weil        lzo="yes"
1981b25c9dffSStefan Weil    else
1982b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
1983b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
1984b25c9dffSStefan Weil        fi
1985b25c9dffSStefan Weil        lzo="no"
1986b25c9dffSStefan Weil    fi
1987607dacd0Sqiaonuohanfi
1988607dacd0Sqiaonuohan
1989607dacd0Sqiaonuohan##########################################
1990607dacd0Sqiaonuohan# snappy check
1991607dacd0Sqiaonuohan
1992607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1993607dacd0Sqiaonuohan    cat > $TMPC << EOF
1994607dacd0Sqiaonuohan#include <snappy-c.h>
1995607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1996607dacd0SqiaonuohanEOF
1997607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1998607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
1999b25c9dffSStefan Weil        snappy="yes"
2000b25c9dffSStefan Weil    else
2001b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2002b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2003b25c9dffSStefan Weil        fi
2004b25c9dffSStefan Weil        snappy="no"
2005b25c9dffSStefan Weil    fi
2006607dacd0Sqiaonuohanfi
2007607dacd0Sqiaonuohan
2008607dacd0Sqiaonuohan##########################################
20096b383c08SPeter Wu# bzip2 check
20106b383c08SPeter Wu
20116b383c08SPeter Wuif test "$bzip2" != "no" ; then
20126b383c08SPeter Wu    cat > $TMPC << EOF
20136b383c08SPeter Wu#include <bzlib.h>
20146b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
20156b383c08SPeter WuEOF
20166b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
20176b383c08SPeter Wu        bzip2="yes"
20186b383c08SPeter Wu    else
20196b383c08SPeter Wu        if test "$bzip2" = "yes"; then
20206b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
20216b383c08SPeter Wu        fi
20226b383c08SPeter Wu        bzip2="no"
20236b383c08SPeter Wu    fi
20246b383c08SPeter Wufi
20256b383c08SPeter Wu
20266b383c08SPeter Wu##########################################
2027f794573eSEduardo Otubo# libseccomp check
2028f794573eSEduardo Otubo
2029f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
2030693e5910SAndrew Jones    case "$cpu" in
2031693e5910SAndrew Jones    i386|x86_64)
2032ba060c53Sdann frazier        libseccomp_minver="2.1.0"
2033693e5910SAndrew Jones        ;;
20345ce43972SJames Hogan    mips)
20355ce43972SJames Hogan        libseccomp_minver="2.2.0"
20365ce43972SJames Hogan        ;;
2037693e5910SAndrew Jones    arm|aarch64)
2038693e5910SAndrew Jones        libseccomp_minver="2.2.3"
2039693e5910SAndrew Jones        ;;
20403e684455SMichael Strosaker    ppc|ppc64)
20413e684455SMichael Strosaker        libseccomp_minver="2.3.0"
20423e684455SMichael Strosaker        ;;
2043693e5910SAndrew Jones    *)
2044693e5910SAndrew Jones        libseccomp_minver=""
2045693e5910SAndrew Jones        ;;
2046693e5910SAndrew Jones    esac
2047693e5910SAndrew Jones
2048693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
2049693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
205089138857SStefan Weil        libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
205189138857SStefan Weil        QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
2052f794573eSEduardo Otubo        seccomp="yes"
2053f794573eSEduardo Otubo    else
2054f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2055693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
2056693e5910SAndrew Jones                feature_not_found "libseccomp" \
2057693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
2058693e5910SAndrew Jones            else
2059693e5910SAndrew Jones                feature_not_found "libseccomp" \
2060693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
2061693e5910SAndrew Jones            fi
2062896848f0SEduardo Otubo        fi
2063e84d5956SYann E. MORIN        seccomp="no"
2064f794573eSEduardo Otubo    fi
2065f794573eSEduardo Otubofi
2066f794573eSEduardo Otubo##########################################
2067e37630caSaliguori# xen probe
2068e37630caSaliguori
2069fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2070c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2071c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2072c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2073c1cdd9d5SJuergen Gross
2074c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2075c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2076c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2077c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2078c1cdd9d5SJuergen Gross    xen=yes
2079c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2080c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
2081c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2082c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2083c1cdd9d5SJuergen Gross    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2084c1cdd9d5SJuergen Gross  else
2085c1cdd9d5SJuergen Gross
2086b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2087d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2088d5b93ddfSAnthony PERARD
208950ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
209050ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
209150ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
209250ced5b3SStefan Weil
209350ced5b3SStefan Weil    # Xen (any)
209450ced5b3SStefan Weil    cat > $TMPC <<EOF
209550ced5b3SStefan Weil#include <xenctrl.h>
209650ced5b3SStefan Weilint main(void) {
209750ced5b3SStefan Weil  return 0;
209850ced5b3SStefan Weil}
209950ced5b3SStefan WeilEOF
210050ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
210150ced5b3SStefan Weil      # Xen not found
210250ced5b3SStefan Weil      if test "$xen" = "yes" ; then
210321684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
210450ced5b3SStefan Weil      fi
210550ced5b3SStefan Weil      xen=no
210650ced5b3SStefan Weil
2107d5b93ddfSAnthony PERARD    # Xen unstable
210869deef08SPeter Maydell    elif
210969deef08SPeter Maydell        cat > $TMPC <<EOF &&
2110da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2111da8090ccSPaul Durrant#define __XEN_TOOLS__
2112da8090ccSPaul Durrant#include <xendevicemodel.h>
2113da8090ccSPaul Durrantint main(void) {
2114da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2115da8090ccSPaul Durrant
2116da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2117da8090ccSPaul Durrant  xendevicemodel_close(xd);
2118da8090ccSPaul Durrant
2119da8090ccSPaul Durrant  return 0;
2120da8090ccSPaul Durrant}
2121da8090ccSPaul DurrantEOF
2122da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2123da8090ccSPaul Durrant      then
2124da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2125f1167ee6SJuergen Gross      xen_ctrl_version=40900
2126da8090ccSPaul Durrant      xen=yes
2127da8090ccSPaul Durrant    elif
2128da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
21295eeb39c2SIan Campbell/*
21305eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
21315eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2132b6eb9b45SPaulina Szubarczyk *
2133b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2134b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2135b6eb9b45SPaulina Szubarczyk */
2136b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2137b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2138b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2139b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2140b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2141b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2142b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2143b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2144b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2145b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2146b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2147b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2148b6eb9b45SPaulina Szubarczyk#endif
2149b6eb9b45SPaulina Szubarczykint main(void) {
2150b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2151b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2152b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2153b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2154b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2155b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2156b6eb9b45SPaulina Szubarczyk
2157b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2158b6eb9b45SPaulina Szubarczyk
2159b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2160b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2161b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2162b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2163b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2164b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2165b6eb9b45SPaulina Szubarczyk
2166b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2167b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2168b6eb9b45SPaulina Szubarczyk
2169b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2170b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2171b6eb9b45SPaulina Szubarczyk
2172b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2173b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2174b6eb9b45SPaulina Szubarczyk
2175b6eb9b45SPaulina Szubarczyk  return 0;
2176b6eb9b45SPaulina Szubarczyk}
2177b6eb9b45SPaulina SzubarczykEOF
2178b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2179b6eb9b45SPaulina Szubarczyk      then
2180f1167ee6SJuergen Gross      xen_ctrl_version=40800
2181b6eb9b45SPaulina Szubarczyk      xen=yes
2182b6eb9b45SPaulina Szubarczyk    elif
2183b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2184b6eb9b45SPaulina Szubarczyk/*
2185b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2186b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
21875eeb39c2SIan Campbell */
21885eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
21895eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
21905eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21915eeb39c2SIan Campbell#include <xenctrl.h>
21925eeb39c2SIan Campbell#include <xenstore.h>
21935eeb39c2SIan Campbell#include <xenevtchn.h>
21945eeb39c2SIan Campbell#include <xengnttab.h>
21955eeb39c2SIan Campbell#include <xenforeignmemory.h>
21965eeb39c2SIan Campbell#include <stdint.h>
21975eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
21985eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
21995eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
22005eeb39c2SIan Campbell#endif
22015eeb39c2SIan Campbellint main(void) {
22025eeb39c2SIan Campbell  xc_interface *xc = NULL;
22035eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
22045eeb39c2SIan Campbell  xenevtchn_handle *xe;
22055eeb39c2SIan Campbell  xengnttab_handle *xg;
22065eeb39c2SIan Campbell  xen_domain_handle_t handle;
22075eeb39c2SIan Campbell
22085eeb39c2SIan Campbell  xs_daemon_open();
22095eeb39c2SIan Campbell
22105eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
22115eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
22125eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22135eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22145eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
22155eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
22165eeb39c2SIan Campbell
22175eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
22185eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
22195eeb39c2SIan Campbell
22205eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
22215eeb39c2SIan Campbell  xenevtchn_fd(xe);
22225eeb39c2SIan Campbell
22235eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
22245eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
22255eeb39c2SIan Campbell
22265eeb39c2SIan Campbell  return 0;
22275eeb39c2SIan Campbell}
22285eeb39c2SIan CampbellEOF
22295eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
22305eeb39c2SIan Campbell      then
2231f1167ee6SJuergen Gross      xen_ctrl_version=40701
22325eeb39c2SIan Campbell      xen=yes
22335eeb39c2SIan Campbell    elif
22345eeb39c2SIan Campbell        cat > $TMPC <<EOF &&
2235e37630caSaliguori#include <xenctrl.h>
2236cdadde39SRoger Pau Monne#include <stdint.h>
2237cdadde39SRoger Pau Monneint main(void) {
2238cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2239cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2240cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2241cdadde39SRoger Pau Monne  return 0;
2242cdadde39SRoger Pau Monne}
2243cdadde39SRoger Pau MonneEOF
2244cdadde39SRoger Pau Monne        compile_prog "" "$xen_libs"
2245cdadde39SRoger Pau Monne      then
2246f1167ee6SJuergen Gross      xen_ctrl_version=40700
2247cdadde39SRoger Pau Monne      xen=yes
2248cdadde39SRoger Pau Monne
2249cdadde39SRoger Pau Monne    # Xen 4.6
2250cdadde39SRoger Pau Monne    elif
2251cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2252cdadde39SRoger Pau Monne#include <xenctrl.h>
2253e108a3c1SAnthony PERARD#include <xenstore.h>
2254d5b93ddfSAnthony PERARD#include <stdint.h>
2255d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2256d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2257d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2258d5b93ddfSAnthony PERARD#endif
2259d5b93ddfSAnthony PERARDint main(void) {
2260d5b93ddfSAnthony PERARD  xc_interface *xc;
2261d5b93ddfSAnthony PERARD  xs_daemon_open();
2262d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2263d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2264d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2265b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22668688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2267d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
226820a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2269d8b441a3SJan Beulich  return 0;
2270d8b441a3SJan Beulich}
2271d8b441a3SJan BeulichEOF
2272d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2273d8b441a3SJan Beulich      then
2274f1167ee6SJuergen Gross      xen_ctrl_version=40600
2275d8b441a3SJan Beulich      xen=yes
2276d8b441a3SJan Beulich
2277d8b441a3SJan Beulich    # Xen 4.5
2278d8b441a3SJan Beulich    elif
2279d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2280d8b441a3SJan Beulich#include <xenctrl.h>
2281d8b441a3SJan Beulich#include <xenstore.h>
2282d8b441a3SJan Beulich#include <stdint.h>
2283d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2284d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2285d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2286d8b441a3SJan Beulich#endif
2287d8b441a3SJan Beulichint main(void) {
2288d8b441a3SJan Beulich  xc_interface *xc;
2289d8b441a3SJan Beulich  xs_daemon_open();
2290d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2291d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2292d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2293d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2294d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22953996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
22963996e85cSPaul Durrant  return 0;
22973996e85cSPaul Durrant}
22983996e85cSPaul DurrantEOF
22993996e85cSPaul Durrant        compile_prog "" "$xen_libs"
23003996e85cSPaul Durrant      then
2301f1167ee6SJuergen Gross      xen_ctrl_version=40500
23023996e85cSPaul Durrant      xen=yes
23033996e85cSPaul Durrant
23043996e85cSPaul Durrant    elif
23053996e85cSPaul Durrant        cat > $TMPC <<EOF &&
23063996e85cSPaul Durrant#include <xenctrl.h>
23073996e85cSPaul Durrant#include <xenstore.h>
23083996e85cSPaul Durrant#include <stdint.h>
23093996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
23103996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
23113996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
23123996e85cSPaul Durrant#endif
23133996e85cSPaul Durrantint main(void) {
23143996e85cSPaul Durrant  xc_interface *xc;
23153996e85cSPaul Durrant  xs_daemon_open();
23163996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
23173996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
23183996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
23193996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
23203996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
23218688e065SStefano Stabellini  return 0;
23228688e065SStefano Stabellini}
23238688e065SStefano StabelliniEOF
23248688e065SStefano Stabellini        compile_prog "" "$xen_libs"
232569deef08SPeter Maydell      then
2326f1167ee6SJuergen Gross      xen_ctrl_version=40200
23278688e065SStefano Stabellini      xen=yes
23288688e065SStefano Stabellini
2329e37630caSaliguori    else
2330fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2331edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2332edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2333fc321b4bSJuan Quintela      fi
2334fc321b4bSJuan Quintela      xen=no
2335e37630caSaliguori    fi
2336d5b93ddfSAnthony PERARD
2337d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2338f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
23395eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
23405eeb39c2SIan Campbell      fi
2341d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
2342d5b93ddfSAnthony PERARD    fi
2343e37630caSaliguori  fi
2344c1cdd9d5SJuergen Grossfi
2345e37630caSaliguori
2346eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2347edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2348eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2349eb6fda0fSAnthony PERARD  else
2350eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
235176ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
235276ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2353eb6fda0fSAnthony PERARD    fi
2354eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2355eb6fda0fSAnthony PERARD  fi
2356eb6fda0fSAnthony PERARDfi
2357eb6fda0fSAnthony PERARD
235864a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
235964a7ad6fSIan Campbell   test "$xen" != "yes"; then
236064a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
236164a7ad6fSIan Campbell	       "which requires Xen support."
236264a7ad6fSIan Campbellfi
236364a7ad6fSIan Campbell
2364e37630caSaliguori##########################################
2365dfffc653SJuan Quintela# Sparse probe
2366dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
23670dba6195SLoïc Minier  if has cgcc; then
2368dfffc653SJuan Quintela    sparse=yes
2369dfffc653SJuan Quintela  else
2370dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
237121684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2372dfffc653SJuan Quintela    fi
2373dfffc653SJuan Quintela    sparse=no
2374dfffc653SJuan Quintela  fi
2375dfffc653SJuan Quintelafi
2376dfffc653SJuan Quintela
2377dfffc653SJuan Quintela##########################################
2378f676c67eSJeremy White# X11 probe
2379f676c67eSJeremy Whitex11_cflags=
2380f676c67eSJeremy Whitex11_libs=-lX11
2381f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
238289138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
238389138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2384f676c67eSJeremy Whitefi
2385f676c67eSJeremy White
2386f676c67eSJeremy White##########################################
2387a4ccabcfSAnthony Liguori# GTK probe
2388a4ccabcfSAnthony Liguori
23899e04c683SStefan Weilif test "$gtkabi" = ""; then
23905fe309ffSGerd Hoffmann    # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
23915fe309ffSGerd Hoffmann    # Use 2.0 as a fallback if that is available.
23925fe309ffSGerd Hoffmann    if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
23939e04c683SStefan Weil        gtkabi=3.0
23945fe309ffSGerd Hoffmann    elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
23959e04c683SStefan Weil        gtkabi=2.0
23965fe309ffSGerd Hoffmann    else
23975fe309ffSGerd Hoffmann        gtkabi=3.0
23989e04c683SStefan Weil    fi
23999e04c683SStefan Weilfi
24009e04c683SStefan Weil
2401a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2402528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
24030a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2404528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2405528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2406bbbf9bfbSStefan Weil    else
2407bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2408bbbf9bfbSStefan Weil    fi
2409bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
241089138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
241189138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
241289138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
24130a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2414f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2415f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
24160a337ed0SGerd Hoffmann        fi
2417bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2418bbbf9bfbSStefan Weil        gtk="yes"
2419bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
24205fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2421bbbf9bfbSStefan Weil    else
2422bbbf9bfbSStefan Weil        gtk="no"
2423bbbf9bfbSStefan Weil    fi
2424bbbf9bfbSStefan Weilfi
2425bbbf9bfbSStefan Weil
2426ddbb0d09SDaniel P. Berrange
2427ddbb0d09SDaniel P. Berrange##########################################
2428ddbb0d09SDaniel P. Berrange# GNUTLS probe
2429ddbb0d09SDaniel P. Berrange
243037371299SPeter Maydellgnutls_works() {
243137371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
243237371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
243337371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
243437371299SPeter Maydell    # builds doesn't work:
243537371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
243637371299SPeter Maydell    #
243737371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
243837371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
243937371299SPeter Maydell        return 1
244037371299SPeter Maydell    fi
244137371299SPeter Maydell
244237371299SPeter Maydell    write_c_skeleton
244337371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
244437371299SPeter Maydell}
244537371299SPeter Maydell
244662893b67SDaniel P. Berrangegnutls_gcrypt=no
2447ed754746SDaniel P. Berrangegnutls_nettle=no
2448ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
244937371299SPeter Maydell    if gnutls_works; then
245089138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
245189138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2452ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2453ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2454ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2455ddbb0d09SDaniel P. Berrange        gnutls="yes"
2456ddbb0d09SDaniel P. Berrange
2457b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2458b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2459b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2460b917da4cSDaniel P. Berrange	else
2461b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2462b917da4cSDaniel P. Berrange	fi
2463b917da4cSDaniel P. Berrange
246462893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
246562893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2466ed754746SDaniel P. Berrange	    gnutls_nettle=yes
246762893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
246889138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2469ed754746SDaniel P. Berrange		*gcrypt*)
2470ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2471ed754746SDaniel P. Berrange		    gnutls_nettle=no
2472ed754746SDaniel P. Berrange		    ;;
2473ed754746SDaniel P. Berrange		*nettle*)
2474ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2475ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2476ed754746SDaniel P. Berrange		    ;;
2477ed754746SDaniel P. Berrange		*)
2478ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2479ed754746SDaniel P. Berrange		    gnutls_nettle=no
2480ed754746SDaniel P. Berrange		    ;;
248162893b67SDaniel P. Berrange	    esac
248262893b67SDaniel P. Berrange	else
248362893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2484ed754746SDaniel P. Berrange	    gnutls_nettle=no
248562893b67SDaniel P. Berrange	fi
2486ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2487ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2488ddbb0d09SDaniel P. Berrange    else
2489ddbb0d09SDaniel P. Berrange        gnutls="no"
2490b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2491ddbb0d09SDaniel P. Berrange    fi
2492ddbb0d09SDaniel P. Berrangeelse
2493b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2494ddbb0d09SDaniel P. Berrangefi
2495ddbb0d09SDaniel P. Berrange
249691bfcdb0SDaniel P. Berrange
249791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
249891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
249991bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
250091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
250191bfcdb0SDaniel P. Berrangethen
250291bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
250391bfcdb0SDaniel P. Berrange    then
250491bfcdb0SDaniel P. Berrange        gcrypt="no"
250591bfcdb0SDaniel P. Berrange    fi
250691bfcdb0SDaniel P. Berrangefi
250791bfcdb0SDaniel P. Berrange
250891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
250991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
251091bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
251191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
251291bfcdb0SDaniel P. Berrangethen
251391bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
251491bfcdb0SDaniel P. Berrange    then
251591bfcdb0SDaniel P. Berrange        nettle="no"
251691bfcdb0SDaniel P. Berrange    fi
251791bfcdb0SDaniel P. Berrangefi
251891bfcdb0SDaniel P. Berrange
251991bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
252091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
252191bfcdb0SDaniel P. Berrange    then
252291bfcdb0SDaniel P. Berrange	return 1
252391bfcdb0SDaniel P. Berrange    fi
252491bfcdb0SDaniel P. Berrange
252591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
252691bfcdb0SDaniel P. Berrange    then
252789138857SStefan Weil	host=$(libgcrypt-config --host)
252891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
252991bfcdb0SDaniel P. Berrange	then
253091bfcdb0SDaniel P. Berrange	    return 1
253191bfcdb0SDaniel P. Berrange	fi
253291bfcdb0SDaniel P. Berrange    fi
253391bfcdb0SDaniel P. Berrange
253491bfcdb0SDaniel P. Berrange    return 0
253591bfcdb0SDaniel P. Berrange}
253691bfcdb0SDaniel P. Berrange
253791bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
253891bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
253989138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
254089138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
254191bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
254291bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
254391bfcdb0SDaniel P. Berrange        # turn breaks static builds...
254491bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
254591bfcdb0SDaniel P. Berrange        then
254691bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
254791bfcdb0SDaniel P. Berrange        fi
254862893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
254962893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
255062893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
255191bfcdb0SDaniel P. Berrange        gcrypt="yes"
255291bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
255391bfcdb0SDaniel P. Berrange           nettle="no"
255491bfcdb0SDaniel P. Berrange        fi
255537788f25SDaniel P. Berrange
255637788f25SDaniel P. Berrange        cat > $TMPC << EOF
255737788f25SDaniel P. Berrange#include <gcrypt.h>
255837788f25SDaniel P. Berrangeint main(void) {
255937788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
256037788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
256137788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
256237788f25SDaniel P. Berrange return 0;
256337788f25SDaniel P. Berrange}
256437788f25SDaniel P. BerrangeEOF
256537788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
256637788f25SDaniel P. Berrange            gcrypt_kdf=yes
256737788f25SDaniel P. Berrange        fi
25681f923c70SLongpeng(Mike)
25691f923c70SLongpeng(Mike)        cat > $TMPC << EOF
25701f923c70SLongpeng(Mike)#include <gcrypt.h>
25711f923c70SLongpeng(Mike)int main(void) {
25721f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
25731f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
25741f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
25751f923c70SLongpeng(Mike)  return 0;
25761f923c70SLongpeng(Mike)}
25771f923c70SLongpeng(Mike)EOF
25781f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
25791f923c70SLongpeng(Mike)            gcrypt_hmac=yes
25801f923c70SLongpeng(Mike)        fi
258162893b67SDaniel P. Berrange    else
258291bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
258362893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
258491bfcdb0SDaniel P. Berrange        else
258591bfcdb0SDaniel P. Berrange            gcrypt="no"
258691bfcdb0SDaniel P. Berrange        fi
258762893b67SDaniel P. Berrange    fi
258862893b67SDaniel P. Berrangefi
258962893b67SDaniel P. Berrange
2590ddbb0d09SDaniel P. Berrange
259191bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2592ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
259389138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
259489138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
259589138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2596ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2597ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2598ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
259991bfcdb0SDaniel P. Berrange        nettle="yes"
2600fff2f982SDaniel P. Berrange
2601fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
26029e87a691SSteven Luo#include <stddef.h>
2603fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2604fff2f982SDaniel P. Berrangeint main(void) {
2605fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2606fff2f982SDaniel P. Berrange     return 0;
2607fff2f982SDaniel P. Berrange}
2608fff2f982SDaniel P. BerrangeEOF
2609fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2610fff2f982SDaniel P. Berrange            nettle_kdf=yes
2611fff2f982SDaniel P. Berrange        fi
2612ed754746SDaniel P. Berrange    else
261391bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2614ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
261591bfcdb0SDaniel P. Berrange        else
261691bfcdb0SDaniel P. Berrange            nettle="no"
2617ed754746SDaniel P. Berrange        fi
2618ed754746SDaniel P. Berrange    fi
261991bfcdb0SDaniel P. Berrangefi
262091bfcdb0SDaniel P. Berrange
262191bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
262291bfcdb0SDaniel P. Berrangethen
262391bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
262491bfcdb0SDaniel P. Berrangefi
2625ed754746SDaniel P. Berrange
26269a2fd434SDaniel P. Berrange##########################################
26279a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
26289a2fd434SDaniel P. Berrange
26299a2fd434SDaniel P. Berrangetasn1=yes
263090246037SDaniel P. Berrangetasn1_cflags=""
263190246037SDaniel P. Berrangetasn1_libs=""
26329a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
263389138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
263489138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
26359a2fd434SDaniel P. Berrangeelse
26369a2fd434SDaniel P. Berrange    tasn1=no
26379a2fd434SDaniel P. Berrangefi
26389a2fd434SDaniel P. Berrange
2639ed754746SDaniel P. Berrange
2640bbbf9bfbSStefan Weil##########################################
2641559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2642559607eaSDaniel P. Berrange
2643559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2644559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2645559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2646559607eaSDaniel P. Berrangefi
2647559607eaSDaniel P. Berrange
2648559607eaSDaniel P. Berrange##########################################
2649bbbf9bfbSStefan Weil# VTE probe
2650bbbf9bfbSStefan Weil
2651bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2652bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2653c6feff9eSCole Robinson      vteminversion="0.32.0"
2654c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2655c6feff9eSCole Robinson        vtepackage="vte-2.91"
2656c6feff9eSCole Robinson      else
2657528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2658c6feff9eSCole Robinson      fi
2659528de90aSDaniel P. Berrange    else
2660528de90aSDaniel P. Berrange      vtepackage="vte"
2661c6feff9eSCole Robinson      vteminversion="0.24.0"
2662528de90aSDaniel P. Berrange    fi
2663c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
266489138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
266589138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
266689138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2667bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2668bbbf9bfbSStefan Weil        vte="yes"
2669bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
26709e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2671c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
26729e04c683SStefan Weil        else
26739e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
26749e04c683SStefan Weil        fi
2675bbbf9bfbSStefan Weil    else
2676bbbf9bfbSStefan Weil        vte="no"
2677a4ccabcfSAnthony Liguori    fi
2678a4ccabcfSAnthony Liguorifi
2679a4ccabcfSAnthony Liguori
2680a4ccabcfSAnthony Liguori##########################################
268111d9f695Sbellard# SDL probe
268211d9f695Sbellard
26833ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
26843ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
268547c03744SDave Airlie
2686ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
26878f4ea9cdSGerd Hoffmann    if $pkg_config --exists "sdl2"; then
2688ee8466d0SCole Robinson        sdlabi=2.0
26898f4ea9cdSGerd Hoffmann    elif $pkg_config --exists "sdl"; then
2690ee8466d0SCole Robinson        sdlabi=1.2
26918f4ea9cdSGerd Hoffmann    else
26928f4ea9cdSGerd Hoffmann        sdlabi=2.0
2693ee8466d0SCole Robinson    fi
2694ee8466d0SCole Robinsonfi
2695ee8466d0SCole Robinson
269647c03744SDave Airlieif test $sdlabi = "2.0"; then
269747c03744SDave Airlie    sdl_config=$sdl2_config
269847c03744SDave Airlie    sdlname=sdl2
269947c03744SDave Airlie    sdlconfigname=sdl2_config
2700e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
270147c03744SDave Airlie    sdlname=sdl
270247c03744SDave Airlie    sdlconfigname=sdl_config
2703e07047cfSCole Robinsonelse
2704e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
27053ec87ffeSPaolo Bonzinifi
27063ec87ffeSPaolo Bonzini
270789138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
270847c03744SDave Airlie  sdl_config=$sdlconfigname
270947c03744SDave Airliefi
271047c03744SDave Airlie
271147c03744SDave Airlieif $pkg_config $sdlname --exists; then
271247c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
271389138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
27143ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
27153ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
271689138857SStefan Weil  sdlversion=$($sdlconfig --version)
2717a0dfd8a4SLoïc Minierelse
2718a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
27198f4ea9cdSGerd Hoffmann    feature_not_found "sdl" "Install SDL2-devel"
2720a0dfd8a4SLoïc Minier  fi
2721a0dfd8a4SLoïc Minier  sdl=no
27229316f803SPaolo Bonzinifi
272329e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
27243ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
27253ec87ffeSPaolo Bonzinifi
272611d9f695Sbellard
27279316f803SPaolo Bonzinisdl_too_old=no
2728c4198157SJuan Quintelaif test "$sdl" != "no" ; then
272911d9f695Sbellard  cat > $TMPC << EOF
273011d9f695Sbellard#include <SDL.h>
273111d9f695Sbellard#undef main /* We don't want SDL to override our main() */
273211d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
273311d9f695SbellardEOF
273489138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
273574f42e18STeLeMan  if test "$static" = "yes" ; then
27365f37e6d4SThomas Huth    if $pkg_config $sdlname --exists; then
27375f37e6d4SThomas Huth      sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
27385f37e6d4SThomas Huth    else
273989138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
27405f37e6d4SThomas Huth    fi
274174f42e18STeLeMan  else
274289138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
274374f42e18STeLeMan  fi
274452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
274589138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
274611d9f695Sbellard      sdl_too_old=yes
274711d9f695Sbellard    else
274811d9f695Sbellard      sdl=yes
274911d9f695Sbellard    fi
27507c1f25b4Sbellard
275167c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
27521ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
275367c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
275489138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
275589138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
275611d9f695Sbellard      fi
275752166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
27581ac88f28SJuan Quintela	:
27591ac88f28SJuan Quintela      else
27601ac88f28SJuan Quintela        sdl=no
27617c1f25b4Sbellard      fi
27627c1f25b4Sbellard    fi # static link
2763c4198157SJuan Quintela  else # sdl not found
2764c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
276521684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2766c4198157SJuan Quintela    fi
2767c4198157SJuan Quintela    sdl=no
27687c1f25b4Sbellard  fi # sdl compile test
2769fd677642Sthsfi
277011d9f695Sbellard
27715368a422Saliguoriif test "$sdl" = "yes" ; then
27725368a422Saliguori  cat > $TMPC <<EOF
27735368a422Saliguori#include <SDL.h>
27745368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
27755368a422Saliguori#include <X11/XKBlib.h>
27765368a422Saliguori#else
27775368a422Saliguori#error No x11 support
27785368a422Saliguori#endif
27795368a422Saliguoriint main(void) { return 0; }
27805368a422SaliguoriEOF
2781f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2782f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2783f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
27845368a422Saliguori  fi
27850705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
27865368a422Saliguorifi
27875368a422Saliguori
27888f28f3fbSths##########################################
27892da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
27902da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
27912da776dbSMichael R. Hines  cat > $TMPC <<EOF
27922da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
27932da776dbSMichael R. Hinesint main(void) { return 0; }
27942da776dbSMichael R. HinesEOF
27952da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
27962da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
27972da776dbSMichael R. Hines    rdma="yes"
27982da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
27992da776dbSMichael R. Hines  else
28002da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28012da776dbSMichael R. Hines        error_exit \
28022da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
28032da776dbSMichael R. Hines            " Your options:" \
28042da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
28052da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28062da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28072da776dbSMichael R. Hines    fi
28082da776dbSMichael R. Hines    rdma="no"
28092da776dbSMichael R. Hines  fi
28102da776dbSMichael R. Hinesfi
28112da776dbSMichael R. Hines
281295c6bff3SBenoît Canet
281395c6bff3SBenoît Canet##########################################
28142f9606b3Saliguori# VNC SASL detection
2815821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
28162f9606b3Saliguori  cat > $TMPC <<EOF
28172f9606b3Saliguori#include <sasl/sasl.h>
28182f9606b3Saliguori#include <stdio.h>
28192f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
28202f9606b3SaliguoriEOF
28212f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
28222f9606b3Saliguori  vnc_sasl_cflags=""
28232f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
282452166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2825ea784e3bSJuan Quintela    vnc_sasl=yes
2826fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2827ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
28282f9606b3Saliguori  else
2829ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
283021684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2831ea784e3bSJuan Quintela    fi
2832ea784e3bSJuan Quintela    vnc_sasl=no
28332f9606b3Saliguori  fi
28342f9606b3Saliguorifi
28352f9606b3Saliguori
28362f9606b3Saliguori##########################################
28372f6f5c7aSCorentin Chary# VNC JPEG detection
2838821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
28392f6f5c7aSCorentin Charycat > $TMPC <<EOF
28402f6f5c7aSCorentin Chary#include <stdio.h>
28412f6f5c7aSCorentin Chary#include <jpeglib.h>
28422f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
28432f6f5c7aSCorentin CharyEOF
28442f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
28452f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
28462f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
28472f6f5c7aSCorentin Chary    vnc_jpeg=yes
28482f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2849ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
28502f6f5c7aSCorentin Chary  else
28512f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
285221684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
28532f6f5c7aSCorentin Chary    fi
28542f6f5c7aSCorentin Chary    vnc_jpeg=no
28552f6f5c7aSCorentin Chary  fi
28562f6f5c7aSCorentin Charyfi
28572f6f5c7aSCorentin Chary
28582f6f5c7aSCorentin Chary##########################################
2859efe556adSCorentin Chary# VNC PNG detection
2860821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2861efe556adSCorentin Charycat > $TMPC <<EOF
2862efe556adSCorentin Chary//#include <stdio.h>
2863efe556adSCorentin Chary#include <png.h>
2864832ce9c2SScott Wood#include <stddef.h>
2865efe556adSCorentin Charyint main(void) {
2866efe556adSCorentin Chary    png_structp png_ptr;
2867efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
28687edc3fedSPeter Maydell    return png_ptr != 0;
2869efe556adSCorentin Chary}
2870efe556adSCorentin CharyEOF
287165d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
287289138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
287389138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
28749af8025eSBrad  else
2875efe556adSCorentin Chary    vnc_png_cflags=""
2876efe556adSCorentin Chary    vnc_png_libs="-lpng"
28779af8025eSBrad  fi
2878efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2879efe556adSCorentin Chary    vnc_png=yes
2880efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
28819af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2882efe556adSCorentin Chary  else
2883efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
288421684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2885efe556adSCorentin Chary    fi
2886efe556adSCorentin Chary    vnc_png=no
2887efe556adSCorentin Chary  fi
2888efe556adSCorentin Charyfi
2889efe556adSCorentin Chary
2890efe556adSCorentin Chary##########################################
289176655d6dSaliguori# fnmatch() probe, used for ACL routines
289276655d6dSaliguorifnmatch="no"
289376655d6dSaliguoricat > $TMPC << EOF
289476655d6dSaliguori#include <fnmatch.h>
289576655d6dSaliguoriint main(void)
289676655d6dSaliguori{
289776655d6dSaliguori    fnmatch("foo", "foo", 0);
289876655d6dSaliguori    return 0;
289976655d6dSaliguori}
290076655d6dSaliguoriEOF
290152166aa0SJuan Quintelaif compile_prog "" "" ; then
290276655d6dSaliguori   fnmatch="yes"
290376655d6dSaliguorifi
290476655d6dSaliguori
290576655d6dSaliguori##########################################
2906c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2907dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2908dce512deSChristoph Hellwig  cat > $TMPC << EOF
2909ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2910dce512deSChristoph Hellwig#include <xfs/xfs.h>
2911dce512deSChristoph Hellwigint main(void)
2912dce512deSChristoph Hellwig{
2913dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2914dce512deSChristoph Hellwig    return 0;
2915dce512deSChristoph Hellwig}
2916dce512deSChristoph HellwigEOF
2917dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2918dce512deSChristoph Hellwig    xfs="yes"
2919dce512deSChristoph Hellwig  else
2920dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
292121684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2922dce512deSChristoph Hellwig    fi
2923dce512deSChristoph Hellwig    xfs=no
2924dce512deSChristoph Hellwig  fi
2925dce512deSChristoph Hellwigfi
2926dce512deSChristoph Hellwig
2927dce512deSChristoph Hellwig##########################################
29288a16d273Sths# vde libraries probe
2929dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29304baae0acSJuan Quintela  vde_libs="-lvdeplug"
29318a16d273Sths  cat > $TMPC << EOF
29328a16d273Sths#include <libvdeplug.h>
29334a7f0e06Spbrookint main(void)
29344a7f0e06Spbrook{
29354a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2936fea08e08SPeter Maydell    char s[] = "";
2937fea08e08SPeter Maydell    vde_open(s, s, &a);
29384a7f0e06Spbrook    return 0;
29394a7f0e06Spbrook}
29408a16d273SthsEOF
294152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29424baae0acSJuan Quintela    vde=yes
29438e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
29448e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2945dfb278bdSJuan Quintela  else
2946dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
294721684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2948dfb278bdSJuan Quintela    fi
2949dfb278bdSJuan Quintela    vde=no
29508a16d273Sths  fi
29518a16d273Sthsfi
29528a16d273Sths
29538a16d273Sths##########################################
29540a985b37SVincenzo Maffione# netmap support probe
29550a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29560a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29570a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29580a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29590a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
296058952137SVincenzo Maffioneif test "$netmap" != "no" ; then
296158952137SVincenzo Maffione  cat > $TMPC << EOF
296258952137SVincenzo Maffione#include <inttypes.h>
296358952137SVincenzo Maffione#include <net/if.h>
296458952137SVincenzo Maffione#include <net/netmap.h>
296558952137SVincenzo Maffione#include <net/netmap_user.h>
29660a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29670a985b37SVincenzo Maffione#error
29680a985b37SVincenzo Maffione#endif
296958952137SVincenzo Maffioneint main(void) { return 0; }
297058952137SVincenzo MaffioneEOF
297158952137SVincenzo Maffione  if compile_prog "" "" ; then
297258952137SVincenzo Maffione    netmap=yes
297358952137SVincenzo Maffione  else
297458952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
297558952137SVincenzo Maffione      feature_not_found "netmap"
297658952137SVincenzo Maffione    fi
297758952137SVincenzo Maffione    netmap=no
297858952137SVincenzo Maffione  fi
297958952137SVincenzo Maffionefi
298058952137SVincenzo Maffione
298158952137SVincenzo Maffione##########################################
298247e98658SCorey Bryant# libcap-ng library probe
298347e98658SCorey Bryantif test "$cap_ng" != "no" ; then
298447e98658SCorey Bryant  cap_libs="-lcap-ng"
298547e98658SCorey Bryant  cat > $TMPC << EOF
298647e98658SCorey Bryant#include <cap-ng.h>
298747e98658SCorey Bryantint main(void)
298847e98658SCorey Bryant{
298947e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
299047e98658SCorey Bryant    return 0;
299147e98658SCorey Bryant}
299247e98658SCorey BryantEOF
299347e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
299447e98658SCorey Bryant    cap_ng=yes
299547e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
299647e98658SCorey Bryant  else
299747e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
299821684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
299947e98658SCorey Bryant    fi
300047e98658SCorey Bryant    cap_ng=no
300147e98658SCorey Bryant  fi
300247e98658SCorey Bryantfi
300347e98658SCorey Bryant
300447e98658SCorey Bryant##########################################
3005c2de5c91Smalc# Sound support libraries probe
30068f28f3fbSths
3007c2de5c91Smalcaudio_drv_probe()
3008c2de5c91Smalc{
3009c2de5c91Smalc    drv=$1
3010c2de5c91Smalc    hdr=$2
3011c2de5c91Smalc    lib=$3
3012c2de5c91Smalc    exp=$4
3013c2de5c91Smalc    cfl=$5
30148f28f3fbSths        cat > $TMPC << EOF
3015c2de5c91Smalc#include <$hdr>
3016c2de5c91Smalcint main(void) { $exp }
30178f28f3fbSthsEOF
301852166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
30198f28f3fbSths        :
30208f28f3fbSths    else
302176ad07a4SPeter Maydell        error_exit "$drv check failed" \
302276ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
30238f28f3fbSths    fi
3024c2de5c91Smalc}
3025c2de5c91Smalc
302689138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3027c2de5c91Smalcfor drv in $audio_drv_list; do
3028c2de5c91Smalc    case $drv in
3029c2de5c91Smalc    alsa)
3030c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
3031e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
3032a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
3033c2de5c91Smalc    ;;
3034c2de5c91Smalc
3035b8e59f18Smalc    pa)
3036e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3037e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3038a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
303967f86e8eSJuan Quintela    audio_pt_int="yes"
3040b8e59f18Smalc    ;;
3041b8e59f18Smalc
3042373967b2SGerd Hoffmann    sdl)
3043373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3044373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3045373967b2SGerd Hoffmann    fi
3046373967b2SGerd Hoffmann    ;;
3047373967b2SGerd Hoffmann
3048997e690aSJuan Quintela    coreaudio)
3049997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
3050997e690aSJuan Quintela    ;;
3051997e690aSJuan Quintela
3052a4bf6780SJuan Quintela    dsound)
3053a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
3054d5631638Smalc      audio_win_int="yes"
3055a4bf6780SJuan Quintela    ;;
3056a4bf6780SJuan Quintela
3057a4bf6780SJuan Quintela    oss)
3058a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
3059a4bf6780SJuan Quintela    ;;
3060a4bf6780SJuan Quintela
3061373967b2SGerd Hoffmann    wav)
3062373967b2SGerd Hoffmann    # XXX: Probes for CoreAudio, DirectSound
30632f6a1ab0Sblueswir1    ;;
30642f6a1ab0Sblueswir1
3065e4c63a6aSmalc    *)
30661c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
306776ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
306876ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3069e4c63a6aSmalc    }
3070e4c63a6aSmalc    ;;
3071c2de5c91Smalc    esac
3072c2de5c91Smalcdone
30738f28f3fbSths
30744d3b6f6eSbalrog##########################################
30752e4d9fb1Saurel32# BrlAPI probe
30762e4d9fb1Saurel32
30774ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3078eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
30792e4d9fb1Saurel32  cat > $TMPC << EOF
30802e4d9fb1Saurel32#include <brlapi.h>
3081832ce9c2SScott Wood#include <stddef.h>
30822e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
30832e4d9fb1Saurel32EOF
308452166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
30852e4d9fb1Saurel32    brlapi=yes
3086264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
30874ffcedb6SJuan Quintela  else
30884ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
308921684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
30904ffcedb6SJuan Quintela    fi
30914ffcedb6SJuan Quintela    brlapi=no
3092eb82284fSJuan Quintela  fi
3093eb82284fSJuan Quintelafi
30942e4d9fb1Saurel32
30952e4d9fb1Saurel32##########################################
30964d3b6f6eSbalrog# curses probe
3097a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3098e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
30998ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
31008ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3101e095e2f3SStefan Weil  else
31027c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
31038ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3104e095e2f3SStefan Weil  fi
3105c584a6d0SJuan Quintela  curses_found=no
31064d3b6f6eSbalrog  cat > $TMPC << EOF
31078ddc5bf9SSamuel Thibault#include <locale.h>
31084d3b6f6eSbalrog#include <curses.h>
31098ddc5bf9SSamuel Thibault#include <wchar.h>
3110ef9a2524SStefan Weilint main(void) {
31118ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
31128ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3113ef9a2524SStefan Weil  resize_term(0, 0);
31148ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
31158ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
31167c703002SSamuel Thibault  add_wch(WACS_DEGREE);
3117271f37abSKamil Rytarowski  return 0;
3118ef9a2524SStefan Weil}
31194d3b6f6eSbalrogEOF
3120ecbe251fSVadim Evard  IFS=:
31218ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3122b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3123b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
31247c703002SSamuel Thibault    IFS=:
31258ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3126ecbe251fSVadim Evard      unset IFS
31278ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3128c584a6d0SJuan Quintela        curses_found=yes
31298ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
31304f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
31314f78ef9aSJuan Quintela        break
31324d3b6f6eSbalrog      fi
31334f78ef9aSJuan Quintela    done
31347c703002SSamuel Thibault    if test "$curses_found" = yes ; then
31357c703002SSamuel Thibault      break
31367c703002SSamuel Thibault    fi
31378ddc5bf9SSamuel Thibault  done
3138ecbe251fSVadim Evard  unset IFS
3139c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3140c584a6d0SJuan Quintela    curses=yes
3141c584a6d0SJuan Quintela  else
3142c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
314321684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3144c584a6d0SJuan Quintela    fi
3145c584a6d0SJuan Quintela    curses=no
3146c584a6d0SJuan Quintela  fi
31474f78ef9aSJuan Quintelafi
31484d3b6f6eSbalrog
3149414f0dabSblueswir1##########################################
3150769ce76dSAlexander Graf# curl probe
3151a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
315265d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3153a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
31544e2b0658SPaolo Bonzini  else
31554e2b0658SPaolo Bonzini    curlconfig=curl-config
31564e2b0658SPaolo Bonzini  fi
3157769ce76dSAlexander Graf  cat > $TMPC << EOF
3158769ce76dSAlexander Graf#include <curl/curl.h>
31590b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3160769ce76dSAlexander GrafEOF
316189138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
316289138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3163b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3164769ce76dSAlexander Graf    curl=yes
3165788c8196SJuan Quintela  else
3166788c8196SJuan Quintela    if test "$curl" = "yes" ; then
316721684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3168788c8196SJuan Quintela    fi
3169788c8196SJuan Quintela    curl=no
3170769ce76dSAlexander Graf  fi
3171769ce76dSAlexander Graffi # test "$curl"
3172769ce76dSAlexander Graf
3173769ce76dSAlexander Graf##########################################
3174fb599c9aSbalrog# bluez support probe
3175a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
3176e820e3f4Sbalrog  cat > $TMPC << EOF
3177e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
3178e820e3f4Sbalrogint main(void) { return bt_error(0); }
3179e820e3f4SbalrogEOF
318089138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
318189138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
318252166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3183a20a6f46SJuan Quintela    bluez=yes
3184e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3185e820e3f4Sbalrog  else
3186a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
318721684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3188a20a6f46SJuan Quintela    fi
3189e820e3f4Sbalrog    bluez="no"
3190e820e3f4Sbalrog  fi
3191fb599c9aSbalrogfi
3192fb599c9aSbalrog
3193fb599c9aSbalrog##########################################
3194e18df141SAnthony Liguori# glib support probe
3195a52d28afSPaolo Bonzini
3196ad04d8cbSPeter Maydellif test "$mingw32" = yes; then
3197ad04d8cbSPeter Maydell    glib_req_ver=2.30
3198ad04d8cbSPeter Maydellelse
3199f40685c6SJohn Snow    glib_req_ver=2.22
3200ad04d8cbSPeter Maydellfi
3201aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3202aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3203aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3204aa0d1f44SPaolo Bonzinifi
3205e26110cfSFam Zheng
32064eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
32074eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
32084eaf7202SSameeh Jubran
32094eaf7202SSameeh Jubranif test "$static" = yes -a "$mingw32" = yes; then
32104eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
32114eaf7202SSameeh Jubranfi
32124eaf7202SSameeh Jubran
3213aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3214e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
321589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
321689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
32174a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
321814015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3219957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3220e18df141SAnthony Liguori    else
3221e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3222e26110cfSFam Zheng    fi
3223e26110cfSFam Zhengdone
3224e26110cfSFam Zheng
3225977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3226977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3227977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3228977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3229977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3230977a82abSDaniel P. Berrange#include <glib.h>
3231977a82abSDaniel P. Berrange#include <unistd.h>
3232977a82abSDaniel P. Berrange
3233977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3234977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3235977a82abSDaniel P. Berrange
3236977a82abSDaniel P. Berrangeint main(void) {
3237977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3238977a82abSDaniel P. Berrange   return 0;
3239977a82abSDaniel P. Berrange}
3240977a82abSDaniel P. BerrangeEOF
3241977a82abSDaniel P. Berrange
32425919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3243977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3244977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3245977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3246977a82abSDaniel P. Berrange	       "build target"
3247977a82abSDaniel P. Berrangefi
3248977a82abSDaniel P. Berrange
32499d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
32509d41401bSMichael S. Tsirkinglib_subprocess=yes
3251a049223aSMarc-André Lureauif ! $pkg_config --atleast-version=2.38 glib-2.0; then
32529d41401bSMichael S. Tsirkin    glib_subprocess=no
32539d41401bSMichael S. Tsirkinfi
32549d41401bSMichael S. Tsirkin
3255bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3256bbbf2e04SJohn Snowcat > $TMPC << EOF
3257bbbf2e04SJohn Snow#include <glib.h>
3258bbbf2e04SJohn Snowint main(void) { return 0; }
3259bbbf2e04SJohn SnowEOF
3260bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3261bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3262bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3263bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3264bbbf2e04SJohn Snow    fi
3265bbbf2e04SJohn Snowfi
3266bbbf2e04SJohn Snow
3267e26110cfSFam Zheng##########################################
3268e26110cfSFam Zheng# SHA command probe for modules
3269e26110cfSFam Zhengif test "$modules" = yes; then
3270e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3271e26110cfSFam Zheng    for c in $shacmd_probe; do
32728ccefb91SFam Zheng        if has $c; then
3273e26110cfSFam Zheng            shacmd="$c"
3274e26110cfSFam Zheng            break
3275e26110cfSFam Zheng        fi
3276e26110cfSFam Zheng    done
3277e26110cfSFam Zheng    if test "$shacmd" = ""; then
3278e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3279e26110cfSFam Zheng    fi
3280e18df141SAnthony Liguorifi
3281e18df141SAnthony Liguori
3282e18df141SAnthony Liguori##########################################
3283e2134eb9SGerd Hoffmann# pixman support probe
3284e2134eb9SGerd Hoffmann
3285e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
328674880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
328774880fe2SRobert Schiele    pixman="none"
3288236f282cSHu Tao  elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3289e2134eb9SGerd Hoffmann    pixman="system"
3290e2134eb9SGerd Hoffmann  else
3291e2134eb9SGerd Hoffmann    pixman="internal"
3292e2134eb9SGerd Hoffmann  fi
3293e2134eb9SGerd Hoffmannfi
329474880fe2SRobert Schieleif test "$pixman" = "none"; then
329574880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
329676ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
329776ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
329876ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
329976ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
330074880fe2SRobert Schiele  fi
330174880fe2SRobert Schiele  pixman_cflags=
330274880fe2SRobert Schiele  pixman_libs=
330374880fe2SRobert Schieleelif test "$pixman" = "system"; then
3304236f282cSHu Tao  # pixman version has been checked above
330589138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
330689138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3307e2134eb9SGerd Hoffmannelse
3308e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
3309236f282cSHu Tao    error_exit "pixman >= 0.21.8 not present. Your options:" \
331076ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
331176ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
331276ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
331376ad07a4SPeter Maydell        "      git submodule update --init pixman"
3314e2134eb9SGerd Hoffmann  fi
33155ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
33165ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
33175ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3318e2134eb9SGerd Hoffmannfi
3319e2134eb9SGerd Hoffmann
3320e2134eb9SGerd Hoffmann##########################################
332117bff52bSM. Mohan Kumar# libcap probe
332217bff52bSM. Mohan Kumar
332317bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
332417bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
332517bff52bSM. Mohan Kumar#include <stdio.h>
332617bff52bSM. Mohan Kumar#include <sys/capability.h>
3327cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
332817bff52bSM. Mohan KumarEOF
332917bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
333017bff52bSM. Mohan Kumar    cap=yes
333117bff52bSM. Mohan Kumar  else
333217bff52bSM. Mohan Kumar    cap=no
333317bff52bSM. Mohan Kumar  fi
333417bff52bSM. Mohan Kumarfi
333517bff52bSM. Mohan Kumar
333617bff52bSM. Mohan Kumar##########################################
3337e5d355d1Saliguori# pthread probe
33384b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
33393c529d93Saliguori
3340e5d355d1Saliguoripthread=no
3341414f0dabSblueswir1cat > $TMPC << EOF
33423c529d93Saliguori#include <pthread.h>
33437a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
33447a42bbe4SStefan Weilint main(void) {
33457a42bbe4SStefan Weil  pthread_t thread;
33467a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
33477a42bbe4SStefan Weil  return 0;
33487a42bbe4SStefan Weil}
3349414f0dabSblueswir1EOF
3350bd00d539SAndreas Färberif compile_prog "" "" ; then
3351bd00d539SAndreas Färber  pthread=yes
3352bd00d539SAndreas Färberelse
3353de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
335452166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3355e5d355d1Saliguori      pthread=yes
3356e3c56761SPeter Portante      found=no
3357e3c56761SPeter Portante      for lib_entry in $LIBS; do
3358e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3359e3c56761SPeter Portante          found=yes
3360e3c56761SPeter Portante          break
3361e3c56761SPeter Portante        fi
3362e3c56761SPeter Portante      done
3363e3c56761SPeter Portante      if test "$found" = "no"; then
33645572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3365e3c56761SPeter Portante      fi
3366409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3367de65fe0fSSebastian Herbszt      break
3368414f0dabSblueswir1    fi
3369de65fe0fSSebastian Herbszt  done
3370bd00d539SAndreas Färberfi
3371414f0dabSblueswir1
33724617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
337376ad07a4SPeter Maydell  error_exit "pthread check failed" \
337476ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3375e5d355d1Saliguorifi
3376e5d355d1Saliguori
33775c312079SDr. David Alan Gilbert# check for pthread_setname_np
33785c312079SDr. David Alan Gilbertpthread_setname_np=no
33795c312079SDr. David Alan Gilbertcat > $TMPC << EOF
33805c312079SDr. David Alan Gilbert#include <pthread.h>
33815c312079SDr. David Alan Gilbert
33825c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
33835c312079SDr. David Alan Gilbertint main(void)
33845c312079SDr. David Alan Gilbert{
33855c312079SDr. David Alan Gilbert    pthread_t thread;
33865c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
33875c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
33885c312079SDr. David Alan Gilbert    return 0;
33895c312079SDr. David Alan Gilbert}
33905c312079SDr. David Alan GilbertEOF
33915c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
33925c312079SDr. David Alan Gilbert  pthread_setname_np=yes
33935c312079SDr. David Alan Gilbertfi
33945c312079SDr. David Alan Gilbert
3395bf9298b9Saliguori##########################################
3396f27aaf4bSChristian Brunner# rbd probe
3397f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3398f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3399f27aaf4bSChristian Brunner#include <stdio.h>
3400ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3401f27aaf4bSChristian Brunnerint main(void) {
3402ad32e9c0SJosh Durgin    rados_t cluster;
3403ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3404f27aaf4bSChristian Brunner    return 0;
3405f27aaf4bSChristian Brunner}
3406f27aaf4bSChristian BrunnerEOF
3407ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3408f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3409f27aaf4bSChristian Brunner    rbd=yes
3410f27aaf4bSChristian Brunner  else
3411f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
341221684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3413f27aaf4bSChristian Brunner    fi
3414f27aaf4bSChristian Brunner    rbd=no
3415f27aaf4bSChristian Brunner  fi
3416f27aaf4bSChristian Brunnerfi
3417f27aaf4bSChristian Brunner
3418f27aaf4bSChristian Brunner##########################################
34190a12ec87SRichard W.M. Jones# libssh2 probe
34204fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
34210a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
342265d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
342389138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
342489138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
34250a12ec87SRichard W.M. Jones    libssh2=yes
34260a12ec87SRichard W.M. Jones  else
34270a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
34284fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
34290a12ec87SRichard W.M. Jones    fi
34300a12ec87SRichard W.M. Jones    libssh2=no
34310a12ec87SRichard W.M. Jones  fi
34320a12ec87SRichard W.M. Jonesfi
34330a12ec87SRichard W.M. Jones
34340a12ec87SRichard W.M. Jones##########################################
34359a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
34369a2d462eSRichard W.M. Jones
34379a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
34389a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
34399a2d462eSRichard W.M. Jones#include <stdio.h>
34409a2d462eSRichard W.M. Jones#include <libssh2.h>
34419a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
34429a2d462eSRichard W.M. Jonesint main(void) {
34439a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
34449a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
34459a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
34469a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
34479a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
34489a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
34499a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
34509a2d462eSRichard W.M. Jones    return 0;
34519a2d462eSRichard W.M. Jones}
34529a2d462eSRichard W.M. JonesEOF
34539a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
34549a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
34559a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
34569a2d462eSRichard W.M. Jones  fi
34579a2d462eSRichard W.M. Jonesfi
34589a2d462eSRichard W.M. Jones
34599a2d462eSRichard W.M. Jones##########################################
34605c6c3a6cSChristoph Hellwig# linux-aio probe
34615c6c3a6cSChristoph Hellwig
34625c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
34635c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
34645c6c3a6cSChristoph Hellwig#include <libaio.h>
34655c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3466832ce9c2SScott Wood#include <stddef.h>
34675c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
34685c6c3a6cSChristoph HellwigEOF
34695c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
34705c6c3a6cSChristoph Hellwig    linux_aio=yes
34715c6c3a6cSChristoph Hellwig  else
34725c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
347321684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
34745c6c3a6cSChristoph Hellwig    fi
34753cfcae3cSLuiz Capitulino    linux_aio=no
34765c6c3a6cSChristoph Hellwig  fi
34775c6c3a6cSChristoph Hellwigfi
34785c6c3a6cSChristoph Hellwig
34795c6c3a6cSChristoph Hellwig##########################################
34803b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
34813b8acc11SPaolo Bonzini
34823b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
34833b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
34843b8acc11SPaolo Bonzinielse
34853b8acc11SPaolo Bonzini  tpm_passthrough=no
34863b8acc11SPaolo Bonzinifi
34873b8acc11SPaolo Bonzini
34883b8acc11SPaolo Bonzini##########################################
3489758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3490758e8e38SVenkateswararao Jujjuri (JV)
3491758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3492758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3493758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3494758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3495f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3496f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3497f2338fb4SPavel Borzenkov#else
34984f26f2b6SAvi Kivity#include <sys/xattr.h>
3499f2338fb4SPavel Borzenkov#endif
3500758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3501758e8e38SVenkateswararao Jujjuri (JV)EOF
35024f26f2b6SAvi Kivity  if compile_prog "" "" ; then
35034f26f2b6SAvi Kivity    attr=yes
35044f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3505f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3506758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3507758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
35084f26f2b6SAvi Kivity    libattr=yes
3509758e8e38SVenkateswararao Jujjuri (JV)  else
3510758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
351121684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3512758e8e38SVenkateswararao Jujjuri (JV)    fi
3513758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3514758e8e38SVenkateswararao Jujjuri (JV)  fi
3515758e8e38SVenkateswararao Jujjuri (JV)fi
3516758e8e38SVenkateswararao Jujjuri (JV)
3517758e8e38SVenkateswararao Jujjuri (JV)##########################################
3518bf9298b9Saliguori# iovec probe
3519bf9298b9Saliguoricat > $TMPC <<EOF
3520db34f0b3Sblueswir1#include <sys/types.h>
3521bf9298b9Saliguori#include <sys/uio.h>
3522db34f0b3Sblueswir1#include <unistd.h>
3523f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3524bf9298b9SaliguoriEOF
3525bf9298b9Saliguoriiovec=no
352652166aa0SJuan Quintelaif compile_prog "" "" ; then
3527bf9298b9Saliguori  iovec=yes
3528bf9298b9Saliguorifi
3529bf9298b9Saliguori
3530f652e6afSaurel32##########################################
3531ceb42de8Saliguori# preadv probe
3532ceb42de8Saliguoricat > $TMPC <<EOF
3533ceb42de8Saliguori#include <sys/types.h>
3534ceb42de8Saliguori#include <sys/uio.h>
3535ceb42de8Saliguori#include <unistd.h>
3536c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3537ceb42de8SaliguoriEOF
3538ceb42de8Saliguoripreadv=no
353952166aa0SJuan Quintelaif compile_prog "" "" ; then
3540ceb42de8Saliguori  preadv=yes
3541ceb42de8Saliguorifi
3542ceb42de8Saliguori
3543ceb42de8Saliguori##########################################
3544f652e6afSaurel32# fdt probe
3545e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3546e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3547e169e1e1SPeter Maydellfdt_required=no
3548e169e1e1SPeter Maydellfor target in $target_list; do
3549e169e1e1SPeter Maydell  case $target in
3550df1d8a1fSPaul Burton    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3551e169e1e1SPeter Maydell      fdt_required=yes
3552e169e1e1SPeter Maydell    ;;
3553e169e1e1SPeter Maydell  esac
3554e169e1e1SPeter Maydelldone
3555e169e1e1SPeter Maydell
3556e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3557e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3558e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3559e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3560e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3561e169e1e1SPeter Maydell  fi
3562e169e1e1SPeter Maydell  fdt=yes
3563e169e1e1SPeter Maydellfi
3564e169e1e1SPeter Maydell
35652df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3566b41af4baSJuan Quintela  fdt_libs="-lfdt"
356796ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
35686e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
3569f652e6afSaurel32  cat > $TMPC << EOF
357031ce0adbSThomas Huth#include <libfdt.h>
357196ce6545SPeter Crosthwaite#include <libfdt_env.h>
35726e85fce0SPaul Burtonint main(void) { fdt_first_subnode(0, 0); return 0; }
3573f652e6afSaurel32EOF
357452166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3575a540f158SPeter Crosthwaite    # system DTC is good - use it
3576f652e6afSaurel32    fdt=yes
3577a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
3578a540f158SPeter Crosthwaite    # have submodule DTC - use it
3579a540f158SPeter Crosthwaite    fdt=yes
3580a540f158SPeter Crosthwaite    dtc_internal="yes"
3581a540f158SPeter Crosthwaite    mkdir -p dtc
3582cab00a5aSMichael S. Tsirkin    if [ "$pwd_is_source_path" != "y" ] ; then
3583a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3584a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
35852df87df7SJuan Quintela    fi
3586a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3587a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3588a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
3589a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
35906e85fce0SPaul Burton    error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
35913f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
3592a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
3593a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
3594a540f158SPeter Crosthwaite  else
3595a540f158SPeter Crosthwaite    # don't have and don't want
3596de3a354aSMichael Walle    fdt_libs=
35972df87df7SJuan Quintela    fdt=no
3598f652e6afSaurel32  fi
3599f652e6afSaurel32fi
3600f652e6afSaurel32
3601a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3602a540f158SPeter Crosthwaite
360320ff075bSMichael Walle##########################################
3604fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3605b1546f32SGerd Hoffmann
3606da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3607014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3608fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3609f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3610f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3611da076ffeSGerd Hoffmann    opengl=yes
3612925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3613925a0400SGerd Hoffmann        gtk_gl="yes"
3614925a0400SGerd Hoffmann    fi
3615cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
361620ff075bSMichael Walle  else
3617da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3618dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
361920ff075bSMichael Walle    fi
3620f676c67eSJeremy White    opengl_cflags=""
3621da076ffeSGerd Hoffmann    opengl_libs=""
3622da076ffeSGerd Hoffmann    opengl=no
362320ff075bSMichael Walle  fi
362420ff075bSMichael Wallefi
362520ff075bSMichael Walle
3626014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3627014cb152SGerd Hoffmann  cat > $TMPC << EOF
3628014cb152SGerd Hoffmann#include <epoxy/egl.h>
3629014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3630014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3631014cb152SGerd Hoffmann#endif
3632014cb152SGerd Hoffmannint main(void) { return 0; }
3633014cb152SGerd HoffmannEOF
3634014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3635014cb152SGerd Hoffmann    opengl_dmabuf=yes
3636014cb152SGerd Hoffmann  fi
3637014cb152SGerd Hoffmannfi
3638c9a12e75SChrysostomos Nanakos
3639c9a12e75SChrysostomos Nanakos
3640eb100396SBharata B Rao##########################################
3641eb100396SBharata B Rao# glusterfs probe
3642eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
364365d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3644e01bee08SBharata B Rao    glusterfs="yes"
364589138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
364689138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3647d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3648d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3649d85fa9ebSJeff Cody    fi
365065d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
36510c14fb47SBharata B Rao      glusterfs_discard="yes"
36520c14fb47SBharata B Rao    fi
36537c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3654df3a429aSNiels de Vos      glusterfs_fallocate="yes"
36557c815372SBharata B Rao      glusterfs_zerofill="yes"
36567c815372SBharata B Rao    fi
3657eb100396SBharata B Rao  else
3658eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
36598efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
36608efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3661eb100396SBharata B Rao    fi
3662e01bee08SBharata B Rao    glusterfs="no"
3663eb100396SBharata B Rao  fi
3664eb100396SBharata B Raofi
3665eb100396SBharata B Rao
366639386ac7Saurel32# Check for inotify functions when we are building linux-user
36673b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36683b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36693b3f24adSaurel32# don't provide them even if kernel supports them.
36703b3f24adSaurel32#
36713b3f24adSaurel32inotify=no
36723b3f24adSaurel32cat > $TMPC << EOF
36733b3f24adSaurel32#include <sys/inotify.h>
36743b3f24adSaurel32
36753b3f24adSaurel32int
36763b3f24adSaurel32main(void)
36773b3f24adSaurel32{
36783b3f24adSaurel32	/* try to start inotify */
36798690e420Saurel32	return inotify_init();
36803b3f24adSaurel32}
36813b3f24adSaurel32EOF
368252166aa0SJuan Quintelaif compile_prog "" "" ; then
36833b3f24adSaurel32  inotify=yes
36843b3f24adSaurel32fi
36853b3f24adSaurel32
3686c05c7a73SRiku Voipioinotify1=no
3687c05c7a73SRiku Voipiocat > $TMPC << EOF
3688c05c7a73SRiku Voipio#include <sys/inotify.h>
3689c05c7a73SRiku Voipio
3690c05c7a73SRiku Voipioint
3691c05c7a73SRiku Voipiomain(void)
3692c05c7a73SRiku Voipio{
3693c05c7a73SRiku Voipio    /* try to start inotify */
3694c05c7a73SRiku Voipio    return inotify_init1(0);
3695c05c7a73SRiku Voipio}
3696c05c7a73SRiku VoipioEOF
3697c05c7a73SRiku Voipioif compile_prog "" "" ; then
3698c05c7a73SRiku Voipio  inotify1=yes
3699c05c7a73SRiku Voipiofi
3700c05c7a73SRiku Voipio
3701099d6b0fSRiku Voipio# check if pipe2 is there
3702099d6b0fSRiku Voipiopipe2=no
3703099d6b0fSRiku Voipiocat > $TMPC << EOF
3704099d6b0fSRiku Voipio#include <unistd.h>
3705099d6b0fSRiku Voipio#include <fcntl.h>
3706099d6b0fSRiku Voipio
3707099d6b0fSRiku Voipioint main(void)
3708099d6b0fSRiku Voipio{
3709099d6b0fSRiku Voipio    int pipefd[2];
37109bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3711099d6b0fSRiku Voipio}
3712099d6b0fSRiku VoipioEOF
371352166aa0SJuan Quintelaif compile_prog "" "" ; then
3714099d6b0fSRiku Voipio  pipe2=yes
3715099d6b0fSRiku Voipiofi
3716099d6b0fSRiku Voipio
371740ff6d7eSKevin Wolf# check if accept4 is there
371840ff6d7eSKevin Wolfaccept4=no
371940ff6d7eSKevin Wolfcat > $TMPC << EOF
372040ff6d7eSKevin Wolf#include <sys/socket.h>
372140ff6d7eSKevin Wolf#include <stddef.h>
372240ff6d7eSKevin Wolf
372340ff6d7eSKevin Wolfint main(void)
372440ff6d7eSKevin Wolf{
372540ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
372640ff6d7eSKevin Wolf    return 0;
372740ff6d7eSKevin Wolf}
372840ff6d7eSKevin WolfEOF
372940ff6d7eSKevin Wolfif compile_prog "" "" ; then
373040ff6d7eSKevin Wolf  accept4=yes
373140ff6d7eSKevin Wolffi
373240ff6d7eSKevin Wolf
37333ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
37343ce34dfbSvibisreenivasansplice=no
37353ce34dfbSvibisreenivasancat > $TMPC << EOF
37363ce34dfbSvibisreenivasan#include <unistd.h>
37373ce34dfbSvibisreenivasan#include <fcntl.h>
37383ce34dfbSvibisreenivasan#include <limits.h>
37393ce34dfbSvibisreenivasan
37403ce34dfbSvibisreenivasanint main(void)
37413ce34dfbSvibisreenivasan{
374266ea0f22SStefan Weil    int len, fd = 0;
37433ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
37443ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
37453ce34dfbSvibisreenivasan    return 0;
37463ce34dfbSvibisreenivasan}
37473ce34dfbSvibisreenivasanEOF
374852166aa0SJuan Quintelaif compile_prog "" "" ; then
37493ce34dfbSvibisreenivasan  splice=yes
37503ce34dfbSvibisreenivasanfi
37513ce34dfbSvibisreenivasan
3752dcc38d1cSMarcelo Tosatti##########################################
3753a99d57bbSWanlong Gao# libnuma probe
3754a99d57bbSWanlong Gao
3755a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3756a99d57bbSWanlong Gao  cat > $TMPC << EOF
3757a99d57bbSWanlong Gao#include <numa.h>
3758a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3759a99d57bbSWanlong GaoEOF
3760a99d57bbSWanlong Gao
3761a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3762a99d57bbSWanlong Gao    numa=yes
3763a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3764a99d57bbSWanlong Gao  else
3765a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3766a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3767a99d57bbSWanlong Gao    fi
3768a99d57bbSWanlong Gao    numa=no
3769a99d57bbSWanlong Gao  fi
3770a99d57bbSWanlong Gaofi
3771a99d57bbSWanlong Gao
37727b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37737b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37747b01cb97SAlexandre Derumier    exit 1
37757b01cb97SAlexandre Derumierfi
37767b01cb97SAlexandre Derumier
3777a99d57bbSWanlong Gao##########################################
37782847b469SFam Zheng# tcmalloc probe
37792847b469SFam Zheng
37802847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
37812847b469SFam Zheng  cat > $TMPC << EOF
37822847b469SFam Zheng#include <stdlib.h>
37832847b469SFam Zhengint main(void) { malloc(1); return 0; }
37842847b469SFam ZhengEOF
37852847b469SFam Zheng
37862847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
37872847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
37882847b469SFam Zheng  else
37892847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
37902847b469SFam Zheng  fi
37912847b469SFam Zhengfi
37922847b469SFam Zheng
37932847b469SFam Zheng##########################################
37947b01cb97SAlexandre Derumier# jemalloc probe
37957b01cb97SAlexandre Derumier
37967b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
37977b01cb97SAlexandre Derumier  cat > $TMPC << EOF
37987b01cb97SAlexandre Derumier#include <stdlib.h>
37997b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
38007b01cb97SAlexandre DerumierEOF
38017b01cb97SAlexandre Derumier
38027b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
38037b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
38047b01cb97SAlexandre Derumier  else
38057b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
38067b01cb97SAlexandre Derumier  fi
38077b01cb97SAlexandre Derumierfi
38087b01cb97SAlexandre Derumier
38097b01cb97SAlexandre Derumier##########################################
3810dcc38d1cSMarcelo Tosatti# signalfd probe
3811dcc38d1cSMarcelo Tosattisignalfd="no"
3812dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3813dcc38d1cSMarcelo Tosatti#include <unistd.h>
3814dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3815dcc38d1cSMarcelo Tosatti#include <signal.h>
3816dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3817dcc38d1cSMarcelo TosattiEOF
3818dcc38d1cSMarcelo Tosatti
3819dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3820dcc38d1cSMarcelo Tosatti  signalfd=yes
3821dcc38d1cSMarcelo Tosattifi
3822dcc38d1cSMarcelo Tosatti
3823c2882b96SRiku Voipio# check if eventfd is supported
3824c2882b96SRiku Voipioeventfd=no
3825c2882b96SRiku Voipiocat > $TMPC << EOF
3826c2882b96SRiku Voipio#include <sys/eventfd.h>
3827c2882b96SRiku Voipio
3828c2882b96SRiku Voipioint main(void)
3829c2882b96SRiku Voipio{
383055cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3831c2882b96SRiku Voipio}
3832c2882b96SRiku VoipioEOF
3833c2882b96SRiku Voipioif compile_prog "" "" ; then
3834c2882b96SRiku Voipio  eventfd=yes
3835c2882b96SRiku Voipiofi
3836c2882b96SRiku Voipio
3837751bcc39SMarc-André Lureau# check if memfd is supported
3838751bcc39SMarc-André Lureaumemfd=no
3839751bcc39SMarc-André Lureaucat > $TMPC << EOF
3840751bcc39SMarc-André Lureau#include <sys/memfd.h>
3841751bcc39SMarc-André Lureau
3842751bcc39SMarc-André Lureauint main(void)
3843751bcc39SMarc-André Lureau{
3844751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3845751bcc39SMarc-André Lureau}
3846751bcc39SMarc-André LureauEOF
3847751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3848751bcc39SMarc-André Lureau  memfd=yes
3849751bcc39SMarc-André Lureaufi
3850751bcc39SMarc-André Lureau
3851751bcc39SMarc-André Lureau
3852751bcc39SMarc-André Lureau
3853d0927938SUlrich Hecht# check for fallocate
3854d0927938SUlrich Hechtfallocate=no
3855d0927938SUlrich Hechtcat > $TMPC << EOF
3856d0927938SUlrich Hecht#include <fcntl.h>
3857d0927938SUlrich Hecht
3858d0927938SUlrich Hechtint main(void)
3859d0927938SUlrich Hecht{
3860d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3861d0927938SUlrich Hecht    return 0;
3862d0927938SUlrich Hecht}
3863d0927938SUlrich HechtEOF
38648fb03151SPeter Maydellif compile_prog "" "" ; then
3865d0927938SUlrich Hecht  fallocate=yes
3866d0927938SUlrich Hechtfi
3867d0927938SUlrich Hecht
38683d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38693d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38703d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38713d4fa43eSKusanagi Kouichi#include <fcntl.h>
38723d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38733d4fa43eSKusanagi Kouichi
38743d4fa43eSKusanagi Kouichiint main(void)
38753d4fa43eSKusanagi Kouichi{
38763d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38773d4fa43eSKusanagi Kouichi    return 0;
38783d4fa43eSKusanagi Kouichi}
38793d4fa43eSKusanagi KouichiEOF
38803d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38813d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38823d4fa43eSKusanagi Kouichifi
38833d4fa43eSKusanagi Kouichi
3884b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3885b953f075SDenis V. Lunevfallocate_zero_range=no
3886b953f075SDenis V. Lunevcat > $TMPC << EOF
3887b953f075SDenis V. Lunev#include <fcntl.h>
3888b953f075SDenis V. Lunev#include <linux/falloc.h>
3889b953f075SDenis V. Lunev
3890b953f075SDenis V. Lunevint main(void)
3891b953f075SDenis V. Lunev{
3892b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3893b953f075SDenis V. Lunev    return 0;
3894b953f075SDenis V. Lunev}
3895b953f075SDenis V. LunevEOF
3896b953f075SDenis V. Lunevif compile_prog "" "" ; then
3897b953f075SDenis V. Lunev  fallocate_zero_range=yes
3898b953f075SDenis V. Lunevfi
3899b953f075SDenis V. Lunev
3900ed911435SKevin Wolf# check for posix_fallocate
3901ed911435SKevin Wolfposix_fallocate=no
3902ed911435SKevin Wolfcat > $TMPC << EOF
3903ed911435SKevin Wolf#include <fcntl.h>
3904ed911435SKevin Wolf
3905ed911435SKevin Wolfint main(void)
3906ed911435SKevin Wolf{
3907ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3908ed911435SKevin Wolf    return 0;
3909ed911435SKevin Wolf}
3910ed911435SKevin WolfEOF
3911ed911435SKevin Wolfif compile_prog "" "" ; then
3912ed911435SKevin Wolf    posix_fallocate=yes
3913ed911435SKevin Wolffi
3914ed911435SKevin Wolf
3915c727f47dSPeter Maydell# check for sync_file_range
3916c727f47dSPeter Maydellsync_file_range=no
3917c727f47dSPeter Maydellcat > $TMPC << EOF
3918c727f47dSPeter Maydell#include <fcntl.h>
3919c727f47dSPeter Maydell
3920c727f47dSPeter Maydellint main(void)
3921c727f47dSPeter Maydell{
3922c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3923c727f47dSPeter Maydell    return 0;
3924c727f47dSPeter Maydell}
3925c727f47dSPeter MaydellEOF
39268fb03151SPeter Maydellif compile_prog "" "" ; then
3927c727f47dSPeter Maydell  sync_file_range=yes
3928c727f47dSPeter Maydellfi
3929c727f47dSPeter Maydell
3930dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3931dace20dcSPeter Maydellfiemap=no
3932dace20dcSPeter Maydellcat > $TMPC << EOF
3933dace20dcSPeter Maydell#include <sys/ioctl.h>
3934dace20dcSPeter Maydell#include <linux/fs.h>
3935dace20dcSPeter Maydell#include <linux/fiemap.h>
3936dace20dcSPeter Maydell
3937dace20dcSPeter Maydellint main(void)
3938dace20dcSPeter Maydell{
3939dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3940dace20dcSPeter Maydell    return 0;
3941dace20dcSPeter Maydell}
3942dace20dcSPeter MaydellEOF
39438fb03151SPeter Maydellif compile_prog "" "" ; then
3944dace20dcSPeter Maydell  fiemap=yes
3945dace20dcSPeter Maydellfi
3946dace20dcSPeter Maydell
3947d0927938SUlrich Hecht# check for dup3
3948d0927938SUlrich Hechtdup3=no
3949d0927938SUlrich Hechtcat > $TMPC << EOF
3950d0927938SUlrich Hecht#include <unistd.h>
3951d0927938SUlrich Hecht
3952d0927938SUlrich Hechtint main(void)
3953d0927938SUlrich Hecht{
3954d0927938SUlrich Hecht    dup3(0, 0, 0);
3955d0927938SUlrich Hecht    return 0;
3956d0927938SUlrich Hecht}
3957d0927938SUlrich HechtEOF
395878f5d726SJan Kiszkaif compile_prog "" "" ; then
3959d0927938SUlrich Hecht  dup3=yes
3960d0927938SUlrich Hechtfi
3961d0927938SUlrich Hecht
39624e0c6529SAlex Bligh# check for ppoll support
39634e0c6529SAlex Blighppoll=no
39644e0c6529SAlex Blighcat > $TMPC << EOF
39654e0c6529SAlex Bligh#include <poll.h>
39664e0c6529SAlex Bligh
39674e0c6529SAlex Blighint main(void)
39684e0c6529SAlex Bligh{
39694e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39704e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39714e0c6529SAlex Bligh    return 0;
39724e0c6529SAlex Bligh}
39734e0c6529SAlex BlighEOF
39744e0c6529SAlex Blighif compile_prog "" "" ; then
39754e0c6529SAlex Bligh  ppoll=yes
39764e0c6529SAlex Blighfi
39774e0c6529SAlex Bligh
3978cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3979cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3980cd758dd0SAlex Blighcat > $TMPC << EOF
3981cd758dd0SAlex Bligh#include <sys/prctl.h>
3982cd758dd0SAlex Bligh
3983cd758dd0SAlex Blighint main(void)
3984cd758dd0SAlex Bligh{
3985cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3986cd758dd0SAlex Bligh    return 0;
3987cd758dd0SAlex Bligh}
3988cd758dd0SAlex BlighEOF
3989cd758dd0SAlex Blighif compile_prog "" "" ; then
3990cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3991cd758dd0SAlex Blighfi
3992cd758dd0SAlex Bligh
39933b6edd16SPeter Maydell# check for epoll support
39943b6edd16SPeter Maydellepoll=no
39953b6edd16SPeter Maydellcat > $TMPC << EOF
39963b6edd16SPeter Maydell#include <sys/epoll.h>
39973b6edd16SPeter Maydell
39983b6edd16SPeter Maydellint main(void)
39993b6edd16SPeter Maydell{
40003b6edd16SPeter Maydell    epoll_create(0);
40013b6edd16SPeter Maydell    return 0;
40023b6edd16SPeter Maydell}
40033b6edd16SPeter MaydellEOF
40048fb03151SPeter Maydellif compile_prog "" "" ; then
40053b6edd16SPeter Maydell  epoll=yes
40063b6edd16SPeter Maydellfi
40073b6edd16SPeter Maydell
4008227f0214SPeter Maydell# epoll_create1 is a later addition
4009227f0214SPeter Maydell# so we must check separately for its presence
40103b6edd16SPeter Maydellepoll_create1=no
40113b6edd16SPeter Maydellcat > $TMPC << EOF
40123b6edd16SPeter Maydell#include <sys/epoll.h>
40133b6edd16SPeter Maydell
40143b6edd16SPeter Maydellint main(void)
40153b6edd16SPeter Maydell{
401619e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
401719e83f6bSPeter Maydell     * a function being called. This is necessary so that on
401819e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
401919e83f6bSPeter Maydell     * the library but not declared in the header file we will
402019e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
402119e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
402219e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
402319e83f6bSPeter Maydell     */
4024c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
40253b6edd16SPeter Maydell}
40263b6edd16SPeter MaydellEOF
40278fb03151SPeter Maydellif compile_prog "" "" ; then
40283b6edd16SPeter Maydell  epoll_create1=yes
40293b6edd16SPeter Maydellfi
40303b6edd16SPeter Maydell
4031a8fd1abaSPeter Maydell# check for sendfile support
4032a8fd1abaSPeter Maydellsendfile=no
4033a8fd1abaSPeter Maydellcat > $TMPC << EOF
4034a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4035a8fd1abaSPeter Maydell
4036a8fd1abaSPeter Maydellint main(void)
4037a8fd1abaSPeter Maydell{
4038a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4039a8fd1abaSPeter Maydell}
4040a8fd1abaSPeter MaydellEOF
4041a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4042a8fd1abaSPeter Maydell  sendfile=yes
4043a8fd1abaSPeter Maydellfi
4044a8fd1abaSPeter Maydell
404551834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
404651834341SRiku Voipiotimerfd=no
404751834341SRiku Voipiocat > $TMPC << EOF
404851834341SRiku Voipio#include <sys/timerfd.h>
404951834341SRiku Voipio
405051834341SRiku Voipioint main(void)
405151834341SRiku Voipio{
405251834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
405351834341SRiku Voipio}
405451834341SRiku VoipioEOF
405551834341SRiku Voipioif compile_prog "" "" ; then
405651834341SRiku Voipio  timerfd=yes
405751834341SRiku Voipiofi
405851834341SRiku Voipio
40599af5c906SRiku Voipio# check for setns and unshare support
40609af5c906SRiku Voipiosetns=no
40619af5c906SRiku Voipiocat > $TMPC << EOF
40629af5c906SRiku Voipio#include <sched.h>
40639af5c906SRiku Voipio
40649af5c906SRiku Voipioint main(void)
40659af5c906SRiku Voipio{
40669af5c906SRiku Voipio    int ret;
40679af5c906SRiku Voipio    ret = setns(0, 0);
40689af5c906SRiku Voipio    ret = unshare(0);
40699af5c906SRiku Voipio    return ret;
40709af5c906SRiku Voipio}
40719af5c906SRiku VoipioEOF
40729af5c906SRiku Voipioif compile_prog "" "" ; then
40739af5c906SRiku Voipio  setns=yes
40749af5c906SRiku Voipiofi
40759af5c906SRiku Voipio
407638860a03SAleksandar Markovic# clock_adjtime probe
407738860a03SAleksandar Markovicclock_adjtime=no
407838860a03SAleksandar Markoviccat > $TMPC <<EOF
407938860a03SAleksandar Markovic#include <time.h>
408038860a03SAleksandar Markovic
408138860a03SAleksandar Markovicint main(void)
408238860a03SAleksandar Markovic{
408338860a03SAleksandar Markovic    return clock_adjtime(0, 0);
408438860a03SAleksandar Markovic}
408538860a03SAleksandar MarkovicEOF
408638860a03SAleksandar Markovicclock_adjtime=no
408738860a03SAleksandar Markovicif compile_prog "" "" ; then
408838860a03SAleksandar Markovic  clock_adjtime=yes
408938860a03SAleksandar Markovicfi
409038860a03SAleksandar Markovic
40915a03cd00SAleksandar Markovic# syncfs probe
40925a03cd00SAleksandar Markovicsyncfs=no
40935a03cd00SAleksandar Markoviccat > $TMPC <<EOF
40945a03cd00SAleksandar Markovic#include <unistd.h>
40955a03cd00SAleksandar Markovic
40965a03cd00SAleksandar Markovicint main(void)
40975a03cd00SAleksandar Markovic{
40985a03cd00SAleksandar Markovic    return syncfs(0);
40995a03cd00SAleksandar Markovic}
41005a03cd00SAleksandar MarkovicEOF
41015a03cd00SAleksandar Markovicsyncfs=no
41025a03cd00SAleksandar Markovicif compile_prog "" "" ; then
41035a03cd00SAleksandar Markovic  syncfs=yes
41045a03cd00SAleksandar Markovicfi
41055a03cd00SAleksandar Markovic
4106cc8ae6deSpbrook# Check if tools are available to build documentation.
4107a25dba17SJuan Quintelaif test "$docs" != "no" ; then
410801668d98SStefan Weil  if has makeinfo && has pod2man; then
4109a25dba17SJuan Quintela    docs=yes
411083a3ab8bSJuan Quintela  else
4111a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
411221684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
411383a3ab8bSJuan Quintela    fi
4114a25dba17SJuan Quintela    docs=no
411583a3ab8bSJuan Quintela  fi
4116cc8ae6deSpbrookfi
4117cc8ae6deSpbrook
4118f514f41cSStefan Weil# Search for bswap_32 function
41196ae9a1f4SJuan Quintelabyteswap_h=no
41206ae9a1f4SJuan Quintelacat > $TMPC << EOF
41216ae9a1f4SJuan Quintela#include <byteswap.h>
41226ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
41236ae9a1f4SJuan QuintelaEOF
412452166aa0SJuan Quintelaif compile_prog "" "" ; then
41256ae9a1f4SJuan Quintela  byteswap_h=yes
41266ae9a1f4SJuan Quintelafi
41276ae9a1f4SJuan Quintela
412875f13596SStefan Weil# Search for bswap32 function
41296ae9a1f4SJuan Quintelabswap_h=no
41306ae9a1f4SJuan Quintelacat > $TMPC << EOF
41316ae9a1f4SJuan Quintela#include <sys/endian.h>
41326ae9a1f4SJuan Quintela#include <sys/types.h>
41336ae9a1f4SJuan Quintela#include <machine/bswap.h>
41346ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
41356ae9a1f4SJuan QuintelaEOF
413652166aa0SJuan Quintelaif compile_prog "" "" ; then
41376ae9a1f4SJuan Quintela  bswap_h=yes
41386ae9a1f4SJuan Quintelafi
41396ae9a1f4SJuan Quintela
4140da93a1fdSaliguori##########################################
4141e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4142c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4143e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
41443c33ea96SPaolo Bonzini    libiscsi="yes"
4145ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4146ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4147c589b249SRonnie Sahlberg  else
4148c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4149e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4150c589b249SRonnie Sahlberg    fi
4151c589b249SRonnie Sahlberg    libiscsi="no"
4152c589b249SRonnie Sahlberg  fi
4153c589b249SRonnie Sahlbergfi
4154c589b249SRonnie Sahlberg
4155c589b249SRonnie Sahlberg##########################################
41568bacde8dSNatanael Copa# Do we need libm
41578bacde8dSNatanael Copacat > $TMPC << EOF
41588bacde8dSNatanael Copa#include <math.h>
4159f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
41608bacde8dSNatanael CopaEOF
41618bacde8dSNatanael Copaif compile_prog "" "" ; then
41628bacde8dSNatanael Copa  :
41638bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
41648bacde8dSNatanael Copa  LIBS="-lm $LIBS"
41658bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
41668bacde8dSNatanael Copaelse
416776ad07a4SPeter Maydell  error_exit "libm check failed"
41688bacde8dSNatanael Copafi
41698bacde8dSNatanael Copa
41708bacde8dSNatanael Copa##########################################
4171da93a1fdSaliguori# Do we need librt
41728bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
41738bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
41748bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
41758bacde8dSNatanael Copa# function in addition.
4176da93a1fdSaliguoricat > $TMPC <<EOF
4177da93a1fdSaliguori#include <signal.h>
4178da93a1fdSaliguori#include <time.h>
41798bacde8dSNatanael Copaint main(void) {
41808bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
41818bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
41828bacde8dSNatanael Copa}
4183da93a1fdSaliguoriEOF
4184da93a1fdSaliguori
418552166aa0SJuan Quintelaif compile_prog "" "" ; then
418607ffa4bdSJuan Quintela  :
41878bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
418818e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
418918e588b1SRick Liu  LIBS="$LIBS -lrt"
419018e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4191da93a1fdSaliguorifi
4192da93a1fdSaliguori
419331ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4194179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
41956362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
41966362a53fSJuan Quintelafi
41976362a53fSJuan Quintela
4198de5071c5SBlue Swirl##########################################
4199cd4ec0b4SGerd Hoffmann# spice probe
4200cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4201cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4202cd4ec0b4SGerd Hoffmann#include <spice.h>
4203cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4204cd4ec0b4SGerd HoffmannEOF
4205710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4206710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
420765d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
420865d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4209cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4210cd4ec0b4SGerd Hoffmann    spice="yes"
4211cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4212cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
42132e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
42142e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4215cd4ec0b4SGerd Hoffmann  else
4216cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
42178efc9363SHu Tao      feature_not_found "spice" \
42188efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4219cd4ec0b4SGerd Hoffmann    fi
4220cd4ec0b4SGerd Hoffmann    spice="no"
4221cd4ec0b4SGerd Hoffmann  fi
4222cd4ec0b4SGerd Hoffmannfi
4223cd4ec0b4SGerd Hoffmann
42247b02f544SMarc-André Lureau# check for smartcard support
4225111a38b0SRobert Relyeasmartcard_cflags=""
42267b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
42277b02f544SMarc-André Lureau    if $pkg_config libcacard; then
42287b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
42297b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
42307b02f544SMarc-André Lureau        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
42317b02f544SMarc-André Lureau        libs_softmmu="$libs_softmmu $libcacard_libs"
42327b02f544SMarc-André Lureau        smartcard="yes"
4233111a38b0SRobert Relyea    else
42347b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
42357b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4236111a38b0SRobert Relyea        fi
42377b02f544SMarc-André Lureau        smartcard="no"
4238111a38b0SRobert Relyea    fi
4239111a38b0SRobert Relyeafi
4240111a38b0SRobert Relyea
42412b2325ffSGerd Hoffmann# check for libusb
42422b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
424365d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
42442b2325ffSGerd Hoffmann        libusb="yes"
4245ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4246ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
42472b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
42482b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
42492b2325ffSGerd Hoffmann    else
42502b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
42518efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
42522b2325ffSGerd Hoffmann        fi
42532b2325ffSGerd Hoffmann        libusb="no"
42542b2325ffSGerd Hoffmann    fi
42552b2325ffSGerd Hoffmannfi
42562b2325ffSGerd Hoffmann
425769354a83SHans de Goede# check for usbredirparser for usb network redirection support
425869354a83SHans de Goedeif test "$usb_redir" != "no" ; then
425965d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
426069354a83SHans de Goede        usb_redir="yes"
4261ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4262ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
426369354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
426456ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
426569354a83SHans de Goede    else
426669354a83SHans de Goede        if test "$usb_redir" = "yes"; then
426721684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
426869354a83SHans de Goede        fi
426969354a83SHans de Goede        usb_redir="no"
427069354a83SHans de Goede    fi
427169354a83SHans de Goedefi
427269354a83SHans de Goede
4273cd4ec0b4SGerd Hoffmann##########################################
4274d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4275d9840e25STomoki Sekiyama
4276d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4277d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4278690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4279d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4280d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4281690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4282d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4283d9840e25STomoki Sekiyama	  ;;
4284690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4285d9840e25STomoki Sekiyama  esac
4286d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4287d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4288d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4289d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4290d9840e25STomoki SekiyamaEOF
4291d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4292d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4293d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4294315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4295f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4296d9840e25STomoki Sekiyama  else
4297d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4298d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4299d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4300d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4301d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4302d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4303d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4304d9840e25STomoki Sekiyama    fi
4305d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4306d9840e25STomoki Sekiyama  fi
4307d9840e25STomoki Sekiyamafi
4308d9840e25STomoki Sekiyama
4309d9840e25STomoki Sekiyama##########################################
4310d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4311d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4312d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4313d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4314d9840e25STomoki Sekiyama
4315d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4316d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4317d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4318d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4319d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4320d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4321d9840e25STomoki Sekiyama    else
4322d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4323d9840e25STomoki Sekiyama    fi
4324d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4325d9840e25STomoki Sekiyama    win_sdk=""
4326d9840e25STomoki Sekiyama  fi
4327d9840e25STomoki Sekiyamafi
4328d9840e25STomoki Sekiyama
4329d9840e25STomoki Sekiyama##########################################
433050cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
433150cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
433250cbebb9SMichael Roth  cat > $TMPC << EOF
433350cbebb9SMichael Roth#include <windows.h>
433450cbebb9SMichael Roth#include <ntddscsi.h>
433550cbebb9SMichael Rothint main(void) {
433650cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
433750cbebb9SMichael Roth#error Missing required ioctl definitions
433850cbebb9SMichael Roth#endif
433950cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
434050cbebb9SMichael Roth  return addr.Lun;
434150cbebb9SMichael Roth}
434250cbebb9SMichael RothEOF
434350cbebb9SMichael Roth  if compile_prog "" "" ; then
434450cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4345c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
434650cbebb9SMichael Roth  fi
434750cbebb9SMichael Rothfi
434850cbebb9SMichael Roth
434950cbebb9SMichael Roth##########################################
43509d9e1521SGerd Hoffmann# virgl renderer probe
43519d9e1521SGerd Hoffmann
43529d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
43539d9e1521SGerd Hoffmann  cat > $TMPC << EOF
43549d9e1521SGerd Hoffmann#include <virglrenderer.h>
43559d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
43569d9e1521SGerd HoffmannEOF
43579d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
43589d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
43599d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
43609d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
43619d9e1521SGerd Hoffmann    virglrenderer="yes"
43629d9e1521SGerd Hoffmann  else
43639d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
43649d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
43659d9e1521SGerd Hoffmann    fi
43669d9e1521SGerd Hoffmann    virglrenderer="no"
43679d9e1521SGerd Hoffmann  fi
43689d9e1521SGerd Hoffmannfi
43699d9e1521SGerd Hoffmann
43709d9e1521SGerd Hoffmann##########################################
43715f6b9e8fSBlue Swirl# check if we have fdatasync
43725f6b9e8fSBlue Swirl
43735f6b9e8fSBlue Swirlfdatasync=no
43745f6b9e8fSBlue Swirlcat > $TMPC << EOF
43755f6b9e8fSBlue Swirl#include <unistd.h>
4376d1722a27SAlexandre Raymondint main(void) {
4377d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4378d1722a27SAlexandre Raymondreturn fdatasync(0);
4379d1722a27SAlexandre Raymond#else
4380e172fe11SStefan Weil#error Not supported
4381d1722a27SAlexandre Raymond#endif
4382d1722a27SAlexandre Raymond}
43835f6b9e8fSBlue SwirlEOF
43845f6b9e8fSBlue Swirlif compile_prog "" "" ; then
43855f6b9e8fSBlue Swirl    fdatasync=yes
43865f6b9e8fSBlue Swirlfi
43875f6b9e8fSBlue Swirl
438894a420b1SStefan Hajnoczi##########################################
4389e78815a5SAndreas Färber# check if we have madvise
4390e78815a5SAndreas Färber
4391e78815a5SAndreas Färbermadvise=no
4392e78815a5SAndreas Färbercat > $TMPC << EOF
4393e78815a5SAndreas Färber#include <sys/types.h>
4394e78815a5SAndreas Färber#include <sys/mman.h>
4395832ce9c2SScott Wood#include <stddef.h>
4396e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4397e78815a5SAndreas FärberEOF
4398e78815a5SAndreas Färberif compile_prog "" "" ; then
4399e78815a5SAndreas Färber    madvise=yes
4400e78815a5SAndreas Färberfi
4401e78815a5SAndreas Färber
4402e78815a5SAndreas Färber##########################################
4403e78815a5SAndreas Färber# check if we have posix_madvise
4404e78815a5SAndreas Färber
4405e78815a5SAndreas Färberposix_madvise=no
4406e78815a5SAndreas Färbercat > $TMPC << EOF
4407e78815a5SAndreas Färber#include <sys/mman.h>
4408832ce9c2SScott Wood#include <stddef.h>
4409e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4410e78815a5SAndreas FärberEOF
4411e78815a5SAndreas Färberif compile_prog "" "" ; then
4412e78815a5SAndreas Färber    posix_madvise=yes
4413e78815a5SAndreas Färberfi
4414e78815a5SAndreas Färber
4415e78815a5SAndreas Färber##########################################
44160a852417SPaul Durrant# check if we have posix_syslog
44170a852417SPaul Durrant
44180a852417SPaul Durrantposix_syslog=no
44190a852417SPaul Durrantcat > $TMPC << EOF
44200a852417SPaul Durrant#include <syslog.h>
44210a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
44220a852417SPaul DurrantEOF
44230a852417SPaul Durrantif compile_prog "" "" ; then
44240a852417SPaul Durrant    posix_syslog=yes
44250a852417SPaul Durrantfi
44260a852417SPaul Durrant
44270a852417SPaul Durrant##########################################
442894a420b1SStefan Hajnoczi# check if trace backend exists
442994a420b1SStefan Hajnoczi
44305b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
443194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
44325b808275SLluís Vilanova  error_exit "invalid trace backends" \
44335b808275SLluís Vilanova      "Please choose supported trace backends."
443494a420b1SStefan Hajnoczifi
443594a420b1SStefan Hajnoczi
44367e24e92aSStefan Hajnoczi##########################################
44377e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
44385b808275SLluís Vilanovaif have_backend "ust"; then
44397e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4440bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
44417e24e92aSStefan Hajnocziint main(void) { return 0; }
44427e24e92aSStefan HajnocziEOF
4443c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4444bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
444589138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
44467e24e92aSStefan Hajnoczi    else
4447c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4448bf15f63cSMohamad Gebai    fi
4449bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
445089138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4451bf15f63cSMohamad Gebai    else
4452bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4453bf15f63cSMohamad Gebai    fi
4454bf15f63cSMohamad Gebai
4455bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4456bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4457bf15f63cSMohamad Gebai  else
4458bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44597e24e92aSStefan Hajnoczi  fi
44607e24e92aSStefan Hajnoczifi
4461b3d08c02SDaniel P. Berrange
4462b3d08c02SDaniel P. Berrange##########################################
4463b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44645b808275SLluís Vilanovaif have_backend "dtrace"; then
4465b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
446676ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4467b3d08c02SDaniel P. Berrange  fi
4468c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4469c276b17dSDaniel P. Berrange  if has 'stap' ; then
4470c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4471c276b17dSDaniel P. Berrange  fi
4472b3d08c02SDaniel P. Berrangefi
4473b3d08c02SDaniel P. Berrange
44747e24e92aSStefan Hajnoczi##########################################
4475519175a2SAlex Barcelo# check and set a backend for coroutine
4476d0e2fce5SAneesh Kumar K.V
44777c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
447833c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
447933c53c54SDaniel P. Berrange# specific one.
44807c2acc70SPeter Maydell
44817c2acc70SPeter Maydellucontext_works=no
4482d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4483d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4484d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4485cdf84806SPeter Maydell#ifdef __stub_makecontext
4486cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4487cdf84806SPeter Maydell#endif
448875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4489d0e2fce5SAneesh Kumar K.VEOF
4490d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
44917c2acc70SPeter Maydell    ucontext_works=yes
4492d0e2fce5SAneesh Kumar K.V  fi
4493519175a2SAlex Barcelofi
44947c2acc70SPeter Maydell
44957c2acc70SPeter Maydellif test "$coroutine" = ""; then
44967c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
44977c2acc70SPeter Maydell    coroutine=win32
44987c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
44997c2acc70SPeter Maydell    coroutine=ucontext
4500519175a2SAlex Barcelo  else
45017c2acc70SPeter Maydell    coroutine=sigaltstack
45027c2acc70SPeter Maydell  fi
45037c2acc70SPeter Maydellelse
45047c2acc70SPeter Maydell  case $coroutine in
45057c2acc70SPeter Maydell  windows)
45067c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
45077c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
45087c2acc70SPeter Maydell    fi
45097c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
45107c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
45117c2acc70SPeter Maydell    coroutine=win32
45127c2acc70SPeter Maydell    ;;
45137c2acc70SPeter Maydell  ucontext)
45147c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
45157c2acc70SPeter Maydell      feature_not_found "ucontext"
45167c2acc70SPeter Maydell    fi
45177c2acc70SPeter Maydell    ;;
451833c53c54SDaniel P. Berrange  sigaltstack)
45197c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
45207c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
45217c2acc70SPeter Maydell    fi
45227c2acc70SPeter Maydell    ;;
45237c2acc70SPeter Maydell  *)
452476ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
45257c2acc70SPeter Maydell    ;;
45267c2acc70SPeter Maydell  esac
4527d0e2fce5SAneesh Kumar K.Vfi
4528d0e2fce5SAneesh Kumar K.V
452970c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
453070c60c08SStefan Hajnoczi  coroutine_pool=yes
453170c60c08SStefan Hajnoczifi
453270c60c08SStefan Hajnoczi
45337d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
45347d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
45357d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
45367d992e4dSPeter Lieven  fi
45377d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
45387d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
45397d992e4dSPeter Lieven    coroutine_pool=no
45407d992e4dSPeter Lieven  fi
45417d992e4dSPeter Lievenfi
45427d992e4dSPeter Lieven
45437d992e4dSPeter Lieven
4544d0e2fce5SAneesh Kumar K.V##########################################
4545d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4546d2042378SAneesh Kumar K.V
45474e1797f9SStefan Weilopen_by_handle_at=no
4548d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4549d2042378SAneesh Kumar K.V#include <fcntl.h>
4550acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4551acc55ba8SStefan Weil# error missing definition
4552acc55ba8SStefan Weil#else
455375cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4554acc55ba8SStefan Weil#endif
4555d2042378SAneesh Kumar K.VEOF
4556d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4557d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4558d2042378SAneesh Kumar K.Vfi
4559d2042378SAneesh Kumar K.V
4560e06a765eSHarsh Prateek Bora########################################
4561e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4562e06a765eSHarsh Prateek Bora
4563e06a765eSHarsh Prateek Boralinux_magic_h=no
4564e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4565e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4566e06a765eSHarsh Prateek Boraint main(void) {
456775cafad7SStefan Weil  return 0;
4568e06a765eSHarsh Prateek Bora}
4569e06a765eSHarsh Prateek BoraEOF
4570e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4571e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4572e06a765eSHarsh Prateek Borafi
4573e06a765eSHarsh Prateek Bora
45748ab1bf12SLuiz Capitulino########################################
4575c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4576c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4577c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4578c95e3080SKevin Wolf# only a warning.
4579c95e3080SKevin Wolf#
4580c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4581c95e3080SKevin Wolf# the build doesn't fail anyway.
4582c95e3080SKevin Wolf
458306d71fa1SPeter Maydellpragma_disable_unused_but_set=no
458406d71fa1SPeter Maydellcat > $TMPC << EOF
4585e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
458606d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4587c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4588e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4589c95e3080SKevin Wolf
459006d71fa1SPeter Maydellint main(void) {
459106d71fa1SPeter Maydell    return 0;
459206d71fa1SPeter Maydell}
459306d71fa1SPeter MaydellEOF
459406d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4595cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4596c95e3080SKevin Wolfelse
4597c95e3080SKevin Wolf    werror=no
459806d71fa1SPeter Maydellfi
459906d71fa1SPeter Maydell
460006d71fa1SPeter Maydell########################################
4601541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
46023f4349dcSKevin Wolf
46033f4349dcSKevin Wolfvalgrind_h=no
46043f4349dcSKevin Wolfcat > $TMPC << EOF
46053f4349dcSKevin Wolf#include <valgrind/valgrind.h>
46063f4349dcSKevin Wolfint main(void) {
46073f4349dcSKevin Wolf  return 0;
46083f4349dcSKevin Wolf}
46093f4349dcSKevin WolfEOF
46103f4349dcSKevin Wolfif compile_prog "" "" ; then
46113f4349dcSKevin Wolf    valgrind_h=yes
46123f4349dcSKevin Wolffi
46133f4349dcSKevin Wolf
46143f4349dcSKevin Wolf########################################
46158ab1bf12SLuiz Capitulino# check if environ is declared
46168ab1bf12SLuiz Capitulino
46178ab1bf12SLuiz Capitulinohas_environ=no
46188ab1bf12SLuiz Capitulinocat > $TMPC << EOF
46198ab1bf12SLuiz Capitulino#include <unistd.h>
46208ab1bf12SLuiz Capitulinoint main(void) {
4621c075a723SBlue Swirl    environ = 0;
46228ab1bf12SLuiz Capitulino    return 0;
46238ab1bf12SLuiz Capitulino}
46248ab1bf12SLuiz CapitulinoEOF
46258ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
46268ab1bf12SLuiz Capitulino    has_environ=yes
46278ab1bf12SLuiz Capitulinofi
46288ab1bf12SLuiz Capitulino
462976a347e1SRichard Henderson########################################
463076a347e1SRichard Henderson# check if cpuid.h is usable.
463176a347e1SRichard Henderson
463276a347e1SRichard Hendersoncpuid_h=no
463376a347e1SRichard Hendersoncat > $TMPC << EOF
463476a347e1SRichard Henderson#include <cpuid.h>
463576a347e1SRichard Hendersonint main(void) {
4636774d566cSPeter Maydell    unsigned a, b, c, d;
4637774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4638774d566cSPeter Maydell
4639774d566cSPeter Maydell    if (max >= 1) {
4640774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4641774d566cSPeter Maydell    }
4642774d566cSPeter Maydell
4643774d566cSPeter Maydell    if (max >= 7) {
4644774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4645774d566cSPeter Maydell    }
4646774d566cSPeter Maydell
464776a347e1SRichard Henderson    return 0;
464876a347e1SRichard Henderson}
464976a347e1SRichard HendersonEOF
465076a347e1SRichard Hendersonif compile_prog "" "" ; then
465176a347e1SRichard Henderson    cpuid_h=yes
465276a347e1SRichard Hendersonfi
465376a347e1SRichard Henderson
4654f540166bSRichard Henderson########################################
4655f540166bSRichard Henderson# check if __[u]int128_t is usable.
4656f540166bSRichard Henderson
4657f540166bSRichard Hendersonint128=no
4658f540166bSRichard Hendersoncat > $TMPC << EOF
4659a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4660a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4661a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4662a00f66abSStefan Weil# endif
4663a00f66abSStefan Weil#endif
4664f540166bSRichard Henderson__int128_t a;
4665f540166bSRichard Henderson__uint128_t b;
4666f540166bSRichard Hendersonint main (void) {
4667f540166bSRichard Henderson  a = a + b;
4668f540166bSRichard Henderson  b = a * b;
4669464e3671SPeter Maydell  a = a * a;
4670f540166bSRichard Henderson  return 0;
4671f540166bSRichard Henderson}
4672f540166bSRichard HendersonEOF
4673f540166bSRichard Hendersonif compile_prog "" "" ; then
4674f540166bSRichard Henderson    int128=yes
4675f540166bSRichard Hendersonfi
467676a347e1SRichard Henderson
46777ebee43eSRichard Henderson#########################################
46787ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
46797ebee43eSRichard Henderson
46807ebee43eSRichard Hendersonatomic128=no
46817ebee43eSRichard Hendersonif test "$int128" = "yes"; then
46827ebee43eSRichard Henderson  cat > $TMPC << EOF
46837ebee43eSRichard Hendersonint main(void)
46847ebee43eSRichard Henderson{
46857ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
46867ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
46877ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
46887ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
46897ebee43eSRichard Henderson  return 0;
46907ebee43eSRichard Henderson}
46917ebee43eSRichard HendersonEOF
46927ebee43eSRichard Henderson  if compile_prog "" "" ; then
46937ebee43eSRichard Henderson    atomic128=yes
46947ebee43eSRichard Henderson  fi
46957ebee43eSRichard Hendersonfi
46967ebee43eSRichard Henderson
4697df79b996SRichard Henderson#########################################
4698df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4699df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4700df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4701df79b996SRichard Henderson
4702df79b996SRichard Hendersoncat > $TMPC << EOF
4703df79b996SRichard Henderson#include <stdint.h>
4704df79b996SRichard Hendersonint main(void)
4705df79b996SRichard Henderson{
4706df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4707df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4708df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4709df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4710df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4711df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4712df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4713df79b996SRichard Henderson#else
4714df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4715df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4716df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4717df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4718df79b996SRichard Henderson#endif
4719df79b996SRichard Henderson  return 0;
4720df79b996SRichard Henderson}
4721df79b996SRichard HendersonEOF
4722df79b996SRichard Hendersonif compile_prog "" "" ; then
4723df79b996SRichard Henderson  atomic64=yes
4724df79b996SRichard Hendersonfi
4725df79b996SRichard Henderson
47261e6e9acaSRichard Henderson########################################
47271e6e9acaSRichard Henderson# check if getauxval is available.
47281e6e9acaSRichard Henderson
47291e6e9acaSRichard Hendersongetauxval=no
47301e6e9acaSRichard Hendersoncat > $TMPC << EOF
47311e6e9acaSRichard Henderson#include <sys/auxv.h>
47321e6e9acaSRichard Hendersonint main(void) {
47331e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
47341e6e9acaSRichard Henderson}
47351e6e9acaSRichard HendersonEOF
47361e6e9acaSRichard Hendersonif compile_prog "" "" ; then
47371e6e9acaSRichard Henderson    getauxval=yes
47381e6e9acaSRichard Hendersonfi
47391e6e9acaSRichard Henderson
4740fd0e6053SJohn Snow########################################
4741fd0e6053SJohn Snow# check if ccache is interfering with
4742fd0e6053SJohn Snow# semantic analysis of macros
4743fd0e6053SJohn Snow
47445e4dfd3dSJohn Snowunset CCACHE_CPP2
4745fd0e6053SJohn Snowccache_cpp2=no
4746fd0e6053SJohn Snowcat > $TMPC << EOF
4747fd0e6053SJohn Snowstatic const int Z = 1;
4748fd0e6053SJohn Snow#define fn() ({ Z; })
4749fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4750fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4751fd0e6053SJohn Snow#define ID(X) (X)
4752fd0e6053SJohn Snowint main(int argc, char *argv[])
4753fd0e6053SJohn Snow{
4754fd0e6053SJohn Snow    int x = 0, y = 0;
4755fd0e6053SJohn Snow    x = ID(x);
4756fd0e6053SJohn Snow    x = fn();
4757fd0e6053SJohn Snow    fn();
4758fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4759fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4760fd0e6053SJohn Snow    return 0;
4761fd0e6053SJohn Snow}
4762fd0e6053SJohn SnowEOF
4763fd0e6053SJohn Snow
4764fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4765fd0e6053SJohn Snow    ccache_cpp2=yes
4766fd0e6053SJohn Snowfi
4767fd0e6053SJohn Snow
4768b553a042SJohn Snow#################################################
4769b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4770b553a042SJohn Snow
4771b553a042SJohn Snowif test "$fortify_source" != "no"; then
4772b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4773b553a042SJohn Snow    fortify_source="no";
4774*e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4775cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4776b553a042SJohn Snow    fortify_source="no";
4777b553a042SJohn Snow  else
4778b553a042SJohn Snow    fortify_source="yes"
4779b553a042SJohn Snow  fi
4780b553a042SJohn Snowfi
4781b553a042SJohn Snow
4782d2042378SAneesh Kumar K.V##########################################
4783277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4784277abf15SJan Vesely
4785277abf15SJan Veselyhave_fsxattr=no
4786277abf15SJan Veselycat > $TMPC << EOF
4787277abf15SJan Vesely#include <linux/fs.h>
4788277abf15SJan Veselystruct fsxattr foo;
4789277abf15SJan Veselyint main(void) {
4790277abf15SJan Vesely  return 0;
4791277abf15SJan Vesely}
4792277abf15SJan VeselyEOF
4793277abf15SJan Veselyif compile_prog "" "" ; then
4794277abf15SJan Vesely    have_fsxattr=yes
4795277abf15SJan Veselyfi
4796277abf15SJan Vesely
4797b66e10e4SPeter Maydell##########################################
4798b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4799575b22b1SLaurent Vivierhave_rtnetlink=no
4800575b22b1SLaurent Viviercat > $TMPC << EOF
4801575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4802575b22b1SLaurent Vivierint main(void) {
4803575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4804575b22b1SLaurent Vivier}
4805575b22b1SLaurent VivierEOF
4806575b22b1SLaurent Vivierif compile_prog "" "" ; then
4807575b22b1SLaurent Vivier    have_rtnetlink=yes
4808575b22b1SLaurent Vivierfi
4809575b22b1SLaurent Vivier
48106a02c806SStefan Hajnoczi##########################################
48116a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
48126a02c806SStefan Hajnoczihave_af_vsock=no
48136a02c806SStefan Hajnoczicat > $TMPC << EOF
48146a02c806SStefan Hajnoczi#include <errno.h>
48156a02c806SStefan Hajnoczi#include <sys/types.h>
48166a02c806SStefan Hajnoczi#include <sys/socket.h>
48176a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
48186a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
48196a02c806SStefan Hajnoczi#endif
48206a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
48216a02c806SStefan Hajnocziint main(void) {
48226a02c806SStefan Hajnoczi    int sock, ret;
48236a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
48246a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
48256a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
48266a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
48276a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
48286a02c806SStefan Hajnoczi        return 0;
48296a02c806SStefan Hajnoczi    }
48306a02c806SStefan Hajnoczi    return -1;
48316a02c806SStefan Hajnoczi}
48326a02c806SStefan HajnocziEOF
48336a02c806SStefan Hajnocziif compile_prog "" "" ; then
48346a02c806SStefan Hajnoczi    have_af_vsock=yes
48356a02c806SStefan Hajnoczifi
48366a02c806SStefan Hajnoczi
48376969ec6cSJames Clarke#################################################
48386969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
48396969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
48406969ec6cSJames Clarke# given. It does no harm to give it on other
48416969ec6cSJames Clarke# platforms too.
48426969ec6cSJames Clarke
48436969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
48446969ec6cSJames Clarke#       contains -Wmissing-prototypes
48456969ec6cSJames Clarkecat > $TMPC << EOF
48466969ec6cSJames Clarkeextern int foo(void);
48476969ec6cSJames Clarkeint foo(void) { return 0; }
48486969ec6cSJames ClarkeEOF
48496969ec6cSJames Clarkeif ! compile_object ""; then
48506969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
48516969ec6cSJames Clarkefi
48527ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
48537ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
48547ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
48557ecf44a5SPaolo Bonzini    break
48567ecf44a5SPaolo Bonzini  fi
48577ecf44a5SPaolo Bonzinidone
48587ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
48597ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
48606969ec6cSJames Clarkefi
48616969ec6cSJames Clarke
4862277abf15SJan Vesely##########################################
48634d04351fSChristopher Covington# check for sysmacros.h
48644d04351fSChristopher Covington
48654d04351fSChristopher Covingtonhave_sysmacros=no
48664d04351fSChristopher Covingtoncat > $TMPC << EOF
48674d04351fSChristopher Covington#include <sys/sysmacros.h>
48684d04351fSChristopher Covingtonint main(void) {
48694d04351fSChristopher Covington    return makedev(0, 0);
48704d04351fSChristopher Covington}
48714d04351fSChristopher CovingtonEOF
48724d04351fSChristopher Covingtonif compile_prog "" "" ; then
48734d04351fSChristopher Covington    have_sysmacros=yes
48744d04351fSChristopher Covingtonfi
48754d04351fSChristopher Covington
48764d04351fSChristopher Covington##########################################
4877da92c3ffSAshish Mittal# Veritas HyperScale block driver VxHS
4878da92c3ffSAshish Mittal# Check if libvxhs is installed
4879da92c3ffSAshish Mittal
4880da92c3ffSAshish Mittalif test "$vxhs" != "no" ; then
4881da92c3ffSAshish Mittal  cat > $TMPC <<EOF
4882da92c3ffSAshish Mittal#include <stdint.h>
4883da92c3ffSAshish Mittal#include <qnio/qnio_api.h>
4884da92c3ffSAshish Mittal
4885da92c3ffSAshish Mittalvoid *vxhs_callback;
4886da92c3ffSAshish Mittal
4887da92c3ffSAshish Mittalint main(void) {
4888da92c3ffSAshish Mittal    iio_init(QNIO_VERSION, vxhs_callback);
4889da92c3ffSAshish Mittal    return 0;
4890da92c3ffSAshish Mittal}
4891da92c3ffSAshish MittalEOF
4892da92c3ffSAshish Mittal  vxhs_libs="-lvxhs -lssl"
4893da92c3ffSAshish Mittal  if compile_prog "" "$vxhs_libs" ; then
4894da92c3ffSAshish Mittal    vxhs=yes
4895da92c3ffSAshish Mittal  else
4896da92c3ffSAshish Mittal    if test "$vxhs" = "yes" ; then
4897da92c3ffSAshish Mittal      feature_not_found "vxhs block device" "Install libvxhs See github"
4898da92c3ffSAshish Mittal    fi
4899da92c3ffSAshish Mittal    vxhs=no
4900da92c3ffSAshish Mittal  fi
4901da92c3ffSAshish Mittalfi
4902da92c3ffSAshish Mittal
4903da92c3ffSAshish Mittal##########################################
490449e00a18SAndreas Grapentin# check for _Static_assert()
490549e00a18SAndreas Grapentin
490649e00a18SAndreas Grapentinhave_static_assert=no
490749e00a18SAndreas Grapentincat > $TMPC << EOF
490849e00a18SAndreas Grapentin_Static_assert(1, "success");
490949e00a18SAndreas Grapentinint main(void) {
491049e00a18SAndreas Grapentin    return 0;
491149e00a18SAndreas Grapentin}
491249e00a18SAndreas GrapentinEOF
491349e00a18SAndreas Grapentinif compile_prog "" "" ; then
491449e00a18SAndreas Grapentin    have_static_assert=yes
491549e00a18SAndreas Grapentinfi
491649e00a18SAndreas Grapentin
491749e00a18SAndreas Grapentin##########################################
4918e86ecd4bSJuan Quintela# End of CC checks
4919e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4920e86ecd4bSJuan Quintela
49211d728c39SBlue Swirlif test "$gcov" = "yes" ; then
49221d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
49231d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4924b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4925e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4926ce278618SPeter Maydellelif test "$debug" = "no"; then
4927ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
4928e86ecd4bSJuan Quintelafi
4929a316e378SJuan Quintela
49306542aa9cSPeter Lieven##########################################
49316542aa9cSPeter Lieven# Do we have libnfs
49326542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
4933b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
49346542aa9cSPeter Lieven    libnfs="yes"
49356542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
49366542aa9cSPeter Lieven  else
49376542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
49388efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
49396542aa9cSPeter Lieven    fi
49406542aa9cSPeter Lieven    libnfs="no"
49416542aa9cSPeter Lieven  fi
49426542aa9cSPeter Lievenfi
49431d728c39SBlue Swirl
49446ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
49456ca026cbSPeter Maydellif test "$werror" = "yes"; then
49466ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
49476ca026cbSPeter Maydellfi
49486ca026cbSPeter Maydell
4949e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
4950e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
49511156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
4952e86ecd4bSJuan Quintela    fi
4953e86ecd4bSJuan Quintelafi
4954e86ecd4bSJuan Quintela
495594dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
495694dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
495794dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
495894dd53c5SGerd Hoffmannelse
495994dd53c5SGerd Hoffmann    POD2MAN="pod2man"
496094dd53c5SGerd Hoffmannfi
496194dd53c5SGerd Hoffmann
4962952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4963952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4964952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
4965952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4966952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
4967952afb71SBlue Swirl        fi
4968952afb71SBlue Swirl    done
4969952afb71SBlue Swirlfi
4970952afb71SBlue Swirl
497110ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
4972e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
4973528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
4974834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
49755a67135aSbellard
49764b1c11fdSDaniel P. Berrangetools=""
49774b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
4978ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
49794b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
49804b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
4981a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
49824b1c11fdSDaniel P. Berrange  fi
49834b1c11fdSDaniel P. Berrangefi
49844b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
4985983eef5aSMeador Inge  if test "$virtfs" != no ; then
4986be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4987983eef5aSMeador Inge      virtfs=yes
498817bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4989983eef5aSMeador Inge    else
4990983eef5aSMeador Inge      if test "$virtfs" = yes; then
49913f3b5388SStefan Weil        error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4992983eef5aSMeador Inge      fi
499317500370SAndreas Färber      virtfs=no
4994983eef5aSMeador Inge    fi
499517bff52bSM. Mohan Kumar  fi
4996d138cee9SMichael Rothfi
49979d6bc27bSMichael Roth
49989d6bc27bSMichael Roth# Probe for guest agent support/options
49999d6bc27bSMichael Roth
5000e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5001b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5002fafcaf1dSMichael Roth      tools="qemu-ga $tools"
5003e8ef31a3SMichael Tokarev      guest_agent=yes
5004e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5005e8ef31a3SMichael Tokarev      guest_agent=no
5006e8ef31a3SMichael Tokarev  else
5007e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5008ca35f780SPaolo Bonzini  fi
50094b1c11fdSDaniel P. Berrangefi
5010ca35f780SPaolo Bonzini
50119d6bc27bSMichael Roth# Guest agent Window MSI  package
50129d6bc27bSMichael Roth
50139d6bc27bSMichael Rothif test "$guest_agent" != yes; then
50149d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
50159d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
50169d6bc27bSMichael Roth  fi
50179d6bc27bSMichael Roth  guest_agent_msi=no
50189d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
50199d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50209d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
50219d6bc27bSMichael Roth  fi
50229d6bc27bSMichael Roth  guest_agent_msi=no
50239d6bc27bSMichael Rothelif ! has wixl; then
50249d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
50259d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
50269d6bc27bSMichael Roth  fi
50279d6bc27bSMichael Roth  guest_agent_msi=no
50281a34904eSMichael Rothelse
50291a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
50301a34904eSMichael Roth  # disabled explicitly
50311a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
50321a34904eSMichael Roth    guest_agent_msi=yes
50331a34904eSMichael Roth  fi
50349d6bc27bSMichael Rothfi
50359d6bc27bSMichael Roth
50361a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
50379d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
50389d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
50399d6bc27bSMichael Roth  fi
50409d6bc27bSMichael Roth
50419d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
50429d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
50439d6bc27bSMichael Roth  fi
50449d6bc27bSMichael Roth
50459d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
50469d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
50479d6bc27bSMichael Roth  fi
50489d6bc27bSMichael Roth
50499d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
505089138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
50519d6bc27bSMichael Roth  fi
50529d6bc27bSMichael Roth
505389138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
50549d6bc27bSMichael Roth
50559d6bc27bSMichael Roth  case "$cpu" in
50569d6bc27bSMichael Roth  x86_64)
50579d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
50589d6bc27bSMichael Roth    ;;
50599d6bc27bSMichael Roth  i386)
50609d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
50619d6bc27bSMichael Roth    ;;
50629d6bc27bSMichael Roth  *)
50639d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
50649d6bc27bSMichael Roth    ;;
50659d6bc27bSMichael Roth  esac
50669d6bc27bSMichael Rothfi
50679d6bc27bSMichael Roth
5068ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5069ca35f780SPaolo Bonziniroms=
5070ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5071ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5072ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
5073e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5074e57218b6SPeter Maydell    # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5075e57218b6SPeter Maydell    # variant; and Windows uses i386pe.
5076e57218b6SPeter Maydell    for emu in elf_i386 elf_i386_fbsd i386pe; do
5077e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5078e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5079ca35f780SPaolo Bonzini            roms="optionrom"
5080e57218b6SPeter Maydell            break
5081e57218b6SPeter Maydell        fi
5082e57218b6SPeter Maydell    done
5083ca35f780SPaolo Bonzinifi
5084d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
508539ac8455SDavid Gibson  roms="$roms spapr-rtas"
508639ac8455SDavid Gibsonfi
5087ca35f780SPaolo Bonzini
50889933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
50899933c305SChristian Borntraeger  roms="$roms s390-ccw"
50909933c305SChristian Borntraegerfi
50919933c305SChristian Borntraeger
5092964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
509392fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5094964c6fa1SRichard Henderson  textseg_addr=
5095964c6fa1SRichard Henderson  case "$cpu" in
5096479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5097479eb121SRichard Henderson      # ??? Rationale for choosing this address
5098964c6fa1SRichard Henderson      textseg_addr=0x60000000
5099964c6fa1SRichard Henderson      ;;
5100964c6fa1SRichard Henderson    mips)
5101479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
5102479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
5103479eb121SRichard Henderson      textseg_addr=0x60000000
5104964c6fa1SRichard Henderson      ;;
5105964c6fa1SRichard Henderson  esac
5106964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
5107964c6fa1SRichard Henderson    cat > $TMPC <<EOF
5108964c6fa1SRichard Henderson    int main(void) { return 0; }
5109964c6fa1SRichard HendersonEOF
5110964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5111964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
5112964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
5113964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
5114964c6fa1SRichard Henderson      # at least.
511592fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
511692fe2ba8SPeter Maydell        error_exit \
511792fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
511892fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
511992fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
512092fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
512192fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
512292fe2ba8SPeter Maydell            "--disable-user option to configure."
512392fe2ba8SPeter Maydell      fi
512492fe2ba8SPeter Maydell
5125964c6fa1SRichard Henderson      $ld --verbose | sed \
5126964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
5127964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
5128964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5129964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5130964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
5131964c6fa1SRichard Henderson    fi
5132964c6fa1SRichard Henderson  fi
5133964c6fa1SRichard Hendersonfi
5134964c6fa1SRichard Henderson
513511cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
513611cde1c8SBruno 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.
513711cde1c8SBruno Dominguezif has $cxx; then
513811cde1c8SBruno Dominguez    cat > $TMPC <<EOF
513911cde1c8SBruno Dominguezint c_function(void);
514011cde1c8SBruno Dominguezint main(void) { return c_function(); }
514111cde1c8SBruno DominguezEOF
514211cde1c8SBruno Dominguez
514311cde1c8SBruno Dominguez    compile_object
514411cde1c8SBruno Dominguez
514511cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
514611cde1c8SBruno Dominguezextern "C" {
514711cde1c8SBruno Dominguez   int c_function(void);
514811cde1c8SBruno Dominguez}
514911cde1c8SBruno Dominguezint c_function(void) { return 42; }
515011cde1c8SBruno DominguezEOF
515111cde1c8SBruno Dominguez
515211cde1c8SBruno Dominguez    update_cxxflags
515311cde1c8SBruno Dominguez
515411cde1c8SBruno Dominguez    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
515511cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
515611cde1c8SBruno Dominguez        :
515711cde1c8SBruno Dominguez    else
515811cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
515911cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
516011cde1c8SBruno Dominguez        cxx=
516111cde1c8SBruno Dominguez    fi
516211cde1c8SBruno Dominguezelse
516311cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
516411cde1c8SBruno Dominguez    cxx=
516511cde1c8SBruno Dominguezfi
516611cde1c8SBruno Dominguez
516702d34f62SCole Robinsonecho_version() {
516802d34f62SCole Robinson    if test "$1" = "yes" ; then
516902d34f62SCole Robinson        echo "($2)"
517002d34f62SCole Robinson    fi
517102d34f62SCole Robinson}
517202d34f62SCole Robinson
517350e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
517450e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
517550e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
51765ca9388aSGerd Hoffmann
51777d13299dSbellardecho "Install prefix    $prefix"
517889138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
517989138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
518089138857SStefan Weilecho "library directory $(eval echo $libdir)"
518189138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
518289138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
518389138857SStefan Weilecho "include directory $(eval echo $includedir)"
518489138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
518511d9f695Sbellardif test "$mingw32" = "no" ; then
518689138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
518789138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
518843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
51895a699bbbSLaszlo Ersekelse
51905a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
5191d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
519211d9f695Sbellardfi
51935a67135aSbellardecho "Source path       $source_path"
51947d13299dSbellardecho "C compiler        $cc"
519583469015Sbellardecho "Host C compiler   $host_cc"
519683f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
51973c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
519845d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
51990c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
5200a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
52010c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
52027d13299dSbellardecho "make              $make"
52036a882643Spbrookecho "install           $install"
5204c886edfbSBlue Swirlecho "python            $python"
5205e2d8830eSBradif test "$slirp" = "yes" ; then
5206e2d8830eSBrad    echo "smbd              $smbd"
5207e2d8830eSBradfi
520817969268SFam Zhengecho "module support    $modules"
5209a98fd896Sbellardecho "host CPU          $cpu"
5210de83cd02Sbellardecho "host big endian   $bigendian"
521197a847bcSbellardecho "target list       $target_list"
52127d13299dSbellardecho "gprof enabled     $gprof"
521303b4fe7dSaliguoriecho "sparse enabled    $sparse"
52141625af87Saliguoriecho "strip binaries    $strip_opt"
521505c2a3e7Sbellardecho "profiler          $profiler"
521643ce4dfeSbellardecho "static build      $static"
52175b0753e0Sbellardif test "$darwin" = "yes" ; then
52185b0753e0Sbellard    echo "Cocoa support     $cocoa"
52195b0753e0Sbellardfi
5220e2134eb9SGerd Hoffmannecho "pixman            $pixman"
522189138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
522289138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
5223925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
522489138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
5225a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
5226ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
5227b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
522891bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
522937788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
523089138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
5231fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
52329a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
52334d3b6f6eSbalrogecho "curses support    $curses"
52349d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
5235769ce76dSAlexander Grafecho "curl support      $curl"
523667b915a5Sbellardecho "mingw32 support   $mingw32"
52370c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
5238b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
5239b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
5240983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
5241821601eaSJes Sorensenecho "VNC support       $vnc"
5242821601eaSJes Sorensenif test "$vnc" = "yes" ; then
52432f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
52442f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
5245efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
5246821601eaSJes Sorensenfi
52473142255cSblueswir1if test -n "$sparc_cpu"; then
52483142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
52493142255cSblueswir1fi
5250e37630caSaliguoriecho "xen support       $xen"
52513996e85cSPaul Durrantif test "$xen" = "yes" ; then
52523996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
525364a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
52543996e85cSPaul Durrantfi
52552e4d9fb1Saurel32echo "brlapi support    $brlapi"
5256a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5257a25dba17SJuan Quintelaecho "Documentation     $docs"
525840d6444eSAvi Kivityecho "PIE               $pie"
52598a16d273Sthsecho "vde support       $vde"
526058952137SVincenzo Maffioneecho "netmap support    $netmap"
52615c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5262758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
526377755340Sthsecho "Install blobs     $blobs"
5264b31a0277SJuan Quintelaecho "KVM support       $kvm"
5265b0cb0a66SVincent Palatinecho "HAX support       $hax"
5266b3f6ea7eSPaolo Bonziniecho "TCG support       $tcg"
5267b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes" ; then
5268b3f6ea7eSPaolo Bonzini    echo "TCG debug enabled $debug_tcg"
52699195b2c2SStefan Weil    echo "TCG interpreter   $tcg_interpreter"
5270b3f6ea7eSPaolo Bonzinifi
5271b3f6ea7eSPaolo Bonziniecho "RDMA support      $rdma"
5272f652e6afSaurel32echo "fdt support       $fdt"
5273ceb42de8Saliguoriecho "preadv support    $preadv"
52745f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5275e78815a5SAndreas Färberecho "madvise           $madvise"
5276e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
527747e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5278d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
52795e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5280fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
52815b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5282713572a7SMarc-André Lureauif have_backend "simple"; then
52839410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5284e00e36fbSStefan Weilfi
528589138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5286f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5287dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
52887b02f544SMarc-André Lureauecho "smartcard support $smartcard"
52892b2325ffSGerd Hoffmannecho "libusb            $libusb"
529069354a83SHans de Goedeecho "usb net redir     $usb_redir"
5291da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5292014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5293c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
52946542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5295d138cee9SMichael Rothecho "build guest agent $guest_agent"
5296d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
529750cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
52984c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5299f794573eSEduardo Otuboecho "seccomp support   $seccomp"
53007c2acc70SPeter Maydellecho "coroutine backend $coroutine"
530170c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
53027d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5303eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
53041d728c39SBlue Swirlecho "gcov              $gcov_tool"
53051d728c39SBlue Swirlecho "gcov enabled      $gcov"
5306ab214c29SStefan Bergerecho "TPM support       $tpm"
53070a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
53083b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
53093556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5310ed1701c6SDr. David Alan Gilbertecho "Live block migration $live_block_migration"
5311607dacd0Sqiaonuohanecho "lzo support       $lzo"
5312607dacd0Sqiaonuohanecho "snappy support    $snappy"
53136b383c08SPeter Wuecho "bzip2 support     $bzip2"
5314a99d57bbSWanlong Gaoecho "NUMA host support $numa"
53152847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
53167b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
531799f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5318a6b1d4c0SChanglong Xieecho "replication support $replication"
5319da92c3ffSAshish Mittalecho "VxHS block device $vxhs"
532067b915a5Sbellard
53211ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
532224b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5323e8cd23deSbellardfi
532497a847bcSbellard
5325898be3e0SPeter Maydellif test "$supported_cpu" = "no"; then
5326898be3e0SPeter Maydell    echo
5327898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5328898be3e0SPeter Maydell    echo
5329898be3e0SPeter Maydell    echo "CPU host architecture $cpu support is not currently maintained."
5330898be3e0SPeter Maydell    echo "The QEMU project intends to remove support for this host CPU in"
5331898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5332898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5333898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5334898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5335898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5336898be3e0SPeter Maydellfi
5337898be3e0SPeter Maydell
5338898be3e0SPeter Maydellif test "$supported_os" = "no"; then
5339898be3e0SPeter Maydell    echo
5340898be3e0SPeter Maydell    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5341898be3e0SPeter Maydell    echo
5342c50126aaSPeter Maydell    echo "Host OS $targetos support is not currently maintained."
5343c50126aaSPeter Maydell    echo "The QEMU project intends to remove support for this host OS in"
5344898be3e0SPeter Maydell    echo "a future release if nobody volunteers to maintain it and to"
5345898be3e0SPeter Maydell    echo "provide a build host for our continuous integration setup."
5346898be3e0SPeter Maydell    echo "configure has succeeded and you can continue to build, but"
5347898be3e0SPeter Maydell    echo "if you care about QEMU on this platform you should contact"
5348898be3e0SPeter Maydell    echo "us upstream at qemu-devel@nongnu.org."
5349898be3e0SPeter Maydellfi
5350898be3e0SPeter Maydell
535198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
535297a847bcSbellard
5353dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5354dbd99ae3SStefan Weil
535598ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
535698ec69acSJuan Quintelaecho >> $config_host_mak
535798ec69acSJuan Quintela
5358e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
535999d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
536099d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
53613aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
53628bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
53630f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
536499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
536599d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
536622d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
53679afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
53689afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5369e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
53705a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5371785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
53725a699bbbSLaszlo Ersekfi
5373f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5374f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
537511cde1c8SBruno Dominguezecho "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5376f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5377834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5378f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5379804edf29SJuan Quintela
538098ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5381727e5283SPaolo Bonzini
5382f8393946Saurel32if test "$debug_tcg" = "yes" ; then
53832358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5384f8393946Saurel32fi
53851625af87Saliguoriif test "$strip_opt" = "yes" ; then
538652ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
53871625af87Saliguorifi
53887d13299dSbellardif test "$bigendian" = "yes" ; then
5389e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
539097a847bcSbellardfi
539167b915a5Sbellardif test "$mingw32" = "yes" ; then
539298ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
539389138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
53949fe6de94SBlue Swirl  version_major=${rc_version%%.*}
53959fe6de94SBlue Swirl  rc_version=${rc_version#*.}
53969fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
53979fe6de94SBlue Swirl  rc_version=${rc_version#*.}
53989fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
53999fe6de94SBlue Swirl  version_micro=0
54009fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
54019fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5402d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5403d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5404f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5405d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5406d9840e25STomoki Sekiyama  fi
540750cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
540850cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
540950cbebb9SMichael Roth  fi
54101a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
54119dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
54129dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
54139dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
54149dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
54159dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
54169dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
54179dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
54189dacf32dSYossi Hindin  fi
5419210fa556Spbrookelse
542035f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5421210fa556Spbrookfi
5422128ab2ffSblueswir1
5423dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5424dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5425dffcb71cSMark McLoughlinfi
5426dffcb71cSMark McLoughlin
542783fb7adfSbellardif test "$darwin" = "yes" ; then
542898ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
542983fb7adfSbellardfi
5430b29fe3edSmalc
5431b29fe3edSmalcif test "$aix" = "yes" ; then
543298ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
5433b29fe3edSmalcfi
5434b29fe3edSmalc
5435ec530c81Sbellardif test "$solaris" = "yes" ; then
543698ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
54372358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
54380475a5caSths  if test "$needs_libsunmath" = "yes" ; then
543975b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
54400475a5caSths  fi
5441ec530c81Sbellardfi
5442179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5443179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5444179cf400SAndreas Färberfi
544597a847bcSbellardif test "$static" = "yes" ; then
544698ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
544797a847bcSbellardfi
54481ba16968SStefan Weilif test "$profiler" = "yes" ; then
54492358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
545005c2a3e7Sbellardfi
5451c20709aaSbellardif test "$slirp" = "yes" ; then
545298ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5453e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5454c20709aaSbellardfi
54558a16d273Sthsif test "$vde" = "yes" ; then
545698ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
54578a16d273Sthsfi
545858952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
545958952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
546058952137SVincenzo Maffionefi
5461015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5462015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5463015a33bdSGongleifi
546447e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
546547e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
546647e98658SCorey Bryantfi
54672358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
54680c58ac1cSmalcfor drv in $audio_drv_list; do
546989138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
547098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
54710c58ac1cSmalcdone
547267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
547367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
547467f86e8eSJuan Quintelafi
5475d5631638Smalcif test "$audio_win_int" = "yes" ; then
5476d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5477d5631638Smalcfi
5478b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5479b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5480821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5481821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5482821601eaSJes Sorensenfi
54832f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
548498ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
54852f9606b3Saliguorifi
5486821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
54872f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
54882f6f5c7aSCorentin Charyfi
5489821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5490efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5491efe556adSCorentin Charyfi
549276655d6dSaliguoriif test "$fnmatch" = "yes" ; then
54932358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
549476655d6dSaliguorifi
5495dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5496dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5497dce512deSChristoph Hellwigfi
549889138857SStefan Weilqemu_version=$(head $source_path/VERSION)
549998ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
55002358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
550198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
550298ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5503a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
550498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5505cc8ae6deSpbrookfi
550617969268SFam Zhengif test "$modules" = "yes"; then
5507e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5508e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
550989138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
551017969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
551117969268SFam Zhengfi
55121ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
551398ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5514a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
55158ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
551649ecc3faSbellardfi
551749ecc3faSbellardif test "$cocoa" = "yes" ; then
551898ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
551949ecc3faSbellardfi
55204d3b6f6eSbalrogif test "$curses" = "yes" ; then
552198ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5522ab4e5602SJan Kiszkafi
5523099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
55242358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5525099d6b0fSRiku Voipiofi
552640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
552740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
552840ff6d7eSKevin Wolffi
55293ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
55302358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
55313ce34dfbSvibisreenivasanfi
5532c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5533c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5534c2882b96SRiku Voipiofi
5535751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5536751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5537751bcc39SMarc-André Lureaufi
5538d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5539d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5540d0927938SUlrich Hechtfi
55413d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
55423d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
55433d4fa43eSKusanagi Kouichifi
5544b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5545b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5546b953f075SDenis V. Lunevfi
5547ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5548ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5549ed911435SKevin Wolffi
5550c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5551c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5552c727f47dSPeter Maydellfi
5553dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5554dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5555dace20dcSPeter Maydellfi
5556d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5557d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5558d0927938SUlrich Hechtfi
55594e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
55604e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
55614e0c6529SAlex Blighfi
5562cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5563cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5564cd758dd0SAlex Blighfi
55653b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
55663b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
55673b6edd16SPeter Maydellfi
55683b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
55693b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
55703b6edd16SPeter Maydellfi
5571a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5572a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5573a8fd1abaSPeter Maydellfi
557451834341SRiku Voipioif test "$timerfd" = "yes" ; then
557551834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
557651834341SRiku Voipiofi
55779af5c906SRiku Voipioif test "$setns" = "yes" ; then
55789af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
55799af5c906SRiku Voipiofi
558038860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
558138860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
558238860a03SAleksandar Markovicfi
55835a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
55845a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
55855a03cd00SAleksandar Markovicfi
55863b3f24adSaurel32if test "$inotify" = "yes" ; then
55872358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
55883b3f24adSaurel32fi
5589c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5590c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5591c05c7a73SRiku Voipiofi
55926ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
55936ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
55946ae9a1f4SJuan Quintelafi
55956ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
55966ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
55976ae9a1f4SJuan Quintelafi
5598769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5599d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5600b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
56016ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5602769ce76dSAlexander Graffi
56032e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
560498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
56052e4d9fb1Saurel32fi
5606fb599c9aSbalrogif test "$bluez" = "yes" ; then
560798ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5608ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5609fb599c9aSbalrogfi
5610d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
56119d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
56129d41401bSMichael S. Tsirkinfi
5613a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5614a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5615a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5616a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5617014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5618925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5619925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5620925a0400SGerd Hoffmann  fi
5621bbbf9bfbSStefan Weilfi
5622a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5623ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5624ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5625ddbb0d09SDaniel P. Berrangefi
5626b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5627b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5628b917da4cSDaniel P. Berrangefi
562991bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
563091bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
56311f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
56321f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
56331f923c70SLongpeng(Mike)  fi
563437788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
563537788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
563637788f25SDaniel P. Berrange  fi
563762893b67SDaniel P. Berrangefi
563891bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
563991bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5640becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5641fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5642fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5643fff2f982SDaniel P. Berrange  fi
5644ed754746SDaniel P. Berrangefi
56459a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
56469a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
56479a2fd434SDaniel P. Berrangefi
5648559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5649559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5650559607eaSDaniel P. Berrangefi
56516b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
56526b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
56536b39b063SEric Blakefi
5654277abf15SJan Vesely
5655277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5656277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5657277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5658277abf15SJan Vesely# if this macro is set.
5659277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5660277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5661277abf15SJan Veselyfi
5662bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5663bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5664a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5665a4ccabcfSAnthony Liguorifi
56669d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
56679d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
56689d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
56699d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
56709d9e1521SGerd Hoffmannfi
5671e37630caSaliguoriif test "$xen" = "yes" ; then
56726dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5673d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
567464a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
567564a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
567664a7ad6fSIan Campbell  fi
5677e37630caSaliguorifi
56785c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
56795c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
56805c6c3a6cSChristoph Hellwigfi
5681758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5682758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5683758e8e38SVenkateswararao Jujjuri (JV)fi
56844f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
56854f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
56864f26f2b6SAvi Kivityfi
5687983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5688758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5689758e8e38SVenkateswararao Jujjuri (JV)fi
56905e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
56915e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
56925e9be92dSNicholas Bellingerfi
569303ce5744SNikolay Nikolaevif test "$vhost_net" = "yes" ; then
569403ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
569503ce5744SNikolay Nikolaevfi
5696fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5697fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5698fc0b9b0eSStefan Hajnoczifi
569977755340Sthsif test "$blobs" = "yes" ; then
570098ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
570177755340Sthsfi
5702bf9298b9Saliguoriif test "$iovec" = "yes" ; then
57032358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5704bf9298b9Saliguorifi
5705ceb42de8Saliguoriif test "$preadv" = "yes" ; then
57062358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5707ceb42de8Saliguorifi
5708f652e6afSaurel32if test "$fdt" = "yes" ; then
57093f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5710f652e6afSaurel32fi
5711dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5712dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5713dcc38d1cSMarcelo Tosattifi
5714b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
5715b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
57169195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
57179195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
57189195b2c2SStefan Weil  fi
5719b3f6ea7eSPaolo Bonzinifi
57205f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
57215f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
57225f6b9e8fSBlue Swirlfi
5723e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5724e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5725e78815a5SAndreas Färberfi
5726e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5727e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5728e78815a5SAndreas Färberfi
572997a847bcSbellard
5730cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5731cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5732cd4ec0b4SGerd Hoffmannfi
5733cd4ec0b4SGerd Hoffmann
57347b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
57357b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5736111a38b0SRobert Relyeafi
5737111a38b0SRobert Relyea
57382b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
57392b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
57402b2325ffSGerd Hoffmannfi
57412b2325ffSGerd Hoffmann
574269354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
574369354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
574469354a83SHans de Goedefi
574569354a83SHans de Goede
5746da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5747da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5748da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5749014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5750014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5751014cb152SGerd Hoffmann  fi
575220ff075bSMichael Wallefi
575320ff075bSMichael Walle
575499f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
575599f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
575699f2dbd3SLiang Lifi
575799f2dbd3SLiang Li
5758607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5759607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5760607dacd0Sqiaonuohanfi
5761607dacd0Sqiaonuohan
5762607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5763607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5764607dacd0Sqiaonuohanfi
5765607dacd0Sqiaonuohan
57666b383c08SPeter Wuif test "$bzip2" = "yes" ; then
57676b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
57686b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
57696b383c08SPeter Wufi
57706b383c08SPeter Wu
5771c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5772d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
57736ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
57746ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5775c589b249SRonnie Sahlbergfi
5776c589b249SRonnie Sahlberg
57776542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
57784be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
57794be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
57806542aa9cSPeter Lievenfi
57816542aa9cSPeter Lieven
5782f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5783f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5784f794573eSEduardo Otubofi
5785f794573eSEduardo Otubo
578683fb7adfSbellard# XXX: suppress that
57877d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
57882358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
57897d3505c5Sbellardfi
57907d3505c5Sbellard
57914d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
57924d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
57934d9310f4SDaniel P. Berrangefi
57943556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
57953556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
57963556c233SPaolo Bonzinifi
5797f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5798d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
57996ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
58006ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5801f27aaf4bSChristian Brunnerfi
580220ff6c80SAnthony Liguori
58037c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
580470c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
580570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
580670c60c08SStefan Hajnoczielse
580770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
580870c60c08SStefan Hajnoczifi
5809d0e2fce5SAneesh Kumar K.V
58107d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
58117d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
58127d992e4dSPeter Lievenfi
58137d992e4dSPeter Lieven
5814d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5815d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5816d2042378SAneesh Kumar K.Vfi
5817d2042378SAneesh Kumar K.V
5818e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5819e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5820e06a765eSHarsh Prateek Borafi
5821e06a765eSHarsh Prateek Bora
5822cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5823cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
582406d71fa1SPeter Maydellfi
582506d71fa1SPeter Maydell
58263f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
58273f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
58283f4349dcSKevin Wolffi
58293f4349dcSKevin Wolf
58308ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
58318ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
58328ab1bf12SLuiz Capitulinofi
58338ab1bf12SLuiz Capitulino
583476a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
583576a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
583676a347e1SRichard Hendersonfi
583776a347e1SRichard Henderson
5838f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5839f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5840f540166bSRichard Hendersonfi
5841f540166bSRichard Henderson
58427ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
58437ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
58447ebee43eSRichard Hendersonfi
58457ebee43eSRichard Henderson
5846df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5847df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5848df79b996SRichard Hendersonfi
5849df79b996SRichard Henderson
58501e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
58511e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
58521e6e9acaSRichard Hendersonfi
58531e6e9acaSRichard Henderson
5854eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5855d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
58566ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
58576ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5858eb100396SBharata B Raofi
5859eb100396SBharata B Rao
5860d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5861d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5862d85fa9ebSJeff Codyfi
5863d85fa9ebSJeff Cody
58640c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
58650c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
58660c14fb47SBharata B Raofi
58670c14fb47SBharata B Rao
5868df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
5869df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
5870df3a429aSNiels de Vosfi
5871df3a429aSNiels de Vos
58727c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
58737c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
58747c815372SBharata B Raofi
58757c815372SBharata B Rao
58760a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
5877d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
58786ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
58796ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
58800a12ec87SRichard W.M. Jonesfi
58810a12ec87SRichard W.M. Jones
5882ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5883ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5884ed1701c6SDr. David Alan Gilbertfi
5885ed1701c6SDr. David Alan Gilbert
588668063649Sblueswir1# USB host support
5887b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
58882b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
5889b5613fdcSGerd Hoffmannelse
589098ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
5891b5613fdcSGerd Hoffmannfi
589268063649Sblueswir1
58933b8acc11SPaolo Bonzini# TPM passthrough support?
58943b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
58953b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
58963b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
58973b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
58983b8acc11SPaolo Bonzini  fi
58993b8acc11SPaolo Bonzinifi
59003b8acc11SPaolo Bonzini
59015b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
59025b808275SLluís Vilanovaif have_backend "nop"; then
59036d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
590422890ab5SPrerna Saxenafi
59055b808275SLluís Vilanovaif have_backend "simple"; then
59066d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
59076d8a764eSLluís  # Set the appropriate trace file.
5908953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
59099410b56cSPrerna Saxenafi
5910ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5911ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
59126d8a764eSLluísfi
59135b808275SLluís Vilanovaif have_backend "ust"; then
59146d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
59156d8a764eSLluísfi
59165b808275SLluís Vilanovaif have_backend "dtrace"; then
59176d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
59186d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
59196d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
59206d8a764eSLluís  fi
5921c276b17dSDaniel P. Berrangefi
59225b808275SLluís Vilanovaif have_backend "ftrace"; then
5923781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5924781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5925781e9545SEiichi Tsukata  else
592621684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5927781e9545SEiichi Tsukata  fi
5928781e9545SEiichi Tsukatafi
59290a852417SPaul Durrantif have_backend "syslog"; then
59300a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
59310a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
59320a852417SPaul Durrant  else
59330a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
59340a852417SPaul Durrant  fi
59350a852417SPaul Durrantfi
59369410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
59379410b56cSPrerna Saxena
59382da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
59392da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
59402da776dbSMichael R. Hinesfi
59412da776dbSMichael R. Hines
5942575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5943575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5944575b22b1SLaurent Vivierfi
5945575b22b1SLaurent Vivier
5946a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
5947a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
5948a6b1d4c0SChanglong Xiefi
5949a6b1d4c0SChanglong Xie
59506a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
59516a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
59526a02c806SStefan Hajnoczifi
59536a02c806SStefan Hajnoczi
59544d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
59554d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
59564d04351fSChristopher Covingtonfi
59574d04351fSChristopher Covington
595849e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
595949e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
596049e00a18SAndreas Grapentinfi
596149e00a18SAndreas Grapentin
59625c312079SDr. David Alan Gilbert# Hold two types of flag:
59635c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
59645c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
59655c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
59665c312079SDr. David Alan Gilbert#                                     platform
59675c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
59685c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
59695c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
59705c312079SDr. David Alan Gilbertfi
59715c312079SDr. David Alan Gilbert
5972da92c3ffSAshish Mittalif test "$vxhs" = "yes" ; then
5973da92c3ffSAshish Mittal  echo "CONFIG_VXHS=y" >> $config_host_mak
5974da92c3ffSAshish Mittal  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
5975da92c3ffSAshish Mittalfi
5976da92c3ffSAshish Mittal
59775b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
59785b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
59795b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
59805b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
59815b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
59825b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5983c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
59845b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
598540d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
598640d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
59875b5e3037SPaolo Bonzinielse
59885b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
59895b5e3037SPaolo Bonzinifi
59905b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
59915b5e3037SPaolo Bonzini
599298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
599398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
5994804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
5995804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
59961901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
59971901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
59981901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
599921655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6000c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
6001804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6002a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6003a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
6004a31a8642SMichael S. Tsirkinfi
60052b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
6006804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
600783f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
60083c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6009804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
601045d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6011cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
60125f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
60133dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6014804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6015804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
60164852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
60179fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
6018e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
601946eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6020a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
602111cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6022f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6023e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
6024e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
602580fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
60262944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
6027e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
6028e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6029e39f0062SPaolo Bonzinifi
603042da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
603142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
603242da6041SGerd Hoffmannelse
603342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
603442da6041SGerd Hoffmannfi
6035e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
603646eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
60376969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6038e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
603973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
60403e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6041409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6042804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
604317969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
604417969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6045957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
604690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
604790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
604894dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
6049cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
60501d728c39SBlue Swirlif test "$gcov" = "yes" ; then
60511d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
60521d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
60531d728c39SBlue Swirlfi
6054804edf29SJuan Quintela
60556efd7517SPeter Maydell# use included Linux headers
60566efd7517SPeter Maydellif test "$linux" = "yes" ; then
6057a307beb6SAndreas Färber  mkdir -p linux-headers
60586efd7517SPeter Maydell  case "$cpu" in
6059c72b26ecSRichard Henderson  i386|x86_64|x32)
606008312a63SPeter Maydell    linux_arch=x86
60616efd7517SPeter Maydell    ;;
60626efd7517SPeter Maydell  ppcemb|ppc|ppc64)
606308312a63SPeter Maydell    linux_arch=powerpc
60646efd7517SPeter Maydell    ;;
60656efd7517SPeter Maydell  s390x)
606608312a63SPeter Maydell    linux_arch=s390
606708312a63SPeter Maydell    ;;
60681f080313SClaudio Fontana  aarch64)
60691f080313SClaudio Fontana    linux_arch=arm64
60701f080313SClaudio Fontana    ;;
6071222e7d11SSanjay Lal  mips64)
6072222e7d11SSanjay Lal    linux_arch=mips
6073222e7d11SSanjay Lal    ;;
607408312a63SPeter Maydell  *)
607508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
607608312a63SPeter Maydell    linux_arch="$cpu"
60776efd7517SPeter Maydell    ;;
60786efd7517SPeter Maydell  esac
607908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
608008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
608108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
608208312a63SPeter Maydell    fi
60836efd7517SPeter Maydellfi
60846efd7517SPeter Maydell
608597a847bcSbellardfor target in $target_list; do
608697a847bcSbellardtarget_dir="$target"
608725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
608889138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
608997a847bcSbellardtarget_bigendian="no"
60901f3d3c8fSJuan Quintela
6091c1799a84SPaolo Bonzinicase "$target_name" in
60924a09d0bbSRichard Henderson  armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6093ea2d6a39SJuan Quintela  target_bigendian=yes
6094ea2d6a39SJuan Quintela  ;;
6095ea2d6a39SJuan Quintelaesac
609697a847bcSbellardtarget_softmmu="no"
6097997344f3Sbellardtarget_user_only="no"
6098831b7825Sthstarget_linux_user="no"
609984778508Sblueswir1target_bsd_user="no"
61009e407a85Spbrookcase "$target" in
6101c1799a84SPaolo Bonzini  ${target_name}-softmmu)
61029e407a85Spbrook    target_softmmu="yes"
61039e407a85Spbrook    ;;
6104c1799a84SPaolo Bonzini  ${target_name}-linux-user)
61059e407a85Spbrook    target_user_only="yes"
61069e407a85Spbrook    target_linux_user="yes"
61079e407a85Spbrook    ;;
6108c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
610984778508Sblueswir1    target_user_only="yes"
611084778508Sblueswir1    target_bsd_user="yes"
611184778508Sblueswir1    ;;
61129e407a85Spbrook  *)
611376ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
61149e407a85Spbrook    exit 1
61159e407a85Spbrook    ;;
61169e407a85Spbrookesac
6117831b7825Sths
611897a847bcSbellardmkdir -p $target_dir
611925be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
612097a847bcSbellard
6121e5fe0c52Spbrookbflt="no"
6122ca759f9eSAlex Bennéemttcg="no"
612389138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
612456aebc89Spbrookgdb_xml_files=""
61257ba1e619Saliguori
6126c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
61276acff7daSJuan QuintelaTARGET_BASE_ARCH=""
6128e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
6129e73aae67SJuan Quintela
6130c1799a84SPaolo Bonzinicase "$target_name" in
61312408a527Saurel32  i386)
6132b8158192SAbdallah Bouassida    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
61332408a527Saurel32  ;;
61342408a527Saurel32  x86_64)
61356acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
6136b8158192SAbdallah Bouassida    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
61372408a527Saurel32  ;;
61382408a527Saurel32  alpha)
61395ee4f3c2SRichard Henderson    mttcg="yes"
61402408a527Saurel32  ;;
61412408a527Saurel32  arm|armeb)
6142b498c8a0SJuan Quintela    TARGET_ARCH=arm
6143e5fe0c52Spbrook    bflt="yes"
6144ca759f9eSAlex Bennée    mttcg="yes"
614556aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
61462408a527Saurel32  ;;
61476a49fa95SAlexander Graf  aarch64)
61486a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
61496a49fa95SAlexander Graf    bflt="yes"
6150ca759f9eSAlex Bennée    mttcg="yes"
61518f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
61526a49fa95SAlexander Graf  ;;
61532408a527Saurel32  cris)
61542408a527Saurel32  ;;
615561766fe9SRichard Henderson  hppa)
615661766fe9SRichard Henderson  ;;
6157613a22c9SMichael Walle  lm32)
6158613a22c9SMichael Walle  ;;
61592408a527Saurel32  m68k)
61600938cda5Saurel32    bflt="yes"
61615a4526b2SLaurent Vivier    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
61622408a527Saurel32  ;;
6163877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
6164877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
616572b675caSEdgar E. Iglesias    bflt="yes"
616672b675caSEdgar E. Iglesias  ;;
61672408a527Saurel32  mips|mipsel)
6168b498c8a0SJuan Quintela    TARGET_ARCH=mips
616925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
61702408a527Saurel32  ;;
61712408a527Saurel32  mipsn32|mipsn32el)
6172597e2cecSRichard Henderson    TARGET_ARCH=mips64
61736acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
617425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6175597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
61762408a527Saurel32  ;;
61772408a527Saurel32  mips64|mips64el)
6178b498c8a0SJuan Quintela    TARGET_ARCH=mips64
61796acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
618025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
61812408a527Saurel32  ;;
6182d15a9c23SAnthony Green  moxie)
6183d15a9c23SAnthony Green  ;;
6184e671711cSMarek Vasut  nios2)
6185e671711cSMarek Vasut  ;;
61864a09d0bbSRichard Henderson  or1k)
6187e67db06eSJia Liu    TARGET_ARCH=openrisc
6188e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
6189e67db06eSJia Liu  ;;
61902408a527Saurel32  ppc)
6191c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
61922408a527Saurel32  ;;
61932408a527Saurel32  ppcemb)
61946acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6195e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6196c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
61972408a527Saurel32  ;;
61982408a527Saurel32  ppc64)
61996acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6200e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
6201f0b0685dSNikunj A Dadhania    mttcg=yes
62021438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62032408a527Saurel32  ;;
62049c35126cSDoug Kwan  ppc64le)
62059c35126cSDoug Kwan    TARGET_ARCH=ppc64
62069c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
62079c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
6208f0b0685dSNikunj A Dadhania    mttcg=yes
62091438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62109c35126cSDoug Kwan  ;;
62112408a527Saurel32  ppc64abi32)
6212b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
62136acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
6214e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
621525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62161438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
62172408a527Saurel32  ;;
62182408a527Saurel32  sh4|sh4eb)
6219b498c8a0SJuan Quintela    TARGET_ARCH=sh4
62204dbed897Spbrook    bflt="yes"
62212408a527Saurel32  ;;
62222408a527Saurel32  sparc)
62232408a527Saurel32  ;;
62242408a527Saurel32  sparc64)
62256acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
62262408a527Saurel32  ;;
62272408a527Saurel32  sparc32plus)
6228b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
62296acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
6230e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
623125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
62322408a527Saurel32  ;;
623324e804ecSAlexander Graf  s390x)
62348a641ff6SDavid Hildenbrand    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
623524e804ecSAlexander Graf  ;;
6236444e06b1SChen Gang  tilegx)
6237444e06b1SChen Gang  ;;
62385ecaa4edSPeter Crosthwaite  tricore)
62395ecaa4edSPeter Crosthwaite  ;;
6240d2fbca94SGuan Xuetao  unicore32)
6241d2fbca94SGuan Xuetao  ;;
6242cfa550c6SMax Filippov  xtensa|xtensaeb)
6243cfa550c6SMax Filippov    TARGET_ARCH=xtensa
6244cfa550c6SMax Filippov  ;;
62452408a527Saurel32  *)
624676ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
62472408a527Saurel32  ;;
62482408a527Saurel32esac
62495e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
62505e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
62515e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
62525e8861a0SPaolo Bonzinifi
62535e8861a0SPaolo Bonzini
62545e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
62555e8861a0SPaolo Bonzini
625699afc91dSDaniel P. Berrangeupper() {
625799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
625899afc91dSDaniel P. Berrange}
625999afc91dSDaniel P. Berrange
626089138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
626125be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
6262c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
626325be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6264e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
6265e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
6266e6e91b9cSJuan Quintelafi
626725be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6268adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
6269adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6270adfc3e91SStacey Sonfi
62713b6b7550SPaolo Bonzini
62723b6b7550SPaolo Bonziniif supported_xen_target $target; then
627325be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
6274eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
6275eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6276eb6fda0fSAnthony PERARD    fi
6277432d268cSJun Nakajimafi
62783b6b7550SPaolo Bonziniif supported_kvm_target $target; then
627925be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
62801ba16968SStefan Weil    if test "$vhost_net" = "yes" ; then
6281d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6282421f4448SMarc-André Lureau        echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
6283d5970055SMichael S. Tsirkin    fi
6284c59249f9SJuan Quintelafi
62853b6b7550SPaolo Bonziniif supported_hax_target $target; then
6286b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
6287b0cb0a66SVincent Palatinfi
6288de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
628925be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
629097a847bcSbellardfi
629197a847bcSbellardif test "$target_softmmu" = "yes" ; then
629225be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6293ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
6294ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6295ca759f9eSAlex Bennée  fi
6296de83cd02Sbellardfi
6297997344f3Sbellardif test "$target_user_only" = "yes" ; then
629825be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6299a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6300997344f3Sbellardfi
6301831b7825Sthsif test "$target_linux_user" = "yes" ; then
630225be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6303831b7825Sthsfi
630456aebc89Spbrooklist=""
630556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
630656aebc89Spbrook  for x in $gdb_xml_files; do
630756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
630856aebc89Spbrook  done
630925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
63103d0f1517SJuan Quintelafi
6311de83cd02Sbellard
6312e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
631325be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6314e5fe0c52Spbrookfi
631584778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
631625be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
631784778508Sblueswir1fi
63185b0753e0Sbellard
63194afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6320fa282484SJuan Quintela
63214afddb55SJuan Quintelacflags=""
6322fa282484SJuan Quintelaldflags=""
63239b8e111fSJuan Quintela
6324c765fcacSPeter Crosthwaitedisas_config() {
6325c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6326c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6327c765fcacSPeter Crosthwaite}
6328c765fcacSPeter Crosthwaite
632964656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
633064656024SJuan Quintela  case "$i" in
633164656024SJuan Quintela  alpha)
6332c765fcacSPeter Crosthwaite    disas_config "ALPHA"
633364656024SJuan Quintela  ;;
633482295d8aSRichard Henderson  aarch64)
633582295d8aSRichard Henderson    if test -n "${cxx}"; then
6336c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
633782295d8aSRichard Henderson    fi
633882295d8aSRichard Henderson  ;;
633964656024SJuan Quintela  arm)
6340c765fcacSPeter Crosthwaite    disas_config "ARM"
6341999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6342c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6343999b53ecSClaudio Fontana    fi
634464656024SJuan Quintela  ;;
634564656024SJuan Quintela  cris)
6346c765fcacSPeter Crosthwaite    disas_config "CRIS"
634764656024SJuan Quintela  ;;
6348429b31a2SRichard Henderson  hppa)
6349429b31a2SRichard Henderson    disas_config "HPPA"
6350429b31a2SRichard Henderson  ;;
6351c72b26ecSRichard Henderson  i386|x86_64|x32)
6352c765fcacSPeter Crosthwaite    disas_config "I386"
635364656024SJuan Quintela  ;;
6354903ec55cSAurelien Jarno  ia64*)
6355c765fcacSPeter Crosthwaite    disas_config "IA64"
6356903ec55cSAurelien Jarno  ;;
635779368f49SMichael Walle  lm32)
6358c765fcacSPeter Crosthwaite    disas_config "LM32"
635979368f49SMichael Walle  ;;
636064656024SJuan Quintela  m68k)
6361c765fcacSPeter Crosthwaite    disas_config "M68K"
636264656024SJuan Quintela  ;;
6363877fdc12SEdgar E. Iglesias  microblaze*)
6364c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
636564656024SJuan Quintela  ;;
636664656024SJuan Quintela  mips*)
6367c765fcacSPeter Crosthwaite    disas_config "MIPS"
636864656024SJuan Quintela  ;;
6369d15a9c23SAnthony Green  moxie*)
6370c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6371d15a9c23SAnthony Green  ;;
6372e671711cSMarek Vasut  nios2)
6373e671711cSMarek Vasut    disas_config "NIOS2"
6374e671711cSMarek Vasut  ;;
63754a09d0bbSRichard Henderson  or1k)
6376c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6377e67db06eSJia Liu  ;;
637864656024SJuan Quintela  ppc*)
6379c765fcacSPeter Crosthwaite    disas_config "PPC"
638064656024SJuan Quintela  ;;
638124e804ecSAlexander Graf  s390*)
6382c765fcacSPeter Crosthwaite    disas_config "S390"
638364656024SJuan Quintela  ;;
638464656024SJuan Quintela  sh4)
6385c765fcacSPeter Crosthwaite    disas_config "SH4"
638664656024SJuan Quintela  ;;
638764656024SJuan Quintela  sparc*)
6388c765fcacSPeter Crosthwaite    disas_config "SPARC"
638964656024SJuan Quintela  ;;
6390cfa550c6SMax Filippov  xtensa*)
6391c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6392cfa550c6SMax Filippov  ;;
639364656024SJuan Quintela  esac
639464656024SJuan Quinteladone
63959195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6396c765fcacSPeter Crosthwaite  disas_config "TCI"
63979195b2c2SStefan Weilfi
639864656024SJuan Quintela
63996ee7126fSJuan Quintelacase "$ARCH" in
64006ee7126fSJuan Quintelaalpha)
64016ee7126fSJuan Quintela  # Ensure there's only a single GP
64026ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
64036ee7126fSJuan Quintela;;
64046ee7126fSJuan Quintelaesac
64056ee7126fSJuan Quintela
6406d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
640725be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6408d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6409d02c1db3SJuan Quintela    cflags="-p $cflags"
6410d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6411d02c1db3SJuan Quintela  fi
6412d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6413d02c1db3SJuan Quintela    ldflags="-p $ldflags"
641425be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6415d02c1db3SJuan Quintela  fi
6416d02c1db3SJuan Quintelafi
6417d02c1db3SJuan Quintela
64189b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6419964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6420fa282484SJuan Quintelafi
6421fa282484SJuan Quintela
642225be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
642325be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6424fa282484SJuan Quintela
642597a847bcSbellarddone # for target in $targets
64267d13299dSbellard
6427b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
6428b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
6429b776eca1SGerd Hoffmannfi
6430b776eca1SGerd Hoffmann
6431a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6432a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6433a540f158SPeter Crosthwaitefi
6434a540f158SPeter Crosthwaite
6435a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6436a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6437a99d57bbSWanlong Gaofi
6438a99d57bbSWanlong Gao
6439fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6440fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6441fd0e6053SJohn Snowfi
6442fd0e6053SJohn Snow
6443d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6444f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6445d59157eaSPaolo BonziniDIRS="$DIRS docs docs/interop fsdev"
64469933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
64472d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
64482dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6449c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6450c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6451aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6452ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6453446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
64549933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
64552d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
64564652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
64573a586d2fSStefan HajnocziFILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6458753d11f2SRichard Hendersonfor bios_file in \
6459753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6460225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
64615acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6462753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6463753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6464e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6465753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
64664e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6467753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6468753d11f2SRichard Hendersondo
646989138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
64707ea78b74SJan Kiszkadone
647189138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6472c2304b52SMarcel Apfelbaumdo
647389138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6474c2304b52SMarcel Apfelbaumdone
6475d1807a4fSPaolo Bonzinimkdir -p $DIRS
64767d13299dSbellardfor f in $FILES ; do
6477cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6478f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6479f9245e10SPeter Maydell    fi
64807d13299dSbellarddone
64811ad2134fSPaul Brook
6482c34ebfdcSAnthony Liguori# temporary config to build submodules
64832d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6484c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
648537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6486c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6487cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
64885f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6489c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6490c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
64913dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6492c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6493a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6494c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
6495c34ebfdcSAnthony Liguoridone
6496c34ebfdcSAnthony Liguori
6497fe31017fSMarc-André Lureau# set up tests data directory
6498fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6499fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6500fe31017fSMarc-André Lureaufi
6501fe31017fSMarc-André Lureau
650276c7560aSMax Reitz# set up qemu-iotests in this build directory
650376c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
650476c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
650576c7560aSMax Reitz
650676c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
650776c7560aSMax Reitzecho >> "$iotests_common_env"
650876c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
650976c7560aSMax Reitz
651076c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
651176c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
651276c7560aSMax Reitzfi
651376c7560aSMax Reitz
6514dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6515dc655404SMichael S. Tsirkincat <<EOD >config.status
6516dc655404SMichael S. Tsirkin#!/bin/sh
6517dc655404SMichael S. Tsirkin# Generated by configure.
6518dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6519dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6520dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6521dc655404SMichael S. TsirkinEOD
6522dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6523dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6524cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6525dc655404SMichael S. Tsirkinchmod +x config.status
6526dc655404SMichael S. Tsirkin
65278cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6528