xref: /openbmc/qemu/configure (revision b8e0c4938b610a56028303dd8a2429cf1de71bb8)
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
14dedad027SDaniel P. Berrangé# make source path absolute
15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd)
16dedad027SDaniel P. Berrangé
17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path"
18dedad027SDaniel P. Berrangéthen
19dedad027SDaniel P. Berrangé    echo "Using './build' as the directory for build output"
20dedad027SDaniel P. Berrangé
21dedad027SDaniel P. Berrangé    MARKER=build/auto-created-by-configure
22dedad027SDaniel P. Berrangé
23dedad027SDaniel P. Berrangé    if test -e build
24dedad027SDaniel P. Berrangé    then
25dedad027SDaniel P. Berrangé        if test -f $MARKER
26dedad027SDaniel P. Berrangé        then
27dedad027SDaniel P. Berrangé           rm -rf build
28dedad027SDaniel P. Berrangé        else
29dedad027SDaniel P. Berrangé            echo "ERROR: ./build dir already exists and was not previously created by configure"
30dedad027SDaniel P. Berrangé            exit 1
31dedad027SDaniel P. Berrangé        fi
32dedad027SDaniel P. Berrangé    fi
33dedad027SDaniel P. Berrangé
34dedad027SDaniel P. Berrangé    mkdir build
35dedad027SDaniel P. Berrangé    touch $MARKER
36dedad027SDaniel P. Berrangé
37dedad027SDaniel P. Berrangé    cat > GNUmakefile <<'EOF'
38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree
39dedad027SDaniel P. Berrangé# 'make' command invocation
40dedad027SDaniel P. Berrangé
41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),)
42dedad027SDaniel P. Berrangérecurse: all
43dedad027SDaniel P. Berrangéendif
44dedad027SDaniel P. Berrangé
45dedad027SDaniel P. Berrangé.NOTPARALLEL: %
46dedad027SDaniel P. Berrangé%: force
47dedad027SDaniel P. Berrangé	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48dedad027SDaniel P. Berrangé	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49dedad027SDaniel P. Berrangé	@if test "$(MAKECMDGOALS)" = "distclean" && \
50dedad027SDaniel P. Berrangé	    test -e build/auto-created-by-configure ; \
51dedad027SDaniel P. Berrangé	then \
52dedad027SDaniel P. Berrangé	    rm -rf build GNUmakefile ; \
53dedad027SDaniel P. Berrangé	fi
54dedad027SDaniel P. Berrangéforce: ;
55dedad027SDaniel P. Berrangé.PHONY: force
56dedad027SDaniel P. BerrangéGNUmakefile: ;
57dedad027SDaniel P. Berrangé
58dedad027SDaniel P. BerrangéEOF
59dedad027SDaniel P. Berrangé    cd build
60dedad027SDaniel P. Berrangé    exec $source_path/configure "$@"
61dedad027SDaniel P. Berrangéfi
62dedad027SDaniel P. Berrangé
638cd05ab6SPeter Maydell# Temporary directory used for files created while
648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
658cd05ab6SPeter Maydell# we can safely blow away any previous version of it
668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
678cd05ab6SPeter Maydell# it when configure exits.)
688cd05ab6SPeter MaydellTMPDIR1="config-temp"
698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
728cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
738cd05ab6SPeter Maydell    exit 1
747d13299dSbellardfi
757d13299dSbellard
768cd05ab6SPeter MaydellTMPB="qemu-conf"
778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
8126fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
827d13299dSbellard
83da1d85e3SGerd Hoffmannrm -f config.log
849ac81bbbSmalc
85b48e3611SPeter Maydell# Print a helpful header at the top of config.log
86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
87979ae168SPeter Maydellprintf "# Configured with:" >> config.log
88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
89979ae168SPeter Maydellecho >> config.log
90b48e3611SPeter Maydellecho "#" >> config.log
91b48e3611SPeter Maydell
92835af899SPaolo Bonziniquote_sh() {
93835af899SPaolo Bonzini    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94835af899SPaolo Bonzini}
95835af899SPaolo Bonzini
96d880a3baSPaolo Bonziniprint_error() {
97d880a3baSPaolo Bonzini    (echo
9876ad07a4SPeter Maydell    echo "ERROR: $1"
9976ad07a4SPeter Maydell    while test -n "$2"; do
10076ad07a4SPeter Maydell        echo "       $2"
10176ad07a4SPeter Maydell        shift
10276ad07a4SPeter Maydell    done
103d880a3baSPaolo Bonzini    echo) >&2
104d880a3baSPaolo Bonzini}
105d880a3baSPaolo Bonzini
106d880a3baSPaolo Bonzinierror_exit() {
107d880a3baSPaolo Bonzini    print_error "$@"
10876ad07a4SPeter Maydell    exit 1
10976ad07a4SPeter Maydell}
11076ad07a4SPeter Maydell
1119c83ffd8SPeter Maydelldo_compiler() {
1129c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1139c83ffd8SPeter Maydell    # is compiler binary to execute.
114630d86b7SDavid CARLIER    compiler="$1"
1159c83ffd8SPeter Maydell    shift
1168bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1178bbe05d7SIan Jackson        echo >>config.log "
1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1208bbe05d7SIan Jackson    '; fi
1219c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1229c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1238dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1248dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1258dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1268dc38a78SPeter Maydell    # obvious to developers.
1278dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1288dc38a78SPeter Maydell        return 0
1298dc38a78SPeter Maydell    fi
1308dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1318dc38a78SPeter Maydell    case "$*" in
1328dc38a78SPeter Maydell        *-Werror*)
1338dc38a78SPeter Maydell           return 0
1348dc38a78SPeter Maydell        ;;
1358dc38a78SPeter Maydell    esac
1369c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1379c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13876ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13976ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
14076ad07a4SPeter Maydell        "will be at the bottom of config.log." \
14176ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1428dc38a78SPeter Maydell}
1438dc38a78SPeter Maydell
1449c83ffd8SPeter Maydelldo_cc() {
1459c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1499c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
1509c83ffd8SPeter Maydell}
1519c83ffd8SPeter Maydell
15200849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15300849b92SRichard Hendersonadd_to() {
15400849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15500849b92SRichard Henderson}
15600849b92SRichard Henderson
1579c83ffd8SPeter Maydellupdate_cxxflags() {
1589c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1599c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1609c83ffd8SPeter Maydell    # because they only make sense for C programs.
16153422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1625770e8afSPaolo Bonzini    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
1639c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1649c83ffd8SPeter Maydell        case $arg in
1659c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1669c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1679c83ffd8SPeter Maydell                ;;
1689c83ffd8SPeter Maydell            *)
1699c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1709c83ffd8SPeter Maydell                ;;
1719c83ffd8SPeter Maydell        esac
1729c83ffd8SPeter Maydell    done
1739c83ffd8SPeter Maydell}
1749c83ffd8SPeter Maydell
17552166aa0SJuan Quintelacompile_object() {
176fd0e6053SJohn Snow  local_cflags="$1"
1775770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17852166aa0SJuan Quintela}
17952166aa0SJuan Quintela
18052166aa0SJuan Quintelacompile_prog() {
18152166aa0SJuan Quintela  local_cflags="$1"
18252166aa0SJuan Quintela  local_ldflags="$2"
1835770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
1845770e8afSPaolo Bonzini      $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
18552166aa0SJuan Quintela}
18652166aa0SJuan Quintela
18711568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18811568d6dSPaolo Bonzinisymlink() {
18972b8b5a1SStefan Weil  rm -rf "$2"
190ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
19172b8b5a1SStefan Weil  ln -s "$1" "$2"
19211568d6dSPaolo Bonzini}
19311568d6dSPaolo Bonzini
1940dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1950dba6195SLoïc Minier# executable or a builtin)
1960dba6195SLoïc Minierhas() {
1970dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1980dba6195SLoïc Minier}
1990dba6195SLoïc Minier
2000a01d76fSMarc-André Lureauversion_ge () {
2012df52b9bSAlex Bennée    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
2022df52b9bSAlex Bennée    local_ver2=$(echo "$2" | tr . ' ')
2030a01d76fSMarc-André Lureau    while true; do
2040a01d76fSMarc-André Lureau        set x $local_ver1
2050a01d76fSMarc-André Lureau        local_first=${2-0}
206c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207c44a33e2SStefano Garzarella        shift ${2:+2}
2080a01d76fSMarc-André Lureau        local_ver1=$*
2090a01d76fSMarc-André Lureau        set x $local_ver2
2100a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2110a01d76fSMarc-André Lureau        test $# = 1 && return 0
2120a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2130a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
214c44a33e2SStefano Garzarella        shift ${2:+2}
2150a01d76fSMarc-André Lureau        local_ver2=$*
2160a01d76fSMarc-André Lureau    done
2170a01d76fSMarc-André Lureau}
2180a01d76fSMarc-André Lureau
2195b808275SLluís Vilanovahave_backend () {
2205b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2215b808275SLluís Vilanova}
2225b808275SLluís Vilanova
2233b6b7550SPaolo Bonziniglob() {
2243b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2253b6b7550SPaolo Bonzini}
2263b6b7550SPaolo Bonzini
227e9a3591fSChristian Borntraegerld_has() {
228e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
229e9a3591fSChristian Borntraeger}
230e9a3591fSChristian Borntraeger
2314ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2324ace32e2SAntonio Ospitethen
2334ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2344ace32e2SAntonio Ospitefi
2354ace32e2SAntonio Ospite
23614211825SAntonio Ospite# default parameters
2372ff6b91eSJuan Quintelacpu=""
238a31a8642SMichael S. Tsirkiniasl="iasl"
2391e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
24043ce4dfeSbellardstatic="no"
2413812c0c4SJoelle van Dynecross_compile="no"
2427d13299dSbellardcross_prefix=""
2430c58ac1cSmalcaudio_drv_list=""
244b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
245b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
246e49d021eSPeter Maydellhost_cc="cc"
247d5631638Smalcaudio_win_int=""
248957f1f99SMichael Rothlibs_qga=""
2495bc62e01SGerd Hoffmanndebug_info="yes"
250cdad781dSDaniele Buonolto="false"
25163678e17SSteven Noonanstack_protector=""
2521e4f6065SDaniele Buonosafe_stack=""
253afc3a8f9SAlex Bennéeuse_containers="yes"
254f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255ac0df51dSaliguori
25692712822SDaniel P. Berrangeif test -e "$source_path/.git"
25792712822SDaniel P. Berrangethen
2587d7dbf9dSDan Streetman    git_submodules_action="update"
25992712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
2603ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
2613ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
26292712822SDaniel P. Berrangeelse
2637d7dbf9dSDan Streetman    git_submodules_action="ignore"
264aef45d51SDaniel P. Berrange    git_submodules=""
2655c0ef67aSDaniel P. Berrangé
2665c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
2675c0ef67aSDaniel P. Berrangé    then
2685c0ef67aSDaniel P. Berrangé        echo
2695c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
2705c0ef67aSDaniel P. Berrangé        echo
2715c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
2725c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
2735c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
2745c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
2755c0ef67aSDaniel P. Berrangé        echo
276a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
2775c0ef67aSDaniel P. Berrangé        echo
2785c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
2795c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
2805c0ef67aSDaniel P. Berrangé        echo
2815c0ef67aSDaniel P. Berrangé        exit 1
2825c0ef67aSDaniel P. Berrangé    fi
28392712822SDaniel P. Berrangefi
284cc84d63aSDaniel P. Berrangegit="git"
285ac0df51dSaliguori
286afb63ebdSStefan Weil# Don't accept a target_list environment variable.
287afb63ebdSStefan Weilunset target_list
288447e133fSAlex Bennéeunset target_list_exclude
289377529c0SPaolo Bonzini
290377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
291377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
292377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
293377529c0SPaolo Bonzini#              unless --disable-foo is given
294377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
295377529c0SPaolo Bonzini#              feature will searched for,
296377529c0SPaolo Bonzini#              if not found, configure exits with error
297377529c0SPaolo Bonzini#
298377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
299377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
300377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
301377529c0SPaolo Bonzini
302c87ea116SAlex Bennéedefault_feature=""
303c87ea116SAlex Bennée# parse CC options second
304c87ea116SAlex Bennéefor opt do
305c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
306c87ea116SAlex Bennée  case "$opt" in
307c87ea116SAlex Bennée      --without-default-features)
308c87ea116SAlex Bennée          default_feature="no"
309c87ea116SAlex Bennée  ;;
310c87ea116SAlex Bennée  esac
311c87ea116SAlex Bennéedone
312c87ea116SAlex Bennée
3138c6d4ff4SPaolo Bonzinibrlapi="auto"
314f9cd86feSPaolo Bonzinicurl="auto"
3155285e593SYonggang Luoiconv="auto"
3165285e593SYonggang Luocurses="auto"
317e3667660SYonggang Luodocs="auto"
318fbb4121dSPaolo Bonzinifdt="auto"
31958952137SVincenzo Maffionenetmap="no"
32035be72baSPaolo Bonzinisdl="auto"
32135be72baSPaolo Bonzinisdl_image="auto"
322422a5fd0SJoelle van Dynecoreaudio="auto"
323cece116cSMisono Tomohirovirtiofsd="auto"
32469202b40SPaolo Bonzinivirtfs="auto"
3255c53015aSPaolo Bonzinilibudev="auto"
3266ec0e15dSPaolo Bonzinimpath="auto"
327a0b93237SPaolo Bonzinivnc="enabled"
328deb62371SPaolo Bonzinisparse="auto"
329c87ea116SAlex Bennéevde="$default_feature"
330a0b93237SPaolo Bonzinivnc_sasl="auto"
331a0b93237SPaolo Bonzinivnc_jpeg="auto"
332a0b93237SPaolo Bonzinivnc_png="auto"
3334113f4cfSLaurent Vivierxkbcommon="auto"
334c87ea116SAlex Bennéexen="$default_feature"
335c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3361badb709SPaolo Bonzinixen_pci_passthrough="auto"
337c87ea116SAlex Bennéelinux_aio="$default_feature"
338c87ea116SAlex Bennéelinux_io_uring="$default_feature"
339727c8bb8SPaolo Bonzinicap_ng="auto"
340f7f2d651SPaolo Bonziniattr="auto"
341c87ea116SAlex Bennéexfs="$default_feature"
3421badb709SPaolo Bonzinitcg="enabled"
343c87ea116SAlex Bennéemembarrier="$default_feature"
344c87ea116SAlex Bennéevhost_net="$default_feature"
345c87ea116SAlex Bennéevhost_crypto="$default_feature"
346c87ea116SAlex Bennéevhost_scsi="$default_feature"
347c87ea116SAlex Bennéevhost_vsock="$default_feature"
348d88618f7SStefan Hajnoczivhost_user="no"
349e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
350c87ea116SAlex Bennéevhost_user_fs="$default_feature"
3513bd40ec7SPaolo Bonzinikvm="auto"
3523bd40ec7SPaolo Bonzinihax="auto"
3533bd40ec7SPaolo Bonzinihvf="auto"
3543bd40ec7SPaolo Bonziniwhpx="auto"
35574a414a1SReinoud Zandijknvmm="auto"
356c87ea116SAlex Bennéerdma="$default_feature"
357c87ea116SAlex Bennéepvrdma="$default_feature"
358377529c0SPaolo Bonzinigprof="no"
359377529c0SPaolo Bonzinidebug_tcg="no"
360377529c0SPaolo Bonzinidebug="no"
361247724cbSMarc-André Lureausanitizers="no"
3620aebab04SLingfeng Yangtsan="no"
363c87ea116SAlex Bennéefortify_source="$default_feature"
364377529c0SPaolo Bonzinistrip_opt="yes"
36523a77b2dSPaolo Bonzinitcg_interpreter="false"
366377529c0SPaolo Bonzinibigendian="no"
367377529c0SPaolo Bonzinimingw32="no"
3681d728c39SBlue Swirlgcov="no"
369c7328271SMiroslav RezaninaEXESUF=""
370484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
37117969268SFam Zhengmodules="no"
372bd83c861SChristian Ehrhardtmodule_upgrades="no"
373377529c0SPaolo Bonziniprefix="/usr/local"
37410ff82d1SMarc-André Lureauqemu_suffix="qemu"
3754d34a86bSPaolo Bonzinislirp="auto"
376377529c0SPaolo Bonzinioss_lib=""
377377529c0SPaolo Bonzinibsd="no"
378377529c0SPaolo Bonzinilinux="no"
379377529c0SPaolo Bonzinisolaris="no"
380377529c0SPaolo Bonziniprofiler="no"
381b4e312e9SPaolo Bonzinicocoa="auto"
382377529c0SPaolo Bonzinisoftmmu="yes"
383377529c0SPaolo Bonzinilinux_user="no"
384377529c0SPaolo Bonzinibsd_user="no"
385c8d5450bSPaolo Bonziniblobs="true"
386377529c0SPaolo Bonzinipkgversion=""
38740d6444eSAvi Kivitypie=""
3883556c233SPaolo Bonziniqom_cast_debug="yes"
389baf86d6bSPaolo Bonzinitrace_backends="log"
390377529c0SPaolo Bonzinitrace_file="trace"
391c87ea116SAlex Bennéespice="$default_feature"
392fabd1e93SPaolo Bonzinirbd="auto"
393c87ea116SAlex Bennéesmartcard="$default_feature"
3940a40bcb7SCésar Belleyu2f="auto"
395c87ea116SAlex Bennéelibusb="$default_feature"
396c87ea116SAlex Bennéeusb_redir="$default_feature"
397c87ea116SAlex Bennéeopengl="$default_feature"
3985dd89908SRichard Hendersoncpuid_h="no"
399c87ea116SAlex Bennéeavx2_opt="$default_feature"
4008b18cdbfSRichard Hendersoncapstone="auto"
4010c32a0aeSPaolo Bonzinilzo="auto"
402241611eaSPaolo Bonzinisnappy="auto"
40329ba6116SPaolo Bonzinibzip2="auto"
404ecea3696SPaolo Bonzinilzfse="auto"
405b1def33dSPaolo Bonzinizstd="auto"
406c87ea116SAlex Bennéeguest_agent="$default_feature"
407d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
40850cbebb9SMichael Rothguest_agent_ntddscsi="no"
409b846ab7cSPaolo Bonziniguest_agent_msi="auto"
410c87ea116SAlex Bennéevss_win32_sdk="$default_feature"
411d9840e25STomoki Sekiyamawin_sdk="no"
412c87ea116SAlex Bennéewant_tools="$default_feature"
4139db405a3SPaolo Bonzinilibiscsi="auto"
41430045c05SPaolo Bonzinilibnfs="auto"
415519175a2SAlex Barcelocoroutine=""
416c87ea116SAlex Bennéecoroutine_pool="$default_feature"
4177d992e4dSPeter Lievendebug_stack_usage="no"
418f0d92b56SLongpeng(Mike)crypto_afalg="no"
4199e62ba48SDaniele Buonocfi="false"
4209e62ba48SDaniele Buonocfi_debug="false"
42190835c2bSPaolo Bonziniseccomp="auto"
42208821ca2SPaolo Bonziniglusterfs="auto"
4231b695471SPaolo Bonzinigtk="auto"
424a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
425c87ea116SAlex Bennéegnutls="$default_feature"
426c87ea116SAlex Bennéenettle="$default_feature"
427dc2207afSDaniel P. Berrangénettle_xts="no"
428c87ea116SAlex Bennéegcrypt="$default_feature"
4291f923c70SLongpeng(Mike)gcrypt_hmac="no"
430e0576942SDaniel P. Berrangégcrypt_xts="no"
431e0576942SDaniel P. Berrangéqemu_private_xts="yes"
432c87ea116SAlex Bennéeauth_pam="$default_feature"
433c87ea116SAlex Bennéevte="$default_feature"
434c87ea116SAlex Bennéevirglrenderer="$default_feature"
435c87ea116SAlex Bennéetpm="$default_feature"
436c87ea116SAlex Bennéelibssh="$default_feature"
437c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes}
438c87ea116SAlex Bennéenuma="$default_feature"
4392847b469SFam Zhengtcmalloc="no"
4407b01cb97SAlexandre Derumierjemalloc="no"
441c87ea116SAlex Bennéereplication=${default_feature:-yes}
442c87ea116SAlex Bennéebochs=${default_feature:-yes}
443c87ea116SAlex Bennéecloop=${default_feature:-yes}
444c87ea116SAlex Bennéedmg=${default_feature:-yes}
445c87ea116SAlex Bennéeqcow1=${default_feature:-yes}
446c87ea116SAlex Bennéevdi=${default_feature:-yes}
447c87ea116SAlex Bennéevvfat=${default_feature:-yes}
448c87ea116SAlex Bennéeqed=${default_feature:-yes}
449c87ea116SAlex Bennéeparallels=${default_feature:-yes}
450e1c42697SDaniel P. Berrangésheepdog="no"
451c87ea116SAlex Bennéelibxml2="$default_feature"
452ba59fb77SPaolo Bonzinidebug_mutex="no"
453c87ea116SAlex Bennéelibpmem="$default_feature"
4547bc3ca7fSPaolo Bonzinidefault_devices="true"
45540e8c6f4SAlex Bennéeplugins="no"
456adc28027SAlexander Bulekovfuzzing="no"
457b767d257SMarek Marczykowski-Góreckirng_none="no"
458c87ea116SAlex Bennéesecret_keyring="$default_feature"
459c87ea116SAlex Bennéelibdaxctl="$default_feature"
460a5665051SPaolo Bonzinimeson=""
46148328880SPaolo Bonzinininja=""
462a5665051SPaolo Bonziniskip_meson=no
4630e8e77d4SAlex Bennéegettext="auto"
464a484a719SMax Reitzfuse="auto"
465df4ea709SMax Reitzfuse_lseek="auto"
466106ad1f9SPaolo Bonzinimultiprocess="auto"
467*b8e0c493SJoelle van Dyneslirp_smbd="$default_feature"
468377529c0SPaolo Bonzini
469aa087962SPaolo Bonzinimalloc_trim="auto"
47020cf7b8eSDenis Plotnikovgio="$default_feature"
471898be3e0SPeter Maydell
472c87ea116SAlex Bennée# parse CC options second
473ac0df51dSaliguorifor opt do
47489138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
475ac0df51dSaliguori  case "$opt" in
476ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
4773812c0c4SJoelle van Dyne                    cross_compile="yes"
478ac0df51dSaliguori  ;;
4793d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
480ac0df51dSaliguori  ;;
48183f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
48283f73fceSTomoki Sekiyama  ;;
4832ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4842ff6b91eSJuan Quintela  ;;
485de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
486db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
487e2a2ed06SJuan Quintela  ;;
48811cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
48911cde1c8SBruno Dominguez  ;;
490db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
491f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
492e2a2ed06SJuan Quintela  ;;
4935bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4945bc62e01SGerd Hoffmann  ;;
4955bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4965bc62e01SGerd Hoffmann  ;;
497d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
498d75402b5SAlex Bennée  ;;
499d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
500d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
5012038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
502d422b2bcSAlex Bennée  ;;
503d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
5042038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
505d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
5062038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
507d75402b5SAlex Bennée  ;;
508ac0df51dSaliguori  esac
509ac0df51dSaliguoridone
510ac0df51dSaliguori# OS specific
511ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
51293148aa5SStefan Weil# we can eliminate its usage altogether.
513ac0df51dSaliguori
514e49d021eSPeter Maydell# Preferred compiler:
515e49d021eSPeter Maydell#  ${CC} (if set)
516e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
517e49d021eSPeter Maydell#  system compiler
518e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
519e49d021eSPeter Maydell  cc="$host_cc"
520e49d021eSPeter Maydellelse
521b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
522e49d021eSPeter Maydellfi
523e49d021eSPeter Maydell
52483f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
52583f73fceSTomoki Sekiyama  cxx="c++"
52683f73fceSTomoki Sekiyamaelse
52783f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
52883f73fceSTomoki Sekiyamafi
52983f73fceSTomoki Sekiyama
530b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
531cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5325f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5333dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
534b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
535b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5369f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5374852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
538b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
539b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
54017884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
54117884d7bSSergei Trofimovichquery_pkg_config() {
54217884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
54317884d7bSSergei Trofimovich}
54417884d7bSSergei Trofimovichpkg_config=query_pkg_config
54547c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
546ac0df51dSaliguori
54745d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
54845d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
54945d285abSPeter Maydell
550be17dc90SMichael S. Tsirkin# default flags for all hosts
5512d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5522d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5532d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5542d31515bSPeter Maydell# provides these semantics.)
555086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
556086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
557c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
558be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5595770e8afSPaolo Bonzini
5605770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
5615770e8afSPaolo BonziniCONFIGURE_CFLAGS="-std=gnu99 -Wall"
5625770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
563086d5f75SPaolo Bonzini
564be17dc90SMichael S. Tsirkin
565ac0df51dSaliguoricheck_define() {
566ac0df51dSaliguoricat > $TMPC <<EOF
567ac0df51dSaliguori#if !defined($1)
568fd786e1aSPeter Maydell#error $1 not defined
569ac0df51dSaliguori#endif
570ac0df51dSaliguoriint main(void) { return 0; }
571ac0df51dSaliguoriEOF
57252166aa0SJuan Quintela  compile_object
573ac0df51dSaliguori}
574ac0df51dSaliguori
575307119e7SGerd Hoffmanncheck_include() {
576307119e7SGerd Hoffmanncat > $TMPC <<EOF
577307119e7SGerd Hoffmann#include <$1>
578307119e7SGerd Hoffmannint main(void) { return 0; }
579307119e7SGerd HoffmannEOF
580307119e7SGerd Hoffmann  compile_object
581307119e7SGerd Hoffmann}
582307119e7SGerd Hoffmann
58393b25869SJohn Snowwrite_c_skeleton() {
58493b25869SJohn Snow    cat > $TMPC <<EOF
58593b25869SJohn Snowint main(void) { return 0; }
58693b25869SJohn SnowEOF
58793b25869SJohn Snow}
58893b25869SJohn Snow
589adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
590adc28027SAlexander Bulekov    cat > $TMPC <<EOF
591adc28027SAlexander Bulekov#include <stdint.h>
592adc28027SAlexander Bulekov#include <sys/types.h>
593adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
594adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
595adc28027SAlexander BulekovEOF
596adc28027SAlexander Bulekov}
597adc28027SAlexander Bulekov
598bbea4050SPeter Maydellif check_define __linux__ ; then
599bbea4050SPeter Maydell  targetos="Linux"
600bbea4050SPeter Maydellelif check_define _WIN32 ; then
601bbea4050SPeter Maydell  targetos='MINGW32'
602bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
603bbea4050SPeter Maydell  targetos='OpenBSD'
604bbea4050SPeter Maydellelif check_define __sun__ ; then
605bbea4050SPeter Maydell  targetos='SunOS'
606bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
607bbea4050SPeter Maydell  targetos='Haiku'
608951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
609951fedfcSPeter Maydell  targetos='FreeBSD'
610951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
611951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
612951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
613951fedfcSPeter Maydell  targetos='DragonFly'
614951fedfcSPeter Maydellelif check_define __NetBSD__; then
615951fedfcSPeter Maydell  targetos='NetBSD'
616951fedfcSPeter Maydellelif check_define __APPLE__; then
617951fedfcSPeter Maydell  targetos='Darwin'
618bbea4050SPeter Maydellelse
619951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
620951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
621951fedfcSPeter Maydell  # be the result of a missing compiler.
622951fedfcSPeter Maydell  targetos='bogus'
623bbea4050SPeter Maydellfi
624bbea4050SPeter Maydell
625bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
626bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
627bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
628bbea4050SPeter Maydell# the correct CPU with the --cpu option.
629bbea4050SPeter Maydellcase $targetos in
630bbea4050SPeter MaydellDarwin)
6315869f8ddSGerd Hoffmann  HOST_DSOSUF=".dylib"
632bbea4050SPeter Maydell  ;;
633bbea4050SPeter MaydellSunOS)
63489138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
635bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
636bbea4050SPeter Maydell    cpu="x86_64"
637bbea4050SPeter Maydell  fi
638bbea4050SPeter Maydellesac
639bbea4050SPeter Maydell
6402ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6412ff6b91eSJuan Quintela  # command line argument
6422ff6b91eSJuan Quintela  :
6432ff6b91eSJuan Quintelaelif check_define __i386__ ; then
644ac0df51dSaliguori  cpu="i386"
645ac0df51dSaliguorielif check_define __x86_64__ ; then
646c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
647c72b26ecSRichard Henderson    cpu="x32"
648c72b26ecSRichard Henderson  else
649ac0df51dSaliguori    cpu="x86_64"
650c72b26ecSRichard Henderson  fi
6513aa9bd6cSblueswir1elif check_define __sparc__ ; then
6523aa9bd6cSblueswir1  if check_define __arch64__ ; then
6533aa9bd6cSblueswir1    cpu="sparc64"
6543aa9bd6cSblueswir1  else
6553aa9bd6cSblueswir1    cpu="sparc"
6563aa9bd6cSblueswir1  fi
657fdf7ed96Smalcelif check_define _ARCH_PPC ; then
658fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
659f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
660f8378accSRichard Henderson      cpu="ppc64le"
661f8378accSRichard Henderson    else
662fdf7ed96Smalc      cpu="ppc64"
663f8378accSRichard Henderson    fi
664ac0df51dSaliguori  else
665fdf7ed96Smalc    cpu="ppc"
666fdf7ed96Smalc  fi
667afa05235SAurelien Jarnoelif check_define __mips__ ; then
668afa05235SAurelien Jarno  cpu="mips"
669d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
670d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
671d66ed0eaSAurelien Jarno    cpu="s390x"
672d66ed0eaSAurelien Jarno  else
673d66ed0eaSAurelien Jarno    cpu="s390"
674d66ed0eaSAurelien Jarno  fi
675c4f80543SAlistair Franciselif check_define __riscv ; then
676c4f80543SAlistair Francis  if check_define _LP64 ; then
677c4f80543SAlistair Francis    cpu="riscv64"
678c4f80543SAlistair Francis  else
679c4f80543SAlistair Francis    cpu="riscv32"
680c4f80543SAlistair Francis  fi
68121d89f84SPeter Maydellelif check_define __arm__ ; then
68221d89f84SPeter Maydell  cpu="arm"
6831f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6841f080313SClaudio Fontana  cpu="aarch64"
685fdf7ed96Smalcelse
68689138857SStefan Weil  cpu=$(uname -m)
687ac0df51dSaliguorifi
688ac0df51dSaliguori
689359bc95dSPeter MaydellARCH=
690359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
691359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6927d13299dSbellardcase "$cpu" in
693ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
694898be3e0SPeter Maydell  ;;
695f8378accSRichard Henderson  ppc64le)
696f8378accSRichard Henderson    ARCH="ppc64"
697f8378accSRichard Henderson  ;;
6987d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
69997a847bcSbellard    cpu="i386"
7007d13299dSbellard  ;;
701aaa5fa14Saurel32  x86_64|amd64)
702aaa5fa14Saurel32    cpu="x86_64"
703aaa5fa14Saurel32  ;;
70421d89f84SPeter Maydell  armv*b|armv*l|arm)
70521d89f84SPeter Maydell    cpu="arm"
7067d13299dSbellard  ;;
7071f080313SClaudio Fontana  aarch64)
7081f080313SClaudio Fontana    cpu="aarch64"
7091f080313SClaudio Fontana  ;;
710afa05235SAurelien Jarno  mips*)
711afa05235SAurelien Jarno    cpu="mips"
712afa05235SAurelien Jarno  ;;
7133142255cSblueswir1  sparc|sun4[cdmuv])
714ae228531Sbellard    cpu="sparc"
715ae228531Sbellard  ;;
7167d13299dSbellard  *)
717359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
718359bc95dSPeter Maydell    ARCH=unknown
7197d13299dSbellard  ;;
7207d13299dSbellardesac
721359bc95dSPeter Maydellif test -z "$ARCH"; then
722359bc95dSPeter Maydell  ARCH="$cpu"
723359bc95dSPeter Maydellfi
724e2d52ad3SJuan Quintela
7257d13299dSbellard# OS specific
7260dbfc675SJuan Quintela
7277d13299dSbellardcase $targetos in
72867b915a5SbellardMINGW32*)
72967b915a5Sbellard  mingw32="yes"
7303cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
731307119e7SGerd Hoffmann  if check_include dsound.h; then
7323cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
733307119e7SGerd Hoffmann  else
734307119e7SGerd Hoffmann    audio_drv_list=""
735307119e7SGerd Hoffmann  fi
736898be3e0SPeter Maydell  supported_os="yes"
737fb648e9cSDaniel P. Berrangé  pie="no"
73867b915a5Sbellard;;
7395c40d2bdSthsGNU/kFreeBSD)
740a167ba50SAurelien Jarno  bsd="yes"
7416a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7420bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7435c40d2bdSths;;
7447d3505c5SbellardFreeBSD)
7457d3505c5Sbellard  bsd="yes"
7460db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7476a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7480bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
749f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
75058952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7517d3505c5Sbellard;;
752c5e97233Sblueswir1DragonFly)
753c5e97233Sblueswir1  bsd="yes"
7540db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7556a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7560bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
757c5e97233Sblueswir1;;
7587d3505c5SbellardNetBSD)
7597d3505c5Sbellard  bsd="yes"
7600db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7616a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7620bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7638ef92a88Sblueswir1  oss_lib="-lossaudio"
7647d3505c5Sbellard;;
7657d3505c5SbellardOpenBSD)
7667d3505c5Sbellard  bsd="yes"
7670db4a067SPaolo Bonzini  make="${MAKE-gmake}"
768f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
7690bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
7707d3505c5Sbellard;;
77183fb7adfSbellardDarwin)
77283fb7adfSbellard  bsd="yes"
77383fb7adfSbellard  darwin="yes"
774422a5fd0SJoelle van Dyne  audio_drv_list="try-coreaudio try-sdl"
77514382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
776a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
777a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
778a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
77983fb7adfSbellard;;
780ec530c81SbellardSunOS)
781ec530c81Sbellard  solaris="yes"
7820db4a067SPaolo Bonzini  make="${MAKE-gmake}"
783e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7846b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7856a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
7866b4d2ba1Sths  fi
787c2de5c91Smalc  audio_possible_drivers="oss sdl"
788d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
789d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
790d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
791d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
792ec530c81Sbellard;;
793179cf400SAndreas FärberHaiku)
794179cf400SAndreas Färber  haiku="yes"
795cde99253SThomas Huth  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE $QEMU_CFLAGS"
796179cf400SAndreas Färber;;
797898be3e0SPeter MaydellLinux)
7987183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
7990bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8005327cf48Sbellard  linux="yes"
801831b7825Sths  linux_user="yes"
802c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
803898be3e0SPeter Maydell;;
8047d13299dSbellardesac
8057d13299dSbellard
8067d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
807b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
80884778508Sblueswir1    bsd_user="yes"
8097d3505c5Sbellard  fi
81008de3949SAndreas Färberfi
8117d3505c5Sbellard
8120db4a067SPaolo Bonzini: ${make=${MAKE-make}}
813b6daf4d3SPaolo Bonzini
814faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
815faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
816ddf90699SEduardo Habkost# we check that too
817faf44142SDaniel P. Berrangépython=
8180a01d76fSMarc-André Lureauexplicit_python=no
819ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
820faf44142SDaniel P. Berrangédo
821faf44142SDaniel P. Berrangé    if has "$binary"
822faf44142SDaniel P. Berrangé    then
82395c5f2deSPaolo Bonzini        python=$(command -v "$binary")
824faf44142SDaniel P. Berrangé        break
825faf44142SDaniel P. Berrangé    fi
826faf44142SDaniel P. Berrangédone
827903458c8SMarkus Armbruster
828903458c8SMarkus Armbruster
82939d87c8cSAlex Bennée# Check for ancillary tools used in testing
83039d87c8cSAlex Bennéegenisoimage=
8313df437c7SAlex Bennéefor binary in genisoimage mkisofs
83239d87c8cSAlex Bennéedo
83339d87c8cSAlex Bennée    if has $binary
83439d87c8cSAlex Bennée    then
83539d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
83639d87c8cSAlex Bennée        break
83739d87c8cSAlex Bennée    fi
83839d87c8cSAlex Bennéedone
83939d87c8cSAlex Bennée
8403c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8413c4a4d0dSPeter Maydellif has clang; then
8423c4a4d0dSPeter Maydell  objcc=clang
8433c4a4d0dSPeter Maydellelse
8443c4a4d0dSPeter Maydell  objcc="$cc"
8453c4a4d0dSPeter Maydellfi
8463c4a4d0dSPeter Maydell
8473457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8483457a3f8SJuan Quintela  EXESUF=".exe"
849484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
85078e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
8515770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
85293b25869SJohn Snow  write_c_skeleton;
853d17f305aSPaolo Bonzini  prefix="/qemu"
85477433a5fSMarc-André Lureau  qemu_suffix=""
855105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8563457a3f8SJuan Quintelafi
8573457a3f8SJuan Quintela
858487fefdbSAnthony Liguoriwerror=""
85985aa5189Sbellard
8607d13299dSbellardfor opt do
86189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8627d13299dSbellard  case "$opt" in
8632efc3265Sbellard  --help|-h) show_help=yes
8642efc3265Sbellard  ;;
86599123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
86699123e13SMike Frysinger  ;;
867b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8687d13299dSbellard  ;;
869b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
87032ce6337Sbellard  ;;
871ac0df51dSaliguori  --cross-prefix=*)
8727d13299dSbellard  ;;
873ac0df51dSaliguori  --cc=*)
8747d13299dSbellard  ;;
875b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
87683469015Sbellard  ;;
87783f73fceSTomoki Sekiyama  --cxx=*)
87883f73fceSTomoki Sekiyama  ;;
879e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
880e007dbecSMichael S. Tsirkin  ;;
8813c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8823c4a4d0dSPeter Maydell  ;;
883b1a550a0Spbrook  --make=*) make="$optarg"
8847d13299dSbellard  ;;
885b6daf4d3SPaolo Bonzini  --install=*)
8866a882643Spbrook  ;;
8870a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
888c886edfbSBlue Swirl  ;;
8892eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8902eb054c2SPeter Maydell  ;;
891a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
892a5665051SPaolo Bonzini  ;;
893a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
894a5665051SPaolo Bonzini  ;;
89548328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
89648328880SPaolo Bonzini  ;;
897e2d8830eSBrad  --smbd=*) smbd="$optarg"
898e2d8830eSBrad  ;;
899e2a2ed06SJuan Quintela  --extra-cflags=*)
9007d13299dSbellard  ;;
90111cde1c8SBruno Dominguez  --extra-cxxflags=*)
90211cde1c8SBruno Dominguez  ;;
903e2a2ed06SJuan Quintela  --extra-ldflags=*)
9047d13299dSbellard  ;;
9055bc62e01SGerd Hoffmann  --enable-debug-info)
9065bc62e01SGerd Hoffmann  ;;
9075bc62e01SGerd Hoffmann  --disable-debug-info)
9085bc62e01SGerd Hoffmann  ;;
909d75402b5SAlex Bennée  --cross-cc-*)
910d75402b5SAlex Bennée  ;;
91117969268SFam Zheng  --enable-modules)
91217969268SFam Zheng      modules="yes"
91317969268SFam Zheng  ;;
9143aa88b31SStefan Hajnoczi  --disable-modules)
9153aa88b31SStefan Hajnoczi      modules="no"
9163aa88b31SStefan Hajnoczi  ;;
917bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
918bd83c861SChristian Ehrhardt  ;;
919bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
920bd83c861SChristian Ehrhardt  ;;
9212ff6b91eSJuan Quintela  --cpu=*)
9227d13299dSbellard  ;;
923b1a550a0Spbrook  --target-list=*) target_list="$optarg"
924447e133fSAlex Bennée                   if test "$target_list_exclude"; then
925447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
926447e133fSAlex Bennée                   fi
927447e133fSAlex Bennée  ;;
928447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
929447e133fSAlex Bennée                   if test "$target_list"; then
930447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
931447e133fSAlex Bennée                   fi
932de83cd02Sbellard  ;;
9335b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9345b808275SLluís Vilanova  ;;
9355b808275SLluís Vilanova  # XXX: backwards compatibility
9365b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
93794a420b1SStefan Hajnoczi  ;;
93874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9399410b56cSPrerna Saxena  ;;
9407bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
941f3494749SPaolo Bonzini  ;;
9427bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
943f3494749SPaolo Bonzini  ;;
944c87ea116SAlex Bennée  --without-default-features) # processed above
945c87ea116SAlex Bennée  ;;
9467d13299dSbellard  --enable-gprof) gprof="yes"
9477d13299dSbellard  ;;
9481d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9491d728c39SBlue Swirl  ;;
95079427693SLoïc Minier  --static)
95179427693SLoïc Minier    static="yes"
95217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
95343ce4dfeSbellard  ;;
9540b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9550b24e75fSPaolo Bonzini  ;;
9560b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9570b24e75fSPaolo Bonzini  ;;
9583aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9593aa5d2beSAlon Levy  ;;
9608bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9618bf188aaSMichael Tokarev  ;;
9620f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9630f94d6daSAlon Levy  ;;
964528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9650b24e75fSPaolo Bonzini  ;;
96677433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
967023d3d67SEduardo Habkost  ;;
968c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9690b24e75fSPaolo Bonzini  ;;
970fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
971fe0038beSPaolo Bonzini  ;;
972ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
97307381cc1SAnthony Liguori  ;;
974785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
975785c23aeSLuiz Capitulino  ;;
9763d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9773d5eecabSGerd Hoffmann  ;;
978181ce1d0SOlaf Hering  --host=*|--build=*|\
979181ce1d0SOlaf Hering  --disable-dependency-tracking|\
980785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
981fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
982023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
983023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
984023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
985023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
986023ddd74SMax Filippov    # lots of directory switches by default.
987023ddd74SMax Filippov  ;;
98835be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
98997a847bcSbellard  ;;
99035be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
991c4198157SJuan Quintela  ;;
99235be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
993a442fe2fSDaniel P. Berrangé  ;;
99435be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
995a442fe2fSDaniel P. Berrangé  ;;
9963556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9973556c233SPaolo Bonzini  ;;
9983556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9993556c233SPaolo Bonzini  ;;
100069202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
1001983eef5aSMeador Inge  ;;
100269202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
1003983eef5aSMeador Inge  ;;
10045c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
10055c53015aSPaolo Bonzini  ;;
10065c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
10075c53015aSPaolo Bonzini  ;;
1008cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
1009cece116cSMisono Tomohiro  ;;
1010cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
1011cece116cSMisono Tomohiro  ;;
10126ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
1013fe8fc5aeSPaolo Bonzini  ;;
10146ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
1015fe8fc5aeSPaolo Bonzini  ;;
1016a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1017821601eaSJes Sorensen  ;;
1018a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1019821601eaSJes Sorensen  ;;
10200e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
1021e8f3bd71SMarc-André Lureau  ;;
10220e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
1023e8f3bd71SMarc-André Lureau  ;;
10242f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10252f6a1ab0Sblueswir1  ;;
10260c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10270c58ac1cSmalc  ;;
102889138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1029b64ec4e4SFam Zheng  ;;
103089138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1031eb852011SMarkus Armbruster  ;;
1032f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1033f8393946Saurel32  ;;
1034f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1035f8393946Saurel32  ;;
1036f3d08ee6SPaul Brook  --enable-debug)
1037f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1038f3d08ee6SPaul Brook      debug_tcg="yes"
10391fcc6d42SPeter Xu      debug_mutex="yes"
1040f3d08ee6SPaul Brook      debug="yes"
1041f3d08ee6SPaul Brook      strip_opt="no"
1042b553a042SJohn Snow      fortify_source="no"
1043f3d08ee6SPaul Brook  ;;
1044247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1045247724cbSMarc-André Lureau  ;;
1046247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1047247724cbSMarc-André Lureau  ;;
10480aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10490aebab04SLingfeng Yang  ;;
10500aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10510aebab04SLingfeng Yang  ;;
1052deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
105303b4fe7dSaliguori  ;;
1054deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
105503b4fe7dSaliguori  ;;
10561625af87Saliguori  --disable-strip) strip_opt="no"
10571625af87Saliguori  ;;
1058a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10592f9606b3Saliguori  ;;
1060a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1061ea784e3bSJuan Quintela  ;;
1062a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10632f6f5c7aSCorentin Chary  ;;
1064a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10652f6f5c7aSCorentin Chary  ;;
1066a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1067efe556adSCorentin Chary  ;;
1068a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1069efe556adSCorentin Chary  ;;
10704d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1071c20709aaSbellard  ;;
1072fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1073fd6fc214SPaolo Bonzini  ;;
10744d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10757c57bdd8SMarc-André Lureau  ;;
1076675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1077675b9b53SMarc-André Lureau  ;;
1078e0e6c8c0Saliguori  --disable-vde) vde="no"
10798a16d273Sths  ;;
1080dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1081dfb278bdSJuan Quintela  ;;
108258952137SVincenzo Maffione  --disable-netmap) netmap="no"
108358952137SVincenzo Maffione  ;;
108458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
108558952137SVincenzo Maffione  ;;
10861badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1087e37630caSaliguori  ;;
10881badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1089fc321b4bSJuan Quintela  ;;
10901badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1091eb6fda0fSAnthony PERARD  ;;
10921badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1093eb6fda0fSAnthony PERARD  ;;
10948c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
10952e4d9fb1Saurel32  ;;
10968c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
10974ffcedb6SJuan Quintela  ;;
10981badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10997ba1e619Saliguori  ;;
11001badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1101b31a0277SJuan Quintela  ;;
11021badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1103180fb750Szhanghailiang  ;;
11041badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1105180fb750Szhanghailiang  ;;
11061badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1107c97d6d2cSSergio Andres Gomez Del Real  ;;
11081badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1109c97d6d2cSSergio Andres Gomez Del Real  ;;
111074a414a1SReinoud Zandijk  --disable-nvmm) nvmm="disabled"
111174a414a1SReinoud Zandijk  ;;
111274a414a1SReinoud Zandijk  --enable-nvmm) nvmm="enabled"
111374a414a1SReinoud Zandijk  ;;
11141badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1115d661d9a4SJustin Terry (VM)  ;;
11161badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1117d661d9a4SJustin Terry (VM)  ;;
1118c6fbea47SRichard Henderson  --disable-tcg-interpreter) tcg_interpreter="false"
11199195b2c2SStefan Weil  ;;
1120c6fbea47SRichard Henderson  --enable-tcg-interpreter) tcg_interpreter="true"
11219195b2c2SStefan Weil  ;;
1122727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
112347e98658SCorey Bryant  ;;
1124727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
112547e98658SCorey Bryant  ;;
11261badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1127b3f6ea7eSPaolo Bonzini  ;;
11281badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1129b3f6ea7eSPaolo Bonzini  ;;
1130aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11315a22ab71SYang Zhong  ;;
1132aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11335a22ab71SYang Zhong  ;;
1134cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1135cd4ec0b4SGerd Hoffmann  ;;
1136cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1137cd4ec0b4SGerd Hoffmann  ;;
11389db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1139c589b249SRonnie Sahlberg  ;;
11409db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1141c589b249SRonnie Sahlberg  ;;
114230045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11436542aa9cSPeter Lieven  ;;
114430045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11456542aa9cSPeter Lieven  ;;
114605c2a3e7Sbellard  --enable-profiler) profiler="yes"
114705c2a3e7Sbellard  ;;
1148b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
114914821030SPavel Borzenkov  ;;
1150a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11515b0753e0Sbellard  ;;
1152cad25d69Spbrook  --disable-system) softmmu="no"
11530a8e90f4Spbrook  ;;
1154cad25d69Spbrook  --enable-system) softmmu="yes"
11550a8e90f4Spbrook  ;;
11560953a80fSZachary Amsden  --disable-user)
11570953a80fSZachary Amsden      linux_user="no" ;
11580953a80fSZachary Amsden      bsd_user="no" ;
11590953a80fSZachary Amsden  ;;
11600953a80fSZachary Amsden  --enable-user) ;;
1161831b7825Sths  --disable-linux-user) linux_user="no"
11620a8e90f4Spbrook  ;;
1163831b7825Sths  --enable-linux-user) linux_user="yes"
1164831b7825Sths  ;;
116584778508Sblueswir1  --disable-bsd-user) bsd_user="no"
116684778508Sblueswir1  ;;
116784778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
116884778508Sblueswir1  ;;
116940d6444eSAvi Kivity  --enable-pie) pie="yes"
117034005a00SKirill A. Shutemov  ;;
117140d6444eSAvi Kivity  --disable-pie) pie="no"
117234005a00SKirill A. Shutemov  ;;
117385aa5189Sbellard  --enable-werror) werror="yes"
117485aa5189Sbellard  ;;
117585aa5189Sbellard  --disable-werror) werror="no"
117685aa5189Sbellard  ;;
1177cdad781dSDaniele Buono  --enable-lto) lto="true"
1178cdad781dSDaniele Buono  ;;
1179cdad781dSDaniele Buono  --disable-lto) lto="false"
1180cdad781dSDaniele Buono  ;;
118163678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
118263678e17SSteven Noonan  ;;
118363678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
118463678e17SSteven Noonan  ;;
11851e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11861e4f6065SDaniele Buono  ;;
11871e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11881e4f6065SDaniele Buono  ;;
11899e62ba48SDaniele Buono  --enable-cfi)
11909e62ba48SDaniele Buono      cfi="true";
11919e62ba48SDaniele Buono      lto="true";
11929e62ba48SDaniele Buono  ;;
11939e62ba48SDaniele Buono  --disable-cfi) cfi="false"
11949e62ba48SDaniele Buono  ;;
11959e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
11969e62ba48SDaniele Buono  ;;
11979e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
11989e62ba48SDaniele Buono  ;;
11995285e593SYonggang Luo  --disable-curses) curses="disabled"
12004d3b6f6eSbalrog  ;;
12015285e593SYonggang Luo  --enable-curses) curses="enabled"
1202c584a6d0SJuan Quintela  ;;
12035285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1204e08bb301SSamuel Thibault  ;;
12055285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1206e08bb301SSamuel Thibault  ;;
1207f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1208769ce76dSAlexander Graf  ;;
1209f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1210788c8196SJuan Quintela  ;;
1211fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
12122df87df7SJuan Quintela  ;;
1213fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1214fbb4121dSPaolo Bonzini  ;;
1215fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1216fbb4121dSPaolo Bonzini  ;;
1217fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
12182df87df7SJuan Quintela  ;;
12195c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12205c6c3a6cSChristoph Hellwig  ;;
12215c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12225c6c3a6cSChristoph Hellwig  ;;
1223c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1224c10dd856SAarushi Mehta  ;;
1225c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1226c10dd856SAarushi Mehta  ;;
1227f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1228758e8e38SVenkateswararao Jujjuri (JV)  ;;
1229f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1230758e8e38SVenkateswararao Jujjuri (JV)  ;;
1231a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1232a40161cbSPaolo Bonzini  ;;
1233a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1234a40161cbSPaolo Bonzini  ;;
1235c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
123677755340Sths  ;;
12377e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12384a19f1ecSpbrook  ;;
1239519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1240519175a2SAlex Barcelo  ;;
124170c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
124270c60c08SStefan Hajnoczi  ;;
124370c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
124470c60c08SStefan Hajnoczi  ;;
12457d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12467d992e4dSPeter Lieven  ;;
1247f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1248f0d92b56SLongpeng(Mike)  ;;
1249f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1250f0d92b56SLongpeng(Mike)  ;;
1251e3667660SYonggang Luo  --disable-docs) docs="disabled"
125270ec5dc0SAnthony Liguori  ;;
1253e3667660SYonggang Luo  --enable-docs) docs="enabled"
125483a3ab8bSJuan Quintela  ;;
1255d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1256d5970055SMichael S. Tsirkin  ;;
1257d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1258d5970055SMichael S. Tsirkin  ;;
1259042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1260042cea27SGonglei  ;;
1261299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1262042cea27SGonglei  ;;
12635e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12645e9be92dSNicholas Bellinger  ;;
12655e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12665e9be92dSNicholas Bellinger  ;;
1267fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1268fc0b9b0eSStefan Hajnoczi  ;;
1269fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1270fc0b9b0eSStefan Hajnoczi  ;;
1271e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1272bc15e44cSStefan Hajnoczi  ;;
1273e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1274bc15e44cSStefan Hajnoczi  ;;
127598fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
127698fc1adaSDr. David Alan Gilbert  ;;
127798fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
127898fc1adaSDr. David Alan Gilbert  ;;
1279da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
128020ff075bSMichael Walle  ;;
1281da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
128220ff075bSMichael Walle  ;;
1283fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1284f27aaf4bSChristian Brunner  ;;
1285fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1286f27aaf4bSChristian Brunner  ;;
12878c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12888c84cf11SSergei Trofimovich  ;;
12898c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12908c84cf11SSergei Trofimovich  ;;
12917b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1292111a38b0SRobert Relyea  ;;
12937b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1294111a38b0SRobert Relyea  ;;
12950a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12960a40bcb7SCésar Belley  ;;
12970a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
12980a40bcb7SCésar Belley  ;;
12992b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
13002b2325ffSGerd Hoffmann  ;;
13012b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
13022b2325ffSGerd Hoffmann  ;;
130369354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
130469354a83SHans de Goede  ;;
130569354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
130669354a83SHans de Goede  ;;
13071ffb3bbbSPaolo Bonzini  --disable-zlib-test)
13081ece9905SAlon Levy  ;;
13090c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1310b25c9dffSStefan Weil  ;;
13110c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1312607dacd0Sqiaonuohan  ;;
1313241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1314b25c9dffSStefan Weil  ;;
1315241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1316607dacd0Sqiaonuohan  ;;
131729ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
13186b383c08SPeter Wu  ;;
131929ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
13206b383c08SPeter Wu  ;;
1321ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
132283bc1f97SJulio Faracco  ;;
1323ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
132483bc1f97SJulio Faracco  ;;
1325b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
13263a678481SJuan Quintela  ;;
1327b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13283a678481SJuan Quintela  ;;
1329d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1330d138cee9SMichael Roth  ;;
1331d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1332d138cee9SMichael Roth  ;;
1333b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13349dacf32dSYossi Hindin  ;;
1335b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13369dacf32dSYossi Hindin  ;;
1337d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1338d9840e25STomoki Sekiyama  ;;
1339d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1340d9840e25STomoki Sekiyama  ;;
1341d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1342d9840e25STomoki Sekiyama  ;;
1343d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1344d9840e25STomoki Sekiyama  ;;
1345d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1346d9840e25STomoki Sekiyama  ;;
1347d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1348d9840e25STomoki Sekiyama  ;;
13494b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13504b1c11fdSDaniel P. Berrange  ;;
13514b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13524b1c11fdSDaniel P. Berrange  ;;
135390835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1354f794573eSEduardo Otubo  ;;
135590835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1356f794573eSEduardo Otubo  ;;
135708821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1358eb100396SBharata B Rao  ;;
135986583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
136086583a07SLiam Merwick  ;;
136186583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
136286583a07SLiam Merwick  ;;
13636b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13646b8cd447SRobert Hoo  ;;
13656b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13666b8cd447SRobert Hoo  ;;
13676b8cd447SRobert Hoo
136808821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1369eb100396SBharata B Rao  ;;
137052b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
137152b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1372583f6e7bSStefan Hajnoczi  ;;
1373cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1374cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1375cb6414dfSFam Zheng  ;;
1376315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1377315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1378315d3184SFam Zheng  ;;
13791b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1380a4ccabcfSAnthony Liguori  ;;
13811b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1382a4ccabcfSAnthony Liguori  ;;
1383a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1384a1c5e949SDaniel P. Berrange  ;;
1385ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1386ddbb0d09SDaniel P. Berrange  ;;
1387ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1388ddbb0d09SDaniel P. Berrange  ;;
138991bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
139091bfcdb0SDaniel P. Berrange  ;;
139191bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
139291bfcdb0SDaniel P. Berrange  ;;
139391bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
139491bfcdb0SDaniel P. Berrange  ;;
139591bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
139691bfcdb0SDaniel P. Berrange  ;;
13978953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
13988953caf3SDaniel P. Berrange  ;;
13998953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
14008953caf3SDaniel P. Berrange  ;;
14012da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14022da776dbSMichael R. Hines  ;;
14032da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14042da776dbSMichael R. Hines  ;;
140521ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
140621ab34c9SMarcel Apfelbaum  ;;
140721ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
140821ab34c9SMarcel Apfelbaum  ;;
1409bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1410bbbf9bfbSStefan Weil  ;;
1411bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1412bbbf9bfbSStefan Weil  ;;
14139d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14149d9e1521SGerd Hoffmann  ;;
14159d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
14169d9e1521SGerd Hoffmann  ;;
1417e91c793cSCole Robinson  --disable-tpm) tpm="no"
1418e91c793cSCole Robinson  ;;
1419ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1420ab214c29SStefan Berger  ;;
1421b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14220a12ec87SRichard W.M. Jones  ;;
1423b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14240a12ec87SRichard W.M. Jones  ;;
1425ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1426ed1701c6SDr. David Alan Gilbert  ;;
1427ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1428ed1701c6SDr. David Alan Gilbert  ;;
1429a99d57bbSWanlong Gao  --disable-numa) numa="no"
1430a99d57bbSWanlong Gao  ;;
1431a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1432a99d57bbSWanlong Gao  ;;
1433ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1434ed279a06SKlim Kireev  ;;
1435ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1436ed279a06SKlim Kireev  ;;
14372847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14382847b469SFam Zheng  ;;
14392847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14402847b469SFam Zheng  ;;
14417b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14427b01cb97SAlexandre Derumier  ;;
14437b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14447b01cb97SAlexandre Derumier  ;;
1445a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1446a6b1d4c0SChanglong Xie  ;;
1447a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1448a6b1d4c0SChanglong Xie  ;;
14492f740136SJeff Cody  --disable-bochs) bochs="no"
14502f740136SJeff Cody  ;;
14512f740136SJeff Cody  --enable-bochs) bochs="yes"
14522f740136SJeff Cody  ;;
14532f740136SJeff Cody  --disable-cloop) cloop="no"
14542f740136SJeff Cody  ;;
14552f740136SJeff Cody  --enable-cloop) cloop="yes"
14562f740136SJeff Cody  ;;
14572f740136SJeff Cody  --disable-dmg) dmg="no"
14582f740136SJeff Cody  ;;
14592f740136SJeff Cody  --enable-dmg) dmg="yes"
14602f740136SJeff Cody  ;;
14612f740136SJeff Cody  --disable-qcow1) qcow1="no"
14622f740136SJeff Cody  ;;
14632f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14642f740136SJeff Cody  ;;
14652f740136SJeff Cody  --disable-vdi) vdi="no"
14662f740136SJeff Cody  ;;
14672f740136SJeff Cody  --enable-vdi) vdi="yes"
14682f740136SJeff Cody  ;;
14692f740136SJeff Cody  --disable-vvfat) vvfat="no"
14702f740136SJeff Cody  ;;
14712f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14722f740136SJeff Cody  ;;
14732f740136SJeff Cody  --disable-qed) qed="no"
14742f740136SJeff Cody  ;;
14752f740136SJeff Cody  --enable-qed) qed="yes"
14762f740136SJeff Cody  ;;
14772f740136SJeff Cody  --disable-parallels) parallels="no"
14782f740136SJeff Cody  ;;
14792f740136SJeff Cody  --enable-parallels) parallels="yes"
14802f740136SJeff Cody  ;;
14812f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14822f740136SJeff Cody  ;;
14832f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14842f740136SJeff Cody  ;;
1485e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1486e6a74868SMarc-André Lureau  ;;
1487299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1488299e6f19SPaolo Bonzini  ;;
1489108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1490108a6481SCindy Lu  ;;
1491108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1492108a6481SCindy Lu  ;;
1493299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1494299e6f19SPaolo Bonzini  ;;
1495299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1496e6a74868SMarc-André Lureau  ;;
14978b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14988ca80760SRichard Henderson  ;;
14998b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
15008ca80760SRichard Henderson  ;;
15018b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1502e219c499SRichard Henderson  ;;
1503e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1504e219c499SRichard Henderson  ;;
1505cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1506cc84d63aSDaniel P. Berrange  ;;
15077d7dbf9dSDan Streetman  --enable-git-update)
15087d7dbf9dSDan Streetman      git_submodules_action="update"
15097d7dbf9dSDan Streetman      echo "--enable-git-update deprecated, use --with-git-submodules=update"
1510f62bbee5SDaniel P. Berrange  ;;
15117d7dbf9dSDan Streetman  --disable-git-update)
15127d7dbf9dSDan Streetman      git_submodules_action="validate"
15137d7dbf9dSDan Streetman      echo "--disable-git-update deprecated, use --with-git-submodules=validate"
15147d7dbf9dSDan Streetman  ;;
15157d7dbf9dSDan Streetman  --with-git-submodules=*)
15167d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1517f62bbee5SDaniel P. Berrange  ;;
1518ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1519ba59fb77SPaolo Bonzini  ;;
1520ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1521ba59fb77SPaolo Bonzini  ;;
152217824406SJunyan He  --enable-libpmem) libpmem=yes
152317824406SJunyan He  ;;
152417824406SJunyan He  --disable-libpmem) libpmem=no
152517824406SJunyan He  ;;
15264113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
152775411919SJames Le Cuirot  ;;
15284113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
152975411919SJames Le Cuirot  ;;
153040e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
153140e8c6f4SAlex Bennée  ;;
153240e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
153340e8c6f4SAlex Bennée  ;;
1534afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1535afc3a8f9SAlex Bennée  ;;
1536afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1537afc3a8f9SAlex Bennée  ;;
1538adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1539adc28027SAlexander Bulekov  ;;
1540adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1541adc28027SAlexander Bulekov  ;;
1542f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1543f48e590aSAlex Bennée  ;;
1544b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1545b767d257SMarek Marczykowski-Górecki  ;;
1546b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1547b767d257SMarek Marczykowski-Górecki  ;;
154854e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
154954e7aac0SAlexey Krasikov  ;;
155054e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
155154e7aac0SAlexey Krasikov  ;;
155221b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
155321b2eca6SJingqi Liu  ;;
155421b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
155521b2eca6SJingqi Liu  ;;
1556a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1557a484a719SMax Reitz  ;;
1558a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1559a484a719SMax Reitz  ;;
1560df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1561df4ea709SMax Reitz  ;;
1562df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1563df4ea709SMax Reitz  ;;
1564106ad1f9SPaolo Bonzini  --enable-multiprocess) multiprocess="enabled"
15653090de69SJagannathan Raman  ;;
1566106ad1f9SPaolo Bonzini  --disable-multiprocess) multiprocess="disabled"
15673090de69SJagannathan Raman  ;;
156820cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
156920cf7b8eSDenis Plotnikov  ;;
157020cf7b8eSDenis Plotnikov  --disable-gio) gio=no
157120cf7b8eSDenis Plotnikov  ;;
1572*b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1573*b8e0c493SJoelle van Dyne  ;;
1574*b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1575*b8e0c493SJoelle van Dyne  ;;
15762d2ad6d0SFam Zheng  *)
15772d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15782d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15792d2ad6d0SFam Zheng      exit 1
15807f1559c6Sbalrog  ;;
15817d13299dSbellard  esac
15827d13299dSbellarddone
15837d13299dSbellard
15847d7dbf9dSDan Streetmancase $git_submodules_action in
15857d7dbf9dSDan Streetman    update|validate)
15867d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
15877d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
15887d7dbf9dSDan Streetman            exit 1
15897d7dbf9dSDan Streetman        fi
15907d7dbf9dSDan Streetman    ;;
15917d7dbf9dSDan Streetman    ignore)
15927d7dbf9dSDan Streetman    ;;
15937d7dbf9dSDan Streetman    *)
15947d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
15957d7dbf9dSDan Streetman        exit 1
15967d7dbf9dSDan Streetman    ;;
15977d7dbf9dSDan Streetmanesac
15987d7dbf9dSDan Streetman
159922a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
160022a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
160122a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
160222a87800SMarc-André Lureau
160322a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
160415588a62SJoshua Watt    bindir="${bindir:-$prefix}"
160522a87800SMarc-André Lureauelse
160615588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
160715588a62SJoshua Wattfi
160822a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
160922a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1610ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
161122a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
161222a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
161316bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
161416bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
161522a87800SMarc-André Lureau
161640293e58Sbellardcase "$cpu" in
1617e3608d66SRichard Henderson    ppc)
1618e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1619db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1620e3608d66SRichard Henderson           ;;
1621e3608d66SRichard Henderson    ppc64)
1622e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1623db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1624e3608d66SRichard Henderson           ;;
16259b9c37c3SRichard Henderson    sparc)
1626f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1627db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16283142255cSblueswir1           ;;
1629ed968ff1SJuan Quintela    sparc64)
163079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1631db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16323142255cSblueswir1           ;;
163376d83bdeSths    s390)
1634061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1635db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
163628d7cc49SRichard Henderson           ;;
163728d7cc49SRichard Henderson    s390x)
1638061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1639db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
164076d83bdeSths           ;;
164140293e58Sbellard    i386)
164279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1643db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
164440293e58Sbellard           ;;
164540293e58Sbellard    x86_64)
16467ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16477ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16487ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16497ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1650db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1651379f6698SPaul Brook           ;;
1652c72b26ecSRichard Henderson    x32)
1653c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1654db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1655c72b26ecSRichard Henderson           ;;
165630163d89SPeter Maydell    # No special flags required for other host CPUs
16573142255cSblueswir1esac
16583142255cSblueswir1
16592038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
16602038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
166179f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
166279f3b12fSPeter Crosthwaite
1663affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1664affc88ccSPeter Maydell# support, even if we're using TCI.
1665affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1666affc88ccSPeter Maydell  bsd_user="no"
1667affc88ccSPeter Maydell  linux_user="no"
1668affc88ccSPeter Maydellfi
1669affc88ccSPeter Maydell
167060e0df25SPeter Maydelldefault_target_list=""
16712cc1a901SThomas Huthdeprecated_targets_list=ppc64abi32-linux-user,lm32-softmmu,unicore32-softmmu
1672fdb75aefSPaolo Bonzinideprecated_features=""
16736e92f823SPeter Maydellmak_wilds=""
16746e92f823SPeter Maydell
167560e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
167673362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-softmmu.mak"
167760e0df25SPeter Maydellfi
167860e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
167973362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-linux-user.mak"
168060e0df25SPeter Maydellfi
168160e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
168273362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-bsd-user.mak"
168360e0df25SPeter Maydellfi
168460e0df25SPeter Maydell
16853a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
16863a5ae4a9SAlex Bennée# skip it.
16873a5ae4a9SAlex Bennéeif test -z "$target_list"; then
16883a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
16893a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
16903a5ae4a9SAlex Bennée    else
16913a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
16923a5ae4a9SAlex Bennée    fi
16932d838d9bSAlex Bennéefi
16942d838d9bSAlex Bennée
1695447e133fSAlex Bennéefor config in $mak_wilds; do
1696447e133fSAlex Bennée    target="$(basename "$config" .mak)"
169798db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1698447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1699447e133fSAlex Bennée    fi
1700447e133fSAlex Bennéedone
17016e92f823SPeter Maydell
1702c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
170364a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1704c53eeaf7SStefan Hajnoczi
1705af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1706af5db58eSpbrookcat << EOF
1707af5db58eSpbrook
1708af5db58eSpbrookUsage: configure [options]
1709af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1710af5db58eSpbrook
171108fb77edSStefan WeilStandard options:
171208fb77edSStefan Weil  --help                   print this message
171308fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
171408fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
171508fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
17162deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
171708fb77edSStefan Weil$(echo Available targets: $default_target_list | \
171808fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
17192deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
17202deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1721447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
172208fb77edSStefan Weil
172308fb77edSStefan WeilAdvanced options (experts only):
17243812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
172508fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
172608fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
172708fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
172808fb77edSStefan Weil                           build time
172908fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
173008fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
173108fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
173211cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
173308fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1734d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1735d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
173608fb77edSStefan Weil  --make=MAKE              use specified make [$make]
173708fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17382eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1739a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
174048328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
174108fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1742db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
17437d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
17447d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
17457d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
174608fb77edSStefan Weil  --static                 enable static build [$static]
174708fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
174810ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1749fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
175010ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
175108fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
175208fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1753db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
175410ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
175508fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17563d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
175713336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1758ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1759db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1760c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1761c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1762c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1763c035c8d6SPaolo Bonzini                           desired devices in default-configs/devices/)
176408fb77edSStefan Weil  --enable-debug           enable common debug build options
1765247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17660aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
176708fb77edSStefan Weil  --disable-strip          disable stripping binaries
176808fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
176963678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
177008fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
177108fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
177208fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
177308fb77edSStefan Weil  --block-drv-rw-whitelist=L
177408fb77edSStefan Weil                           set block driver read-write whitelist
177508fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
177608fb77edSStefan Weil  --block-drv-ro-whitelist=L
177708fb77edSStefan Weil                           set block driver read-only whitelist
177808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
17795b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1780c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
178108fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
178208fb77edSStefan Weil                           Default:trace-<pid>
1783c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1784e9a16e38SPhilippe Mathieu-Daudé  --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
17855a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1786c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1787c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
178808fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
178933c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
179008fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1791c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1792c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1793c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1794a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1795c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1796c12d66aaSLin Ma  --enable-profiler        profiler support
1797c12d66aaSLin Ma  --enable-debug-stack-usage
1798c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
179940e8c6f4SAlex Bennée  --enable-plugins
180040e8c6f4SAlex Bennée                           enable plugins via shared library loading
1801afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1802f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1803c23f23b9SMichael Tokarev
1804c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1805c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1806c87ea116SAlex Bennée(unless built with --without-default-features):
1807c23f23b9SMichael Tokarev
1808c23f23b9SMichael Tokarev  system          all system emulation targets
1809c23f23b9SMichael Tokarev  user            supported user emulation targets
1810c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1811c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1812c23f23b9SMichael Tokarev  docs            build documentation
1813c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1814c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1815c23f23b9SMichael Tokarev  pie             Position Independent Executables
181621e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1817bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1818c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1819c23f23b9SMichael Tokarev  debug-info      debugging information
1820cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1821c23f23b9SMichael Tokarev  sparse          sparse checker
18221e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18231e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
18249e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
18259e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
18269e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
18279e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
18289e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
18299e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
18309e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1831ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
183291bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
183391bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18348953caf3SDaniel P. Berrange  auth-pam        PAM access control
1835c23f23b9SMichael Tokarev  sdl             SDL UI
183604c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1837c23f23b9SMichael Tokarev  gtk             gtk UI
1838c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1839c23f23b9SMichael Tokarev  curses          curses UI
1840e08bb301SSamuel Thibault  iconv           font glyph conversion support
1841c23f23b9SMichael Tokarev  vnc             VNC UI support
1842c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1843c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1844c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1845c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1846c23f23b9SMichael Tokarev  virtfs          VirtFS
1847cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18485c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1849fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1850c23f23b9SMichael Tokarev  xen             xen backend driver support
185170c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1852c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1853c23f23b9SMichael Tokarev  curl            curl connectivity
1854a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1855c23f23b9SMichael Tokarev  fdt             fdt device tree
1856c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1857b0cb0a66SVincent Palatin  hax             HAX acceleration support
1858c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
185974a414a1SReinoud Zandijk  nvmm            NVMM acceleration support
1860d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
186121ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
186221ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1863c23f23b9SMichael Tokarev  vde             support for vde network
1864c23f23b9SMichael Tokarev  netmap          support for netmap network
1865c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1866c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1867c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1868c23f23b9SMichael Tokarev  attr            attr and xattr support
1869299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1870299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1871299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1872299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1873299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1874299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1875bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1876108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1877c23f23b9SMichael Tokarev  spice           spice
1878c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1879c23f23b9SMichael Tokarev  libiscsi        iscsi support
1880c23f23b9SMichael Tokarev  libnfs          nfs support
18817b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
18820a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1883c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1884ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1885c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1886c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1887c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1888c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1889c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
189083bc1f97SJulio Faracco  lzfse           support of lzfse compression library
189183bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
18923a678481SJuan Quintela  zstd            support for zstd compression library
1893d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1894c23f23b9SMichael Tokarev  seccomp         seccomp support
1895c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1896c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1897c23f23b9SMichael Tokarev  tpm             TPM support
1898b10d49d7SPino Toscano  libssh          ssh block device support
1899c23f23b9SMichael Tokarev  numa            libnuma support
1900ed279a06SKlim Kireev  libxml2         for Parallels image format
1901c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19027b01cb97SAlexandre Derumier  jemalloc        jemalloc support
190386583a07SLiam Merwick  avx2            AVX2 optimization support
19046b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1905a6b1d4c0SChanglong Xie  replication     replication support
1906c12d66aaSLin Ma  opengl          opengl support
1907c12d66aaSLin Ma  virglrenderer   virgl rendering support
1908c12d66aaSLin Ma  xfsctl          xfsctl support
1909c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19108de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19112f740136SJeff Cody  bochs           bochs image format support
19122f740136SJeff Cody  cloop           cloop image format support
19132f740136SJeff Cody  dmg             dmg image format support
19142f740136SJeff Cody  qcow1           qcow v1 image format support
19152f740136SJeff Cody  vdi             vdi image format support
19162f740136SJeff Cody  vvfat           vvfat image format support
19172f740136SJeff Cody  qed             qed image format support
19182f740136SJeff Cody  parallels       parallels image format support
1919e1c42697SDaniel P. Berrangé  sheepdog        sheepdog block driver support (deprecated)
1920f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19218ca80760SRichard Henderson  capstone        capstone disassembler support
1922ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
192317824406SJunyan He  libpmem         libpmem support
192475411919SJames Le Cuirot  xkbcommon       xkbcommon support
1925b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
192621b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1927a484a719SMax Reitz  fuse            FUSE block device export
1928df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
1929106ad1f9SPaolo Bonzini  multiprocess    Out of process device emulation support
193020cf7b8eSDenis Plotnikov  gio             libgio support
1931*b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
193208fb77edSStefan Weil
193308fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1934af5db58eSpbrookEOF
19352d2ad6d0SFam Zhengexit 0
1936af5db58eSpbrookfi
1937af5db58eSpbrook
19389c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1939bb768f71SThomas Huthrm -f */config-devices.mak.d
19409c790242SThomas Huth
1941faf44142SDaniel P. Berrangéif test -z "$python"
1942faf44142SDaniel P. Berrangéthen
1943c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1944c53eeaf7SStefan Hajnoczifi
19458e2c76bdSRoman Bolshakovif ! has "$make"
19468e2c76bdSRoman Bolshakovthen
19478e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19488e2c76bdSRoman Bolshakovfi
1949c53eeaf7SStefan Hajnoczi
1950c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1951c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19521b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19531b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1954c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1955c53eeaf7SStefan Hajnoczifi
1956c53eeaf7SStefan Hajnoczi
1957755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1958406ab2f3SCleber Rosapython_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
1959755ee70fSCleber Rosa
1960c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1961c53eeaf7SStefan Hajnoczipython="$python -B"
1962c53eeaf7SStefan Hajnoczi
19630a01d76fSMarc-André Lureauif test -z "$meson"; then
19646ebd89cfSPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
19650a01d76fSMarc-André Lureau        meson=meson
19667d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
19670a01d76fSMarc-André Lureau        meson=git
19680a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19690a01d76fSMarc-André Lureau        meson=internal
19700a01d76fSMarc-André Lureau    else
19710a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19720a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19730a01d76fSMarc-André Lureau        else
1974a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1975a5665051SPaolo Bonzini        fi
19760a01d76fSMarc-André Lureau    fi
19770a01d76fSMarc-André Lureauelse
19780a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19790a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19800a01d76fSMarc-André Lureau    #
19810a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
19820a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
19830a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
19840a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
19850a01d76fSMarc-André Lureau        case "$meson" in
19860a01d76fSMarc-André Lureau            git | internal) ;;
19870a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
19880a01d76fSMarc-André Lureau        esac
19890a01d76fSMarc-André Lureau    fi
19900a01d76fSMarc-André Lureaufi
1991a5665051SPaolo Bonzini
19920a01d76fSMarc-André Lureauif test "$meson" = git; then
19930a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
19940a01d76fSMarc-André Lureaufi
19950a01d76fSMarc-André Lureau
19960a01d76fSMarc-André Lureaucase "$meson" in
19970a01d76fSMarc-André Lureau    git | internal)
19980a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
19990a01d76fSMarc-André Lureau        ;;
200084ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
20010a01d76fSMarc-André Lureauesac
20020a01d76fSMarc-André Lureau
200309e93326SPaolo Bonzini# Probe for ninja
200448328880SPaolo Bonzini
200548328880SPaolo Bonziniif test -z "$ninja"; then
200648328880SPaolo Bonzini    for c in ninja ninja-build samu; do
200748328880SPaolo Bonzini        if has $c; then
200848328880SPaolo Bonzini            ninja=$(command -v "$c")
200948328880SPaolo Bonzini            break
201048328880SPaolo Bonzini        fi
201148328880SPaolo Bonzini    done
201209e93326SPaolo Bonzini    if test -z "$ninja"; then
201309e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
201409e93326SPaolo Bonzini    fi
201548328880SPaolo Bonzinifi
2016a5665051SPaolo Bonzini
20179aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20189aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20199aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20209aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20219aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20229aae6e54SDaniel Henrique Barbozaif compile_object ; then
20239aae6e54SDaniel Henrique Barboza  : C compiler works ok
20249aae6e54SDaniel Henrique Barbozaelse
20259aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20269aae6e54SDaniel Henrique Barbozafi
20279aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20289aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20299aae6e54SDaniel Henrique Barbozafi
20309aae6e54SDaniel Henrique Barboza
20319c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20329c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20339c83ffd8SPeter Maydellif test -z "$werror" ; then
20347d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
2035e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20369c83ffd8SPeter Maydell        werror="yes"
20379c83ffd8SPeter Maydell    else
20389c83ffd8SPeter Maydell        werror="no"
20399c83ffd8SPeter Maydell    fi
20409c83ffd8SPeter Maydellfi
20419c83ffd8SPeter Maydell
2042975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2043fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2044fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2045fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2046fb59dabdSPeter Maydell    # host OS we should stop now.
2047951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2048fb59dabdSPeter Maydellfi
2049fb59dabdSPeter Maydell
2050efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2051efc6c070SThomas Huthcat > $TMPC << EOF
2052efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2053efc6c070SThomas Huth# ifdef __apple_build_version__
2054efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2055efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
2056efc6c070SThomas Huth#  endif
2057efc6c070SThomas Huth# else
2058efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2059efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
2060efc6c070SThomas Huth#  endif
2061efc6c070SThomas Huth# endif
2062efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2063efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2064efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
2065efc6c070SThomas Huth# endif
2066efc6c070SThomas Huth#else
2067efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2068efc6c070SThomas Huth#endif
2069efc6c070SThomas Huthint main (void) { return 0; }
2070efc6c070SThomas HuthEOF
2071efc6c070SThomas Huthif ! compile_prog "" "" ; then
2072efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2073efc6c070SThomas Huthfi
2074efc6c070SThomas Huth
207500849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
207600849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
207700849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
207800849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
207900849b92SRichard Henderson# just silently disable some features, so it's too error prone.
208000849b92SRichard Henderson
208100849b92SRichard Hendersonwarn_flags=
208200849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
208300849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
208400849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
208500849b92SRichard Hendersonadd_to warn_flags -Wformat-security
208600849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
208700849b92SRichard Hendersonadd_to warn_flags -Winit-self
208800849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
208900849b92SRichard Hendersonadd_to warn_flags -Wempty-body
209000849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
209100849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
209200849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
20930a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
209400849b92SRichard Henderson
209500849b92SRichard Hendersonnowarn_flags=
209600849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
209700849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
209800849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
209900849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
210000849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2101aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2102bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
210300849b92SRichard Henderson
210400849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
210593b25869SJohn Snow
210693b25869SJohn Snowcc_has_warning_flag() {
210793b25869SJohn Snow    write_c_skeleton;
210893b25869SJohn Snow
2109a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2110a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2111a1d29d6cSPeter Maydell    # warning options).
211293b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
211393b25869SJohn Snow    compile_prog "-Werror $optflag" ""
211493b25869SJohn Snow}
211593b25869SJohn Snow
211693b25869SJohn Snowfor flag in $gcc_flags; do
211793b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21188d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21198d05095cSPaolo Bonzini    fi
21208d05095cSPaolo Bonzinidone
21218d05095cSPaolo Bonzini
212263678e17SSteven Noonanif test "$stack_protector" != "no"; then
2123fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2124fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2125fccd35a0SRodrigo Rebello{
2126fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2127fccd35a0SRodrigo Rebello    while (*c) {
2128fccd35a0SRodrigo Rebello        *p++ = *c++;
2129fccd35a0SRodrigo Rebello    }
2130fccd35a0SRodrigo Rebello    return 0;
2131fccd35a0SRodrigo Rebello}
2132fccd35a0SRodrigo RebelloEOF
213363678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21343b463a3fSMiroslav Rezanina  sp_on=0
213563678e17SSteven Noonan  for flag in $gcc_flags; do
2136590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2137590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2138086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2139590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
214063678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2141db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21423b463a3fSMiroslav Rezanina      sp_on=1
214363678e17SSteven Noonan      break
214463678e17SSteven Noonan    fi
214563678e17SSteven Noonan  done
21463b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21473b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21483b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21493b463a3fSMiroslav Rezanina    fi
21503b463a3fSMiroslav Rezanina  fi
215137746c5eSMarc-André Lureaufi
215237746c5eSMarc-André Lureau
215320bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
215420bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
215520bc94a2SPaolo Bonzinicat > $TMPC << EOF
215620bc94a2SPaolo Bonzinistruct {
215720bc94a2SPaolo Bonzini  int a[2];
215820bc94a2SPaolo Bonzini} x = {0};
215920bc94a2SPaolo BonziniEOF
216020bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
216120bc94a2SPaolo Bonzini  :
216220bc94a2SPaolo Bonzinielse
216320bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
216420bc94a2SPaolo Bonzinifi
216520bc94a2SPaolo Bonzini
216621e709aaSMarc-André Lureau# Our module code doesn't support Windows
216721e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
216821e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
216921e709aaSMarc-André Lureaufi
217021e709aaSMarc-André Lureau
2171bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2172bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2173bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2174bd83c861SChristian Ehrhardtfi
2175bd83c861SChristian Ehrhardt
2176d376e9deSThomas Huth# Static linking is not possible with modules or PIE
217740d6444eSAvi Kivityif test "$static" = "yes" ; then
2178aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2179aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2180aa0d1f44SPaolo Bonzini  fi
218140d6444eSAvi Kivityfi
218240d6444eSAvi Kivity
2183768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2184768b7855SEmilio G. Cota  cat > $TMPC << EOF
2185768b7855SEmilio G. Cotastatic __thread int tls_var;
2186768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2187768b7855SEmilio G. CotaEOF
2188768b7855SEmilio G. Cota
2189768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2190768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2191768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2192768b7855SEmilio G. Cotafi
2193768b7855SEmilio G. Cota
219440d6444eSAvi Kivitycat > $TMPC << EOF
219521d4a791SAvi Kivity
219621d4a791SAvi Kivity#ifdef __linux__
219721d4a791SAvi Kivity#  define THREAD __thread
219821d4a791SAvi Kivity#else
219921d4a791SAvi Kivity#  define THREAD
220021d4a791SAvi Kivity#endif
220121d4a791SAvi Kivitystatic THREAD int tls_var;
220221d4a791SAvi Kivityint main(void) { return tls_var; }
220340d6444eSAvi KivityEOF
2204b2634124SRichard Henderson
2205b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2206412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2207412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2208412aeacdSAlex Bennéefi
2209412aeacdSAlex Bennée
221012781462SRichard Hendersonif test "$static" = "yes"; then
2211eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
22125770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
221312781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
221412781462SRichard Henderson    pie="yes"
221512781462SRichard Henderson  elif test "$pie" = "yes"; then
221612781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
221712781462SRichard Henderson  else
221812781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
221912781462SRichard Henderson    pie="no"
222012781462SRichard Henderson  fi
222112781462SRichard Hendersonelif test "$pie" = "no"; then
22225770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2223eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
22245770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
22255770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
222640d6444eSAvi Kivity  pie="yes"
22272c674109SRichard Hendersonelif test "$pie" = "yes"; then
222876ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
222940d6444eSAvi Kivityelse
223040d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
223140d6444eSAvi Kivity  pie="no"
223240d6444eSAvi Kivityfi
223340d6444eSAvi Kivity
2234e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2235e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2236e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2237e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2238e6cbd751SRichard Hendersonfi
2239e6cbd751SRichard Henderson
224009dada40SPaolo Bonzini##########################################
224109dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
224209dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
224309dada40SPaolo Bonzini# specification is necessary
224409dada40SPaolo Bonzini
224509dada40SPaolo Bonziniif test "$cpu" = "i386"; then
224609dada40SPaolo Bonzini  cat > $TMPC << EOF
224709dada40SPaolo Bonzinistatic int sfaa(int *ptr)
224809dada40SPaolo Bonzini{
224909dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
225009dada40SPaolo Bonzini}
225109dada40SPaolo Bonzini
225209dada40SPaolo Bonziniint main(void)
225309dada40SPaolo Bonzini{
225409dada40SPaolo Bonzini  int val = 42;
22551405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
225609dada40SPaolo Bonzini  sfaa(&val);
225709dada40SPaolo Bonzini  return val;
225809dada40SPaolo Bonzini}
225909dada40SPaolo BonziniEOF
226009dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
226109dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
226209dada40SPaolo Bonzini  fi
226309dada40SPaolo Bonzinifi
226409dada40SPaolo Bonzini
226509dada40SPaolo Bonzini#########################################
2266ec530c81Sbellard# Solaris specific configure tool chain decisions
226709dada40SPaolo Bonzini
2268ec530c81Sbellardif test "$solaris" = "yes" ; then
22696792aa11SLoïc Minier  if has ar; then
22706792aa11SLoïc Minier    :
22716792aa11SLoïc Minier  else
2272ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
227376ad07a4SPeter Maydell      error_exit "No path includes ar" \
227476ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2275ec530c81Sbellard    fi
227676ad07a4SPeter Maydell    error_exit "No path includes ar"
2277ec530c81Sbellard  fi
2278ec530c81Sbellardfi
2279ec530c81Sbellard
2280afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2281fdb75aefSPaolo Bonzini    default_targets=yes
2282d880a3baSPaolo Bonzini    for target in $default_target_list; do
2283d880a3baSPaolo Bonzini        target_list="$target_list $target"
2284d880a3baSPaolo Bonzini    done
2285d880a3baSPaolo Bonzini    target_list="${target_list# }"
2286121afa9eSAnthony Liguorielse
2287fdb75aefSPaolo Bonzini    default_targets=no
228889138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2289d880a3baSPaolo Bonzini    for target in $target_list; do
229025b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
229125b48338SPeter Maydell        # friendly error message than if we let it fall through.
229225b48338SPeter Maydell        case " $default_target_list " in
229325b48338SPeter Maydell            *" $target "*)
229425b48338SPeter Maydell                ;;
229525b48338SPeter Maydell            *)
229625b48338SPeter Maydell                error_exit "Unknown target name '$target'"
229725b48338SPeter Maydell                ;;
229825b48338SPeter Maydell        esac
229925b48338SPeter Maydell    done
2300d880a3baSPaolo Bonzinifi
230125b48338SPeter Maydell
2302fdb75aefSPaolo Bonzinifor target in $target_list; do
2303fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2304fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2305fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2306fdb75aefSPaolo Bonzini    fi
2307fdb75aefSPaolo Bonzinidone
2308fdb75aefSPaolo Bonzini
2309f55fe278SPaolo Bonzini# see if system emulation was really requested
2310f55fe278SPaolo Bonzinicase " $target_list " in
2311f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2312f55fe278SPaolo Bonzini  ;;
2313f55fe278SPaolo Bonzini  *) softmmu=no
2314f55fe278SPaolo Bonzini  ;;
2315f55fe278SPaolo Bonziniesac
23165327cf48Sbellard
2317249247c9SJuan Quintelafeature_not_found() {
2318249247c9SJuan Quintela  feature=$1
231921684af0SStewart Smith  remedy=$2
2320249247c9SJuan Quintela
232176ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
232221684af0SStewart Smith      "configure was not able to find it." \
232321684af0SStewart Smith      "$remedy"
2324249247c9SJuan Quintela}
2325249247c9SJuan Quintela
23267d13299dSbellard# ---
23277d13299dSbellard# big/little endian test
23287d13299dSbellardcat > $TMPC << EOF
232961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
233061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
233161cc919fSMike Frysingerextern int foo(short *, short *);
233261cc919fSMike Frysingerint main(int argc, char *argv[]) {
233361cc919fSMike Frysinger    return foo(big_endian, little_endian);
23347d13299dSbellard}
23357d13299dSbellardEOF
23367d13299dSbellard
233761cc919fSMike Frysingerif compile_object ; then
233812f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
233961cc919fSMike Frysinger        bigendian="yes"
234012f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
234161cc919fSMike Frysinger        bigendian="no"
23427d13299dSbellard    else
23437d13299dSbellard        echo big/little test failed
23447d13299dSbellard    fi
23457d13299dSbellardelse
234661cc919fSMike Frysinger    echo big/little test failed
23477d13299dSbellardfi
23487d13299dSbellard
2349b0a47e79SJuan Quintela##########################################
2350e10ee3f5SPhilippe Mathieu-Daudé# system tools
2351e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2352e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2353e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2354e10ee3f5SPhilippe Mathieu-Daudé    else
2355e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2356e10ee3f5SPhilippe Mathieu-Daudé    fi
2357e10ee3f5SPhilippe Mathieu-Daudéfi
2358e10ee3f5SPhilippe Mathieu-Daudé
2359e10ee3f5SPhilippe Mathieu-Daudé##########################################
236090520ee4SPhilippe Mathieu-Daudé# Disable features only meaningful for system-mode emulation
236190520ee4SPhilippe Mathieu-Daudéif test "$softmmu" = "no"; then
236290520ee4SPhilippe Mathieu-Daudé    audio_drv_list=""
236390520ee4SPhilippe Mathieu-Daudéfi
236490520ee4SPhilippe Mathieu-Daudé
236590520ee4SPhilippe Mathieu-Daudé##########################################
23666b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
23676b39b063SEric Blakecat > $TMPC << EOF
23686b39b063SEric Blake#include <stdint.h>
23696b39b063SEric Blake#include <stdio.h>
23706b39b063SEric Blakeint main(int argc, char *argv[]) {
23716b39b063SEric Blake    return printf("%zu", SIZE_MAX);
23726b39b063SEric Blake}
23736b39b063SEric BlakeEOF
23746b39b063SEric Blakehave_broken_size_max=no
23756b39b063SEric Blakeif ! compile_object -Werror ; then
23766b39b063SEric Blake    have_broken_size_max=yes
23776b39b063SEric Blakefi
23786b39b063SEric Blake
2379a30878e7SPeter Maydell##########################################
2380015a33bdSGonglei# L2TPV3 probe
2381015a33bdSGonglei
2382015a33bdSGongleicat > $TMPC <<EOF
2383015a33bdSGonglei#include <sys/socket.h>
2384bff6cb72SMichael Tokarev#include <linux/ip.h>
2385015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2386015a33bdSGongleiEOF
2387015a33bdSGongleiif compile_prog "" "" ; then
2388015a33bdSGonglei  l2tpv3=yes
2389015a33bdSGongleielse
2390015a33bdSGonglei  l2tpv3=no
2391015a33bdSGongleifi
2392015a33bdSGonglei
2393195588ccSDavid CARLIERcat > $TMPC <<EOF
2394195588ccSDavid CARLIER#include <sys/mman.h>
2395195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2396195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2397195588ccSDavid CARLIER}
2398195588ccSDavid CARLIEREOF
2399195588ccSDavid CARLIERif compile_prog "" "" ; then
2400195588ccSDavid CARLIER  have_mlockall=yes
2401195588ccSDavid CARLIERelse
2402195588ccSDavid CARLIER  have_mlockall=no
2403195588ccSDavid CARLIERfi
2404195588ccSDavid CARLIER
2405299e6f19SPaolo Bonzini#########################################
2406299e6f19SPaolo Bonzini# vhost interdependencies and host support
2407299e6f19SPaolo Bonzini
2408299e6f19SPaolo Bonzini# vhost backends
2409d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2410d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2411299e6f19SPaolo Bonzinifi
2412108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2413108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2414108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2415108a6481SCindy Lufi
2416299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2417299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2418299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2419299e6f19SPaolo Bonzinifi
2420299e6f19SPaolo Bonzini
2421299e6f19SPaolo Bonzini# vhost-kernel devices
2422299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2423299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2424299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2425299e6f19SPaolo Bonzinifi
2426299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2427299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2428299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2429299e6f19SPaolo Bonzinifi
2430299e6f19SPaolo Bonzini
2431299e6f19SPaolo Bonzini# vhost-user backends
2432299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2433299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2434299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2435299e6f19SPaolo Bonzinifi
2436299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2437299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2438299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2439299e6f19SPaolo Bonzinifi
244098fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
244198fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
244298fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
244398fc1adaSDr. David Alan Gilbertfi
2444108a6481SCindy Lu#vhost-vdpa backends
2445108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2446108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2447108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2448108a6481SCindy Lufi
2449299e6f19SPaolo Bonzini
245040bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2451299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2452299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
245340bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2454299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2455299e6f19SPaolo Bonzinifi
2456299e6f19SPaolo Bonzini
2457015a33bdSGonglei##########################################
2458779ab5e3SStefan Weil# pkg-config probe
2459779ab5e3SStefan Weil
2460779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
246176ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2462779ab5e3SStefan Weilfi
2463779ab5e3SStefan Weil
2464779ab5e3SStefan Weil##########################################
2465b0a47e79SJuan Quintela# NPTL probe
2466b0a47e79SJuan Quintela
246724cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2468bd0c5661Spbrook  cat > $TMPC <<EOF
2469bd0c5661Spbrook#include <sched.h>
247030813ceaSpbrook#include <linux/futex.h>
2471182eacc0SStefan Weilint main(void) {
2472bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2473bd0c5661Spbrook#error bork
2474bd0c5661Spbrook#endif
2475182eacc0SStefan Weil  return 0;
2476bd0c5661Spbrook}
2477bd0c5661SpbrookEOF
247824cb36a6SPeter Maydell  if ! compile_object ; then
247921684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2480b0a47e79SJuan Quintela  fi
2481bd0c5661Spbrookfi
2482bd0c5661Spbrook
2483ac62922eSbalrog##########################################
2484e37630caSaliguori# xen probe
2485e37630caSaliguori
24861badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2487c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2488c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2489c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2490c1cdd9d5SJuergen Gross
2491c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2492c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2493c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2494c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
24951badb709SPaolo Bonzini    xen=enabled
24965b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2497c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
249858ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
249958ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
250058ea9a7aSAnthony PERARD    fi
2501582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2502582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2503c1cdd9d5SJuergen Gross  else
2504c1cdd9d5SJuergen Gross
25055b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2506d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2507d5b93ddfSAnthony PERARD
250850ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
250950ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
251050ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
251150ced5b3SStefan Weil
251250ced5b3SStefan Weil    # Xen (any)
251350ced5b3SStefan Weil    cat > $TMPC <<EOF
251450ced5b3SStefan Weil#include <xenctrl.h>
251550ced5b3SStefan Weilint main(void) {
251650ced5b3SStefan Weil  return 0;
251750ced5b3SStefan Weil}
251850ced5b3SStefan WeilEOF
251950ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
252050ced5b3SStefan Weil      # Xen not found
25211badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
252221684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
252350ced5b3SStefan Weil      fi
25241badb709SPaolo Bonzini      xen=disabled
252550ced5b3SStefan Weil
2526d5b93ddfSAnthony PERARD    # Xen unstable
252769deef08SPeter Maydell    elif
252869deef08SPeter Maydell        cat > $TMPC <<EOF &&
25292cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25302cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25312cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2532d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25332cbf8903SRoss Lagerwallint main(void) {
25342cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2535d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25362cbf8903SRoss Lagerwall
25372cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25382cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25392cbf8903SRoss Lagerwall
2540d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2541d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2542d3c49ebbSPaul Durrant
25432cbf8903SRoss Lagerwall  return 0;
25442cbf8903SRoss Lagerwall}
25452cbf8903SRoss LagerwallEOF
25462cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25472cbf8903SRoss Lagerwall      then
25482cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25492cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25501badb709SPaolo Bonzini      xen=enabled
25512cbf8903SRoss Lagerwall    elif
25522cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25535ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25545ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
255558ea9a7aSAnthony PERARD#include <xentoolcore.h>
25565ba3d756SIgor Druzhininint main(void) {
25575ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25585ba3d756SIgor Druzhinin
25595ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25605ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
256158ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25625ba3d756SIgor Druzhinin
25635ba3d756SIgor Druzhinin  return 0;
25645ba3d756SIgor Druzhinin}
25655ba3d756SIgor DruzhininEOF
256658ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25675ba3d756SIgor Druzhinin      then
256858ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25695ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25701badb709SPaolo Bonzini      xen=enabled
25715ba3d756SIgor Druzhinin    elif
25725ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2573da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2574da8090ccSPaul Durrant#define __XEN_TOOLS__
2575da8090ccSPaul Durrant#include <xendevicemodel.h>
2576da8090ccSPaul Durrantint main(void) {
2577da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2578da8090ccSPaul Durrant
2579da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2580da8090ccSPaul Durrant  xendevicemodel_close(xd);
2581da8090ccSPaul Durrant
2582da8090ccSPaul Durrant  return 0;
2583da8090ccSPaul Durrant}
2584da8090ccSPaul DurrantEOF
2585da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2586da8090ccSPaul Durrant      then
2587da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2588f1167ee6SJuergen Gross      xen_ctrl_version=40900
25891badb709SPaolo Bonzini      xen=enabled
2590da8090ccSPaul Durrant    elif
2591da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
25925eeb39c2SIan Campbell/*
25935eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
25945eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2595b6eb9b45SPaulina Szubarczyk *
2596b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2597b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2598b6eb9b45SPaulina Szubarczyk */
2599b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2600b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2601b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2602b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2603b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2604b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2605b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2606b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2607b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2608b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2609b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2610b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2611b6eb9b45SPaulina Szubarczyk#endif
2612b6eb9b45SPaulina Szubarczykint main(void) {
2613b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2614b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2615b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2616b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2617b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2618b6eb9b45SPaulina Szubarczyk
2619b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2620b6eb9b45SPaulina Szubarczyk
2621b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2622b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2623b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2624b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2625b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2626b6eb9b45SPaulina Szubarczyk
2627b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2628b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2629b6eb9b45SPaulina Szubarczyk
2630b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2631b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2632b6eb9b45SPaulina Szubarczyk
2633b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2634b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2635b6eb9b45SPaulina Szubarczyk
2636b6eb9b45SPaulina Szubarczyk  return 0;
2637b6eb9b45SPaulina Szubarczyk}
2638b6eb9b45SPaulina SzubarczykEOF
2639b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2640b6eb9b45SPaulina Szubarczyk      then
2641f1167ee6SJuergen Gross      xen_ctrl_version=40800
26421badb709SPaolo Bonzini      xen=enabled
2643b6eb9b45SPaulina Szubarczyk    elif
2644b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2645b6eb9b45SPaulina Szubarczyk/*
2646b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2647b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26485eeb39c2SIan Campbell */
26495eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26505eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26515eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26525eeb39c2SIan Campbell#include <xenctrl.h>
26535eeb39c2SIan Campbell#include <xenstore.h>
26545eeb39c2SIan Campbell#include <xenevtchn.h>
26555eeb39c2SIan Campbell#include <xengnttab.h>
26565eeb39c2SIan Campbell#include <xenforeignmemory.h>
26575eeb39c2SIan Campbell#include <stdint.h>
26585eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26595eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26605eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26615eeb39c2SIan Campbell#endif
26625eeb39c2SIan Campbellint main(void) {
26635eeb39c2SIan Campbell  xc_interface *xc = NULL;
26645eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26655eeb39c2SIan Campbell  xenevtchn_handle *xe;
26665eeb39c2SIan Campbell  xengnttab_handle *xg;
26675eeb39c2SIan Campbell
26685eeb39c2SIan Campbell  xs_daemon_open();
26695eeb39c2SIan Campbell
26705eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26715eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26725eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26735eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26745eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26755eeb39c2SIan Campbell
26765eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26775eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26785eeb39c2SIan Campbell
26795eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26805eeb39c2SIan Campbell  xenevtchn_fd(xe);
26815eeb39c2SIan Campbell
26825eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26835eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26845eeb39c2SIan Campbell
26855eeb39c2SIan Campbell  return 0;
26865eeb39c2SIan Campbell}
26875eeb39c2SIan CampbellEOF
26885eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26895eeb39c2SIan Campbell      then
2690f1167ee6SJuergen Gross      xen_ctrl_version=40701
26911badb709SPaolo Bonzini      xen=enabled
2692cdadde39SRoger Pau Monne
2693cdadde39SRoger Pau Monne    # Xen 4.6
2694cdadde39SRoger Pau Monne    elif
2695cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2696cdadde39SRoger Pau Monne#include <xenctrl.h>
2697e108a3c1SAnthony PERARD#include <xenstore.h>
2698d5b93ddfSAnthony PERARD#include <stdint.h>
2699d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2700d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2701d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2702d5b93ddfSAnthony PERARD#endif
2703d5b93ddfSAnthony PERARDint main(void) {
2704d5b93ddfSAnthony PERARD  xc_interface *xc;
2705d5b93ddfSAnthony PERARD  xs_daemon_open();
2706d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2707d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2708d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2709b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27108688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2711d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
271220a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2713d8b441a3SJan Beulich  return 0;
2714d8b441a3SJan Beulich}
2715d8b441a3SJan BeulichEOF
2716d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2717d8b441a3SJan Beulich      then
2718f1167ee6SJuergen Gross      xen_ctrl_version=40600
27191badb709SPaolo Bonzini      xen=enabled
2720d8b441a3SJan Beulich
2721d8b441a3SJan Beulich    # Xen 4.5
2722d8b441a3SJan Beulich    elif
2723d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2724d8b441a3SJan Beulich#include <xenctrl.h>
2725d8b441a3SJan Beulich#include <xenstore.h>
2726d8b441a3SJan Beulich#include <stdint.h>
2727d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2728d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2729d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2730d8b441a3SJan Beulich#endif
2731d8b441a3SJan Beulichint main(void) {
2732d8b441a3SJan Beulich  xc_interface *xc;
2733d8b441a3SJan Beulich  xs_daemon_open();
2734d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2735d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2736d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2737d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2738d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27393996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27403996e85cSPaul Durrant  return 0;
27413996e85cSPaul Durrant}
27423996e85cSPaul DurrantEOF
27433996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27443996e85cSPaul Durrant      then
2745f1167ee6SJuergen Gross      xen_ctrl_version=40500
27461badb709SPaolo Bonzini      xen=enabled
27473996e85cSPaul Durrant
27483996e85cSPaul Durrant    elif
27493996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27503996e85cSPaul Durrant#include <xenctrl.h>
27513996e85cSPaul Durrant#include <xenstore.h>
27523996e85cSPaul Durrant#include <stdint.h>
27533996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27543996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27553996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27563996e85cSPaul Durrant#endif
27573996e85cSPaul Durrantint main(void) {
27583996e85cSPaul Durrant  xc_interface *xc;
27593996e85cSPaul Durrant  xs_daemon_open();
27603996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27613996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27623996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27633996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27643996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27658688e065SStefano Stabellini  return 0;
27668688e065SStefano Stabellini}
27678688e065SStefano StabelliniEOF
27688688e065SStefano Stabellini        compile_prog "" "$xen_libs"
276969deef08SPeter Maydell      then
2770f1167ee6SJuergen Gross      xen_ctrl_version=40200
27711badb709SPaolo Bonzini      xen=enabled
27728688e065SStefano Stabellini
2773e37630caSaliguori    else
27741badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2775edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2776edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2777fc321b4bSJuan Quintela      fi
27781badb709SPaolo Bonzini      xen=disabled
2779e37630caSaliguori    fi
2780d5b93ddfSAnthony PERARD
27811badb709SPaolo Bonzini    if test "$xen" = enabled; then
2782f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2783582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
27845eeb39c2SIan Campbell      fi
2785d5b93ddfSAnthony PERARD    fi
2786e37630caSaliguori  fi
2787c1cdd9d5SJuergen Grossfi
2788e37630caSaliguori
2789d661d9a4SJustin Terry (VM)##########################################
2790ddbb0d09SDaniel P. Berrange# GNUTLS probe
2791ddbb0d09SDaniel P. Berrange
2792ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2793a73e82efSRichard Henderson    pass="no"
2794a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
279589138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
279689138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2797a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
2798a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
2799a73e82efSRichard Henderson        write_c_skeleton
2800a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
2801a73e82efSRichard Henderson            pass="yes"
2802a73e82efSRichard Henderson        fi
2803a73e82efSRichard Henderson    fi
2804a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
2805a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2806ddbb0d09SDaniel P. Berrange    else
2807a73e82efSRichard Henderson        gnutls="$pass"
2808ddbb0d09SDaniel P. Berrange    fi
2809ddbb0d09SDaniel P. Berrangefi
2810ddbb0d09SDaniel P. Berrange
281191bfcdb0SDaniel P. Berrange
281291bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
281391bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2814a0722409SDaniel P. Berrangé# explicitly
281591bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
281691bfcdb0SDaniel P. Berrangethen
2817a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
281891bfcdb0SDaniel P. Berrange    then
281991bfcdb0SDaniel P. Berrange        gcrypt="no"
282091bfcdb0SDaniel P. Berrange    fi
282191bfcdb0SDaniel P. Berrangefi
282291bfcdb0SDaniel P. Berrange
282391bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
282491bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2825a0722409SDaniel P. Berrangé# explicitly
282691bfcdb0SDaniel P. Berrangeif test -z "$nettle"
282791bfcdb0SDaniel P. Berrangethen
2828a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
282991bfcdb0SDaniel P. Berrange    then
283091bfcdb0SDaniel P. Berrange        nettle="no"
283191bfcdb0SDaniel P. Berrange    fi
283291bfcdb0SDaniel P. Berrangefi
283391bfcdb0SDaniel P. Berrange
2834dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
283591bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
283691bfcdb0SDaniel P. Berrange    then
283791bfcdb0SDaniel P. Berrange	return 1
283891bfcdb0SDaniel P. Berrange    fi
283991bfcdb0SDaniel P. Berrange
284091bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
284191bfcdb0SDaniel P. Berrange    then
284289138857SStefan Weil	host=$(libgcrypt-config --host)
284391bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
284491bfcdb0SDaniel P. Berrange	then
284591bfcdb0SDaniel P. Berrange	    return 1
284691bfcdb0SDaniel P. Berrange	fi
284791bfcdb0SDaniel P. Berrange    fi
284891bfcdb0SDaniel P. Berrange
2849dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2850dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2851dea7a64eSDaniel P. Berrangé
2852dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2853dea7a64eSDaniel P. Berrangé    then
2854dea7a64eSDaniel P. Berrangé       return 1
2855dea7a64eSDaniel P. Berrangé    fi
2856dea7a64eSDaniel P. Berrangé
285791bfcdb0SDaniel P. Berrange    return 0
285891bfcdb0SDaniel P. Berrange}
285991bfcdb0SDaniel P. Berrange
2860a0722409SDaniel P. Berrangé
2861a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
2862a73e82efSRichard Henderson    pass="no"
286364dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2864a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2865a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2866a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2867a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2868a73e82efSRichard Henderson        write_c_skeleton
2869a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
2870a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
2871a0722409SDaniel P. Berrangé               gcrypt="no"
2872a0722409SDaniel P. Berrangé            fi
2873a73e82efSRichard Henderson            pass="yes"
2874a73e82efSRichard Henderson        fi
2875a73e82efSRichard Henderson    fi
2876dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
2877dc2207afSDaniel P. Berrangé    then
2878dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
2879dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
2880dc2207afSDaniel P. Berrangéint main(void) {
2881dc2207afSDaniel P. Berrangé  return 0;
2882dc2207afSDaniel P. Berrangé}
2883dc2207afSDaniel P. BerrangéEOF
2884dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2885dc2207afSDaniel P. Berrangé            nettle_xts=yes
2886dc2207afSDaniel P. Berrangé            qemu_private_xts=no
2887dc2207afSDaniel P. Berrangé        fi
2888dc2207afSDaniel P. Berrangé    fi
2889a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
289064dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2891a0722409SDaniel P. Berrangé    else
2892a73e82efSRichard Henderson        nettle="$pass"
2893a0722409SDaniel P. Berrangé    fi
2894a0722409SDaniel P. Berrangéfi
2895a0722409SDaniel P. Berrangé
289691bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2897a73e82efSRichard Henderson    pass="no"
2898dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
289989138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
290089138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
2901a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
290291bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
290391bfcdb0SDaniel P. Berrange        # turn breaks static builds...
290491bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
290591bfcdb0SDaniel P. Berrange        then
290691bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
290791bfcdb0SDaniel P. Berrange        fi
29081f923c70SLongpeng(Mike)
2909a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2910a73e82efSRichard Henderson        write_c_skeleton
2911a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
2912a73e82efSRichard Henderson            pass="yes"
2913a73e82efSRichard Henderson        fi
2914a73e82efSRichard Henderson    fi
2915a73e82efSRichard Henderson    if test "$pass" = "yes"; then
291637788f25SDaniel P. Berrange        gcrypt="yes"
29171f923c70SLongpeng(Mike)        cat > $TMPC << EOF
29181f923c70SLongpeng(Mike)#include <gcrypt.h>
29191f923c70SLongpeng(Mike)int main(void) {
29201f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
29211f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
29221f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
29231f923c70SLongpeng(Mike)  return 0;
29241f923c70SLongpeng(Mike)}
29251f923c70SLongpeng(Mike)EOF
29261f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
29271f923c70SLongpeng(Mike)            gcrypt_hmac=yes
29281f923c70SLongpeng(Mike)        fi
2929e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
2930e0576942SDaniel P. Berrangé#include <gcrypt.h>
2931e0576942SDaniel P. Berrangéint main(void) {
2932e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
2933e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
2934e0576942SDaniel P. Berrangé  return 0;
2935e0576942SDaniel P. Berrangé}
2936e0576942SDaniel P. BerrangéEOF
2937e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2938e0576942SDaniel P. Berrangé            gcrypt_xts=yes
2939e0576942SDaniel P. Berrangé            qemu_private_xts=no
2940e0576942SDaniel P. Berrangé        fi
2941a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
2942dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
294391bfcdb0SDaniel P. Berrange    else
294491bfcdb0SDaniel P. Berrange        gcrypt="no"
294591bfcdb0SDaniel P. Berrange    fi
294662893b67SDaniel P. Berrangefi
294762893b67SDaniel P. Berrange
2948ddbb0d09SDaniel P. Berrange
294991bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
295091bfcdb0SDaniel P. Berrangethen
295191bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
295291bfcdb0SDaniel P. Berrangefi
2953ed754746SDaniel P. Berrange
29549a2fd434SDaniel P. Berrange##########################################
29559a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
29569a2fd434SDaniel P. Berrange
29579a2fd434SDaniel P. Berrangetasn1=yes
295890246037SDaniel P. Berrangetasn1_cflags=""
295990246037SDaniel P. Berrangetasn1_libs=""
29609a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
296189138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
296289138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
29639a2fd434SDaniel P. Berrangeelse
29649a2fd434SDaniel P. Berrange    tasn1=no
29659a2fd434SDaniel P. Berrangefi
29669a2fd434SDaniel P. Berrange
2967ed754746SDaniel P. Berrange
2968bbbf9bfbSStefan Weil##########################################
29698953caf3SDaniel P. Berrange# PAM probe
29708953caf3SDaniel P. Berrange
29718953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
29728953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
29738953caf3SDaniel P. Berrange#include <security/pam_appl.h>
29748953caf3SDaniel P. Berrange#include <stdio.h>
29758953caf3SDaniel P. Berrangeint main(void) {
29768953caf3SDaniel P. Berrange   const char *service_name = "qemu";
29778953caf3SDaniel P. Berrange   const char *user = "frank";
29789c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
29798953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
29809c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
29818953caf3SDaniel P. Berrange   return 0;
29828953caf3SDaniel P. Berrange}
29838953caf3SDaniel P. BerrangeEOF
29848953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
29858953caf3SDaniel P. Berrange        auth_pam=yes
29868953caf3SDaniel P. Berrange    else
29878953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
29888953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
29898953caf3SDaniel P. Berrange        else
29908953caf3SDaniel P. Berrange            auth_pam=no
29918953caf3SDaniel P. Berrange        fi
29928953caf3SDaniel P. Berrange    fi
29938953caf3SDaniel P. Berrangefi
29948953caf3SDaniel P. Berrange
2995559607eaSDaniel P. Berrange##########################################
2996bbbf9bfbSStefan Weil# VTE probe
2997bbbf9bfbSStefan Weil
2998bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2999c6feff9eSCole Robinson    vteminversion="0.32.0"
3000c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3001c6feff9eSCole Robinson      vtepackage="vte-2.91"
3002c6feff9eSCole Robinson    else
3003528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3004c6feff9eSCole Robinson    fi
3005c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
300689138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
300789138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
300889138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3009bbbf9bfbSStefan Weil        vte="yes"
3010bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3011c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
30129e04c683SStefan Weil    else
3013bbbf9bfbSStefan Weil        vte="no"
3014a4ccabcfSAnthony Liguori    fi
3015a4ccabcfSAnthony Liguorifi
3016a4ccabcfSAnthony Liguori
3017a4ccabcfSAnthony Liguori##########################################
30182da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
30192da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
30202da776dbSMichael R. Hines  cat > $TMPC <<EOF
30212da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
30222da776dbSMichael R. Hinesint main(void) { return 0; }
30232da776dbSMichael R. HinesEOF
3024ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
30252da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
30262da776dbSMichael R. Hines    rdma="yes"
30272da776dbSMichael R. Hines  else
30282da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
30292da776dbSMichael R. Hines        error_exit \
3030ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
30312da776dbSMichael R. Hines            " Your options:" \
3032ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
30332da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
30342da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
30352da776dbSMichael R. Hines    fi
30362da776dbSMichael R. Hines    rdma="no"
30372da776dbSMichael R. Hines  fi
30382da776dbSMichael R. Hinesfi
30392da776dbSMichael R. Hines
304021ab34c9SMarcel Apfelbaum##########################################
304121ab34c9SMarcel Apfelbaum# PVRDMA detection
304221ab34c9SMarcel Apfelbaum
304321ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
304421ab34c9SMarcel Apfelbaum#include <sys/mman.h>
304521ab34c9SMarcel Apfelbaum
304621ab34c9SMarcel Apfelbaumint
304721ab34c9SMarcel Apfelbaummain(void)
304821ab34c9SMarcel Apfelbaum{
304921ab34c9SMarcel Apfelbaum    char buf = 0;
305021ab34c9SMarcel Apfelbaum    void *addr = &buf;
305121ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
305221ab34c9SMarcel Apfelbaum
305321ab34c9SMarcel Apfelbaum    return 0;
305421ab34c9SMarcel Apfelbaum}
305521ab34c9SMarcel ApfelbaumEOF
305621ab34c9SMarcel Apfelbaum
305721ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
305821ab34c9SMarcel Apfelbaum    case "$pvrdma" in
305921ab34c9SMarcel Apfelbaum    "")
306021ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
306121ab34c9SMarcel Apfelbaum            pvrdma="yes"
306221ab34c9SMarcel Apfelbaum        else
306321ab34c9SMarcel Apfelbaum            pvrdma="no"
306421ab34c9SMarcel Apfelbaum        fi
306521ab34c9SMarcel Apfelbaum        ;;
306621ab34c9SMarcel Apfelbaum    "yes")
306721ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
306821ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
306921ab34c9SMarcel Apfelbaum        fi
307021ab34c9SMarcel Apfelbaum        pvrdma="yes"
307121ab34c9SMarcel Apfelbaum        ;;
307221ab34c9SMarcel Apfelbaum    "no")
307321ab34c9SMarcel Apfelbaum        pvrdma="no"
307421ab34c9SMarcel Apfelbaum        ;;
307521ab34c9SMarcel Apfelbaum    esac
307621ab34c9SMarcel Apfelbaumelse
307721ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
307821ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
307921ab34c9SMarcel Apfelbaum    fi
308021ab34c9SMarcel Apfelbaum    pvrdma="no"
308121ab34c9SMarcel Apfelbaumfi
308295c6bff3SBenoît Canet
3083ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3084ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3085ee108585SYuval Shaia
3086ee108585SYuval Shaiacat > $TMPC <<EOF &&
3087ee108585SYuval Shaia#include <infiniband/verbs.h>
3088ee108585SYuval Shaia
3089ee108585SYuval Shaiaint
3090ee108585SYuval Shaiamain(void)
3091ee108585SYuval Shaia{
3092ee108585SYuval Shaia    struct ibv_mr *mr;
3093ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3094ee108585SYuval Shaia    size_t length = 10;
3095ee108585SYuval Shaia    uint64_t iova = 0;
3096ee108585SYuval Shaia    int access = 0;
3097ee108585SYuval Shaia    void *addr = NULL;
3098ee108585SYuval Shaia
3099ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3100ee108585SYuval Shaia
3101ee108585SYuval Shaia    ibv_dereg_mr(mr);
3102ee108585SYuval Shaia
3103ee108585SYuval Shaia    return 0;
3104ee108585SYuval Shaia}
3105ee108585SYuval ShaiaEOF
3106ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3107ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3108ee108585SYuval Shaia    fi
3109ee108585SYuval Shaiafi
3110ee108585SYuval Shaia
311195c6bff3SBenoît Canet##########################################
3112c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3113dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3114dce512deSChristoph Hellwig  cat > $TMPC << EOF
3115ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3116dce512deSChristoph Hellwig#include <xfs/xfs.h>
3117dce512deSChristoph Hellwigint main(void)
3118dce512deSChristoph Hellwig{
3119dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3120dce512deSChristoph Hellwig    return 0;
3121dce512deSChristoph Hellwig}
3122dce512deSChristoph HellwigEOF
3123dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3124dce512deSChristoph Hellwig    xfs="yes"
3125dce512deSChristoph Hellwig  else
3126dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
3127e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
3128dce512deSChristoph Hellwig    fi
3129dce512deSChristoph Hellwig    xfs=no
3130dce512deSChristoph Hellwig  fi
3131dce512deSChristoph Hellwigfi
3132dce512deSChristoph Hellwig
3133dce512deSChristoph Hellwig##########################################
31348a16d273Sths# vde libraries probe
3135dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
31364baae0acSJuan Quintela  vde_libs="-lvdeplug"
31378a16d273Sths  cat > $TMPC << EOF
31388a16d273Sths#include <libvdeplug.h>
31394a7f0e06Spbrookint main(void)
31404a7f0e06Spbrook{
31414a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3142fea08e08SPeter Maydell    char s[] = "";
3143fea08e08SPeter Maydell    vde_open(s, s, &a);
31444a7f0e06Spbrook    return 0;
31454a7f0e06Spbrook}
31468a16d273SthsEOF
314752166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
31484baae0acSJuan Quintela    vde=yes
3149dfb278bdSJuan Quintela  else
3150dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
315121684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3152dfb278bdSJuan Quintela    fi
3153dfb278bdSJuan Quintela    vde=no
31548a16d273Sths  fi
31558a16d273Sthsfi
31568a16d273Sths
31578a16d273Sths##########################################
31580a985b37SVincenzo Maffione# netmap support probe
31590a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
31600a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
31610a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
31620a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
31630a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
316458952137SVincenzo Maffioneif test "$netmap" != "no" ; then
316558952137SVincenzo Maffione  cat > $TMPC << EOF
316658952137SVincenzo Maffione#include <inttypes.h>
316758952137SVincenzo Maffione#include <net/if.h>
316858952137SVincenzo Maffione#include <net/netmap.h>
316958952137SVincenzo Maffione#include <net/netmap_user.h>
31700a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
31710a985b37SVincenzo Maffione#error
31720a985b37SVincenzo Maffione#endif
317358952137SVincenzo Maffioneint main(void) { return 0; }
317458952137SVincenzo MaffioneEOF
317558952137SVincenzo Maffione  if compile_prog "" "" ; then
317658952137SVincenzo Maffione    netmap=yes
317758952137SVincenzo Maffione  else
317858952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
317958952137SVincenzo Maffione      feature_not_found "netmap"
318058952137SVincenzo Maffione    fi
318158952137SVincenzo Maffione    netmap=no
318258952137SVincenzo Maffione  fi
318358952137SVincenzo Maffionefi
318458952137SVincenzo Maffione
318558952137SVincenzo Maffione##########################################
3186422a5fd0SJoelle van Dyne# detect CoreAudio
3187422a5fd0SJoelle van Dyneif test "$coreaudio" != "no" ; then
3188422a5fd0SJoelle van Dyne  coreaudio_libs="-framework CoreAudio"
3189422a5fd0SJoelle van Dyne  cat > $TMPC << EOF
3190422a5fd0SJoelle van Dyne#include <CoreAudio/CoreAudio.h>
3191422a5fd0SJoelle van Dyneint main(void)
3192422a5fd0SJoelle van Dyne{
3193422a5fd0SJoelle van Dyne  return (int)AudioGetCurrentHostTime();
3194422a5fd0SJoelle van Dyne}
3195422a5fd0SJoelle van DyneEOF
3196422a5fd0SJoelle van Dyne  if compile_prog "" "$coreaudio_libs" ; then
3197422a5fd0SJoelle van Dyne    coreaudio=yes
3198422a5fd0SJoelle van Dyne  else
3199422a5fd0SJoelle van Dyne    coreaudio=no
3200422a5fd0SJoelle van Dyne  fi
3201422a5fd0SJoelle van Dynefi
3202422a5fd0SJoelle van Dyne
3203422a5fd0SJoelle van Dyne##########################################
3204c2de5c91Smalc# Sound support libraries probe
32058f28f3fbSths
320689138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3207c2de5c91Smalcfor drv in $audio_drv_list; do
3208c2de5c91Smalc    case $drv in
3209e42975a1SGerd Hoffmann    alsa | try-alsa)
3210c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3211c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3212478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3213478e943fSPaolo Bonzini        alsa=yes
3214e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3215e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3216e42975a1SGerd Hoffmann        fi
3217e42975a1SGerd Hoffmann    else
3218e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3219e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3220c80a867fSGerd Hoffmann        else
3221c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3222c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3223c80a867fSGerd Hoffmann        fi
3224e42975a1SGerd Hoffmann    fi
3225c2de5c91Smalc    ;;
3226c2de5c91Smalc
3227e42975a1SGerd Hoffmann    pa | try-pa)
3228c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3229478e943fSPaolo Bonzini        libpulse=yes
3230c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3231478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3232e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3233e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3234e42975a1SGerd Hoffmann        fi
3235e42975a1SGerd Hoffmann    else
3236e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3237e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3238c80a867fSGerd Hoffmann        else
3239c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3240c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3241c80a867fSGerd Hoffmann        fi
3242e42975a1SGerd Hoffmann    fi
3243b8e59f18Smalc    ;;
3244b8e59f18Smalc
3245373967b2SGerd Hoffmann    sdl)
3246373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3247373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3248373967b2SGerd Hoffmann    fi
3249373967b2SGerd Hoffmann    ;;
3250373967b2SGerd Hoffmann
3251e42975a1SGerd Hoffmann    try-sdl)
3252e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3253e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3254e42975a1SGerd Hoffmann    else
3255e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3256e42975a1SGerd Hoffmann    fi
3257e42975a1SGerd Hoffmann    ;;
3258e42975a1SGerd Hoffmann
3259422a5fd0SJoelle van Dyne    coreaudio | try-coreaudio)
3260422a5fd0SJoelle van Dyne    if test "$coreaudio" = "no"; then
3261422a5fd0SJoelle van Dyne      if test "$drv" = "try-coreaudio"; then
3262422a5fd0SJoelle van Dyne        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//')
3263422a5fd0SJoelle van Dyne      else
3264422a5fd0SJoelle van Dyne        error_exit "$drv check failed" \
3265422a5fd0SJoelle van Dyne                "Make sure to have the $drv is available."
3266422a5fd0SJoelle van Dyne      fi
3267422a5fd0SJoelle van Dyne    else
3268b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3269422a5fd0SJoelle van Dyne      if test "$drv" = "try-coreaudio"; then
3270422a5fd0SJoelle van Dyne        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/')
3271422a5fd0SJoelle van Dyne      fi
3272422a5fd0SJoelle van Dyne    fi
3273997e690aSJuan Quintela    ;;
3274997e690aSJuan Quintela
3275a4bf6780SJuan Quintela    dsound)
3276b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3277d5631638Smalc      audio_win_int="yes"
3278a4bf6780SJuan Quintela    ;;
3279a4bf6780SJuan Quintela
3280a4bf6780SJuan Quintela    oss)
3281b1149911SFam Zheng      oss_libs="$oss_lib"
3282a4bf6780SJuan Quintela    ;;
3283a4bf6780SJuan Quintela
32842e445703SGeoffrey McRae    jack | try-jack)
32852e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3286478e943fSPaolo Bonzini        libjack=yes
32872e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
32882e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
32892e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
32902e445703SGeoffrey McRae        fi
32912e445703SGeoffrey McRae    else
32922e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
32932e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
32942e445703SGeoffrey McRae        else
32952e445703SGeoffrey McRae            error_exit "$drv check failed" \
32962e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
32972e445703SGeoffrey McRae        fi
32982e445703SGeoffrey McRae    fi
32992e445703SGeoffrey McRae    ;;
33002e445703SGeoffrey McRae
3301e4c63a6aSmalc    *)
33021c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
330376ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
330476ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3305e4c63a6aSmalc    }
3306e4c63a6aSmalc    ;;
3307c2de5c91Smalc    esac
3308c2de5c91Smalcdone
33098f28f3fbSths
33104d3b6f6eSbalrog##########################################
3311e18df141SAnthony Liguori# glib support probe
3312a52d28afSPaolo Bonzini
331300f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3314aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3315aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3316a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3317aa0d1f44SPaolo Bonzinifi
331854cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
331954cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
332054cb65d8SEmilio G. Cotafi
3321e26110cfSFam Zheng
3322aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3323e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
332489138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
332589138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3326e18df141SAnthony Liguori    else
3327e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3328e26110cfSFam Zheng    fi
3329e26110cfSFam Zhengdone
3330e26110cfSFam Zheng
3331215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3332215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3333215b0c2fSPaolo Bonzini
3334215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3335215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3336215b0c2fSPaolo Bonzinifi
3337215b0c2fSPaolo Bonzini
333820cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
333920cf7b8eSDenis Plotnikov    pass=no
3340f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3341f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
3342f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
334325a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
33440dba4897SMarc-André Lureau        if [ ! -x "$gdbus_codegen" ]; then
33450dba4897SMarc-André Lureau            gdbus_codegen=
33460dba4897SMarc-André Lureau        fi
334776346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
334876346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
334976346b62SPeter Maydell        # -lblkid and will give a link error.
335013ceae66SPeter Maydell        cat > $TMPC <<EOF
335113ceae66SPeter Maydell#include <gio/gio.h>
335213ceae66SPeter Maydellint main(void)
335313ceae66SPeter Maydell{
335413ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
335513ceae66SPeter Maydell    return 0;
335613ceae66SPeter Maydell}
335713ceae66SPeter MaydellEOF
335813ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
335920cf7b8eSDenis Plotnikov            pass=yes
336076346b62SPeter Maydell        else
336120cf7b8eSDenis Plotnikov            pass=no
3362f876b765SMarc-André Lureau        fi
3363f876b765SMarc-André Lureau
336420cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
336520cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
336625a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
336725a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
336825a97a56SMarc-André Lureau        fi
336920cf7b8eSDenis Plotnikov    fi
337020cf7b8eSDenis Plotnikov
337120cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
337220cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
337320cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
337420cf7b8eSDenis Plotnikov        else
337520cf7b8eSDenis Plotnikov            gio=no
337620cf7b8eSDenis Plotnikov        fi
337720cf7b8eSDenis Plotnikov    else
337820cf7b8eSDenis Plotnikov        gio=yes
337920cf7b8eSDenis Plotnikov    fi
338020cf7b8eSDenis Plotnikovfi
338125a97a56SMarc-André Lureau
3382977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3383977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3384977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3385977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3386977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3387977a82abSDaniel P. Berrange#include <glib.h>
3388977a82abSDaniel P. Berrange#include <unistd.h>
3389977a82abSDaniel P. Berrange
3390977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3391977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3392977a82abSDaniel P. Berrange
3393977a82abSDaniel P. Berrangeint main(void) {
3394977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3395977a82abSDaniel P. Berrange   return 0;
3396977a82abSDaniel P. Berrange}
3397977a82abSDaniel P. BerrangeEOF
3398977a82abSDaniel P. Berrange
3399215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3400977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3401977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3402977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3403977a82abSDaniel P. Berrange	       "build target"
3404977a82abSDaniel P. Berrangefi
3405977a82abSDaniel P. Berrange
3406bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3407bbbf2e04SJohn Snowcat > $TMPC << EOF
3408bbbf2e04SJohn Snow#include <glib.h>
3409bbbf2e04SJohn Snowint main(void) { return 0; }
3410bbbf2e04SJohn SnowEOF
3411bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3412bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3413bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
34145770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="-Wno-unknown-attributes $CONFIGURE_CFLAGS"
3415bbbf2e04SJohn Snow    fi
3416bbbf2e04SJohn Snowfi
3417bbbf2e04SJohn Snow
34189bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
34199bda600bSEric Blakecat > $TMPC << EOF
34209bda600bSEric Blake#include <glib.h>
34219bda600bSEric Blaketypedef struct Foo {
34229bda600bSEric Blake    int i;
34239bda600bSEric Blake} Foo;
34249bda600bSEric Blakestatic void foo_free(Foo *f)
34259bda600bSEric Blake{
34269bda600bSEric Blake    g_free(f);
34279bda600bSEric Blake}
34289bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
34299bda600bSEric Blakeint main(void) { return 0; }
34309bda600bSEric BlakeEOF
34319bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
34329bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
34339bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
34345770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
34359bda600bSEric Blake    fi
34369bda600bSEric Blakefi
34379bda600bSEric Blake
3438e26110cfSFam Zheng##########################################
3439e26110cfSFam Zheng# SHA command probe for modules
3440e26110cfSFam Zhengif test "$modules" = yes; then
3441e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3442e26110cfSFam Zheng    for c in $shacmd_probe; do
34438ccefb91SFam Zheng        if has $c; then
3444e26110cfSFam Zheng            shacmd="$c"
3445e26110cfSFam Zheng            break
3446e26110cfSFam Zheng        fi
3447e26110cfSFam Zheng    done
3448e26110cfSFam Zheng    if test "$shacmd" = ""; then
3449e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3450e26110cfSFam Zheng    fi
3451e18df141SAnthony Liguorifi
3452e18df141SAnthony Liguori
3453e18df141SAnthony Liguori##########################################
3454e5d355d1Saliguori# pthread probe
34554b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
34563c529d93Saliguori
3457e5d355d1Saliguoripthread=no
3458414f0dabSblueswir1cat > $TMPC << EOF
34593c529d93Saliguori#include <pthread.h>
34607a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
34617a42bbe4SStefan Weilint main(void) {
34627a42bbe4SStefan Weil  pthread_t thread;
34637a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
34647a42bbe4SStefan Weil  return 0;
34657a42bbe4SStefan Weil}
3466414f0dabSblueswir1EOF
3467bd00d539SAndreas Färberif compile_prog "" "" ; then
3468bd00d539SAndreas Färber  pthread=yes
3469bd00d539SAndreas Färberelse
3470de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
347152166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3472e5d355d1Saliguori      pthread=yes
3473de65fe0fSSebastian Herbszt      break
3474414f0dabSblueswir1    fi
3475de65fe0fSSebastian Herbszt  done
3476bd00d539SAndreas Färberfi
3477414f0dabSblueswir1
3478e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
347976ad07a4SPeter Maydell  error_exit "pthread check failed" \
348076ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3481e5d355d1Saliguorifi
3482e5d355d1Saliguori
3483479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3484479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
34855c312079SDr. David Alan Gilbertcat > $TMPC << EOF
34865c312079SDr. David Alan Gilbert#include <pthread.h>
34875c312079SDr. David Alan Gilbert
34885c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
34895c312079SDr. David Alan Gilbertint main(void)
34905c312079SDr. David Alan Gilbert{
34915c312079SDr. David Alan Gilbert    pthread_t thread;
34925c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
34935c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
34945c312079SDr. David Alan Gilbert    return 0;
34955c312079SDr. David Alan Gilbert}
34965c312079SDr. David Alan GilbertEOF
34975c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3498479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3499479a5747SRoman Bolshakovfi
3500479a5747SRoman Bolshakov
3501479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3502479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3503479a5747SRoman Bolshakovcat > $TMPC << EOF
3504479a5747SRoman Bolshakov#include <pthread.h>
3505479a5747SRoman Bolshakov
350612a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3507479a5747SRoman Bolshakovint main(void)
3508479a5747SRoman Bolshakov{
3509479a5747SRoman Bolshakov    pthread_t thread;
3510479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3511479a5747SRoman Bolshakov    return 0;
3512479a5747SRoman Bolshakov}
3513479a5747SRoman BolshakovEOF
3514479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3515479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
35165c312079SDr. David Alan Gilbertfi
35175c312079SDr. David Alan Gilbert
3518bf9298b9Saliguori##########################################
3519b10d49d7SPino Toscano# libssh probe
3520b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3521b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
3522b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3523b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3524b10d49d7SPino Toscano    libssh=yes
35250a12ec87SRichard W.M. Jones  else
3526b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3527b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
35280a12ec87SRichard W.M. Jones    fi
3529b10d49d7SPino Toscano    libssh=no
35300a12ec87SRichard W.M. Jones  fi
35310a12ec87SRichard W.M. Jonesfi
35320a12ec87SRichard W.M. Jones
35330a12ec87SRichard W.M. Jones##########################################
3534b10d49d7SPino Toscano# Check for libssh 0.8
3535b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
3536b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
3537b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
3538b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
35399a2d462eSRichard W.M. Jones
3540b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
35419a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
3542b10d49d7SPino Toscano#include <libssh/libssh.h>
3543b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
35449a2d462eSRichard W.M. JonesEOF
3545b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
3546b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
35479a2d462eSRichard W.M. Jones  fi
35489a2d462eSRichard W.M. Jonesfi
35499a2d462eSRichard W.M. Jones
35509a2d462eSRichard W.M. Jones##########################################
35515c6c3a6cSChristoph Hellwig# linux-aio probe
35525c6c3a6cSChristoph Hellwig
35535c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
35545c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
35555c6c3a6cSChristoph Hellwig#include <libaio.h>
35565c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3557832ce9c2SScott Wood#include <stddef.h>
35585c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
35595c6c3a6cSChristoph HellwigEOF
35605c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
35615c6c3a6cSChristoph Hellwig    linux_aio=yes
35625c6c3a6cSChristoph Hellwig  else
35635c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
356421684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
35655c6c3a6cSChristoph Hellwig    fi
35663cfcae3cSLuiz Capitulino    linux_aio=no
35675c6c3a6cSChristoph Hellwig  fi
35685c6c3a6cSChristoph Hellwigfi
3569c10dd856SAarushi Mehta##########################################
3570c10dd856SAarushi Mehta# linux-io-uring probe
3571c10dd856SAarushi Mehta
3572c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
3573c10dd856SAarushi Mehta  if $pkg_config liburing; then
3574c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
3575c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
3576c10dd856SAarushi Mehta    linux_io_uring=yes
3577c10dd856SAarushi Mehta  else
3578c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
3579c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
3580c10dd856SAarushi Mehta    fi
3581c10dd856SAarushi Mehta    linux_io_uring=no
3582c10dd856SAarushi Mehta  fi
3583c10dd856SAarushi Mehtafi
35845c6c3a6cSChristoph Hellwig
35855c6c3a6cSChristoph Hellwig##########################################
35867aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
35873b8acc11SPaolo Bonzini
35887aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
35897aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
35907aaa6a16SPaolo Bonzini    tpm=no
35913b8acc11SPaolo Bonzini  else
35927aaa6a16SPaolo Bonzini    tpm=yes
35937aaa6a16SPaolo Bonzini  fi
35947aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
35957aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
35967aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
35977aaa6a16SPaolo Bonzini  fi
35983b8acc11SPaolo Bonzinifi
35993b8acc11SPaolo Bonzini
36003b8acc11SPaolo Bonzini##########################################
3601bf9298b9Saliguori# iovec probe
3602bf9298b9Saliguoricat > $TMPC <<EOF
3603db34f0b3Sblueswir1#include <sys/types.h>
3604bf9298b9Saliguori#include <sys/uio.h>
3605db34f0b3Sblueswir1#include <unistd.h>
3606f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3607bf9298b9SaliguoriEOF
3608bf9298b9Saliguoriiovec=no
360952166aa0SJuan Quintelaif compile_prog "" "" ; then
3610bf9298b9Saliguori  iovec=yes
3611bf9298b9Saliguorifi
3612bf9298b9Saliguori
3613f652e6afSaurel32##########################################
3614f652e6afSaurel32# fdt probe
3615e169e1e1SPeter Maydell
3616fbb4121dSPaolo Bonzinicase "$fdt" in
3617fbb4121dSPaolo Bonzini  auto | enabled | internal)
3618fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
36197d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore"; then
3620aef45d51SDaniel P. Berrange      git_submodules="${git_submodules} dtc"
3621aef45d51SDaniel P. Berrange    fi
3622fbb4121dSPaolo Bonzini    ;;
3623fbb4121dSPaolo Bonziniesac
3624f652e6afSaurel32
362520ff075bSMichael Walle##########################################
3626fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3627b1546f32SGerd Hoffmann
3628d52c454aSMarc-André Lureaugbm="no"
3629d52c454aSMarc-André Lureauif $pkg_config gbm; then
3630d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
3631d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
3632d52c454aSMarc-André Lureau    gbm="yes"
3633d52c454aSMarc-André Lureaufi
3634d52c454aSMarc-André Lureau
3635da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3636bc6a3565SAkihiko Odaki  epoxy=no
3637bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
3638bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
3639bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
3640bc6a3565SAkihiko Odakiint main(void) { return 0; }
3641bc6a3565SAkihiko OdakiEOF
3642bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
3643bc6a3565SAkihiko Odaki      epoxy=yes
3644bc6a3565SAkihiko Odaki    fi
3645bc6a3565SAkihiko Odaki  fi
3646bc6a3565SAkihiko Odaki
3647bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
3648bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
3649bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
3650da076ffeSGerd Hoffmann    opengl=yes
365120ff075bSMichael Walle  else
3652da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3653bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
365420ff075bSMichael Walle    fi
3655f676c67eSJeremy White    opengl_cflags=""
3656da076ffeSGerd Hoffmann    opengl_libs=""
3657da076ffeSGerd Hoffmann    opengl=no
365820ff075bSMichael Walle  fi
365920ff075bSMichael Wallefi
366020ff075bSMichael Walle
3661ed279a06SKlim Kireev##########################################
3662ed279a06SKlim Kireev# libxml2 probe
3663ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3664ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3665ed279a06SKlim Kireev        libxml2="yes"
3666ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3667ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3668ed279a06SKlim Kireev    else
3669ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3670ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3671ed279a06SKlim Kireev        fi
3672ed279a06SKlim Kireev        libxml2="no"
3673ed279a06SKlim Kireev    fi
3674ed279a06SKlim Kireevfi
3675c9a12e75SChrysostomos Nanakos
367639386ac7Saurel32# Check for inotify functions when we are building linux-user
36773b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36783b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36793b3f24adSaurel32# don't provide them even if kernel supports them.
36803b3f24adSaurel32#
36813b3f24adSaurel32inotify=no
36823b3f24adSaurel32cat > $TMPC << EOF
36833b3f24adSaurel32#include <sys/inotify.h>
36843b3f24adSaurel32
36853b3f24adSaurel32int
36863b3f24adSaurel32main(void)
36873b3f24adSaurel32{
36883b3f24adSaurel32	/* try to start inotify */
36898690e420Saurel32	return inotify_init();
36903b3f24adSaurel32}
36913b3f24adSaurel32EOF
369252166aa0SJuan Quintelaif compile_prog "" "" ; then
36933b3f24adSaurel32  inotify=yes
36943b3f24adSaurel32fi
36953b3f24adSaurel32
3696c05c7a73SRiku Voipioinotify1=no
3697c05c7a73SRiku Voipiocat > $TMPC << EOF
3698c05c7a73SRiku Voipio#include <sys/inotify.h>
3699c05c7a73SRiku Voipio
3700c05c7a73SRiku Voipioint
3701c05c7a73SRiku Voipiomain(void)
3702c05c7a73SRiku Voipio{
3703c05c7a73SRiku Voipio    /* try to start inotify */
3704c05c7a73SRiku Voipio    return inotify_init1(0);
3705c05c7a73SRiku Voipio}
3706c05c7a73SRiku VoipioEOF
3707c05c7a73SRiku Voipioif compile_prog "" "" ; then
3708c05c7a73SRiku Voipio  inotify1=yes
3709c05c7a73SRiku Voipiofi
3710c05c7a73SRiku Voipio
3711099d6b0fSRiku Voipio# check if pipe2 is there
3712099d6b0fSRiku Voipiopipe2=no
3713099d6b0fSRiku Voipiocat > $TMPC << EOF
3714099d6b0fSRiku Voipio#include <unistd.h>
3715099d6b0fSRiku Voipio#include <fcntl.h>
3716099d6b0fSRiku Voipio
3717099d6b0fSRiku Voipioint main(void)
3718099d6b0fSRiku Voipio{
3719099d6b0fSRiku Voipio    int pipefd[2];
37209bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3721099d6b0fSRiku Voipio}
3722099d6b0fSRiku VoipioEOF
372352166aa0SJuan Quintelaif compile_prog "" "" ; then
3724099d6b0fSRiku Voipio  pipe2=yes
3725099d6b0fSRiku Voipiofi
3726099d6b0fSRiku Voipio
372740ff6d7eSKevin Wolf# check if accept4 is there
372840ff6d7eSKevin Wolfaccept4=no
372940ff6d7eSKevin Wolfcat > $TMPC << EOF
373040ff6d7eSKevin Wolf#include <sys/socket.h>
373140ff6d7eSKevin Wolf#include <stddef.h>
373240ff6d7eSKevin Wolf
373340ff6d7eSKevin Wolfint main(void)
373440ff6d7eSKevin Wolf{
373540ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
373640ff6d7eSKevin Wolf    return 0;
373740ff6d7eSKevin Wolf}
373840ff6d7eSKevin WolfEOF
373940ff6d7eSKevin Wolfif compile_prog "" "" ; then
374040ff6d7eSKevin Wolf  accept4=yes
374140ff6d7eSKevin Wolffi
374240ff6d7eSKevin Wolf
37433ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
37443ce34dfbSvibisreenivasansplice=no
37453ce34dfbSvibisreenivasancat > $TMPC << EOF
37463ce34dfbSvibisreenivasan#include <unistd.h>
37473ce34dfbSvibisreenivasan#include <fcntl.h>
37483ce34dfbSvibisreenivasan#include <limits.h>
37493ce34dfbSvibisreenivasan
37503ce34dfbSvibisreenivasanint main(void)
37513ce34dfbSvibisreenivasan{
375266ea0f22SStefan Weil    int len, fd = 0;
37533ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
37543ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
37553ce34dfbSvibisreenivasan    return 0;
37563ce34dfbSvibisreenivasan}
37573ce34dfbSvibisreenivasanEOF
375852166aa0SJuan Quintelaif compile_prog "" "" ; then
37593ce34dfbSvibisreenivasan  splice=yes
37603ce34dfbSvibisreenivasanfi
37613ce34dfbSvibisreenivasan
3762dcc38d1cSMarcelo Tosatti##########################################
3763a99d57bbSWanlong Gao# libnuma probe
3764a99d57bbSWanlong Gao
3765a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3766a99d57bbSWanlong Gao  cat > $TMPC << EOF
3767a99d57bbSWanlong Gao#include <numa.h>
3768a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3769a99d57bbSWanlong GaoEOF
3770a99d57bbSWanlong Gao
3771a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3772a99d57bbSWanlong Gao    numa=yes
3773ab318051SMarc-André Lureau    numa_libs="-lnuma"
3774a99d57bbSWanlong Gao  else
3775a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3776a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3777a99d57bbSWanlong Gao    fi
3778a99d57bbSWanlong Gao    numa=no
3779a99d57bbSWanlong Gao  fi
3780a99d57bbSWanlong Gaofi
3781a99d57bbSWanlong Gao
3782aa087962SPaolo Bonzinimalloc=system
37837b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37847b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37857b01cb97SAlexandre Derumier    exit 1
3786aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3787aa087962SPaolo Bonzini    malloc=tcmalloc
3788aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3789aa087962SPaolo Bonzini    malloc=jemalloc
37907b01cb97SAlexandre Derumierfi
37917b01cb97SAlexandre Derumier
37927b01cb97SAlexandre Derumier##########################################
3793dcc38d1cSMarcelo Tosatti# signalfd probe
3794dcc38d1cSMarcelo Tosattisignalfd="no"
3795dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3796dcc38d1cSMarcelo Tosatti#include <unistd.h>
3797dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3798dcc38d1cSMarcelo Tosatti#include <signal.h>
3799dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3800dcc38d1cSMarcelo TosattiEOF
3801dcc38d1cSMarcelo Tosatti
3802dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3803dcc38d1cSMarcelo Tosatti  signalfd=yes
3804dcc38d1cSMarcelo Tosattifi
3805dcc38d1cSMarcelo Tosatti
3806d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
3807d339d766SRichard W.M. Jonesoptreset="no"
3808d339d766SRichard W.M. Jonescat > $TMPC << EOF
3809d339d766SRichard W.M. Jones#include <getopt.h>
3810d339d766SRichard W.M. Jonesint main(void) { return optreset; }
3811d339d766SRichard W.M. JonesEOF
3812d339d766SRichard W.M. Jones
3813d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
3814d339d766SRichard W.M. Jones  optreset=yes
3815d339d766SRichard W.M. Jonesfi
3816d339d766SRichard W.M. Jones
3817c2882b96SRiku Voipio# check if eventfd is supported
3818c2882b96SRiku Voipioeventfd=no
3819c2882b96SRiku Voipiocat > $TMPC << EOF
3820c2882b96SRiku Voipio#include <sys/eventfd.h>
3821c2882b96SRiku Voipio
3822c2882b96SRiku Voipioint main(void)
3823c2882b96SRiku Voipio{
382455cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3825c2882b96SRiku Voipio}
3826c2882b96SRiku VoipioEOF
3827c2882b96SRiku Voipioif compile_prog "" "" ; then
3828c2882b96SRiku Voipio  eventfd=yes
3829c2882b96SRiku Voipiofi
3830c2882b96SRiku Voipio
3831751bcc39SMarc-André Lureau# check if memfd is supported
3832751bcc39SMarc-André Lureaumemfd=no
3833751bcc39SMarc-André Lureaucat > $TMPC << EOF
383475e5b70eSPaolo Bonzini#include <sys/mman.h>
3835751bcc39SMarc-André Lureau
3836751bcc39SMarc-André Lureauint main(void)
3837751bcc39SMarc-André Lureau{
3838751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3839751bcc39SMarc-André Lureau}
3840751bcc39SMarc-André LureauEOF
3841751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3842751bcc39SMarc-André Lureau  memfd=yes
3843751bcc39SMarc-André Lureaufi
3844751bcc39SMarc-André Lureau
3845955727d2SCortland Tölva# check for usbfs
3846955727d2SCortland Tölvahave_usbfs=no
3847955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
384896566d09SThomas Petazzoni  cat > $TMPC << EOF
384996566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
385096566d09SThomas Petazzoni
385196566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
385296566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
385396566d09SThomas Petazzoni#endif
385496566d09SThomas Petazzoni
385596566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
385696566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
385796566d09SThomas Petazzoni#endif
385896566d09SThomas Petazzoni
385996566d09SThomas Petazzoniint main(void)
386096566d09SThomas Petazzoni{
386196566d09SThomas Petazzoni    return 0;
386296566d09SThomas Petazzoni}
386396566d09SThomas PetazzoniEOF
386496566d09SThomas Petazzoni  if compile_prog "" ""; then
3865955727d2SCortland Tölva    have_usbfs=yes
3866955727d2SCortland Tölva  fi
3867955727d2SCortland Tölvafi
3868751bcc39SMarc-André Lureau
3869d0927938SUlrich Hecht# check for fallocate
3870d0927938SUlrich Hechtfallocate=no
3871d0927938SUlrich Hechtcat > $TMPC << EOF
3872d0927938SUlrich Hecht#include <fcntl.h>
3873d0927938SUlrich Hecht
3874d0927938SUlrich Hechtint main(void)
3875d0927938SUlrich Hecht{
3876d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3877d0927938SUlrich Hecht    return 0;
3878d0927938SUlrich Hecht}
3879d0927938SUlrich HechtEOF
38808fb03151SPeter Maydellif compile_prog "" "" ; then
3881d0927938SUlrich Hecht  fallocate=yes
3882d0927938SUlrich Hechtfi
3883d0927938SUlrich Hecht
38843d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38853d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38863d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38873d4fa43eSKusanagi Kouichi#include <fcntl.h>
38883d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38893d4fa43eSKusanagi Kouichi
38903d4fa43eSKusanagi Kouichiint main(void)
38913d4fa43eSKusanagi Kouichi{
38923d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38933d4fa43eSKusanagi Kouichi    return 0;
38943d4fa43eSKusanagi Kouichi}
38953d4fa43eSKusanagi KouichiEOF
38963d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38973d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38983d4fa43eSKusanagi Kouichifi
38993d4fa43eSKusanagi Kouichi
3900b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3901b953f075SDenis V. Lunevfallocate_zero_range=no
3902b953f075SDenis V. Lunevcat > $TMPC << EOF
3903b953f075SDenis V. Lunev#include <fcntl.h>
3904b953f075SDenis V. Lunev#include <linux/falloc.h>
3905b953f075SDenis V. Lunev
3906b953f075SDenis V. Lunevint main(void)
3907b953f075SDenis V. Lunev{
3908b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3909b953f075SDenis V. Lunev    return 0;
3910b953f075SDenis V. Lunev}
3911b953f075SDenis V. LunevEOF
3912b953f075SDenis V. Lunevif compile_prog "" "" ; then
3913b953f075SDenis V. Lunev  fallocate_zero_range=yes
3914b953f075SDenis V. Lunevfi
3915b953f075SDenis V. Lunev
3916ed911435SKevin Wolf# check for posix_fallocate
3917ed911435SKevin Wolfposix_fallocate=no
3918ed911435SKevin Wolfcat > $TMPC << EOF
3919ed911435SKevin Wolf#include <fcntl.h>
3920ed911435SKevin Wolf
3921ed911435SKevin Wolfint main(void)
3922ed911435SKevin Wolf{
3923ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3924ed911435SKevin Wolf    return 0;
3925ed911435SKevin Wolf}
3926ed911435SKevin WolfEOF
3927ed911435SKevin Wolfif compile_prog "" "" ; then
3928ed911435SKevin Wolf    posix_fallocate=yes
3929ed911435SKevin Wolffi
3930ed911435SKevin Wolf
3931c727f47dSPeter Maydell# check for sync_file_range
3932c727f47dSPeter Maydellsync_file_range=no
3933c727f47dSPeter Maydellcat > $TMPC << EOF
3934c727f47dSPeter Maydell#include <fcntl.h>
3935c727f47dSPeter Maydell
3936c727f47dSPeter Maydellint main(void)
3937c727f47dSPeter Maydell{
3938c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3939c727f47dSPeter Maydell    return 0;
3940c727f47dSPeter Maydell}
3941c727f47dSPeter MaydellEOF
39428fb03151SPeter Maydellif compile_prog "" "" ; then
3943c727f47dSPeter Maydell  sync_file_range=yes
3944c727f47dSPeter Maydellfi
3945c727f47dSPeter Maydell
3946dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3947dace20dcSPeter Maydellfiemap=no
3948dace20dcSPeter Maydellcat > $TMPC << EOF
3949dace20dcSPeter Maydell#include <sys/ioctl.h>
3950dace20dcSPeter Maydell#include <linux/fs.h>
3951dace20dcSPeter Maydell#include <linux/fiemap.h>
3952dace20dcSPeter Maydell
3953dace20dcSPeter Maydellint main(void)
3954dace20dcSPeter Maydell{
3955dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3956dace20dcSPeter Maydell    return 0;
3957dace20dcSPeter Maydell}
3958dace20dcSPeter MaydellEOF
39598fb03151SPeter Maydellif compile_prog "" "" ; then
3960dace20dcSPeter Maydell  fiemap=yes
3961dace20dcSPeter Maydellfi
3962dace20dcSPeter Maydell
3963d0927938SUlrich Hecht# check for dup3
3964d0927938SUlrich Hechtdup3=no
3965d0927938SUlrich Hechtcat > $TMPC << EOF
3966d0927938SUlrich Hecht#include <unistd.h>
3967d0927938SUlrich Hecht
3968d0927938SUlrich Hechtint main(void)
3969d0927938SUlrich Hecht{
3970d0927938SUlrich Hecht    dup3(0, 0, 0);
3971d0927938SUlrich Hecht    return 0;
3972d0927938SUlrich Hecht}
3973d0927938SUlrich HechtEOF
397478f5d726SJan Kiszkaif compile_prog "" "" ; then
3975d0927938SUlrich Hecht  dup3=yes
3976d0927938SUlrich Hechtfi
3977d0927938SUlrich Hecht
39784e0c6529SAlex Bligh# check for ppoll support
39794e0c6529SAlex Blighppoll=no
39804e0c6529SAlex Blighcat > $TMPC << EOF
39814e0c6529SAlex Bligh#include <poll.h>
39824e0c6529SAlex Bligh
39834e0c6529SAlex Blighint main(void)
39844e0c6529SAlex Bligh{
39854e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39864e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39874e0c6529SAlex Bligh    return 0;
39884e0c6529SAlex Bligh}
39894e0c6529SAlex BlighEOF
39904e0c6529SAlex Blighif compile_prog "" "" ; then
39914e0c6529SAlex Bligh  ppoll=yes
39924e0c6529SAlex Blighfi
39934e0c6529SAlex Bligh
3994cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3995cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3996cd758dd0SAlex Blighcat > $TMPC << EOF
3997cd758dd0SAlex Bligh#include <sys/prctl.h>
3998cd758dd0SAlex Bligh
3999cd758dd0SAlex Blighint main(void)
4000cd758dd0SAlex Bligh{
4001cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4002cd758dd0SAlex Bligh    return 0;
4003cd758dd0SAlex Bligh}
4004cd758dd0SAlex BlighEOF
4005cd758dd0SAlex Blighif compile_prog "" "" ; then
4006cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4007cd758dd0SAlex Blighfi
4008cd758dd0SAlex Bligh
40093b6edd16SPeter Maydell# check for epoll support
40103b6edd16SPeter Maydellepoll=no
40113b6edd16SPeter Maydellcat > $TMPC << EOF
40123b6edd16SPeter Maydell#include <sys/epoll.h>
40133b6edd16SPeter Maydell
40143b6edd16SPeter Maydellint main(void)
40153b6edd16SPeter Maydell{
40163b6edd16SPeter Maydell    epoll_create(0);
40173b6edd16SPeter Maydell    return 0;
40183b6edd16SPeter Maydell}
40193b6edd16SPeter MaydellEOF
40208fb03151SPeter Maydellif compile_prog "" "" ; then
40213b6edd16SPeter Maydell  epoll=yes
40223b6edd16SPeter Maydellfi
40233b6edd16SPeter Maydell
4024227f0214SPeter Maydell# epoll_create1 is a later addition
4025227f0214SPeter Maydell# so we must check separately for its presence
40263b6edd16SPeter Maydellepoll_create1=no
40273b6edd16SPeter Maydellcat > $TMPC << EOF
40283b6edd16SPeter Maydell#include <sys/epoll.h>
40293b6edd16SPeter Maydell
40303b6edd16SPeter Maydellint main(void)
40313b6edd16SPeter Maydell{
403219e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
403319e83f6bSPeter Maydell     * a function being called. This is necessary so that on
403419e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
403519e83f6bSPeter Maydell     * the library but not declared in the header file we will
403619e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
403719e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
403819e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
403919e83f6bSPeter Maydell     */
4040c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
40413b6edd16SPeter Maydell}
40423b6edd16SPeter MaydellEOF
40438fb03151SPeter Maydellif compile_prog "" "" ; then
40443b6edd16SPeter Maydell  epoll_create1=yes
40453b6edd16SPeter Maydellfi
40463b6edd16SPeter Maydell
4047a8fd1abaSPeter Maydell# check for sendfile support
4048a8fd1abaSPeter Maydellsendfile=no
4049a8fd1abaSPeter Maydellcat > $TMPC << EOF
4050a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4051a8fd1abaSPeter Maydell
4052a8fd1abaSPeter Maydellint main(void)
4053a8fd1abaSPeter Maydell{
4054a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4055a8fd1abaSPeter Maydell}
4056a8fd1abaSPeter MaydellEOF
4057a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4058a8fd1abaSPeter Maydell  sendfile=yes
4059a8fd1abaSPeter Maydellfi
4060a8fd1abaSPeter Maydell
406151834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
406251834341SRiku Voipiotimerfd=no
406351834341SRiku Voipiocat > $TMPC << EOF
406451834341SRiku Voipio#include <sys/timerfd.h>
406551834341SRiku Voipio
406651834341SRiku Voipioint main(void)
406751834341SRiku Voipio{
406851834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
406951834341SRiku Voipio}
407051834341SRiku VoipioEOF
407151834341SRiku Voipioif compile_prog "" "" ; then
407251834341SRiku Voipio  timerfd=yes
407351834341SRiku Voipiofi
407451834341SRiku Voipio
40759af5c906SRiku Voipio# check for setns and unshare support
40769af5c906SRiku Voipiosetns=no
40779af5c906SRiku Voipiocat > $TMPC << EOF
40789af5c906SRiku Voipio#include <sched.h>
40799af5c906SRiku Voipio
40809af5c906SRiku Voipioint main(void)
40819af5c906SRiku Voipio{
40829af5c906SRiku Voipio    int ret;
40839af5c906SRiku Voipio    ret = setns(0, 0);
40849af5c906SRiku Voipio    ret = unshare(0);
40859af5c906SRiku Voipio    return ret;
40869af5c906SRiku Voipio}
40879af5c906SRiku VoipioEOF
40889af5c906SRiku Voipioif compile_prog "" "" ; then
40899af5c906SRiku Voipio  setns=yes
40909af5c906SRiku Voipiofi
40919af5c906SRiku Voipio
409238860a03SAleksandar Markovic# clock_adjtime probe
409338860a03SAleksandar Markovicclock_adjtime=no
409438860a03SAleksandar Markoviccat > $TMPC <<EOF
409538860a03SAleksandar Markovic#include <time.h>
4096cd5d20efSJiaxun Yang#include <sys/timex.h>
409738860a03SAleksandar Markovic
409838860a03SAleksandar Markovicint main(void)
409938860a03SAleksandar Markovic{
410038860a03SAleksandar Markovic    return clock_adjtime(0, 0);
410138860a03SAleksandar Markovic}
410238860a03SAleksandar MarkovicEOF
410338860a03SAleksandar Markovicclock_adjtime=no
410438860a03SAleksandar Markovicif compile_prog "" "" ; then
410538860a03SAleksandar Markovic  clock_adjtime=yes
410638860a03SAleksandar Markovicfi
410738860a03SAleksandar Markovic
41085a03cd00SAleksandar Markovic# syncfs probe
41095a03cd00SAleksandar Markovicsyncfs=no
41105a03cd00SAleksandar Markoviccat > $TMPC <<EOF
41115a03cd00SAleksandar Markovic#include <unistd.h>
41125a03cd00SAleksandar Markovic
41135a03cd00SAleksandar Markovicint main(void)
41145a03cd00SAleksandar Markovic{
41155a03cd00SAleksandar Markovic    return syncfs(0);
41165a03cd00SAleksandar Markovic}
41175a03cd00SAleksandar MarkovicEOF
41185a03cd00SAleksandar Markovicsyncfs=no
41195a03cd00SAleksandar Markovicif compile_prog "" "" ; then
41205a03cd00SAleksandar Markovic  syncfs=yes
41215a03cd00SAleksandar Markovicfi
41225a03cd00SAleksandar Markovic
4123f514f41cSStefan Weil# Search for bswap_32 function
41246ae9a1f4SJuan Quintelabyteswap_h=no
41256ae9a1f4SJuan Quintelacat > $TMPC << EOF
41266ae9a1f4SJuan Quintela#include <byteswap.h>
41276ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
41286ae9a1f4SJuan QuintelaEOF
412952166aa0SJuan Quintelaif compile_prog "" "" ; then
41306ae9a1f4SJuan Quintela  byteswap_h=yes
41316ae9a1f4SJuan Quintelafi
41326ae9a1f4SJuan Quintela
413375f13596SStefan Weil# Search for bswap32 function
41346ae9a1f4SJuan Quintelabswap_h=no
41356ae9a1f4SJuan Quintelacat > $TMPC << EOF
41366ae9a1f4SJuan Quintela#include <sys/endian.h>
41376ae9a1f4SJuan Quintela#include <sys/types.h>
41386ae9a1f4SJuan Quintela#include <machine/bswap.h>
41396ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
41406ae9a1f4SJuan QuintelaEOF
414152166aa0SJuan Quintelaif compile_prog "" "" ; then
41426ae9a1f4SJuan Quintela  bswap_h=yes
41436ae9a1f4SJuan Quintelafi
41446ae9a1f4SJuan Quintela
4145f2995ee4SPaolo Bonzini# Check whether we have openpty() in either libc or libutil
4146d99e97e6SThomas Huthcat > $TMPC << EOF
4147d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4148d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4149d99e97e6SThomas HuthEOF
4150d99e97e6SThomas Huth
41519df8b20dSThomas Huthhave_openpty="no"
41529df8b20dSThomas Huthif compile_prog "" "" ; then
41539df8b20dSThomas Huth  have_openpty="yes"
41549df8b20dSThomas Huthelse
4155d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
41569df8b20dSThomas Huth    have_openpty="yes"
4157d99e97e6SThomas Huth  fi
41586362a53fSJuan Quintelafi
41596362a53fSJuan Quintela
4160de5071c5SBlue Swirl##########################################
4161cd4ec0b4SGerd Hoffmann# spice probe
4162cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4163cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4164cd4ec0b4SGerd Hoffmann#include <spice.h>
4165cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4166cd4ec0b4SGerd HoffmannEOF
4167710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4168710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
41691b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
417065d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4171cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4172cd4ec0b4SGerd Hoffmann    spice="yes"
4173cd4ec0b4SGerd Hoffmann  else
4174cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
41758efc9363SHu Tao      feature_not_found "spice" \
41761b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4177cd4ec0b4SGerd Hoffmann    fi
4178cd4ec0b4SGerd Hoffmann    spice="no"
4179cd4ec0b4SGerd Hoffmann  fi
4180cd4ec0b4SGerd Hoffmannfi
4181cd4ec0b4SGerd Hoffmann
41827b02f544SMarc-André Lureau# check for smartcard support
41837b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
41840f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
41857b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
41867b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
41877b02f544SMarc-André Lureau        smartcard="yes"
4188111a38b0SRobert Relyea    else
41897b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
41907b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4191111a38b0SRobert Relyea        fi
41927b02f544SMarc-André Lureau        smartcard="no"
4193111a38b0SRobert Relyea    fi
4194111a38b0SRobert Relyeafi
4195111a38b0SRobert Relyea
41962b2325ffSGerd Hoffmann# check for libusb
41972b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
419865d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
41992b2325ffSGerd Hoffmann        libusb="yes"
4200ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4201ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
42022b2325ffSGerd Hoffmann    else
42032b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
42048efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
42052b2325ffSGerd Hoffmann        fi
42062b2325ffSGerd Hoffmann        libusb="no"
42072b2325ffSGerd Hoffmann    fi
42082b2325ffSGerd Hoffmannfi
42092b2325ffSGerd Hoffmann
421069354a83SHans de Goede# check for usbredirparser for usb network redirection support
421169354a83SHans de Goedeif test "$usb_redir" != "no" ; then
421265d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
421369354a83SHans de Goede        usb_redir="yes"
4214ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4215ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
421669354a83SHans de Goede    else
421769354a83SHans de Goede        if test "$usb_redir" = "yes"; then
421821684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
421969354a83SHans de Goede        fi
422069354a83SHans de Goede        usb_redir="no"
422169354a83SHans de Goede    fi
422269354a83SHans de Goedefi
422369354a83SHans de Goede
4224cd4ec0b4SGerd Hoffmann##########################################
4225d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4226d9840e25STomoki Sekiyama
4227e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4228e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
4229d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4230690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4231d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4232d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4233690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4234d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4235d9840e25STomoki Sekiyama	  ;;
4236690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4237d9840e25STomoki Sekiyama  esac
4238d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4239d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4240d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4241d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4242d9840e25STomoki SekiyamaEOF
4243d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4244d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4245d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4246315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4247f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4248d9840e25STomoki Sekiyama  else
4249d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4250d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4251d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4252d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4253d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4254d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4255d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4256d9840e25STomoki Sekiyama    fi
4257d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4258d9840e25STomoki Sekiyama  fi
4259d9840e25STomoki Sekiyamafi
4260d9840e25STomoki Sekiyama
4261d9840e25STomoki Sekiyama##########################################
4262d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4263d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4264d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4265d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4266d9840e25STomoki Sekiyama
4267e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4268e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4269d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4270d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4271d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4272d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4273d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4274d9840e25STomoki Sekiyama    else
4275d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4276d9840e25STomoki Sekiyama    fi
4277d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4278d9840e25STomoki Sekiyama    win_sdk=""
4279d9840e25STomoki Sekiyama  fi
4280d9840e25STomoki Sekiyamafi
4281d9840e25STomoki Sekiyama
4282d9840e25STomoki Sekiyama##########################################
428350cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4284e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
428550cbebb9SMichael Roth  cat > $TMPC << EOF
428650cbebb9SMichael Roth#include <windows.h>
428750cbebb9SMichael Roth#include <ntddscsi.h>
428850cbebb9SMichael Rothint main(void) {
428950cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
429050cbebb9SMichael Roth#error Missing required ioctl definitions
429150cbebb9SMichael Roth#endif
429250cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
429350cbebb9SMichael Roth  return addr.Lun;
429450cbebb9SMichael Roth}
429550cbebb9SMichael RothEOF
429650cbebb9SMichael Roth  if compile_prog "" "" ; then
429750cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4298996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
429950cbebb9SMichael Roth  fi
430050cbebb9SMichael Rothfi
430150cbebb9SMichael Roth
430250cbebb9SMichael Roth##########################################
43039d9e1521SGerd Hoffmann# virgl renderer probe
43049d9e1521SGerd Hoffmann
43059d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
43069d9e1521SGerd Hoffmann  cat > $TMPC << EOF
43079d9e1521SGerd Hoffmann#include <virglrenderer.h>
43089d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
43099d9e1521SGerd HoffmannEOF
43109d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
43119d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
431247479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
43139d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
43149d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
43159d9e1521SGerd Hoffmann    virglrenderer="yes"
43169d9e1521SGerd Hoffmann  else
43179d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
43189d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
43199d9e1521SGerd Hoffmann    fi
43209d9e1521SGerd Hoffmann    virglrenderer="no"
43219d9e1521SGerd Hoffmann  fi
43229d9e1521SGerd Hoffmannfi
43239d9e1521SGerd Hoffmann
43249d9e1521SGerd Hoffmann##########################################
43258ca80760SRichard Henderson# capstone
43268ca80760SRichard Henderson
4327e219c499SRichard Hendersoncase "$capstone" in
43288b18cdbfSRichard Henderson  auto | enabled | internal)
43298b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
43307d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore"; then
4331e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4332e219c499SRichard Henderson    fi
4333e219c499SRichard Henderson    ;;
4334e219c499SRichard Hendersonesac
43358ca80760SRichard Henderson
43368ca80760SRichard Henderson##########################################
43375f6b9e8fSBlue Swirl# check if we have fdatasync
43385f6b9e8fSBlue Swirl
43395f6b9e8fSBlue Swirlfdatasync=no
43405f6b9e8fSBlue Swirlcat > $TMPC << EOF
43415f6b9e8fSBlue Swirl#include <unistd.h>
4342d1722a27SAlexandre Raymondint main(void) {
4343d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4344d1722a27SAlexandre Raymondreturn fdatasync(0);
4345d1722a27SAlexandre Raymond#else
4346e172fe11SStefan Weil#error Not supported
4347d1722a27SAlexandre Raymond#endif
4348d1722a27SAlexandre Raymond}
43495f6b9e8fSBlue SwirlEOF
43505f6b9e8fSBlue Swirlif compile_prog "" "" ; then
43515f6b9e8fSBlue Swirl    fdatasync=yes
43525f6b9e8fSBlue Swirlfi
43535f6b9e8fSBlue Swirl
435494a420b1SStefan Hajnoczi##########################################
4355e78815a5SAndreas Färber# check if we have madvise
4356e78815a5SAndreas Färber
4357e78815a5SAndreas Färbermadvise=no
4358e78815a5SAndreas Färbercat > $TMPC << EOF
4359e78815a5SAndreas Färber#include <sys/types.h>
4360e78815a5SAndreas Färber#include <sys/mman.h>
4361832ce9c2SScott Wood#include <stddef.h>
4362e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4363e78815a5SAndreas FärberEOF
4364e78815a5SAndreas Färberif compile_prog "" "" ; then
4365e78815a5SAndreas Färber    madvise=yes
4366e78815a5SAndreas Färberfi
4367e78815a5SAndreas Färber
4368e78815a5SAndreas Färber##########################################
4369e78815a5SAndreas Färber# check if we have posix_madvise
4370e78815a5SAndreas Färber
4371e78815a5SAndreas Färberposix_madvise=no
4372e78815a5SAndreas Färbercat > $TMPC << EOF
4373e78815a5SAndreas Färber#include <sys/mman.h>
4374832ce9c2SScott Wood#include <stddef.h>
4375e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4376e78815a5SAndreas FärberEOF
4377e78815a5SAndreas Färberif compile_prog "" "" ; then
4378e78815a5SAndreas Färber    posix_madvise=yes
4379e78815a5SAndreas Färberfi
4380e78815a5SAndreas Färber
4381e78815a5SAndreas Färber##########################################
43829bc5a719SAndreas Gustafsson# check if we have posix_memalign()
43839bc5a719SAndreas Gustafsson
43849bc5a719SAndreas Gustafssonposix_memalign=no
43859bc5a719SAndreas Gustafssoncat > $TMPC << EOF
43869bc5a719SAndreas Gustafsson#include <stdlib.h>
43879bc5a719SAndreas Gustafssonint main(void) {
43889bc5a719SAndreas Gustafsson    void *p;
43899bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
43909bc5a719SAndreas Gustafsson}
43919bc5a719SAndreas GustafssonEOF
43929bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
43939bc5a719SAndreas Gustafsson    posix_memalign=yes
43949bc5a719SAndreas Gustafssonfi
43959bc5a719SAndreas Gustafsson
43969bc5a719SAndreas Gustafsson##########################################
43970a852417SPaul Durrant# check if we have posix_syslog
43980a852417SPaul Durrant
43990a852417SPaul Durrantposix_syslog=no
44000a852417SPaul Durrantcat > $TMPC << EOF
44010a852417SPaul Durrant#include <syslog.h>
44020a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
44030a852417SPaul DurrantEOF
44040a852417SPaul Durrantif compile_prog "" "" ; then
44050a852417SPaul Durrant    posix_syslog=yes
44060a852417SPaul Durrantfi
44070a852417SPaul Durrant
44080a852417SPaul Durrant##########################################
4409401bc051SPeter Maydell# check if we have sem_timedwait
4410401bc051SPeter Maydell
4411401bc051SPeter Maydellsem_timedwait=no
4412401bc051SPeter Maydellcat > $TMPC << EOF
4413401bc051SPeter Maydell#include <semaphore.h>
4414811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
4415401bc051SPeter MaydellEOF
4416401bc051SPeter Maydellif compile_prog "" "" ; then
4417401bc051SPeter Maydell    sem_timedwait=yes
4418401bc051SPeter Maydellfi
4419401bc051SPeter Maydell
4420401bc051SPeter Maydell##########################################
44215c99fa37SKeno Fischer# check if we have strchrnul
44225c99fa37SKeno Fischer
44235c99fa37SKeno Fischerstrchrnul=no
44245c99fa37SKeno Fischercat > $TMPC << EOF
44255c99fa37SKeno Fischer#include <string.h>
44265c99fa37SKeno Fischerint main(void);
44275c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
44285c99fa37SKeno Fischerchar *haystack = (char*)&main;
44295c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
44305c99fa37SKeno FischerEOF
44315c99fa37SKeno Fischerif compile_prog "" "" ; then
44325c99fa37SKeno Fischer    strchrnul=yes
44335c99fa37SKeno Fischerfi
44345c99fa37SKeno Fischer
44358a792b03SJiufei Xue#########################################
44368a792b03SJiufei Xue# check if we have st_atim
44378a792b03SJiufei Xue
44388a792b03SJiufei Xuest_atim=no
44398a792b03SJiufei Xuecat > $TMPC << EOF
44408a792b03SJiufei Xue#include <sys/stat.h>
44418a792b03SJiufei Xue#include <stddef.h>
44428a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
44438a792b03SJiufei XueEOF
44448a792b03SJiufei Xueif compile_prog "" "" ; then
44458a792b03SJiufei Xue    st_atim=yes
44468a792b03SJiufei Xuefi
44478a792b03SJiufei Xue
44485c99fa37SKeno Fischer##########################################
444994a420b1SStefan Hajnoczi# check if trace backend exists
445094a420b1SStefan Hajnoczi
44515b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
445294a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
44535b808275SLluís Vilanova  error_exit "invalid trace backends" \
44545b808275SLluís Vilanova      "Please choose supported trace backends."
445594a420b1SStefan Hajnoczifi
445694a420b1SStefan Hajnoczi
44577e24e92aSStefan Hajnoczi##########################################
44587e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
44595b808275SLluís Vilanovaif have_backend "ust"; then
44607e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4461bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
44627e24e92aSStefan Hajnocziint main(void) { return 0; }
44637e24e92aSStefan HajnocziEOF
4464c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4465bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
446689138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
44677e24e92aSStefan Hajnoczi    else
4468c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4469bf15f63cSMohamad Gebai    fi
4470bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
447189138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4472bf15f63cSMohamad Gebai    else
4473bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4474bf15f63cSMohamad Gebai    fi
4475bf15f63cSMohamad Gebai  else
4476bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44777e24e92aSStefan Hajnoczi  fi
44787e24e92aSStefan Hajnoczifi
4479b3d08c02SDaniel P. Berrange
4480b3d08c02SDaniel P. Berrange##########################################
4481b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44825b808275SLluís Vilanovaif have_backend "dtrace"; then
4483b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
448476ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4485b3d08c02SDaniel P. Berrange  fi
4486c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4487c276b17dSDaniel P. Berrange  if has 'stap' ; then
4488c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
44894b265c79SStefan Hajnoczi
44904b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
44914b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
44924b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
44934b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
44944b265c79SStefan Hajnoczi    # object.
44954b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
4496c276b17dSDaniel P. Berrange  fi
4497b3d08c02SDaniel P. Berrangefi
4498b3d08c02SDaniel P. Berrange
44997e24e92aSStefan Hajnoczi##########################################
4500519175a2SAlex Barcelo# check and set a backend for coroutine
4501d0e2fce5SAneesh Kumar K.V
45027c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
450333c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
450433c53c54SDaniel P. Berrange# specific one.
45057c2acc70SPeter Maydell
45067c2acc70SPeter Maydellucontext_works=no
4507d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4508d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4509d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4510cdf84806SPeter Maydell#ifdef __stub_makecontext
4511cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4512cdf84806SPeter Maydell#endif
451375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4514d0e2fce5SAneesh Kumar K.VEOF
4515d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
45167c2acc70SPeter Maydell    ucontext_works=yes
4517d0e2fce5SAneesh Kumar K.V  fi
4518519175a2SAlex Barcelofi
45197c2acc70SPeter Maydell
45207c2acc70SPeter Maydellif test "$coroutine" = ""; then
45217c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
45227c2acc70SPeter Maydell    coroutine=win32
45237c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
45247c2acc70SPeter Maydell    coroutine=ucontext
4525519175a2SAlex Barcelo  else
45267c2acc70SPeter Maydell    coroutine=sigaltstack
45277c2acc70SPeter Maydell  fi
45287c2acc70SPeter Maydellelse
45297c2acc70SPeter Maydell  case $coroutine in
45307c2acc70SPeter Maydell  windows)
45317c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
45327c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
45337c2acc70SPeter Maydell    fi
45347c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
45357c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
45367c2acc70SPeter Maydell    coroutine=win32
45377c2acc70SPeter Maydell    ;;
45387c2acc70SPeter Maydell  ucontext)
45397c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
45407c2acc70SPeter Maydell      feature_not_found "ucontext"
45417c2acc70SPeter Maydell    fi
45427c2acc70SPeter Maydell    ;;
454333c53c54SDaniel P. Berrange  sigaltstack)
45447c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
45457c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
45467c2acc70SPeter Maydell    fi
45477c2acc70SPeter Maydell    ;;
45487c2acc70SPeter Maydell  *)
454976ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
45507c2acc70SPeter Maydell    ;;
45517c2acc70SPeter Maydell  esac
4552d0e2fce5SAneesh Kumar K.Vfi
4553d0e2fce5SAneesh Kumar K.V
455470c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
455570c60c08SStefan Hajnoczi  coroutine_pool=yes
455670c60c08SStefan Hajnoczifi
455770c60c08SStefan Hajnoczi
45587d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
45597d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
45607d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
45617d992e4dSPeter Lieven    coroutine_pool=no
45627d992e4dSPeter Lieven  fi
45637d992e4dSPeter Lievenfi
45647d992e4dSPeter Lieven
45651e4f6065SDaniele Buono##################################################
45661e4f6065SDaniele Buono# SafeStack
45671e4f6065SDaniele Buono
45681e4f6065SDaniele Buono
45691e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
45701e4f6065SDaniele Buonocat > $TMPC << EOF
45711e4f6065SDaniele Buonoint main(int argc, char *argv[])
45721e4f6065SDaniele Buono{
45731e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
45741e4f6065SDaniele Buono#error SafeStack Disabled
45751e4f6065SDaniele Buono#endif
45761e4f6065SDaniele Buono    return 0;
45771e4f6065SDaniele Buono}
45781e4f6065SDaniele BuonoEOF
45791e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
45801e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
45811e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
45821e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
45831e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
45841e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
45851e4f6065SDaniele Buono  else
45861e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
45871e4f6065SDaniele Buono  fi
45881e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
45891e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
45901e4f6065SDaniele Buono  fi
45911e4f6065SDaniele Buonoelse
45921e4f6065SDaniele Buonocat > $TMPC << EOF
45931e4f6065SDaniele Buonoint main(int argc, char *argv[])
45941e4f6065SDaniele Buono{
45951e4f6065SDaniele Buono#if defined(__has_feature)
45961e4f6065SDaniele Buono#if __has_feature(safe_stack)
45971e4f6065SDaniele Buono#error SafeStack Enabled
45981e4f6065SDaniele Buono#endif
45991e4f6065SDaniele Buono#endif
46001e4f6065SDaniele Buono    return 0;
46011e4f6065SDaniele Buono}
46021e4f6065SDaniele BuonoEOF
46031e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
46041e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
46051e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
46061e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
46071e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
46081e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
46091e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
46101e4f6065SDaniele Buono    fi
46111e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
46121e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
46131e4f6065SDaniele Buono  fi
46141e4f6065SDaniele Buonoelse # "$safe_stack" = ""
46151e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
46161e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
46171e4f6065SDaniele Buono    safe_stack="no"
46181e4f6065SDaniele Buono  else
46191e4f6065SDaniele Buono    safe_stack="yes"
46201e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
46211e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
46221e4f6065SDaniele Buono    fi
46231e4f6065SDaniele Buono  fi
46241e4f6065SDaniele Buonofi
46251e4f6065SDaniele Buonofi
46267d992e4dSPeter Lieven
4627d0e2fce5SAneesh Kumar K.V##########################################
4628d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4629d2042378SAneesh Kumar K.V
46304e1797f9SStefan Weilopen_by_handle_at=no
4631d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4632d2042378SAneesh Kumar K.V#include <fcntl.h>
4633acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4634acc55ba8SStefan Weil# error missing definition
4635acc55ba8SStefan Weil#else
463675cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4637acc55ba8SStefan Weil#endif
4638d2042378SAneesh Kumar K.VEOF
4639d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4640d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4641d2042378SAneesh Kumar K.Vfi
4642d2042378SAneesh Kumar K.V
4643e06a765eSHarsh Prateek Bora########################################
4644e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4645e06a765eSHarsh Prateek Bora
4646e06a765eSHarsh Prateek Boralinux_magic_h=no
4647e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4648e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4649e06a765eSHarsh Prateek Boraint main(void) {
465075cafad7SStefan Weil  return 0;
4651e06a765eSHarsh Prateek Bora}
4652e06a765eSHarsh Prateek BoraEOF
4653e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4654e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4655e06a765eSHarsh Prateek Borafi
4656e06a765eSHarsh Prateek Bora
46578ab1bf12SLuiz Capitulino########################################
4658541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
46593f4349dcSKevin Wolf
46603f4349dcSKevin Wolfvalgrind_h=no
46613f4349dcSKevin Wolfcat > $TMPC << EOF
46623f4349dcSKevin Wolf#include <valgrind/valgrind.h>
46633f4349dcSKevin Wolfint main(void) {
46643f4349dcSKevin Wolf  return 0;
46653f4349dcSKevin Wolf}
46663f4349dcSKevin WolfEOF
46673f4349dcSKevin Wolfif compile_prog "" "" ; then
46683f4349dcSKevin Wolf    valgrind_h=yes
46693f4349dcSKevin Wolffi
46703f4349dcSKevin Wolf
46713f4349dcSKevin Wolf########################################
46728ab1bf12SLuiz Capitulino# check if environ is declared
46738ab1bf12SLuiz Capitulino
46748ab1bf12SLuiz Capitulinohas_environ=no
46758ab1bf12SLuiz Capitulinocat > $TMPC << EOF
46768ab1bf12SLuiz Capitulino#include <unistd.h>
46778ab1bf12SLuiz Capitulinoint main(void) {
4678c075a723SBlue Swirl    environ = 0;
46798ab1bf12SLuiz Capitulino    return 0;
46808ab1bf12SLuiz Capitulino}
46818ab1bf12SLuiz CapitulinoEOF
46828ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
46838ab1bf12SLuiz Capitulino    has_environ=yes
46848ab1bf12SLuiz Capitulinofi
46858ab1bf12SLuiz Capitulino
468676a347e1SRichard Henderson########################################
468776a347e1SRichard Henderson# check if cpuid.h is usable.
468876a347e1SRichard Henderson
468976a347e1SRichard Hendersoncat > $TMPC << EOF
469076a347e1SRichard Henderson#include <cpuid.h>
469176a347e1SRichard Hendersonint main(void) {
4692774d566cSPeter Maydell    unsigned a, b, c, d;
4693774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4694774d566cSPeter Maydell
4695774d566cSPeter Maydell    if (max >= 1) {
4696774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4697774d566cSPeter Maydell    }
4698774d566cSPeter Maydell
4699774d566cSPeter Maydell    if (max >= 7) {
4700774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4701774d566cSPeter Maydell    }
4702774d566cSPeter Maydell
470376a347e1SRichard Henderson    return 0;
470476a347e1SRichard Henderson}
470576a347e1SRichard HendersonEOF
470676a347e1SRichard Hendersonif compile_prog "" "" ; then
470776a347e1SRichard Henderson    cpuid_h=yes
470876a347e1SRichard Hendersonfi
470976a347e1SRichard Henderson
47105dd89908SRichard Henderson##########################################
47115dd89908SRichard Henderson# avx2 optimization requirement check
47125dd89908SRichard Henderson#
47135dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
47145dd89908SRichard Henderson# since we won't be able to select the new routines.
47155dd89908SRichard Henderson
4716e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
47175dd89908SRichard Henderson  cat > $TMPC << EOF
47185dd89908SRichard Henderson#pragma GCC push_options
47195dd89908SRichard Henderson#pragma GCC target("avx2")
47205dd89908SRichard Henderson#include <cpuid.h>
47215dd89908SRichard Henderson#include <immintrin.h>
47225dd89908SRichard Hendersonstatic int bar(void *a) {
47235dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
47245dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
47255dd89908SRichard Henderson}
47265dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
47275dd89908SRichard HendersonEOF
47285dd89908SRichard Henderson  if compile_object "" ; then
47295dd89908SRichard Henderson    avx2_opt="yes"
473086583a07SLiam Merwick  else
473186583a07SLiam Merwick    avx2_opt="no"
47325dd89908SRichard Henderson  fi
47335dd89908SRichard Hendersonfi
47345dd89908SRichard Henderson
47356b8cd447SRobert Hoo##########################################
47366b8cd447SRobert Hoo# avx512f optimization requirement check
47376b8cd447SRobert Hoo#
47386b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
47396b8cd447SRobert Hoo# since we won't be able to select the new routines.
47406b8cd447SRobert Hoo# by default, it is turned off.
47416b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
47426b8cd447SRobert Hoo
47436b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
47446b8cd447SRobert Hoo  cat > $TMPC << EOF
47456b8cd447SRobert Hoo#pragma GCC push_options
47466b8cd447SRobert Hoo#pragma GCC target("avx512f")
47476b8cd447SRobert Hoo#include <cpuid.h>
47486b8cd447SRobert Hoo#include <immintrin.h>
47496b8cd447SRobert Hoostatic int bar(void *a) {
47506b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
47516b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
47526b8cd447SRobert Hoo}
47536b8cd447SRobert Hooint main(int argc, char *argv[])
47546b8cd447SRobert Hoo{
47556b8cd447SRobert Hoo	return bar(argv[0]);
47566b8cd447SRobert Hoo}
47576b8cd447SRobert HooEOF
47586b8cd447SRobert Hoo  if ! compile_object "" ; then
47596b8cd447SRobert Hoo    avx512f_opt="no"
47606b8cd447SRobert Hoo  fi
47616b8cd447SRobert Hooelse
47626b8cd447SRobert Hoo  avx512f_opt="no"
47636b8cd447SRobert Hoofi
47646b8cd447SRobert Hoo
4765f540166bSRichard Henderson########################################
4766f540166bSRichard Henderson# check if __[u]int128_t is usable.
4767f540166bSRichard Henderson
4768f540166bSRichard Hendersonint128=no
4769f540166bSRichard Hendersoncat > $TMPC << EOF
4770f540166bSRichard Henderson__int128_t a;
4771f540166bSRichard Henderson__uint128_t b;
4772f540166bSRichard Hendersonint main (void) {
4773f540166bSRichard Henderson  a = a + b;
4774f540166bSRichard Henderson  b = a * b;
4775464e3671SPeter Maydell  a = a * a;
4776f540166bSRichard Henderson  return 0;
4777f540166bSRichard Henderson}
4778f540166bSRichard HendersonEOF
4779f540166bSRichard Hendersonif compile_prog "" "" ; then
4780f540166bSRichard Henderson    int128=yes
4781f540166bSRichard Hendersonfi
478276a347e1SRichard Henderson
47837ebee43eSRichard Henderson#########################################
47847ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
47857ebee43eSRichard Henderson
47867ebee43eSRichard Hendersonatomic128=no
47877ebee43eSRichard Hendersonif test "$int128" = "yes"; then
47887ebee43eSRichard Henderson  cat > $TMPC << EOF
47897ebee43eSRichard Hendersonint main(void)
47907ebee43eSRichard Henderson{
47917ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
4792bceac547SThomas Huth  y = __atomic_load(&x, 0);
4793bceac547SThomas Huth  __atomic_store(&x, y, 0);
4794bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
47957ebee43eSRichard Henderson  return 0;
47967ebee43eSRichard Henderson}
47977ebee43eSRichard HendersonEOF
47987ebee43eSRichard Henderson  if compile_prog "" "" ; then
47997ebee43eSRichard Henderson    atomic128=yes
48007ebee43eSRichard Henderson  fi
48017ebee43eSRichard Hendersonfi
48027ebee43eSRichard Henderson
4803e6cd4bb5SRichard Hendersoncmpxchg128=no
4804e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
4805e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
4806e6cd4bb5SRichard Hendersonint main(void)
4807e6cd4bb5SRichard Henderson{
4808e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
4809e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
4810e6cd4bb5SRichard Henderson  return 0;
4811e6cd4bb5SRichard Henderson}
4812e6cd4bb5SRichard HendersonEOF
4813e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
4814e6cd4bb5SRichard Henderson    cmpxchg128=yes
4815e6cd4bb5SRichard Henderson  fi
4816e6cd4bb5SRichard Hendersonfi
4817e6cd4bb5SRichard Henderson
4818df79b996SRichard Henderson#########################################
4819df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4820df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4821df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4822df79b996SRichard Henderson
4823df79b996SRichard Hendersoncat > $TMPC << EOF
4824df79b996SRichard Henderson#include <stdint.h>
4825df79b996SRichard Hendersonint main(void)
4826df79b996SRichard Henderson{
4827df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4828df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
48295fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
48305fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
48315fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
48325fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
48335fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
4834df79b996SRichard Henderson#else
4835df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4836df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4837df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4838df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4839df79b996SRichard Henderson#endif
4840df79b996SRichard Henderson  return 0;
4841df79b996SRichard Henderson}
4842df79b996SRichard HendersonEOF
4843df79b996SRichard Hendersonif compile_prog "" "" ; then
4844df79b996SRichard Henderson  atomic64=yes
4845df79b996SRichard Hendersonfi
4846df79b996SRichard Henderson
484726fffe29SEmilio G. Cota#########################################
484826fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
484926fffe29SEmilio G. Cotald_dynamic_list="no"
485026fffe29SEmilio G. Cotaif test "$static" = "no" ; then
485126fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
485226fffe29SEmilio G. Cota{
485326fffe29SEmilio G. Cota  foo;
485426fffe29SEmilio G. Cota};
485526fffe29SEmilio G. CotaEOF
485626fffe29SEmilio G. Cota
485726fffe29SEmilio G. Cota    cat > $TMPC <<EOF
485826fffe29SEmilio G. Cota#include <stdio.h>
485926fffe29SEmilio G. Cotavoid foo(void);
486026fffe29SEmilio G. Cota
486126fffe29SEmilio G. Cotavoid foo(void)
486226fffe29SEmilio G. Cota{
486326fffe29SEmilio G. Cota  printf("foo\n");
486426fffe29SEmilio G. Cota}
486526fffe29SEmilio G. Cota
486626fffe29SEmilio G. Cotaint main(void)
486726fffe29SEmilio G. Cota{
486826fffe29SEmilio G. Cota  foo();
486926fffe29SEmilio G. Cota  return 0;
487026fffe29SEmilio G. Cota}
487126fffe29SEmilio G. CotaEOF
487226fffe29SEmilio G. Cota
487326fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
487426fffe29SEmilio G. Cota        ld_dynamic_list="yes"
487526fffe29SEmilio G. Cota    fi
487626fffe29SEmilio G. Cotafi
487726fffe29SEmilio G. Cota
487826fffe29SEmilio G. Cota#########################################
487926fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
488026fffe29SEmilio G. Cota
488126fffe29SEmilio G. Cotald_exported_symbols_list="no"
488226fffe29SEmilio G. Cotaif test "$static" = "no" ; then
488326fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
488426fffe29SEmilio G. Cota  _foo
488526fffe29SEmilio G. CotaEOF
488626fffe29SEmilio G. Cota
488726fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
488826fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
488926fffe29SEmilio G. Cota    fi
489026fffe29SEmilio G. Cotafi
489126fffe29SEmilio G. Cota
489226fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
489326fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
489426fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
489526fffe29SEmilio G. Cota  error_exit \
489626fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
489726fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
489826fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
489926fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
490026fffe29SEmilio G. Cotafi
490126fffe29SEmilio G. Cota
49021e6e9acaSRichard Henderson########################################
49031e6e9acaSRichard Henderson# check if getauxval is available.
49041e6e9acaSRichard Henderson
49051e6e9acaSRichard Hendersongetauxval=no
49061e6e9acaSRichard Hendersoncat > $TMPC << EOF
49071e6e9acaSRichard Henderson#include <sys/auxv.h>
49081e6e9acaSRichard Hendersonint main(void) {
49091e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
49101e6e9acaSRichard Henderson}
49111e6e9acaSRichard HendersonEOF
49121e6e9acaSRichard Hendersonif compile_prog "" "" ; then
49131e6e9acaSRichard Henderson    getauxval=yes
49141e6e9acaSRichard Hendersonfi
49151e6e9acaSRichard Henderson
4916fd0e6053SJohn Snow########################################
4917fd0e6053SJohn Snow# check if ccache is interfering with
4918fd0e6053SJohn Snow# semantic analysis of macros
4919fd0e6053SJohn Snow
49205e4dfd3dSJohn Snowunset CCACHE_CPP2
4921fd0e6053SJohn Snowccache_cpp2=no
4922fd0e6053SJohn Snowcat > $TMPC << EOF
4923fd0e6053SJohn Snowstatic const int Z = 1;
4924fd0e6053SJohn Snow#define fn() ({ Z; })
4925fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4926fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4927fd0e6053SJohn Snow#define ID(X) (X)
4928fd0e6053SJohn Snowint main(int argc, char *argv[])
4929fd0e6053SJohn Snow{
4930fd0e6053SJohn Snow    int x = 0, y = 0;
4931fd0e6053SJohn Snow    x = ID(x);
4932fd0e6053SJohn Snow    x = fn();
4933fd0e6053SJohn Snow    fn();
4934fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4935fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4936fd0e6053SJohn Snow    return 0;
4937fd0e6053SJohn Snow}
4938fd0e6053SJohn SnowEOF
4939fd0e6053SJohn Snow
4940fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4941fd0e6053SJohn Snow    ccache_cpp2=yes
4942fd0e6053SJohn Snowfi
4943fd0e6053SJohn Snow
4944b553a042SJohn Snow#################################################
4945b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4946b553a042SJohn Snow
4947b553a042SJohn Snowif test "$fortify_source" != "no"; then
4948b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4949b553a042SJohn Snow    fortify_source="no";
4950e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4951cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4952b553a042SJohn Snow    fortify_source="no";
4953b553a042SJohn Snow  else
4954b553a042SJohn Snow    fortify_source="yes"
4955b553a042SJohn Snow  fi
4956b553a042SJohn Snowfi
4957b553a042SJohn Snow
49581efad060SFam Zheng###############################################
49591efad060SFam Zheng# Check if copy_file_range is provided by glibc
49601efad060SFam Zhenghave_copy_file_range=no
49611efad060SFam Zhengcat > $TMPC << EOF
49621efad060SFam Zheng#include <unistd.h>
49631efad060SFam Zhengint main(void) {
49641efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
49651efad060SFam Zheng  return 0;
49661efad060SFam Zheng}
49671efad060SFam ZhengEOF
49681efad060SFam Zhengif compile_prog "" "" ; then
49691efad060SFam Zheng    have_copy_file_range=yes
49701efad060SFam Zhengfi
49711efad060SFam Zheng
4972d2042378SAneesh Kumar K.V##########################################
4973277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4974277abf15SJan Vesely
4975277abf15SJan Veselyhave_fsxattr=no
4976277abf15SJan Veselycat > $TMPC << EOF
4977277abf15SJan Vesely#include <linux/fs.h>
4978277abf15SJan Veselystruct fsxattr foo;
4979277abf15SJan Veselyint main(void) {
4980277abf15SJan Vesely  return 0;
4981277abf15SJan Vesely}
4982277abf15SJan VeselyEOF
4983277abf15SJan Veselyif compile_prog "" "" ; then
4984277abf15SJan Vesely    have_fsxattr=yes
4985277abf15SJan Veselyfi
4986277abf15SJan Vesely
4987b66e10e4SPeter Maydell##########################################
4988a40161cbSPaolo Bonzini# check for usable membarrier system call
4989a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
4990a40161cbSPaolo Bonzini    have_membarrier=no
4991a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
4992a40161cbSPaolo Bonzini        have_membarrier=yes
4993a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
4994a40161cbSPaolo Bonzini        cat > $TMPC << EOF
4995a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
4996a40161cbSPaolo Bonzini    #include <sys/syscall.h>
4997a40161cbSPaolo Bonzini    #include <unistd.h>
4998a40161cbSPaolo Bonzini    #include <stdlib.h>
4999a40161cbSPaolo Bonzini    int main(void) {
5000a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5001a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5002a40161cbSPaolo Bonzini	exit(0);
5003a40161cbSPaolo Bonzini    }
5004a40161cbSPaolo BonziniEOF
5005a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5006a40161cbSPaolo Bonzini            have_membarrier=yes
5007a40161cbSPaolo Bonzini        fi
5008a40161cbSPaolo Bonzini    fi
5009a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5010a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5011a40161cbSPaolo Bonzini    fi
5012a40161cbSPaolo Bonzinielse
5013a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5014a40161cbSPaolo Bonzini    # work on Wine.
5015a40161cbSPaolo Bonzini    membarrier=no
5016a40161cbSPaolo Bonzinifi
5017a40161cbSPaolo Bonzini
5018a40161cbSPaolo Bonzini##########################################
5019b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5020575b22b1SLaurent Vivierhave_rtnetlink=no
5021575b22b1SLaurent Viviercat > $TMPC << EOF
5022575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5023575b22b1SLaurent Vivierint main(void) {
5024575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5025575b22b1SLaurent Vivier}
5026575b22b1SLaurent VivierEOF
5027575b22b1SLaurent Vivierif compile_prog "" "" ; then
5028575b22b1SLaurent Vivier    have_rtnetlink=yes
5029575b22b1SLaurent Vivierfi
5030575b22b1SLaurent Vivier
50316a02c806SStefan Hajnoczi##########################################
50326a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
50336a02c806SStefan Hajnoczihave_af_vsock=no
50346a02c806SStefan Hajnoczicat > $TMPC << EOF
50356a02c806SStefan Hajnoczi#include <errno.h>
50366a02c806SStefan Hajnoczi#include <sys/types.h>
50376a02c806SStefan Hajnoczi#include <sys/socket.h>
50386a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
50396a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
50406a02c806SStefan Hajnoczi#endif
50416a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
50426a02c806SStefan Hajnocziint main(void) {
50436a02c806SStefan Hajnoczi    int sock, ret;
50446a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
50456a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
50466a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
50476a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
50486a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
50496a02c806SStefan Hajnoczi        return 0;
50506a02c806SStefan Hajnoczi    }
50516a02c806SStefan Hajnoczi    return -1;
50526a02c806SStefan Hajnoczi}
50536a02c806SStefan HajnocziEOF
50546a02c806SStefan Hajnocziif compile_prog "" "" ; then
50556a02c806SStefan Hajnoczi    have_af_vsock=yes
50566a02c806SStefan Hajnoczifi
50576a02c806SStefan Hajnoczi
5058f0d92b56SLongpeng(Mike)##########################################
5059f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
50604f67366eSThomas Huthhave_afalg=no
5061f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5062f0d92b56SLongpeng(Mike)#include <errno.h>
5063f0d92b56SLongpeng(Mike)#include <sys/types.h>
5064f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5065f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5066f0d92b56SLongpeng(Mike)int main(void) {
5067f0d92b56SLongpeng(Mike)    int sock;
5068f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5069f0d92b56SLongpeng(Mike)    return sock;
5070f0d92b56SLongpeng(Mike)}
5071f0d92b56SLongpeng(Mike)EOF
5072f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5073f0d92b56SLongpeng(Mike)    have_afalg=yes
5074f0d92b56SLongpeng(Mike)fi
5075f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5076f0d92b56SLongpeng(Mike)then
5077f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5078f0d92b56SLongpeng(Mike)    then
5079f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5080f0d92b56SLongpeng(Mike)    fi
5081f0d92b56SLongpeng(Mike)fi
5082f0d92b56SLongpeng(Mike)
5083f0d92b56SLongpeng(Mike)
50846969ec6cSJames Clarke#################################################
50854d04351fSChristopher Covington# check for sysmacros.h
50864d04351fSChristopher Covington
50874d04351fSChristopher Covingtonhave_sysmacros=no
50884d04351fSChristopher Covingtoncat > $TMPC << EOF
50894d04351fSChristopher Covington#include <sys/sysmacros.h>
50904d04351fSChristopher Covingtonint main(void) {
50914d04351fSChristopher Covington    return makedev(0, 0);
50924d04351fSChristopher Covington}
50934d04351fSChristopher CovingtonEOF
50944d04351fSChristopher Covingtonif compile_prog "" "" ; then
50954d04351fSChristopher Covington    have_sysmacros=yes
50964d04351fSChristopher Covingtonfi
50974d04351fSChristopher Covington
50984d04351fSChristopher Covington##########################################
509949e00a18SAndreas Grapentin# check for _Static_assert()
510049e00a18SAndreas Grapentin
510149e00a18SAndreas Grapentinhave_static_assert=no
510249e00a18SAndreas Grapentincat > $TMPC << EOF
510349e00a18SAndreas Grapentin_Static_assert(1, "success");
510449e00a18SAndreas Grapentinint main(void) {
510549e00a18SAndreas Grapentin    return 0;
510649e00a18SAndreas Grapentin}
510749e00a18SAndreas GrapentinEOF
510849e00a18SAndreas Grapentinif compile_prog "" "" ; then
510949e00a18SAndreas Grapentin    have_static_assert=yes
511049e00a18SAndreas Grapentinfi
511149e00a18SAndreas Grapentin
511249e00a18SAndreas Grapentin##########################################
5113e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5114e674605fSTomáš Golembiovský
5115e674605fSTomáš Golembiovskýhave_utmpx=no
5116e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5117e674605fSTomáš Golembiovský#include <utmpx.h>
5118e674605fSTomáš Golembiovskýstruct utmpx user_info;
5119e674605fSTomáš Golembiovskýint main(void) {
5120e674605fSTomáš Golembiovský    return 0;
5121e674605fSTomáš Golembiovský}
5122e674605fSTomáš GolembiovskýEOF
5123e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5124e674605fSTomáš Golembiovský    have_utmpx=yes
5125e674605fSTomáš Golembiovskýfi
5126e674605fSTomáš Golembiovský
5127e674605fSTomáš Golembiovský##########################################
5128db1ed1abSRichard Henderson# check for getrandom()
5129db1ed1abSRichard Henderson
5130db1ed1abSRichard Hendersonhave_getrandom=no
5131db1ed1abSRichard Hendersoncat > $TMPC << EOF
5132db1ed1abSRichard Henderson#include <sys/random.h>
5133db1ed1abSRichard Hendersonint main(void) {
5134db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
5135db1ed1abSRichard Henderson}
5136db1ed1abSRichard HendersonEOF
5137db1ed1abSRichard Hendersonif compile_prog "" "" ; then
5138db1ed1abSRichard Henderson    have_getrandom=yes
5139db1ed1abSRichard Hendersonfi
5140db1ed1abSRichard Henderson
5141db1ed1abSRichard Henderson##########################################
5142247724cbSMarc-André Lureau# checks for sanitizers
5143247724cbSMarc-André Lureau
5144247724cbSMarc-André Lureauhave_asan=no
5145247724cbSMarc-André Lureauhave_ubsan=no
5146d83414e1SMarc-André Lureauhave_asan_iface_h=no
5147d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5148247724cbSMarc-André Lureau
5149247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5150b9f44da2SMarc-André Lureau  write_c_skeleton
5151247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5152247724cbSMarc-André Lureau      have_asan=yes
5153247724cbSMarc-André Lureau  fi
5154b9f44da2SMarc-André Lureau
5155b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5156b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5157b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5158b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5159b9f44da2SMarc-André Lureau#include <stdlib.h>
5160b9f44da2SMarc-André Lureauint main(void) {
5161b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5162f2dfe54cSLeonid Bloch    if (tmp != NULL) {
5163b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
5164b9f44da2SMarc-André Lureau    }
5165d1abf3fcSOlaf Hering    return 1;
5166f2dfe54cSLeonid Bloch}
5167b9f44da2SMarc-André LureauEOF
5168247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5169247724cbSMarc-André Lureau      have_ubsan=yes
5170247724cbSMarc-André Lureau  fi
5171d83414e1SMarc-André Lureau
5172d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5173d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5174d83414e1SMarc-André Lureau  fi
5175d83414e1SMarc-André Lureau
5176d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5177d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5178d83414e1SMarc-André Lureauint main(void) {
5179d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5180d83414e1SMarc-André Lureau  return 0;
5181d83414e1SMarc-André Lureau}
5182d83414e1SMarc-André LureauEOF
5183d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5184d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5185d83414e1SMarc-André Lureau  fi
5186247724cbSMarc-André Lureaufi
5187247724cbSMarc-André Lureau
5188247724cbSMarc-André Lureau##########################################
5189adc28027SAlexander Bulekov# checks for fuzzer
519054c9e41dSAlexander Bulekovif test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then
5191adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
5192dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
5193adc28027SAlexander Bulekov    have_fuzzer=yes
519464ed6f92SPaolo Bonzini  else
519564ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
519664ed6f92SPaolo Bonzini    exit 1
5197adc28027SAlexander Bulekov  fi
5198adc28027SAlexander Bulekovfi
5199adc28027SAlexander Bulekov
52000aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
52010aebab04SLingfeng Yang# keep it separate until that is not the case.
52020aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
52030aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
52040aebab04SLingfeng Yangfi
52050aebab04SLingfeng Yanghave_tsan=no
52060aebab04SLingfeng Yanghave_tsan_iface_fiber=no
52070aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
52080aebab04SLingfeng Yang  write_c_skeleton
52090aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
52100aebab04SLingfeng Yang      have_tsan=yes
52110aebab04SLingfeng Yang  fi
52120aebab04SLingfeng Yang  cat > $TMPC << EOF
52130aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
52140aebab04SLingfeng Yangint main(void) {
52150aebab04SLingfeng Yang  __tsan_create_fiber(0);
52160aebab04SLingfeng Yang  return 0;
52170aebab04SLingfeng Yang}
52180aebab04SLingfeng YangEOF
52190aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
52200aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
52210aebab04SLingfeng Yang  fi
52220aebab04SLingfeng Yangfi
52230aebab04SLingfeng Yang
5224adc28027SAlexander Bulekov##########################################
522517824406SJunyan He# check for libpmem
522617824406SJunyan He
522717824406SJunyan Heif test "$libpmem" != "no"; then
522817824406SJunyan He	if $pkg_config --exists "libpmem"; then
522917824406SJunyan He		libpmem="yes"
523017824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
523117824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
523217824406SJunyan He	else
523317824406SJunyan He		if test "$libpmem" = "yes" ; then
523417824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
523517824406SJunyan He		fi
523617824406SJunyan He		libpmem="no"
523717824406SJunyan He	fi
523817824406SJunyan Hefi
523917824406SJunyan He
524017824406SJunyan He##########################################
524121b2eca6SJingqi Liu# check for libdaxctl
524221b2eca6SJingqi Liu
524321b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
524421b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
524521b2eca6SJingqi Liu		libdaxctl="yes"
524621b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
524721b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
524821b2eca6SJingqi Liu	else
524921b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
525021b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
525121b2eca6SJingqi Liu		fi
525221b2eca6SJingqi Liu		libdaxctl="no"
525321b2eca6SJingqi Liu	fi
525421b2eca6SJingqi Liufi
525521b2eca6SJingqi Liu
525621b2eca6SJingqi Liu##########################################
5257675b9b53SMarc-André Lureau# check for slirp
5258675b9b53SMarc-André Lureau
5259675b9b53SMarc-André Lureaucase "$slirp" in
52604d34a86bSPaolo Bonzini  auto | enabled | internal)
52614d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
52627d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore"; then
52637c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
52647c57bdd8SMarc-André Lureau    fi
5265675b9b53SMarc-André Lureau    ;;
5266675b9b53SMarc-André Lureauesac
5267675b9b53SMarc-André Lureau
5268*b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
5269*b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
5270*b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
5271*b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
5272*b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
5273*b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
5274*b8e0c493SJoelle van Dyne    fi
5275*b8e0c493SJoelle van Dyne    slirp_smbd=no
5276*b8e0c493SJoelle van Dyne  else
5277*b8e0c493SJoelle van Dyne    slirp_smbd=yes
5278*b8e0c493SJoelle van Dyne  fi
5279*b8e0c493SJoelle van Dynefi
5280*b8e0c493SJoelle van Dyne
528154e7aac0SAlexey Krasikov##########################################
528254e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
528354e7aac0SAlexey Krasikov
528454e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
528554e7aac0SAlexey Krasikov
528654e7aac0SAlexey Krasikov    have_keyring=no
528754e7aac0SAlexey Krasikov    cat > $TMPC << EOF
528854e7aac0SAlexey Krasikov#include <errno.h>
528954e7aac0SAlexey Krasikov#include <asm/unistd.h>
529054e7aac0SAlexey Krasikov#include <linux/keyctl.h>
529154e7aac0SAlexey Krasikov#include <unistd.h>
529254e7aac0SAlexey Krasikovint main(void) {
529354e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
529454e7aac0SAlexey Krasikov}
529554e7aac0SAlexey KrasikovEOF
529654e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
529754e7aac0SAlexey Krasikov        have_keyring=yes
529854e7aac0SAlexey Krasikov    fi
529954e7aac0SAlexey Krasikovfi
530054e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
530154e7aac0SAlexey Krasikovthen
5302b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
530354e7aac0SAlexey Krasikov    then
530454e7aac0SAlexey Krasikov	secret_keyring=yes
530554e7aac0SAlexey Krasikov    else
530654e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
530754e7aac0SAlexey Krasikov	then
530854e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
530954e7aac0SAlexey Krasikovbut not implemented on your system"
531054e7aac0SAlexey Krasikov	else
531154e7aac0SAlexey Krasikov	    secret_keyring=no
531254e7aac0SAlexey Krasikov	fi
531354e7aac0SAlexey Krasikov    fi
531454e7aac0SAlexey Krasikovfi
531554e7aac0SAlexey Krasikov
531692500362SAlexey Krasikov##########################################
5317e86ecd4bSJuan Quintela# End of CC checks
5318e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5319e86ecd4bSJuan Quintela
5320d83414e1SMarc-André Lureauwrite_c_skeleton
5321d83414e1SMarc-André Lureau
53221d728c39SBlue Swirlif test "$gcov" = "yes" ; then
5323bf0e56a3SMarc-André Lureau  :
5324b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5325086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
5326086d5f75SPaolo Bonzini  debug=no
5327086d5f75SPaolo Bonzinifi
5328086d5f75SPaolo Bonzini
5329086d5f75SPaolo Bonzinicase "$ARCH" in
5330086d5f75SPaolo Bonzinialpha)
5331086d5f75SPaolo Bonzini  # Ensure there's only a single GP
5332086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
5333086d5f75SPaolo Bonzini;;
5334086d5f75SPaolo Bonziniesac
5335086d5f75SPaolo Bonzini
5336086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
5337086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
5338086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
5339086d5f75SPaolo Bonzinifi
5340a316e378SJuan Quintela
5341247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5342db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
5343db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
5344d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5345d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5346d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5347d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5348d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5349d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5350d83414e1SMarc-André Lureau  fi
5351247724cbSMarc-André Lureaufi
53520aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
53530aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
53540aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
53550aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
53560aebab04SLingfeng Yang  else
53570aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
53580aebab04SLingfeng Yang  fi
53590aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
53600aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
53610aebab04SLingfeng Yangfi
5362247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5363db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
5364db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
5365247724cbSMarc-André Lureaufi
5366247724cbSMarc-André Lureau
53676542aa9cSPeter Lieven##########################################
53683efac6ebSTomáš Golembiovský
53690aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
53700aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
5371e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5372db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
5373e86ecd4bSJuan Quintela    fi
5374e86ecd4bSJuan Quintelafi
5375e86ecd4bSJuan Quintela
5376952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5377952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5378cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
5379cb8baa77SMark Cave-Ayland
5380cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
5381cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
5382cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
5383cb8baa77SMark Cave-Ayland    fi
5384cb8baa77SMark Cave-Ayland
5385cb8baa77SMark Cave-Ayland    for flag in $flags; do
5386e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5387db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
5388952afb71SBlue Swirl        fi
5389952afb71SBlue Swirl    done
5390952afb71SBlue Swirlfi
5391952afb71SBlue Swirl
5392e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5393e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5394e0580342SKamil Rytarowski  ivshmem=yes
5395e0580342SKamil Rytarowskifi
5396e0580342SKamil Rytarowski
53979d6bc27bSMichael Roth# Probe for guest agent support/options
53989d6bc27bSMichael Roth
5399e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5400a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
5401a5125905SLaurent Vivier      guest_agent=no
5402a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5403e8ef31a3SMichael Tokarev      guest_agent=yes
5404e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5405e8ef31a3SMichael Tokarev      guest_agent=no
5406e8ef31a3SMichael Tokarev  else
5407e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5408ca35f780SPaolo Bonzini  fi
54094b1c11fdSDaniel P. Berrangefi
5410ca35f780SPaolo Bonzini
5411b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
54129d6bc27bSMichael Roth
54139d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
54149d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
54159d6bc27bSMichael Rothfi
54169d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
54179d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
54189d6bc27bSMichael Rothfi
54199d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
542089138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
54219d6bc27bSMichael Rothfi
54229d6bc27bSMichael Roth
5423b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
54249d6bc27bSMichael Roth
5425ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5426ca35f780SPaolo Bonziniroms=
5427e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
5428e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
54297000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
5430e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5431c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5432c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5433c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5434e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5435e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5436ca35f780SPaolo Bonzini            roms="optionrom"
5437e57218b6SPeter Maydell            break
5438e57218b6SPeter Maydell        fi
5439e57218b6SPeter Maydell    done
5440ca35f780SPaolo Bonzinifi
5441ca35f780SPaolo Bonzini
54422e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
54439933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
54442e33c3f8SThomas Huth  write_c_skeleton
54452e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
54469933c305SChristian Borntraeger    roms="$roms s390-ccw"
54471ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
54481ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
54497d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore"; then
54501ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
54511ef6bfc2SPhilippe Mathieu-Daudé    fi
54529933c305SChristian Borntraeger  fi
54532e33c3f8SThomas Huthfi
54549933c305SChristian Borntraeger
545511cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
545611cde1c8SBruno 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.
545711cde1c8SBruno Dominguezif has $cxx; then
545811cde1c8SBruno Dominguez    cat > $TMPC <<EOF
545911cde1c8SBruno Dominguezint c_function(void);
546011cde1c8SBruno Dominguezint main(void) { return c_function(); }
546111cde1c8SBruno DominguezEOF
546211cde1c8SBruno Dominguez
546311cde1c8SBruno Dominguez    compile_object
546411cde1c8SBruno Dominguez
546511cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
546611cde1c8SBruno Dominguezextern "C" {
546711cde1c8SBruno Dominguez   int c_function(void);
546811cde1c8SBruno Dominguez}
546911cde1c8SBruno Dominguezint c_function(void) { return 42; }
547011cde1c8SBruno DominguezEOF
547111cde1c8SBruno Dominguez
547211cde1c8SBruno Dominguez    update_cxxflags
547311cde1c8SBruno Dominguez
54745770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
547511cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
547611cde1c8SBruno Dominguez        :
547711cde1c8SBruno Dominguez    else
547811cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
547911cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
548011cde1c8SBruno Dominguez        cxx=
548111cde1c8SBruno Dominguez    fi
548211cde1c8SBruno Dominguezelse
548311cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
548411cde1c8SBruno Dominguez    cxx=
548511cde1c8SBruno Dominguezfi
548611cde1c8SBruno Dominguez
54877d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
54887d7dbf9dSDan Streetman    exit 1
54895d91a2edSYonggang Luofi
54905d91a2edSYonggang Luo
549198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
549297a847bcSbellard
549398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
549498ec69acSJuan Quintelaecho >> $config_host_mak
549598ec69acSJuan Quintela
5496e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
5497cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
5498aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
54997d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
5500804edf29SJuan Quintela
550198ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5502727e5283SPaolo Bonzini
5503f8393946Saurel32if test "$debug_tcg" = "yes" ; then
55042358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5505f8393946Saurel32fi
55061625af87Saliguoriif test "$strip_opt" = "yes" ; then
550752ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
55081625af87Saliguorifi
55097d13299dSbellardif test "$bigendian" = "yes" ; then
5510e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
551197a847bcSbellardfi
551267b915a5Sbellardif test "$mingw32" = "yes" ; then
551398ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
5514d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5515d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5516f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5517d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5518d9840e25STomoki Sekiyama  fi
551950cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
552076dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
552150cbebb9SMichael Roth  fi
55229dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
55239dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
55249dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
55259dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5526210fa556Spbrookelse
552735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5528210fa556Spbrookfi
5529128ab2ffSblueswir1
5530dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5531dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5532dffcb71cSMark McLoughlinfi
5533dffcb71cSMark McLoughlin
553483fb7adfSbellardif test "$darwin" = "yes" ; then
553598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
553683fb7adfSbellardfi
5537b29fe3edSmalc
5538ec530c81Sbellardif test "$solaris" = "yes" ; then
553998ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5540ec530c81Sbellardfi
5541179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5542179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5543179cf400SAndreas Färberfi
554497a847bcSbellardif test "$static" = "yes" ; then
554598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
554697a847bcSbellardfi
55471ba16968SStefan Weilif test "$profiler" = "yes" ; then
55482358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
554905c2a3e7Sbellardfi
5550c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
5551c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
5552c932ce31SPaolo Bonzinifi
5553f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
5554f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
5555f15bff25SPaolo Bonzinifi
5556*b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
5557*b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
5558e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5559*b8e0c493SJoelle van Dynefi
55608a16d273Sthsif test "$vde" = "yes" ; then
556198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5562e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
55638a16d273Sthsfi
556458952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
556558952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
556658952137SVincenzo Maffionefi
5567015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5568015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5569015a33bdSGongleifi
55704cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
55714cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
55724cc600d2SPaolo Bonzinifi
55732358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
55740c58ac1cSmalcfor drv in $audio_drv_list; do
55751ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5576484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
55770c58ac1cSmalcdone
5578478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
5579478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
5580478e943fSPaolo Bonzinifi
5581b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5582478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
5583478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
5584478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
5585478e943fSPaolo Bonzinifi
5586b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5587478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
5588b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5589b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5590b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
5591478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
5592478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
5593478e943fSPaolo Bonzinifi
55942e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
5595d5631638Smalcif test "$audio_win_int" = "yes" ; then
5596d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5597d5631638Smalcfi
5598b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5599b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5600dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5601dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5602dce512deSChristoph Hellwigfi
560389138857SStefan Weilqemu_version=$(head $source_path/VERSION)
56042358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
560598ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
56062b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
560717969268SFam Zhengif test "$modules" = "yes"; then
5608e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5609e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
561089138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
561117969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
561217969268SFam Zhengfi
5613bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
5614bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
5615bd83c861SChristian Ehrhardtfi
5616099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
56172358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5618099d6b0fSRiku Voipiofi
561940ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
562040ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
562140ff6d7eSKevin Wolffi
56223ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
56232358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
56243ce34dfbSvibisreenivasanfi
5625c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5626c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5627c2882b96SRiku Voipiofi
5628751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5629751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5630751bcc39SMarc-André Lureaufi
5631955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
5632955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
5633955727d2SCortland Tölvafi
5634d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5635d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5636d0927938SUlrich Hechtfi
56373d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
56383d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
56393d4fa43eSKusanagi Kouichifi
5640b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5641b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5642b953f075SDenis V. Lunevfi
5643ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5644ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5645ed911435SKevin Wolffi
5646c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5647c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5648c727f47dSPeter Maydellfi
5649dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5650dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5651dace20dcSPeter Maydellfi
5652d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5653d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5654d0927938SUlrich Hechtfi
56554e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
56564e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
56574e0c6529SAlex Blighfi
5658cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5659cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5660cd758dd0SAlex Blighfi
56613b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
56623b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
56633b6edd16SPeter Maydellfi
56643b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
56653b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
56663b6edd16SPeter Maydellfi
5667a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5668a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5669a8fd1abaSPeter Maydellfi
567051834341SRiku Voipioif test "$timerfd" = "yes" ; then
567151834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
567251834341SRiku Voipiofi
56739af5c906SRiku Voipioif test "$setns" = "yes" ; then
56749af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
56759af5c906SRiku Voipiofi
567638860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
567738860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
567838860a03SAleksandar Markovicfi
56795a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
56805a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
56815a03cd00SAleksandar Markovicfi
56823b3f24adSaurel32if test "$inotify" = "yes" ; then
56832358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
56843b3f24adSaurel32fi
5685c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5686c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5687c05c7a73SRiku Voipiofi
5688401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
5689401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5690401bc051SPeter Maydellfi
56915c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
56925c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
56935c99fa37SKeno Fischerfi
56948a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
56958a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
56968a792b03SJiufei Xuefi
56976ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
56986ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
56996ae9a1f4SJuan Quintelafi
57006ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
57016ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
57026ae9a1f4SJuan Quintelafi
5703f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
5704f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
5705f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
5706f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
570725a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
5708f876b765SMarc-André Lureaufi
5709a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5710ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5711ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5712a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
5713a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
5714ddbb0d09SDaniel P. Berrangefi
571591bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
571691bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
57171f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
57181f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
57191f923c70SLongpeng(Mike)  fi
572046859d93SDaniel P. Berrangé  echo "GCRYPT_CFLAGS=$gcrypt_cflags" >> $config_host_mak
572146859d93SDaniel P. Berrangé  echo "GCRYPT_LIBS=$gcrypt_libs" >> $config_host_mak
572262893b67SDaniel P. Berrangefi
572391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
572491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5725becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5726a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
5727a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
5728ed754746SDaniel P. Berrangefi
5729e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
5730e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
5731e0576942SDaniel P. Berrangéfi
57329a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
57339a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
57349a2fd434SDaniel P. Berrangefi
57358953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
57368953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
57378953caf3SDaniel P. Berrangefi
57386b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
57396b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
57406b39b063SEric Blakefi
57419df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
57429df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
57439df8b20dSThomas Huthfi
5744277abf15SJan Vesely
5745277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5746277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5747277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5748277abf15SJan Vesely# if this macro is set.
5749277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5750277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5751277abf15SJan Veselyfi
57521efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
57531efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
57541efad060SFam Zhengfi
5755bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5756bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5757a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5758e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
5759a4ccabcfSAnthony Liguorifi
57609d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
57619d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
57629d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
57639d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
57649d9e1521SGerd Hoffmannfi
57651badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
57666dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5767d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5768582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
5769582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
5770e37630caSaliguorifi
57715c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
57725c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
57735c6c3a6cSChristoph Hellwigfi
5774c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
5775c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
5776c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
5777c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
5778c10dd856SAarushi Mehtafi
57795e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
57805e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
57815e9be92dSNicholas Bellingerfi
5782af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
5783af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
5784af3bba76SPaolo Bonzinifi
5785af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
578656f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
578703ce5744SNikolay Nikolaevfi
5788108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
5789108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
5790108a6481SCindy Lufi
5791042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
5792042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
5793042cea27SGongleifi
5794fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5795fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
57965fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
57975fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
57985fe97d88SStefano Garzarella  fi
5799fc0b9b0eSStefan Hajnoczifi
5800299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
5801299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
5802299e6f19SPaolo Bonzinifi
5803e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5804e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5805e6a74868SMarc-André Lureaufi
5806108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
5807108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
5808108a6481SCindy Lufi
580998fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
581098fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
581198fc1adaSDr. David Alan Gilbertfi
5812bf9298b9Saliguoriif test "$iovec" = "yes" ; then
58132358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5814bf9298b9Saliguorifi
5815a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
5816a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
5817a40161cbSPaolo Bonzinifi
5818dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5819dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5820dcc38d1cSMarcelo Tosattifi
5821d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
5822d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
5823d339d766SRichard W.M. Jonesfi
58245f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
58255f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
58265f6b9e8fSBlue Swirlfi
5827e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5828e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5829e78815a5SAndreas Färberfi
5830e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5831e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5832e78815a5SAndreas Färberfi
58339bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
58349bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
58359bc5a719SAndreas Gustafssonfi
5836cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5837cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
58382634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
58392634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
5840cd4ec0b4SGerd Hoffmannfi
5841cd4ec0b4SGerd Hoffmann
58427b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
58437b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
58447b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
58457b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
5846111a38b0SRobert Relyeafi
5847111a38b0SRobert Relyea
58482b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
58492b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5850b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
5851b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
58522b2325ffSGerd Hoffmannfi
58532b2325ffSGerd Hoffmann
585469354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
585569354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5856cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
5857cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
585869354a83SHans de Goedefi
585969354a83SHans de Goede
5860da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5861da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5862de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5863da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
586420ff075bSMichael Wallefi
586520ff075bSMichael Walle
5866d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
5867d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
5868d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
5869d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
5870d52c454aSMarc-André Lureaufi
5871d52c454aSMarc-André Lureau
5872d52c454aSMarc-André Lureau
587399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
587499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
587599f2dbd3SLiang Lifi
587699f2dbd3SLiang Li
58776b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
58786b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
58796b8cd447SRobert Hoofi
58806b8cd447SRobert Hoo
588183fb7adfSbellard# XXX: suppress that
58827d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
58832358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
58847d3505c5Sbellardfi
58857d3505c5Sbellard
58863556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
58873556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
58883556c233SPaolo Bonzinifi
588920ff6c80SAnthony Liguori
58907c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
589170c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
589270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
589370c60c08SStefan Hajnoczielse
589470c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
589570c60c08SStefan Hajnoczifi
5896d0e2fce5SAneesh Kumar K.V
58977d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
58987d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
58997d992e4dSPeter Lievenfi
59007d992e4dSPeter Lieven
5901f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5902f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5903f0d92b56SLongpeng(Mike)fi
5904f0d92b56SLongpeng(Mike)
5905d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5906d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5907d2042378SAneesh Kumar K.Vfi
5908d2042378SAneesh Kumar K.V
5909e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5910e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5911e06a765eSHarsh Prateek Borafi
5912e06a765eSHarsh Prateek Bora
59133f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
59143f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
59153f4349dcSKevin Wolffi
59163f4349dcSKevin Wolf
5917d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
5918d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
5919d83414e1SMarc-André Lureaufi
5920d83414e1SMarc-André Lureau
59210aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
59220aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
59230aebab04SLingfeng Yangfi
59240aebab04SLingfeng Yang
59258ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
59268ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
59278ab1bf12SLuiz Capitulinofi
59288ab1bf12SLuiz Capitulino
592976a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
593076a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
593176a347e1SRichard Hendersonfi
593276a347e1SRichard Henderson
5933f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5934f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5935f540166bSRichard Hendersonfi
5936f540166bSRichard Henderson
59377ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
59387ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
59397ebee43eSRichard Hendersonfi
59407ebee43eSRichard Henderson
5941e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
5942e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
5943e6cd4bb5SRichard Hendersonfi
5944e6cd4bb5SRichard Henderson
5945df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5946df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5947df79b996SRichard Hendersonfi
5948df79b996SRichard Henderson
59491e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
59501e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
59511e6e9acaSRichard Hendersonfi
59521e6e9acaSRichard Henderson
5953b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
5954484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
5955b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
5956b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
59570a12ec87SRichard W.M. Jonesfi
59580a12ec87SRichard W.M. Jones
5959ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5960ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5961ed1701c6SDr. David Alan Gilbertfi
5962ed1701c6SDr. David Alan Gilbert
59633b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
59643cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
59653b8acc11SPaolo Bonzinifi
59663b8acc11SPaolo Bonzini
59675b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
59685b808275SLluís Vilanovaif have_backend "nop"; then
59696d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
597022890ab5SPrerna Saxenafi
59715b808275SLluís Vilanovaif have_backend "simple"; then
59726d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
59736d8a764eSLluís  # Set the appropriate trace file.
5974953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
59759410b56cSPrerna Saxenafi
5976ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5977ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
59786d8a764eSLluísfi
59795b808275SLluís Vilanovaif have_backend "ust"; then
59806d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5981a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
5982a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
59836d8a764eSLluísfi
59845b808275SLluís Vilanovaif have_backend "dtrace"; then
59856d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
59866d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
59876d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
59886d8a764eSLluís  fi
5989c276b17dSDaniel P. Berrangefi
59905b808275SLluís Vilanovaif have_backend "ftrace"; then
5991781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5992781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5993781e9545SEiichi Tsukata  else
599421684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5995781e9545SEiichi Tsukata  fi
5996781e9545SEiichi Tsukatafi
59970a852417SPaul Durrantif have_backend "syslog"; then
59980a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
59990a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
60000a852417SPaul Durrant  else
60010a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
60020a852417SPaul Durrant  fi
60030a852417SPaul Durrantfi
60049410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
60059410b56cSPrerna Saxena
60062da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
60072da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6008392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
60092da776dbSMichael R. Hinesfi
60102da776dbSMichael R. Hines
601121ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
601221ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
601321ab34c9SMarcel Apfelbaumfi
601421ab34c9SMarcel Apfelbaum
6015575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6016575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6017575b22b1SLaurent Vivierfi
6018575b22b1SLaurent Vivier
6019ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6020ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6021ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6022ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6023ed279a06SKlim Kireevfi
6024ed279a06SKlim Kireev
6025a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6026a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6027a6b1d4c0SChanglong Xiefi
6028a6b1d4c0SChanglong Xie
60296a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
60306a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
60316a02c806SStefan Hajnoczifi
60326a02c806SStefan Hajnoczi
60334d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
60344d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
60354d04351fSChristopher Covingtonfi
60364d04351fSChristopher Covington
603749e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
603849e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
603949e00a18SAndreas Grapentinfi
604049e00a18SAndreas Grapentin
6041e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6042e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6043e674605fSTomáš Golembiovskýfi
6044db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
6045db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
6046db1ed1abSRichard Hendersonfi
6047e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6048e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6049e0580342SKamil Rytarowskifi
6050ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
6051ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6052ba59fb77SPaolo Bonzinifi
6053e0580342SKamil Rytarowski
60545c312079SDr. David Alan Gilbert# Hold two types of flag:
60555c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
60565c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
6057479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
60585c312079SDr. David Alan Gilbert#                                     platform
6059479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
60605c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6061479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
6062479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
6063479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6064479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
60655c312079SDr. David Alan Gilbertfi
60665c312079SDr. David Alan Gilbert
606717824406SJunyan Heif test "$libpmem" = "yes" ; then
606817824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
6069c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
6070c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
607117824406SJunyan Hefi
607217824406SJunyan He
607321b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
607421b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
6075c7c91a74SBruce Rogers  echo "LIBDAXCTL_LIBS=$libdaxctl_libs" >> $config_host_mak
607621b2eca6SJingqi Liufi
607721b2eca6SJingqi Liu
60782f740136SJeff Codyif test "$bochs" = "yes" ; then
60792f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
60802f740136SJeff Codyfi
60812f740136SJeff Codyif test "$cloop" = "yes" ; then
60822f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
60832f740136SJeff Codyfi
60842f740136SJeff Codyif test "$dmg" = "yes" ; then
60852f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
60862f740136SJeff Codyfi
60872f740136SJeff Codyif test "$qcow1" = "yes" ; then
60882f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
60892f740136SJeff Codyfi
60902f740136SJeff Codyif test "$vdi" = "yes" ; then
60912f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
60922f740136SJeff Codyfi
60932f740136SJeff Codyif test "$vvfat" = "yes" ; then
60942f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
60952f740136SJeff Codyfi
60962f740136SJeff Codyif test "$qed" = "yes" ; then
60972f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
60982f740136SJeff Codyfi
60992f740136SJeff Codyif test "$parallels" = "yes" ; then
61002f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
61012f740136SJeff Codyfi
61022f740136SJeff Codyif test "$sheepdog" = "yes" ; then
6103e1c42697SDaniel P. Berrangé  add_to deprecated_features "sheepdog"
61042f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
61052f740136SJeff Codyfi
6106195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
6107195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
6108195588ccSDavid CARLIERfi
6109adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
611054c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
611154c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
611254c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
6113efce01bcSAlexander Bulekov    # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
6114efce01bcSAlexander Bulekov    # compiled code.
6115086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
6116efce01bcSAlexander Bulekov    # To build non-fuzzer binaries with --enable-fuzzing, link everything with
6117efce01bcSAlexander Bulekov    # fsanitize=fuzzer-no-link. Otherwise, the linker will be unable to bind
6118efce01bcSAlexander Bulekov    # the fuzzer-related callbacks added by instrumentation.
6119efce01bcSAlexander Bulekov    QEMU_LDFLAGS="$QEMU_LDFLAGS -fsanitize=fuzzer-no-link"
6120efce01bcSAlexander Bulekov    # For the actual fuzzer binaries, we need to link against the libfuzzer
6121efce01bcSAlexander Bulekov    # library. Provide the flags for doing this in FUZZ_EXE_LDFLAGS. The meson
6122efce01bcSAlexander Bulekov    # rule for the fuzzer adds these to the link_args. They need to be
6123efce01bcSAlexander Bulekov    # configurable, to support OSS-Fuzz
612454c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
612554c9e41dSAlexander Bulekov  else
612654c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
612754c9e41dSAlexander Bulekov  fi
6128adc28027SAlexander Bulekovfi
61292f740136SJeff Cody
613040e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
613140e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
613226fffe29SEmilio G. Cota    # Copy the export object list to the build dir
613326fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
613426fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
613526fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
613626fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
613726fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
613826fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
613926fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
614026fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
614126fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
614226fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
614326fffe29SEmilio G. Cota    else
614426fffe29SEmilio G. Cota	error_exit \
614526fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
614626fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
614726fffe29SEmilio G. Cota    fi
614840e8c6f4SAlex Bennéefi
614940e8c6f4SAlex Bennée
6150f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
6151b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
6152d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
6153f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
6154f48e590aSAlex Bennée    fi
6155b1863cccSAlex Bennéefi
6156f48e590aSAlex Bennée
615754e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
615854e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
615954e7aac0SAlexey Krasikovfi
616054e7aac0SAlexey Krasikov
616198ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6162804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6163c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
616439d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
6165a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
616609e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
6167804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6168a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6169859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
6170a31a8642SMichael S. Tsirkinfi
617183f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
61723c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6173804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
617445d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6175cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
61765f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
61773dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6178804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6179804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
61809f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
61814852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
6182daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
61839fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
618446eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6185a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
618611cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6187a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
6188a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
61898a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
6190e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6191804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
6192484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
6193f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
619490246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
619590246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
61961d728c39SBlue Swirlif test "$gcov" = "yes" ; then
61971d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
61981d728c39SBlue Swirlfi
6199804edf29SJuan Quintela
6200adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
6201adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
6202adc28027SAlexander Bulekovfi
620354c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
62043efac6ebSTomáš Golembiovský
6205b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
6206b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
6207b767d257SMarek Marczykowski-Góreckifi
6208b767d257SMarek Marczykowski-Górecki
62096efd7517SPeter Maydell# use included Linux headers
62106efd7517SPeter Maydellif test "$linux" = "yes" ; then
6211a307beb6SAndreas Färber  mkdir -p linux-headers
62126efd7517SPeter Maydell  case "$cpu" in
6213c72b26ecSRichard Henderson  i386|x86_64|x32)
621408312a63SPeter Maydell    linux_arch=x86
62156efd7517SPeter Maydell    ;;
6216f8378accSRichard Henderson  ppc|ppc64|ppc64le)
621708312a63SPeter Maydell    linux_arch=powerpc
62186efd7517SPeter Maydell    ;;
62196efd7517SPeter Maydell  s390x)
622008312a63SPeter Maydell    linux_arch=s390
622108312a63SPeter Maydell    ;;
62221f080313SClaudio Fontana  aarch64)
62231f080313SClaudio Fontana    linux_arch=arm64
62241f080313SClaudio Fontana    ;;
6225222e7d11SSanjay Lal  mips64)
6226222e7d11SSanjay Lal    linux_arch=mips
6227222e7d11SSanjay Lal    ;;
622808312a63SPeter Maydell  *)
622908312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
623008312a63SPeter Maydell    linux_arch="$cpu"
62316efd7517SPeter Maydell    ;;
62326efd7517SPeter Maydell  esac
623308312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
623408312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
623508312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
623608312a63SPeter Maydell    fi
62376efd7517SPeter Maydellfi
62386efd7517SPeter Maydell
623997a847bcSbellardfor target in $target_list; do
624097a847bcSbellard    target_dir="$target"
624189138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
624297a847bcSbellard    mkdir -p $target_dir
6243fdb75aefSPaolo Bonzini    case $target in
6244fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
6245fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
62462408a527Saurel32    esac
624756aebc89Spbrookdone
62487d13299dSbellard
6249765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
6250fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
6251fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
6252fdb75aefSPaolo Bonzinifi
6253a540f158SPeter Crosthwaite
6254a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6255a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6256ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
6257a99d57bbSWanlong Gaofi
6258a99d57bbSWanlong Gao
6259fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6260fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6261fd0e6053SJohn Snowfi
6262fd0e6053SJohn Snow
62631e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
62641e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
62651e4f6065SDaniele Buonofi
62661e4f6065SDaniele Buono
6267e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
6268e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
6269e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
6270e29e5c6eSPeter Maydell# (these can be both files and directories).
6271e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
6272e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
6273e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
6274e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
6275e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
6276e29e5c6eSPeter Maydell# directory and symlink the directory instead.
627709db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
627809db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
627909db9b9dSGerd Hoffmann# a "make distclean" in between.
62801cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
62811cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
6282b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
6283744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
62848db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
6285c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
62862038f8c8SPaolo BonziniLINKS="Makefile"
6287e8f3bd71SMarc-André LureauLINKS="$LINKS tests/tcg/lm32/Makefile"
62883941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
6289ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
6290e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
62918db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
6292e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
6293e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
629439950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
629539950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
62968f8fd9edSCleber RosaLINKS="$LINKS python"
6297c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
629809db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
6299753d11f2SRichard Hendersonfor bios_file in \
6300753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
63013a631b8eSBin Meng    $source_path/pc-bios/*.elf \
6302225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
6303753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6304753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6305e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6306753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
63074e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
630826ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
6309753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6310753d11f2SRichard Hendersondo
6311e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
63127ea78b74SJan Kiszkadone
6313d1807a4fSPaolo Bonzinimkdir -p $DIRS
6314e29e5c6eSPeter Maydellfor f in $LINKS ; do
63150f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
6316f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6317f9245e10SPeter Maydell    fi
63187d13299dSbellarddone
631909db9b9dSGerd Hoffmannfor f in $UNLINK ; do
632009db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
632109db9b9dSGerd Hoffmann        rm -f "$f"
632209db9b9dSGerd Hoffmann    fi
632309db9b9dSGerd Hoffmanndone
63241ad2134fSPaul Brook
63252038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
63262038f8c8SPaolo Bonzini  export $i
63272038f8c8SPaolo Bonzinidone
6328de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
63292038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
63302038f8c8SPaolo Bonzini
6331c34ebfdcSAnthony Liguori# temporary config to build submodules
63328db2a4fdSGerd Hoffmannfor rom in seabios; do
6333c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
633437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6335c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6336cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
63375f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6338c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6339c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
63403dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6341c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6342a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6343c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
63449f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
6345c34ebfdcSAnthony Liguoridone
6346c34ebfdcSAnthony Liguori
6347a5665051SPaolo Bonziniif test "$skip_meson" = no; then
6348fc929892SMarc-André Lureaucross="config-meson.cross.new"
6349fc929892SMarc-André Lureaumeson_quote() {
635047b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
6351fc929892SMarc-André Lureau}
6352fc929892SMarc-André Lureau
6353fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
6354fc929892SMarc-André Lureauecho "[properties]" >> $cross
6355fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
635647b30835SPaolo Bonziniecho "[built-in options]" >> $cross
635747b30835SPaolo Bonziniecho "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
635847b30835SPaolo Bonziniecho "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
635947b30835SPaolo Bonziniecho "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
636047b30835SPaolo Bonziniecho "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
6361fc929892SMarc-André Lureauecho "[binaries]" >> $cross
636247b30835SPaolo Bonziniecho "c = [$(meson_quote $cc)]" >> $cross
636347b30835SPaolo Bonzinitest -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
63640ca321eaSJoelle van Dynetest -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
636547b30835SPaolo Bonziniecho "ar = [$(meson_quote $ar)]" >> $cross
636647b30835SPaolo Bonziniecho "nm = [$(meson_quote $nm)]" >> $cross
636747b30835SPaolo Bonziniecho "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
636847b30835SPaolo Bonziniecho "ranlib = [$(meson_quote $ranlib)]" >> $cross
6369e8178514SPaolo Bonziniif has $sdl2_config; then
637047b30835SPaolo Bonzini  echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
6371e8178514SPaolo Bonzinifi
637247b30835SPaolo Bonziniecho "strip = [$(meson_quote $strip)]" >> $cross
637347b30835SPaolo Bonziniecho "windres = [$(meson_quote $windres)]" >> $cross
63743812c0c4SJoelle van Dyneif test "$cross_compile" = "yes"; then
6375fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
6376fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
6377fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
6378fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
6379fc929892SMarc-André Lureau    fi
6380853b4bafSThomas Huth    if test "$linux" = "yes" ; then
6381853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
6382853b4bafSThomas Huth    fi
63830ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
63840ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
63850ca321eaSJoelle van Dyne    fi
6386fc929892SMarc-André Lureau    case "$ARCH" in
6387f6bca9dfSJoelle van Dyne        i386)
6388fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
6389fc929892SMarc-André Lureau            ;;
6390f6bca9dfSJoelle van Dyne        x86_64)
6391f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
6392f6bca9dfSJoelle van Dyne            ;;
6393fc929892SMarc-André Lureau        ppc64le)
6394fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
6395fc929892SMarc-André Lureau            ;;
6396fc929892SMarc-André Lureau        *)
6397fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
6398fc929892SMarc-André Lureau            ;;
6399fc929892SMarc-André Lureau    esac
6400fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
6401fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
6402fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
6403fc929892SMarc-André Lureau    else
6404fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
6405fc929892SMarc-André Lureau    fi
6406fc929892SMarc-André Lureauelse
6407fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
6408fc929892SMarc-André Lureaufi
6409fc929892SMarc-André Lureaumv $cross config-meson.cross
6410fc929892SMarc-André Lureau
6411a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
6412a5cb7c5aSPaolo Bonziniunset staticpic
6413a5cb7c5aSPaolo Bonziniif ! version_ge "$($meson --version)" 0.56.0; then
6414a5cb7c5aSPaolo Bonzini  staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
6415a5cb7c5aSPaolo Bonzinifi
641609e93326SPaolo BonziniNINJA=$ninja $meson setup \
6417d17f305aSPaolo Bonzini        --prefix "$prefix" \
6418d17f305aSPaolo Bonzini        --libdir "$libdir" \
6419d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
6420d17f305aSPaolo Bonzini        --bindir "$bindir" \
6421d17f305aSPaolo Bonzini        --includedir "$includedir" \
6422d17f305aSPaolo Bonzini        --datadir "$datadir" \
6423d17f305aSPaolo Bonzini        --mandir "$mandir" \
6424d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
642516bf7a33SPaolo Bonzini        --localedir "$localedir" \
6426d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
6427d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
642816bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
642973f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
6430a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
6431a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
6432a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
6433a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
6434da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
6435a5cb7c5aSPaolo Bonzini        ${staticpic:+-Db_staticpic=$staticpic} \
6436bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
64379e62ba48SDaniele Buono        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
6438deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
643974a414a1SReinoud Zandijk        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
64401badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
64411b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
6442a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
6443cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
64448c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
64459db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
644630045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
6447ecea3696SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
6448727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
64497bc3ca7fSPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices \
6450c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
6451106ad1f9SPaolo Bonzini        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
6452b846ab7cSPaolo Bonzini        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
6453c87ea116SAlex Bennée        $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
6454c6fbea47SRichard Henderson	-Dtcg_interpreter=$tcg_interpreter \
6455fc929892SMarc-André Lureau        $cross_arg \
6456a5665051SPaolo Bonzini        "$PWD" "$source_path"
6457a5665051SPaolo Bonzini
6458a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
6459a5665051SPaolo Bonzini    error_exit "meson setup failed"
6460a5665051SPaolo Bonzinifi
6461a5665051SPaolo Bonzinifi
6462a5665051SPaolo Bonzini
64632d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
64642d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
64652d838d9bSAlex Bennée    echo "Please see docs/system/deprecated.rst"
64662d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
64672d838d9bSAlex Bennéefi
64682d838d9bSAlex Bennée
6469dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6470dc655404SMichael S. Tsirkincat <<EOD >config.status
6471dc655404SMichael S. Tsirkin#!/bin/sh
6472dc655404SMichael S. Tsirkin# Generated by configure.
6473dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6474dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6475dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6476dc655404SMichael S. TsirkinEOD
6477e811da7fSDaniel P. Berrangé
6478e811da7fSDaniel P. Berrangépreserve_env() {
6479e811da7fSDaniel P. Berrangé    envname=$1
6480e811da7fSDaniel P. Berrangé
6481e811da7fSDaniel P. Berrangé    eval envval=\$$envname
6482e811da7fSDaniel P. Berrangé
6483e811da7fSDaniel P. Berrangé    if test -n "$envval"
6484e811da7fSDaniel P. Berrangé    then
6485e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
6486e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
6487e811da7fSDaniel P. Berrangé    else
6488e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
6489e811da7fSDaniel P. Berrangé    fi
6490e811da7fSDaniel P. Berrangé}
6491e811da7fSDaniel P. Berrangé
6492e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
6493e811da7fSDaniel P. Berrangé# features/build target configure will detect
6494e811da7fSDaniel P. Berrangépreserve_env AR
6495e811da7fSDaniel P. Berrangépreserve_env AS
6496e811da7fSDaniel P. Berrangépreserve_env CC
6497e811da7fSDaniel P. Berrangépreserve_env CPP
6498e811da7fSDaniel P. Berrangépreserve_env CXX
6499e811da7fSDaniel P. Berrangépreserve_env INSTALL
6500e811da7fSDaniel P. Berrangépreserve_env LD
6501e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
6502e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
6503e811da7fSDaniel P. Berrangépreserve_env MAKE
6504e811da7fSDaniel P. Berrangépreserve_env NM
6505e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
6506e811da7fSDaniel P. Berrangépreserve_env PATH
6507e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
6508e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
6509e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
6510e811da7fSDaniel P. Berrangépreserve_env PYTHON
6511e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
6512e811da7fSDaniel P. Berrangépreserve_env SMBD
6513e811da7fSDaniel P. Berrangépreserve_env STRIP
6514e811da7fSDaniel P. Berrangépreserve_env WINDRES
6515e811da7fSDaniel P. Berrangé
6516dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6517a5665051SPaolo Bonzinifor i in "$0" "$@"; do
6518835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
6519a5665051SPaolo Bonzinidone
6520cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6521dc655404SMichael S. Tsirkinchmod +x config.status
6522dc655404SMichael S. Tsirkin
65238cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6524